Skip to content

Commit

Permalink
Merge pull request #200 from team-xquare/feature/155_improvement_navi…
Browse files Browse the repository at this point in the history
…gation

🔀 :: (#186) Feature/155 improve navigation
  • Loading branch information
rladmsdh committed Jun 28, 2023
2 parents 9195c88 + 9dc49bf commit ac321cf
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ dependencies {
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.work:work-runtime-ktx:2.7.1'

def nav_version = "2.4.2"
def nav_version = "2.5.3"
implementation("androidx.navigation:navigation-compose:$nav_version")

implementation "com.google.dagger:hilt-android:$hilt_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,33 @@ package com.xquare.xquare_android.component
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.material.Icon
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.NavDestination.Companion.hierarchy
import androidx.navigation.compose.currentBackStackEntryAsState
import com.semicolon.design.Body3
import com.semicolon.design.color.primary.gray.gray50
import com.semicolon.design.color.primary.gray.gray300
import com.semicolon.design.color.primary.gray.gray800
import com.semicolon.design.color.primary.gray.gray900
import com.semicolon.design.color.primary.white.white
import com.xquare.xquare_android.navigation.BottomNavigationItem
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@Composable
fun BottomNavigation(
Expand All @@ -41,13 +50,16 @@ fun BottomNavigation(
.weight(1f)
.background(color = white)
.clickable(
interactionSource = MutableInteractionSource(),
indication = rememberRipple(
radius = 28.dp
),
enabled = !selected
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(radius = 28.dp),
) {
navController.navigate(screen.route) { popUpTo(0) }
navController.navigate(screen.route) {
popUpTo(0) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
},
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ fun AlarmItem(
"APPLICATION_PICNIC_PASS",
"APPLICATION_WEEKEND_PICNIC",
"APPLICATION_WEEKEND_PICNIC_RESERVATION" -> R.drawable.ic_apply
"ALL_BAD_POINT","ALL_PENALTY_LEVEL"->R.drawable.img_bad
"ALL_GOOD_POINT", "FEED_NOTICE_LIKE", "FEED_BAMBOO_LIKE" ->R.drawable.img_good
"FEED_NOTICE","FEED_NOTICE_COMMENT", "FEED_BAMBOO_COMMENT", -> R.drawable.ic_feed
"ALL_BAD_POINT","ALL_PENALTY_LEVEL"->R.drawable.ic_thums_down
"ALL_GOOD_POINT"->R.drawable.ic_thumbs_up
"FEED_NOTICE","FEED_NOTICE_COMMENT", "FEED_NOTICE_LIKE",
"FEED_BAMBOO_COMMENT", "FEED_BAMBOO_LIKE" -> R.drawable.ic_feed
"SCHEDULE_LOCAL","SCHEDULE_SOCIAL" -> R.drawable.ic_schedule
else -> R.drawable.ic_alarm
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ fun HomeScreen(navController: NavController) {
viewModel.run {
fetchPassTime()
fetchClassPosition()
fetchUserSimpleData()
fetchTodayMeal()
}
viewModel.eventFlow.collect {
when (it) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class HomeViewModel @Inject constructor(
private val _userSimpleData = MutableStateFlow(HomeUserEntity("", "", 0, 0))
val userSimpleData: StateFlow<HomeUserEntity> = _userSimpleData

init {
fetchTodayMeal()
fetchUserSimpleData()
}
private val _todayMeal = MutableStateFlow(
MealEntity(
emptyList(),
Expand All @@ -36,15 +40,15 @@ class HomeViewModel @Inject constructor(
))
val todayMeal: StateFlow<MealEntity> = _todayMeal

fun fetchUserSimpleData() {
private fun fetchUserSimpleData() {
execute(
job = { fetchUserSimpleDataUseCase.execute(Unit) },
onSuccess = { it.collect { userSimpleData -> _userSimpleData.tryEmit(userSimpleData)} },
onFailure = { }
)
}

fun fetchTodayMeal() {
private fun fetchTodayMeal() {
execute(
job = {
fetchTodayMealUseCase.execute(Unit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ fun ScheduleScreen(navController: NavController) {
var isLoadingSchedule by remember { mutableStateOf(false) }
var loadingMonth by remember { mutableStateOf(LocalDate.now().monthValue) }

LaunchedEffect(Unit){
timetableViewModel.run {
fetchWeekTimetables()
}
}

LaunchedEffect(Unit) {
scheduleViewModel.fetchSchedules(loadingMonth)
scheduleViewModel.eventFlow.collect {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import javax.inject.Inject
class TimetableViewModel @Inject constructor(
private val fetchWeekTimetablesUseCase: FetchWeekTimetablesUseCase,
): BaseViewModel<TimetableViewModel.Event>() {
init {
fetchWeekTimetables()
}

private val _timetable = MutableStateFlow(
TimetableEntity(
emptyList()
))
val timetable: MutableStateFlow<TimetableEntity> = _timetable
fun fetchWeekTimetables() {
private fun fetchWeekTimetables() {
execute(
job = { fetchWeekTimetablesUseCase.execute(Unit) },
onSuccess = { it.collect { timetable -> _timetable.tryEmit(timetable) } },
Expand Down
17 changes: 9 additions & 8 deletions app/src/main/res/drawable/ic_thumbs_up.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="21dp"
android:height="20dp"
android:viewportWidth="21"
android:viewportHeight="20">
<path
android:pathData="M1.954,8.204C1.4491,8.204 0.9648,8.4046 0.6077,8.7617C0.2506,9.1188 0.05,9.6031 0.05,10.108V18.095C0.05,19.147 0.902,20 1.954,20H3.884V8.204H1.954ZM17.413,5.997H12.871V1.736C12.8713,1.3537 12.7453,0.982 12.5126,0.6786C12.2799,0.3752 11.9536,0.1571 11.5843,0.0582C11.215,-0.0408 10.8233,-0.015 10.4701,0.1314C10.117,0.2778 9.822,0.5368 9.6311,0.868L5.3951,8.204H5.384V20H14.618C15.4694,20 16.2963,19.7148 16.9666,19.1899C17.6369,18.665 18.112,17.9306 18.316,17.104L20.1861,9.54C20.2901,9.1192 20.2971,8.6802 20.2064,8.2562C20.1157,7.8323 19.9297,7.4345 19.6625,7.0932C19.3953,6.7517 19.0539,6.4756 18.6641,6.2857C18.2744,6.0958 17.8466,5.9971 17.413,5.997"
android:fillColor="#5C5961"
android:fillType="evenOdd"/>
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path android:fillType="evenOdd"
android:pathData="M10.4238 4.26561C10.0922 4.43142 9.84959 4.73386 9.75966 5.09355L8.72107 9.24792V19.8703H16.4465C17.57 19.8703 18.5378 19.0785 18.7603 17.9772L19.9524 12.0759C20.2478 10.6139 19.1301 9.24792 17.6386 9.24792L12.2619 9.24792V5.40159C12.2619 4.45744 11.2683 3.84337 10.4238 4.26561ZM4 9.24792H7.5408V19.8703H4V9.24792Z"
android:fillColor="#5C5961"/>

</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_thums_down.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillType="evenOdd"
android:pathData="M13.5762 19.7344C13.9078 19.5686 14.1504 19.2661 14.2403 18.9064L15.2789 14.7521L15.2789 4.12968L7.55354 4.12968C6.43004 4.12968 5.46222 4.92153 5.23975 6.02278L4.04756 11.9241C3.75222 13.3861 4.86987 14.7521 6.36135 14.7521L11.7381 14.7521V18.5984C11.7381 19.5426 12.7317 20.1566 13.5762 19.7344ZM20 14.7521H16.4592V4.12968H20L20 14.7521Z"
android:fillColor="#5C5961" />
</vector>
Binary file removed app/src/main/res/drawable/img_bad.png
Binary file not shown.
Binary file removed app/src/main/res/drawable/img_good.png
Binary file not shown.

0 comments on commit ac321cf

Please sign in to comment.