Skip to content

Commit

Permalink
[Feature] MA01,MA03 기능 & 디자인 QA (#128)
Browse files Browse the repository at this point in the history
* [feat]: MA01,MA03 기능 & 디자인 QA

* [fix]
  • Loading branch information
jinuemong authored Mar 6, 2024
1 parent 2a20b8b commit 7a305f7
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fun FieldSelectComponent(
.background(color = Gray000)
.border(
width = 1.dp,
color = if (isSelected) Primary4 else Gray400,
color = if (isSelected) Primary4 else Gray500,
shape = Shapes.medium
)
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ac.dnd.mour.android.presentation.R
import ac.dnd.mour.android.presentation.common.theme.Body1
import ac.dnd.mour.android.presentation.common.theme.Body2
import ac.dnd.mour.android.presentation.common.theme.Gray400
import ac.dnd.mour.android.presentation.common.theme.Gray500
import ac.dnd.mour.android.presentation.common.theme.Gray600
import ac.dnd.mour.android.presentation.common.theme.Gray700
import ac.dnd.mour.android.presentation.common.theme.Gray900
Expand Down Expand Up @@ -75,7 +76,7 @@ fun TypingTextField(
keyboardActions: KeyboardActions = KeyboardActions.Default,
visualTransformation: VisualTransformation = VisualTransformation.None,
backgroundColor: Color = Color.White,
basicBorderColor: Color = Gray400,
basicBorderColor: Color = Gray500,
cursorColor: Color? = null,
hintTextColor: Color = Gray700,
textStyle: TextStyle = Body1.merge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ package ac.dnd.mour.android.presentation.ui.main.home

object HomeConstant {
const val ROUTE = "/home"

const val ROUTE_ARGUMENT_MESSAGE = "message"
const val ROUTE_STRUCTURE = "${ROUTE}?$ROUTE_ARGUMENT_MESSAGE={$ROUTE_ARGUMENT_MESSAGE}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ import androidx.compose.runtime.getValue
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavType
import androidx.navigation.compose.composable
import androidx.navigation.navArgument

fun NavGraphBuilder.homeDestination(
appState: ApplicationState
) {
composable(
route = HomeConstant.ROUTE
route = HomeConstant.ROUTE_STRUCTURE,
arguments = listOf(
navArgument(HomeConstant.ROUTE_ARGUMENT_MESSAGE) {
type = NavType.StringType
defaultValue = ""
}
)
) {

val viewModel: HomeViewModel = hiltViewModel()

val model: HomeModel = let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import ac.dnd.mour.android.presentation.common.util.coroutine.event.MutableEvent
import ac.dnd.mour.android.presentation.common.util.coroutine.event.asEventFlow
import androidx.lifecycle.SavedStateHandle
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import javax.inject.Inject

@HiltViewModel
class HomeViewModel @Inject constructor(
Expand All @@ -22,7 +22,24 @@ class HomeViewModel @Inject constructor(
private val _event: MutableEventFlow<HomeEvent> = MutableEventFlow()
val event: EventFlow<HomeEvent> = _event.asEventFlow()

val message: String by lazy {
savedStateHandle.get<String>(HomeConstant.ROUTE_ARGUMENT_MESSAGE) ?: ""
}

init {
if (message.isNotEmpty()) {
viewMessage(message)
}
}

fun onIntent(intent: HomeIntent) {

}

private fun viewMessage(message: String) {
launch {
_event.emit(HomeEvent.ShowSnackBar(message))
}
savedStateHandle.remove<String>(HomeConstant.ROUTE_ARGUMENT_MESSAGE)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package ac.dnd.mour.android.presentation.ui.main.home.common.group.get

import ac.dnd.mour.android.domain.model.feature.group.Group

sealed interface GetGroupIntent {
data class OnDelete(val id: Long) : GetGroupIntent
data class OnEdit(val group: Group) : GetGroupIntent
data class OnAdd(val group: Group) : GetGroupIntent
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fun GetGroupScreen(
appState: ApplicationState,
groups: List<Group>,
onDismissRequest: () -> Unit,
onGroupChange: (List<Group>) -> Unit,
onGroupChange: () -> Unit,
onResult: (Group) -> Unit,
viewModel: GetGroupViewModel = hiltViewModel()
) {
Expand Down Expand Up @@ -104,7 +104,7 @@ private fun GetGroupScreen(
appState: ApplicationState,
onDismissRequest: () -> Unit,
onResult: (Group) -> Unit,
onGroupChange: (List<Group>) -> Unit,
onGroupChange: () -> Unit,
model: GetGroupModel,
intent: (GetGroupIntent) -> Unit,
event: EventFlow<GetGroupEvent>,
Expand Down Expand Up @@ -287,8 +287,11 @@ private fun GetGroupScreen(
modifier = Modifier
.fillMaxWidth()
.background(color = Gray200)
.padding(
horizontal = 20.dp,
vertical = 12.dp
)
.height(56.dp)
.padding(horizontal = 20.dp)
.align(Alignment.BottomCenter),
contentAlignment = Alignment.CenterStart
) {
Expand Down Expand Up @@ -332,7 +335,7 @@ private fun GetGroupScreen(
},
onConfirm = {
intent(GetGroupIntent.OnDelete(model.groups[currentDeleteGroupIndex].id))
onGroupChange(model.groups)
onGroupChange()
currentDeleteGroupIndex = -1
},
onDismissRequest = {
Expand All @@ -349,8 +352,7 @@ private fun GetGroupScreen(
},
prevGroup = model.groups[currentEditGroupIndex],
onResult = {
intent(GetGroupIntent.OnEdit(it))
onGroupChange(model.groups)
onGroupChange()
currentEditGroupIndex = -1
}
)
Expand All @@ -363,9 +365,8 @@ private fun GetGroupScreen(
isShowingAddGroupSheet = false
},
onResult = {
onGroupChange()
isShowingAddGroupSheet = false
intent(GetGroupIntent.OnAdd(it))
onGroupChange(model.groups)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import ac.dnd.mour.android.presentation.common.util.coroutine.event.MutableEvent
import ac.dnd.mour.android.presentation.common.util.coroutine.event.asEventFlow
import androidx.lifecycle.SavedStateHandle
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import javax.inject.Inject

@HiltViewModel
class GetGroupViewModel @Inject constructor(
Expand All @@ -33,8 +33,6 @@ class GetGroupViewModel @Inject constructor(
fun onIntent(intent: GetGroupIntent) {
when (intent) {
is GetGroupIntent.OnDelete -> deleteGroup(intent.id)
is GetGroupIntent.OnAdd -> addGroup(intent.group)
is GetGroupIntent.OnEdit -> editGroup(intent.group)
}
}

Expand All @@ -61,18 +59,4 @@ class GetGroupViewModel @Inject constructor(
}
}
}

private fun addGroup(group: Group) {
_groups.value = _groups.value.toMutableList().also {
it.add(group)
}
}

private fun editGroup(newGroup: Group) {
_groups.value = _groups.value.toMutableList().also {
it.replaceAll { group ->
if (group.id == newGroup.id) newGroup else group
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package ac.dnd.mour.android.presentation.ui.main.home.common.relation

import ac.dnd.mour.android.domain.model.feature.group.Group

sealed interface RelationIntent {
data class OnClickAdd(
val groupId: Long,
Expand Down Expand Up @@ -40,8 +38,5 @@ sealed interface RelationIntent {
) : RelationIntent

data object OnClickLoadFriend : RelationIntent

data class OnGroupChange(
val groups: List<Group>
) : RelationIntent
data object OnGroupChange : RelationIntent
}
Loading

0 comments on commit 7a305f7

Please sign in to comment.