From 257c10e1a34df5e01218fe9161a0fcf5562b3b79 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Tue, 30 Jan 2024 01:11:43 +0900 Subject: [PATCH 1/6] =?UTF-8?q?#36=20fix=20:=20=EB=B0=B0=EA=B2=BD=EC=83=89?= =?UTF-8?q?=EC=83=81=20dialog=20state=20+=20stopwatch=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/color/src/main/AndroidManifest.xml | 5 +++ .../color/navigation/ColorNavigation.kt | 43 ------------------- .../app/feature/color/ui/ColorActivity.kt | 30 +++++++++++++ .../feature/main/navigation/TiTiNavHost.kt | 17 +++++--- .../feature/time/content/TimeColorDialog.kt | 5 ++- .../time/ui/stopwatch/StopWatchScreen.kt | 15 +++---- .../time/ui/stopwatch/StopWatchViewModel.kt | 4 +- .../app/feature/time/ui/timer/TimerScreen.kt | 16 +++---- 8 files changed, 62 insertions(+), 73 deletions(-) delete mode 100644 feature/color/src/main/kotlin/com/titi/app/feature/color/navigation/ColorNavigation.kt create mode 100644 feature/color/src/main/kotlin/com/titi/app/feature/color/ui/ColorActivity.kt diff --git a/feature/color/src/main/AndroidManifest.xml b/feature/color/src/main/AndroidManifest.xml index a5918e68..5c4d96c2 100644 --- a/feature/color/src/main/AndroidManifest.xml +++ b/feature/color/src/main/AndroidManifest.xml @@ -1,4 +1,9 @@ + + + \ No newline at end of file diff --git a/feature/color/src/main/kotlin/com/titi/app/feature/color/navigation/ColorNavigation.kt b/feature/color/src/main/kotlin/com/titi/app/feature/color/navigation/ColorNavigation.kt deleted file mode 100644 index b20db2be..00000000 --- a/feature/color/src/main/kotlin/com/titi/app/feature/color/navigation/ColorNavigation.kt +++ /dev/null @@ -1,43 +0,0 @@ -package com.titi.app.feature.color.navigation - -import androidx.navigation.NavController -import androidx.navigation.NavGraphBuilder -import androidx.navigation.NavType -import androidx.navigation.compose.composable -import androidx.navigation.compose.navigation -import androidx.navigation.navArgument -import com.titi.app.feature.color.ui.ColorScreen - -const val COLOR_GRAPH_MODE_ARG = "recordingMode" -const val COLOR_GRAPH_SCREEN = "colorGraph" -const val COLOR_GRAPH_ROUTE = "$COLOR_GRAPH_SCREEN?$COLOR_GRAPH_MODE_ARG={$COLOR_GRAPH_MODE_ARG}" - -private const val COLOR_SCREEN = "color" -private const val COLOR_ROUTE = COLOR_SCREEN - -fun NavController.navigateToColorGraph(recordingMode: Int) { - navigate(route = makeRoute(recordingMode)) -} - -private fun makeRoute(recordingMode: Int) = - "$COLOR_GRAPH_SCREEN?$COLOR_GRAPH_MODE_ARG=$recordingMode" - -fun NavGraphBuilder.colorGraph(onFinish: () -> Unit) { - navigation( - route = COLOR_GRAPH_ROUTE, - startDestination = COLOR_ROUTE, - arguments = - listOf( - navArgument(COLOR_GRAPH_MODE_ARG) { - NavType.IntType - }, - ), - ) { - composable(route = COLOR_ROUTE) { - ColorScreen( - recordingMode = 1, - onFinish = onFinish, - ) - } - } -} diff --git a/feature/color/src/main/kotlin/com/titi/app/feature/color/ui/ColorActivity.kt b/feature/color/src/main/kotlin/com/titi/app/feature/color/ui/ColorActivity.kt new file mode 100644 index 00000000..59bde972 --- /dev/null +++ b/feature/color/src/main/kotlin/com/titi/app/feature/color/ui/ColorActivity.kt @@ -0,0 +1,30 @@ +package com.titi.app.feature.color.ui + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import com.titi.app.core.designsystem.theme.TiTiTheme +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class ColorActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + val recordingMode = intent.getIntExtra( + "recordingMode", + 1, + ) + + setContent { + TiTiTheme { + ColorScreen( + recordingMode = recordingMode, + onFinish = { + finish() + }, + ) + } + } + } +} diff --git a/feature/main/src/main/kotlin/com/titi/app/feature/main/navigation/TiTiNavHost.kt b/feature/main/src/main/kotlin/com/titi/app/feature/main/navigation/TiTiNavHost.kt index c0e32ea8..189dd62f 100644 --- a/feature/main/src/main/kotlin/com/titi/app/feature/main/navigation/TiTiNavHost.kt +++ b/feature/main/src/main/kotlin/com/titi/app/feature/main/navigation/TiTiNavHost.kt @@ -1,12 +1,13 @@ package com.titi.app.feature.main.navigation +import android.content.Intent import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.navigation.compose.NavHost import com.titi.app.core.util.toJson -import com.titi.app.feature.color.navigation.colorGraph -import com.titi.app.feature.color.navigation.navigateToColorGraph +import com.titi.app.feature.color.ui.ColorActivity import com.titi.app.feature.main.ui.SplashResultState import com.titi.app.feature.main.ui.TiTiAppState import com.titi.app.feature.main.ui.toFeatureTimeModel @@ -25,6 +26,7 @@ fun TiTiNavHost( modifier: Modifier = Modifier, ) { val navController = appState.navController + val context = LocalContext.current LaunchedEffect(Unit) { if (splashResultState.recordTimes.recording) { @@ -47,7 +49,12 @@ fun TiTiNavHost( STOPWATCH_SCREEN }, splashResultState = splashResultState.toFeatureTimeModel(), - onNavigateToColor = navController::navigateToColorGraph, + onNavigateToColor = { + val intent = Intent(context, ColorActivity::class.java).apply { + putExtra("recordingMode", it) + } + context.startActivity(intent) + }, onNavigateToMeasure = navController::navigateToMeasuringGraph, nestedGraphs = { measuringGraph( @@ -59,10 +66,6 @@ fun TiTiNavHost( navController.popBackStack() }, ) - - colorGraph( - onFinish = { navController.popBackStack() }, - ) }, ) } diff --git a/feature/time/src/main/kotlin/com/titi/app/feature/time/content/TimeColorDialog.kt b/feature/time/src/main/kotlin/com/titi/app/feature/time/content/TimeColorDialog.kt index 7c1d7645..af1fe1b2 100644 --- a/feature/time/src/main/kotlin/com/titi/app/feature/time/content/TimeColorDialog.kt +++ b/feature/time/src/main/kotlin/com/titi/app/feature/time/content/TimeColorDialog.kt @@ -28,7 +28,9 @@ fun TimeColorDialog( title = stringResource(id = R.string.custom_color), positiveText = stringResource(id = R.string.Ok), negativeText = stringResource(id = R.string.Cancel), - onPositive = {}, + onPositive = { + onShowDialog(false) + }, onNegative = onNegative, ), onShowDialog = onShowDialog, @@ -37,7 +39,6 @@ fun TimeColorDialog( backgroundColor = backgroundColor, textColor = textColor, onClickBackgroundColor = { - onShowDialog(false) onClickBackgroundColor() }, onClickTextColor = onClickTextColor, diff --git a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/stopwatch/StopWatchScreen.kt b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/stopwatch/StopWatchScreen.kt index e2cb16dc..85fd609e 100644 --- a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/stopwatch/StopWatchScreen.kt +++ b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/stopwatch/StopWatchScreen.kt @@ -71,8 +71,7 @@ fun StopWatchScreen( if (showSelectColorDialog) { TimeColorDialog( backgroundColor = Color(uiState.stopWatchColor.backgroundColor), - textColor = - if (uiState.stopWatchColor.isTextColorBlack) { + textColor = if (uiState.stopWatchColor.isTextColorBlack) { Color.Black } else { Color.White @@ -110,8 +109,7 @@ fun StopWatchScreen( if (showCheckTaskDailyDialog) { TimeCheckDailyDialog( - title = - if (!uiState.isSetTask && !uiState.isDailyAfter6AM) { + title = if (!uiState.isSetTask && !uiState.isDailyAfter6AM) { stringResource(id = R.string.daily_task_check_title) } else if (!uiState.isSetTask) { stringResource(id = R.string.task_check_title) @@ -127,8 +125,7 @@ fun StopWatchScreen( StopWatchScreen( uiState = uiState, backgroundColor = Color(uiState.stopWatchColor.backgroundColor), - textColor = - if (uiState.stopWatchColor.isTextColorBlack) { + textColor = if (uiState.stopWatchColor.isTextColorBlack) { TdsColor.BLACK } else { TdsColor.WHITE @@ -185,8 +182,7 @@ private fun StopWatchScreen( val scrollState = rememberScrollState() Column( - modifier = - Modifier + modifier = Modifier .fillMaxSize() .background(backgroundColor) .padding(top = 16.dp) @@ -215,8 +211,7 @@ private fun StopWatchScreen( TdsTimer( outCircularLineColor = textColor.getColor(), outCircularProgress = outCircularProgress, - inCircularLineTrackColor = - if (textColor == TdsColor.WHITE) { + inCircularLineTrackColor = if (textColor == TdsColor.WHITE) { TdsColor.BLACK } else { TdsColor.WHITE diff --git a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/stopwatch/StopWatchViewModel.kt b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/stopwatch/StopWatchViewModel.kt index b97da012..e16283a8 100644 --- a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/stopwatch/StopWatchViewModel.kt +++ b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/stopwatch/StopWatchViewModel.kt @@ -66,7 +66,7 @@ constructor( fun updateColor(isTextBlackColor: Boolean = false) { viewModelScope.launch { updateColorUseCase( - recordingMode = 1, + recordingMode = 2, isTextColorBlack = isTextBlackColor, ) } @@ -76,7 +76,7 @@ constructor( viewModelScope.launch { if (::prevStopWatchColor.isInitialized) { updateColorUseCase( - recordingMode = 1, + recordingMode = 2, backgroundColor = prevStopWatchColor.backgroundColor, isTextColorBlack = prevStopWatchColor.isTextColorBlack, ) diff --git a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/timer/TimerScreen.kt b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/timer/TimerScreen.kt index a8e282e8..74b5a84f 100644 --- a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/timer/TimerScreen.kt +++ b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/timer/TimerScreen.kt @@ -75,8 +75,7 @@ fun TimerScreen( if (showSelectColorDialog) { TimeColorDialog( backgroundColor = Color(uiState.timerColor.backgroundColor), - textColor = - if (uiState.timerColor.isTextColorBlack) { + textColor = if (uiState.timerColor.isTextColorBlack) { Color.Black } else { Color.White @@ -87,7 +86,9 @@ fun TimerScreen( onShowDialog = { showSelectColorDialog = it }, - onClickBackgroundColor = onNavigateToColor, + onClickBackgroundColor = { + onNavigateToColor() + }, onClickTextColor = { viewModel.updateColor(it) }, @@ -115,8 +116,7 @@ fun TimerScreen( if (showCheckTaskDailyDialog) { TimeCheckDailyDialog( - title = - if (!uiState.isSetTask && !uiState.isDailyAfter6AM) { + title = if (!uiState.isSetTask && !uiState.isDailyAfter6AM) { stringResource(id = R.string.daily_task_check_title) } else if (!uiState.isSetTask) { stringResource(id = R.string.task_check_title) @@ -219,8 +219,7 @@ private fun TimerScreen( val scrollState = rememberScrollState() Column( - modifier = - Modifier + modifier = Modifier .fillMaxSize() .background(backgroundColor) .padding(top = 16.dp) @@ -250,8 +249,7 @@ private fun TimerScreen( isFinish = isFinish, outCircularLineColor = textColor.getColor(), outCircularProgress = outCircularProgress, - inCircularLineTrackColor = - if (textColor == TdsColor.WHITE) { + inCircularLineTrackColor = if (textColor == TdsColor.WHITE) { TdsColor.BLACK } else { TdsColor.WHITE From 84bb55f9f312be097cc052b57d4716259e11bbca Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Tue, 30 Jan 2024 01:18:23 +0900 Subject: [PATCH 2/6] =?UTF-8?q?#36=20fix=20:=20dilog=20=ED=8F=B0=ED=8A=B8?= =?UTF-8?q?=20=EC=83=89=EC=83=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/core/designsystem/component/TdsInputTextField.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsInputTextField.kt b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsInputTextField.kt index 4186705d..8194f7f7 100644 --- a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsInputTextField.kt +++ b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsInputTextField.kt @@ -36,8 +36,13 @@ fun TdsOutlinedInputTextField( modifier = modifier, value = text, onValueChange = onValueChange, - textStyle = TdsTextStyle.NORMAL_TEXT_STYLE.getTextStyle(fontSize = fontSize) - .copy(textAlign = TextAlign.Center), + textStyle = TdsTextStyle + .NORMAL_TEXT_STYLE + .getTextStyle(fontSize = fontSize) + .copy( + color = TdsColor.TEXT.getColor(), + textAlign = TextAlign.Center, + ), keyboardOptions = keyboardOptions, keyboardActions = keyboardActions, ) { innerTextField -> From 07555828f8e1ae0bc9a0d5009a3be71780362e61 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Wed, 31 Jan 2024 22:06:55 +0900 Subject: [PATCH 3/6] =?UTF-8?q?#36=20fix=20:=20=ED=83=9C=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=20=EA=B8=B8=EC=9D=B4=20>=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/time/ui/task/TaskBottomSheet.kt | 94 ++++++++----------- 1 file changed, 41 insertions(+), 53 deletions(-) diff --git a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/task/TaskBottomSheet.kt b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/task/TaskBottomSheet.kt index 61864266..62949023 100644 --- a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/task/TaskBottomSheet.kt +++ b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/task/TaskBottomSheet.kt @@ -77,14 +77,15 @@ fun TaskBottomSheet( if (showAddTaskDialog) { taskName = "" TdsDialog( - tdsDialogInfo = - TdsDialogInfo.Confirm( + tdsDialogInfo = TdsDialogInfo.Confirm( title = stringResource(id = R.string.add_task_title), message = stringResource(id = R.string.add_task_message), cancelable = false, positiveText = stringResource(id = R.string.Ok), onPositive = { - viewModel.addTask(taskName) + if (taskName.isNotEmpty()) { + viewModel.addTask(taskName) + } }, negativeText = stringResource(id = R.string.Cancel), ), @@ -100,8 +101,7 @@ fun TaskBottomSheet( } TdsOutlinedInputTextField( - modifier = - Modifier + modifier = Modifier .fillMaxWidth() .height(26.dp) .padding(horizontal = 15.dp) @@ -127,8 +127,7 @@ fun TaskBottomSheet( val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) ModalBottomSheet( - modifier = - Modifier + modifier = Modifier .fillMaxHeight(0.9f) .fillMaxWidth() .navigationBarsPadding(), @@ -218,8 +217,7 @@ fun TaskBottomSheet( seconds = "" TdsDialog( - tdsDialogInfo = - TdsDialogInfo.Confirm( + tdsDialogInfo = TdsDialogInfo.Confirm( title = editTask.taskName, message = stringResource(id = R.string.edit_task_target_time), positiveText = stringResource(id = R.string.Ok), @@ -254,18 +252,17 @@ fun TaskBottomSheet( keyboard?.show() } - val confirm = - TdsDialogInfo.Confirm( - title = stringResource(id = R.string.modify_task_title), - message = stringResource(id = R.string.add_task_message), - positiveText = stringResource(id = R.string.Ok), - onPositive = { - if (editTaskName.text != editTask.taskName) { - onModifyTaskName(Pair(editTask, editTaskName.text)) - } - }, - negativeText = stringResource(id = R.string.Cancel), - ) + val confirm = TdsDialogInfo.Confirm( + title = stringResource(id = R.string.modify_task_title), + message = stringResource(id = R.string.add_task_message), + positiveText = stringResource(id = R.string.Ok), + onPositive = { + if (editTaskName.text != editTask.taskName) { + onModifyTaskName(Pair(editTask, editTaskName.text)) + } + }, + negativeText = stringResource(id = R.string.Cancel), + ) TdsDialog( tdsDialogInfo = confirm, @@ -274,8 +271,7 @@ fun TaskBottomSheet( }, ) { TdsOutlinedInputTextField( - modifier = - Modifier + modifier = Modifier .fillMaxWidth() .height(26.dp) .padding(horizontal = 15.dp) @@ -291,15 +287,13 @@ fun TaskBottomSheet( Column(modifier = Modifier.fillMaxSize()) { Box( - modifier = - Modifier + modifier = Modifier .fillMaxWidth() .padding(horizontal = 12.dp), ) { TdsTextButton( modifier = Modifier.align(Alignment.CenterStart), - text = - if (editMode) { + text = if (editMode) { stringResource(id = R.string.done) } else { stringResource(id = R.string.edit) @@ -330,21 +324,19 @@ fun TaskBottomSheet( } val listState = rememberLazyListState() - val dragDropState = - rememberDragDropState(lazyListState = listState) { from, to -> - onTaskMove(Pair(from, to)) - } - val modifier = - if (editMode) { - Modifier - .dragContainer(dragDropState) - .fillMaxSize() - .padding(horizontal = 20.dp) - } else { - Modifier - .fillMaxSize() - .padding(horizontal = 20.dp) - } + val dragDropState = rememberDragDropState(lazyListState = listState) { from, to -> + onTaskMove(Pair(from, to)) + } + val modifier = if (editMode) { + Modifier + .dragContainer(dragDropState) + .fillMaxSize() + .padding(horizontal = 20.dp) + } else { + Modifier + .fillMaxSize() + .padding(horizontal = 20.dp) + } LazyColumn( modifier = modifier, @@ -353,8 +345,7 @@ fun TaskBottomSheet( itemsIndexed(uiState.tasks) { index, task -> DraggableItem(dragDropState = dragDropState, index = index) { isDragging -> TdsTaskListItem( - modifier = - Modifier + modifier = Modifier .fillMaxWidth() .background( color = @@ -364,8 +355,7 @@ fun TaskBottomSheet( TdsColor.BACKGROUND.getColor() }, ), - tdsTask = - TdsTask( + tdsTask = TdsTask( taskTargetTime = task.taskTargetTime, isTaskTargetTimeOn = task.isTaskTargetTimeOn, taskName = task.taskName, @@ -379,11 +369,10 @@ fun TaskBottomSheet( }, onLongClickTask = { editTask = task - editTaskName = - editTaskName.copy( - text = task.taskName, - selection = TextRange(task.taskName.length), - ) + editTaskName = editTaskName.copy( + text = task.taskName, + selection = TextRange(task.taskName.length), + ) showTaskNameModifyDialog = true }, onEdit = { @@ -418,8 +407,7 @@ private fun TaskBottomSheetPreview() { TaskBottomSheet( uiState = TaskUiState( - tasks = - listOf( + tasks = listOf( Task( id = 0, position = 0, From 3030a9e73c7643c0d1a91a3907bbbf0a19df052e Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Wed, 31 Jan 2024 22:23:54 +0900 Subject: [PATCH 4/6] =?UTF-8?q?#36=20fix=20:=20ColorScreen=20=EB=86=92?= =?UTF-8?q?=EC=9D=B4=20=EC=9D=B4=EC=8A=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../titi/app/feature/color/ui/ColorScreen.kt | 105 ++++++++++-------- 1 file changed, 56 insertions(+), 49 deletions(-) diff --git a/feature/color/src/main/kotlin/com/titi/app/feature/color/ui/ColorScreen.kt b/feature/color/src/main/kotlin/com/titi/app/feature/color/ui/ColorScreen.kt index 0bed7a1e..c5496b5f 100644 --- a/feature/color/src/main/kotlin/com/titi/app/feature/color/ui/ColorScreen.kt +++ b/feature/color/src/main/kotlin/com/titi/app/feature/color/ui/ColorScreen.kt @@ -37,6 +37,7 @@ import com.airbnb.mvrx.compose.mavericksViewModel import com.github.skydoves.colorpicker.compose.AlphaSlider import com.github.skydoves.colorpicker.compose.AlphaTile import com.github.skydoves.colorpicker.compose.BrightnessSlider +import com.github.skydoves.colorpicker.compose.ColorPickerController import com.github.skydoves.colorpicker.compose.HsvColorPicker import com.github.skydoves.colorpicker.compose.rememberColorPickerController import com.titi.app.core.designsystem.R @@ -55,16 +56,14 @@ fun ColorScreen( recordingMode: Int, onFinish: () -> Unit, ) { - val controller = rememberColorPickerController() - val uiState by viewModel.collectAsState() + val controller = rememberColorPickerController() var showDialog by remember { mutableStateOf(false) } var selectedColor by remember { mutableLongStateOf(0L) } if (showDialog) { TdsDialog( - tdsDialogInfo = - TdsDialogInfo.Confirm( + tdsDialogInfo = TdsDialogInfo.Confirm( title = stringResource(R.string.setting_background_text), cancelable = false, positiveText = stringResource(id = R.string.Ok), @@ -80,8 +79,7 @@ fun ColorScreen( onShowDialog = { showDialog = it }, ) { Box( - modifier = - Modifier + modifier = Modifier .size(40.dp) .clip(RoundedCornerShape(6.dp)) .background(Color(selectedColor)) @@ -90,16 +88,44 @@ fun ColorScreen( } } + ColorScreen( + uiState = uiState, + controller = controller, + onShowDialog = { + selectedColor = it + showDialog = true + }, + onClickCancel = onFinish, + onClickConfirm = { + viewModel.addBackgroundColor( + colors = uiState.colors, + color = controller.selectedColor.value.toArgb().toLong(), + ) + viewModel.updateColor( + recordingMode = recordingMode, + color = controller.selectedColor.value.toArgb().toLong(), + ) + onFinish() + }, + ) +} + +@Composable +private fun ColorScreen( + uiState: ColorUiState, + controller: ColorPickerController, + onShowDialog: (Long) -> Unit, + onClickCancel: () -> Unit, + onClickConfirm: () -> Unit, +) { Column( - modifier = - Modifier + modifier = Modifier .fillMaxSize() .background(Color.Black), ) { HsvColorPicker( - modifier = - Modifier - .size(450.dp) + modifier = Modifier + .weight(1f) .padding( vertical = 10.dp, horizontal = 24.dp, @@ -108,8 +134,7 @@ fun ColorScreen( ) TdsText( - modifier = - Modifier + modifier = Modifier .fillMaxWidth() .padding(horizontal = 24.dp), text = "#${controller.selectedColor.value.hexCode}", @@ -122,8 +147,7 @@ fun ColorScreen( Spacer(modifier = Modifier.height(10.dp)) AlphaSlider( - modifier = - Modifier + modifier = Modifier .fillMaxWidth() .padding( vertical = 10.dp, @@ -134,8 +158,7 @@ fun ColorScreen( ) BrightnessSlider( - modifier = - Modifier + modifier = Modifier .fillMaxWidth() .padding( vertical = 10.dp, @@ -146,8 +169,7 @@ fun ColorScreen( ) Row( - modifier = - Modifier + modifier = Modifier .padding( top = 10.dp, start = 24.dp, @@ -155,8 +177,7 @@ fun ColorScreen( ), ) { AlphaTile( - modifier = - Modifier + modifier = Modifier .size(80.dp) .clip(RoundedCornerShape(6.dp)) .border(2.dp, Color.LightGray), @@ -168,18 +189,14 @@ fun ColorScreen( ColorPresetContent( modifier = Modifier.fillMaxWidth(), colors = uiState.colors, - onShowDialog = { - selectedColor = it - showDialog = true - }, + onShowDialog = onShowDialog, ) } - Spacer(modifier = Modifier.weight(1f)) + Spacer(modifier = Modifier.height(10.dp)) ColorButtons( - modifier = - Modifier + modifier = Modifier .fillMaxWidth() .padding( top = 10.dp, @@ -188,18 +205,8 @@ fun ColorScreen( bottom = 24.dp, ), color = controller.selectedColor.value, - onClickCancel = onFinish, - onClickConfirm = { - viewModel.addBackgroundColor( - colors = uiState.colors, - color = controller.selectedColor.value.toArgb().toLong(), - ) - viewModel.updateColor( - recordingMode = recordingMode, - color = controller.selectedColor.value.toArgb().toLong(), - ) - onFinish() - }, + onClickCancel = onClickCancel, + onClickConfirm = onClickConfirm, ) } } @@ -213,8 +220,7 @@ private fun ColorPresetContent( Column(modifier = modifier) { repeat(2) { columnIndex -> Row( - modifier = - Modifier + modifier = Modifier .fillMaxWidth() .padding(bottom = 10.dp), horizontalArrangement = Arrangement.SpaceBetween, @@ -222,8 +228,7 @@ private fun ColorPresetContent( repeat(6) { rowIndex -> val index = columnIndex * 6 + rowIndex Box( - modifier = - Modifier + modifier = Modifier .size(35.dp) .clip(RoundedCornerShape(6.dp)) .border(2.dp, Color.LightGray) @@ -231,8 +236,7 @@ private fun ColorPresetContent( ) { colors.getOrNull(index)?.let { Box( - modifier = - Modifier + modifier = Modifier .fillMaxSize() .background(Color(it)) .clickable { onShowDialog(it) }, @@ -285,13 +289,16 @@ private fun ColorButtons( } } -@Preview +@Preview(widthDp = 600, heightDp = 600) @Composable private fun ColorScreenPreview() { TiTiTheme { ColorScreen( - recordingMode = 1, - onFinish = {}, + uiState = ColorUiState(), + controller = rememberColorPickerController(), + onClickConfirm = {}, + onClickCancel = {}, + onShowDialog = {}, ) } } From 3f6154cc23b3dde77c60165be92e791abc978f42 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Wed, 31 Jan 2024 23:19:41 +0900 Subject: [PATCH 5/6] =?UTF-8?q?#36=20fix=20:=20=EB=9D=BC=EC=9D=B4=ED=8A=B8?= =?UTF-8?q?=20=EB=AA=A8=EB=93=9C=20=EB=8B=A4=ED=81=AC=20=EB=AA=A8=EB=93=9C?= =?UTF-8?q?=20=EC=BB=AC=EB=9F=AC=20=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/designsystem/component/TdsDialog.kt | 6 ++--- .../component/TdsInputTextField.kt | 10 ++++++-- .../designsystem/component/TdsTaskListItem.kt | 2 +- .../titi/app/core/designsystem/theme/Color.kt | 23 ++++++++++++++++++- .../feature/time/content/TimeColorDialog.kt | 5 +--- .../feature/time/ui/task/TaskBottomSheet.kt | 9 ++++---- 6 files changed, 38 insertions(+), 17 deletions(-) diff --git a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsDialog.kt b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsDialog.kt index 0e71244b..a0132acc 100644 --- a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsDialog.kt +++ b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsDialog.kt @@ -1,6 +1,5 @@ package com.titi.app.core.designsystem.component -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -12,7 +11,6 @@ import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -25,7 +23,7 @@ import com.titi.app.core.designsystem.theme.TiTiTheme @Composable fun TdsDialog( - modifier: Modifier = Modifier.background(color = TdsColor.BACKGROUND.getColor()), + modifier: Modifier = Modifier, tdsDialogInfo: TdsDialogInfo, onShowDialog: (Boolean) -> Unit, bodyContent: (@Composable () -> Unit)? = null, @@ -45,7 +43,7 @@ fun TdsDialog( .fillMaxWidth() .wrapContentHeight(), shape = RoundedCornerShape(14.dp), - color = Color.Transparent, + color = TdsColor.ALERT_BACKGROUND.getColor(), ) { Column( modifier = modifier, diff --git a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsInputTextField.kt b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsInputTextField.kt index 8194f7f7..eb028355 100644 --- a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsInputTextField.kt +++ b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsInputTextField.kt @@ -12,6 +12,8 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview @@ -45,6 +47,7 @@ fun TdsOutlinedInputTextField( ), keyboardOptions = keyboardOptions, keyboardActions = keyboardActions, + cursorBrush = SolidColor(TdsColor.TEXT.getColor()), ) { innerTextField -> Box( modifier = modifier @@ -53,7 +56,8 @@ fun TdsOutlinedInputTextField( color = TdsColor.DIVIDER.getColor(), shape = RoundedCornerShape(4.dp), ) - .background(TdsColor.BACKGROUND.getColor()), + .clip(RoundedCornerShape(4.dp)) + .background(TdsColor.TERTIARY_BACKGROUND.getColor()), contentAlignment = Alignment.Center, ) { innerTextField() @@ -82,6 +86,7 @@ fun TdsOutlinedInputTextField( .copy(textAlign = TextAlign.Center), keyboardOptions = keyboardOptions, keyboardActions = keyboardActions, + cursorBrush = SolidColor(TdsColor.TEXT.getColor()), ) { innerTextField -> Box( modifier = @@ -91,7 +96,8 @@ fun TdsOutlinedInputTextField( color = TdsColor.DIVIDER.getColor(), shape = RoundedCornerShape(4.dp), ) - .background(TdsColor.BACKGROUND.getColor()), + .clip(RoundedCornerShape(4.dp)) + .background(TdsColor.TERTIARY_BACKGROUND.getColor()), contentAlignment = Alignment.Center, ) { innerTextField() diff --git a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsTaskListItem.kt b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsTaskListItem.kt index bbbf2eb9..b6bf566a 100644 --- a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsTaskListItem.kt +++ b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsTaskListItem.kt @@ -112,7 +112,7 @@ fun TdsTaskListItem( checkedTrackColor = themeColor, checkedBorderColor = Color.Transparent, checkedThumbColor = Color.White, - uncheckedTrackColor = TdsColor.DIVIDER.getColor(), + uncheckedTrackColor = TdsColor.SWITCH_BACKGROUND.getColor(), uncheckedBorderColor = Color.Transparent, uncheckedThumbColor = Color.White, ), diff --git a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/theme/Color.kt b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/theme/Color.kt index 8c3647fe..054cd05f 100644 --- a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/theme/Color.kt +++ b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/theme/Color.kt @@ -20,6 +20,10 @@ data class TdsColorsPalette( val d12: Color = Color.Unspecified, val textColor: Color = Color.Unspecified, val backgroundColor: Color = Color.Unspecified, + val secondaryBackgroundColor: Color = Color.Unspecified, + val switchBackgroundColor: Color = Color.Unspecified, + val alertBackgroundColor: Color = Color.Unspecified, + val tertiaryBackgroundColor: Color = Color.Unspecified, val redColor: Color = Color.Unspecified, val blueColor: Color = Color.Unspecified, val dividerColor: Color = Color.Unspecified, @@ -44,6 +48,10 @@ val TdsLightColorsPalette = d12 = Color(0xFF928AEA), textColor = Color(0xFF000000), backgroundColor = Color(0xFFFFFFFF), + secondaryBackgroundColor = Color(0xFFF2F2F7), + switchBackgroundColor = Color(0xFFE9E9EB), + alertBackgroundColor = Color(0xD1EEEEEE), + tertiaryBackgroundColor = Color(0xFFFFFFFF), redColor = Color(0xFFFF453A), blueColor = Color(0xFF0A84FF), dividerColor = Color(0x4D000000), @@ -68,9 +76,13 @@ val TdsDarkColorsPalette = d12 = Color(0xFF6379EB), textColor = Color(0xFFFFFFFF), backgroundColor = Color(0xFF000000), + secondaryBackgroundColor = Color(0xFF1C1C1E), + switchBackgroundColor = Color(0xFF39393D), + alertBackgroundColor = Color(0xD12B2B2B), + tertiaryBackgroundColor = Color(0xFF2C2C2E), redColor = Color(0xFFFF453A), blueColor = Color(0xFF0A84FF), - dividerColor = Color(0x99000000), + dividerColor = Color(0x4DFFFFFF), lightGrayColor = Color(0xFF555555), whiteColor = Color(0xFFFFFFFF), blackColor = Color(0xFF000000), @@ -92,6 +104,10 @@ enum class TdsColor { TEXT, BACKGROUND, + SECONDARY_BACKGROUND, + SWITCH_BACKGROUND, + ALERT_BACKGROUND, + TERTIARY_BACKGROUND, RED, BLUE, DIVIDER, @@ -118,6 +134,11 @@ enum class TdsColor { TEXT -> TiTiTheme.colors.textColor BACKGROUND -> TiTiTheme.colors.backgroundColor + SECONDARY_BACKGROUND -> TiTiTheme.colors.secondaryBackgroundColor + SWITCH_BACKGROUND -> TiTiTheme.colors.switchBackgroundColor + ALERT_BACKGROUND -> TiTiTheme.colors.alertBackgroundColor + TERTIARY_BACKGROUND -> TiTiTheme.colors.tertiaryBackgroundColor + RED -> TiTiTheme.colors.redColor BLUE -> TiTiTheme.colors.blueColor DIVIDER -> TiTiTheme.colors.dividerColor diff --git a/feature/time/src/main/kotlin/com/titi/app/feature/time/content/TimeColorDialog.kt b/feature/time/src/main/kotlin/com/titi/app/feature/time/content/TimeColorDialog.kt index af1fe1b2..49af82b2 100644 --- a/feature/time/src/main/kotlin/com/titi/app/feature/time/content/TimeColorDialog.kt +++ b/feature/time/src/main/kotlin/com/titi/app/feature/time/content/TimeColorDialog.kt @@ -1,6 +1,5 @@ package com.titi.app.feature.time.content -import androidx.compose.foundation.background import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height import androidx.compose.runtime.Composable @@ -22,9 +21,7 @@ fun TimeColorDialog( onClickTextColor: (Boolean) -> Unit, ) { TdsDialog( - modifier = Modifier.background(color = Color(0xCCFFFFFF)), - tdsDialogInfo = - TdsDialogInfo.Confirm( + tdsDialogInfo = TdsDialogInfo.Confirm( title = stringResource(id = R.string.custom_color), positiveText = stringResource(id = R.string.Ok), negativeText = stringResource(id = R.string.Cancel), diff --git a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/task/TaskBottomSheet.kt b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/task/TaskBottomSheet.kt index 62949023..79b729f4 100644 --- a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/task/TaskBottomSheet.kt +++ b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/task/TaskBottomSheet.kt @@ -135,8 +135,8 @@ fun TaskBottomSheet( sheetState = bottomSheetState, shape = RoundedCornerShape(topStart = 8.dp, topEnd = 8.dp), tonalElevation = 0.dp, - containerColor = TdsColor.BACKGROUND.getColor(), - contentColor = TdsColor.BACKGROUND.getColor(), + containerColor = TdsColor.SECONDARY_BACKGROUND.getColor(), + contentColor = TdsColor.SECONDARY_BACKGROUND.getColor(), dragHandle = null, ) { TaskBottomSheet( @@ -348,11 +348,10 @@ fun TaskBottomSheet( modifier = Modifier .fillMaxWidth() .background( - color = - if (isDragging) { + color = if (isDragging) { TdsColor.DIVIDER.getColor() } else { - TdsColor.BACKGROUND.getColor() + TdsColor.SECONDARY_BACKGROUND.getColor() }, ), tdsTask = TdsTask( From 37b4a1c575accce47f09eaa05c5d0ad343ee94db Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Thu, 1 Feb 2024 00:25:27 +0900 Subject: [PATCH 6/6] =?UTF-8?q?#36=20fix=20:=20=EB=B0=94=ED=85=80=ED=83=AD?= =?UTF-8?q?=20=EC=83=81=EB=8B=A8=ED=99=94=EB=A9=B4=20=EC=83=89=EC=83=81?= =?UTF-8?q?=EC=B0=A8=EC=9D=B4=20=EC=9D=B4=EC=8A=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../titi/app/feature/main/navigation/TiTiNavHost.kt | 3 +-- .../kotlin/com/titi/app/feature/main/ui/TiTiApp.kt | 11 +++++++++-- .../com/titi/app/feature/time/ui/timer/TimerScreen.kt | 3 +-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/feature/main/src/main/kotlin/com/titi/app/feature/main/navigation/TiTiNavHost.kt b/feature/main/src/main/kotlin/com/titi/app/feature/main/navigation/TiTiNavHost.kt index 189dd62f..8e275a8a 100644 --- a/feature/main/src/main/kotlin/com/titi/app/feature/main/navigation/TiTiNavHost.kt +++ b/feature/main/src/main/kotlin/com/titi/app/feature/main/navigation/TiTiNavHost.kt @@ -42,8 +42,7 @@ fun TiTiNavHost( exitTransition = appState.exitTransition, ) { timeGraph( - startDestination = - if (splashResultState.recordTimes.recordingMode == 1) { + startDestination = if (splashResultState.recordTimes.recordingMode == 1) { TIMER_SCREEN } else { STOPWATCH_SCREEN diff --git a/feature/main/src/main/kotlin/com/titi/app/feature/main/ui/TiTiApp.kt b/feature/main/src/main/kotlin/com/titi/app/feature/main/ui/TiTiApp.kt index 12accbd9..231370d5 100644 --- a/feature/main/src/main/kotlin/com/titi/app/feature/main/ui/TiTiApp.kt +++ b/feature/main/src/main/kotlin/com/titi/app/feature/main/ui/TiTiApp.kt @@ -6,6 +6,8 @@ import android.os.Build import android.util.Log import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.tween import androidx.compose.foundation.background import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding @@ -62,7 +64,6 @@ fun TiTiApp( val bottomNavigationColor by appState.bottomNavigationColor.collectAsStateWithLifecycle() Scaffold( - containerColor = Color(bottomNavigationColor), bottomBar = { if (appState.shouldShowBottomBar) { TiTiBottomBar( @@ -92,8 +93,14 @@ private fun TiTiBottomBar( onNavigateToDestination: (TopLevelDestination) -> Unit, currentDestination: NavDestination?, ) { + val animateBottomNavigationBackgroundColor by animateColorAsState( + targetValue = Color(bottomNavigationColor), + tween(0), + label = "animateBottomNavigationBackgroundColor", + ) + NavigationBar( - containerColor = Color(bottomNavigationColor), + containerColor = animateBottomNavigationBackgroundColor, tonalElevation = 0.dp, ) { destinations.forEach { destination -> diff --git a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/timer/TimerScreen.kt b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/timer/TimerScreen.kt index 74b5a84f..8231591d 100644 --- a/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/timer/TimerScreen.kt +++ b/feature/time/src/main/kotlin/com/titi/app/feature/time/ui/timer/TimerScreen.kt @@ -150,8 +150,7 @@ fun TimerScreen( uiState = uiState, isFinish = isFinish, backgroundColor = Color(uiState.timerColor.backgroundColor), - textColor = - if (uiState.timerColor.isTextColorBlack) { + textColor = if (uiState.timerColor.isTextColorBlack) { TdsColor.BLACK } else { TdsColor.WHITE