Skip to content

Commit

Permalink
set notif message in DB
Browse files Browse the repository at this point in the history
  • Loading branch information
Metaroll committed Dec 9, 2024
1 parent 77e773f commit 1ab6437
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ fun SettingsScreen(
viewModel: SettingsViewModel = koinViewModel(),
onSwitchProtectionScreen: (Boolean) -> Unit,
) {
val dbHelper: IPeriodDatabaseHelper = koinInject()
val viewState = viewModel.viewState.collectAsStateWithLifecycle().value
val isDarkMode = isDarkMode()
LaunchedEffect(isDarkMode) {
Expand Down Expand Up @@ -133,7 +132,7 @@ fun SettingsScreen(
)
SettingText(
text = stringResource(R.string.period_notification_message),
message = dbHelper.getSettingByKey("period_notification_message")?.value.toString()
key = "period_notification_message"
)

Spacer(Modifier.height(16.dp))
Expand Down Expand Up @@ -456,8 +455,10 @@ private fun ColorPickerPreview() {
private fun SettingText(
text: String,
modifier: Modifier = Modifier,
message: String,
key: String,
) {
val dbHelper: IPeriodDatabaseHelper = koinInject()
val message = dbHelper.getSettingByKey(key)?.value.toString()
var showDialog by remember { mutableStateOf(false) }
var newMessage by remember { mutableStateOf(message) }

Expand Down Expand Up @@ -487,7 +488,7 @@ private fun SettingText(
},
confirmButton = {
Button(onClick = {
// TODO save text field to DB
dbHelper.updateSetting(key = key, value = newMessage)
showDialog = false
}) {
Text(text = stringResource(id = R.string.save_button))
Expand Down

0 comments on commit 1ab6437

Please sign in to comment.