Skip to content

Commit

Permalink
Merge pull request #108 from M00NJ/settings-screen-improvements
Browse files Browse the repository at this point in the history
Small settings menu improvements
  • Loading branch information
Bnyro authored Jul 20, 2023
2 parents 2e93e26 + 4f333a2 commit 4d274db
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 29 deletions.
7 changes: 3 additions & 4 deletions app/src/main/java/com/bnyro/clock/ui/prefs/ButtonGroupPref.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ fun ButtonGroupPref(
) {
Column(
modifier = Modifier
.padding(horizontal = 10.dp)
.padding(top = 10.dp)
.padding(top = 8.dp)
) {
Text(title)
Spacer(modifier = Modifier.height(5.dp))
Spacer(modifier = Modifier.height(8.dp))
Row(
modifier = Modifier
.fillMaxWidth()
) {
val cornerRadius = 16.dp
val cornerRadius = 20.dp
var selectedItem by remember {
mutableStateOf(
Preferences.instance.getString(preferenceKey, defaultValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fun IconPreference(
.clickable(interactionSource = interactionSource, indication = null) {
onClick.invoke()
}
.padding(start = 10.dp, top = 7.dp),
.padding(top = 8.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Expand Down
13 changes: 4 additions & 9 deletions app/src/main/java/com/bnyro/clock/ui/prefs/SettingsCategory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,19 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun SettingsCategory(
title: String
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(
start = 10.dp,
top = 5.dp
)
modifier = Modifier.fillMaxWidth()
.padding(top = 16.dp)
) {
Text(
text = title.uppercase(),
fontSize = 10.sp,
color = MaterialTheme.colorScheme.secondary
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.primary
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Checkbox
import androidx.compose.material3.Switch
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.bnyro.clock.util.Preferences

@Composable
fun CheckboxPref(
fun SwitchPref(
prefKey: String,
title: String,
summary: String? = null,
Expand All @@ -35,7 +33,6 @@ fun CheckboxPref(
Row(
modifier = Modifier
.fillMaxWidth()
.padding(start = 10.dp)
.clickable(
interactionSource = interactionSource,
indication = null
Expand All @@ -50,7 +47,7 @@ fun CheckboxPref(
title = title,
summary = summary
)
Checkbox(
Switch(
checked = checked,
onCheckedChange = {
checked = it
Expand Down
11 changes: 4 additions & 7 deletions app/src/main/java/com/bnyro/clock/ui/screens/SettingsScreen.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.bnyro.clock.ui.screens

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
Expand All @@ -19,9 +17,9 @@ import com.bnyro.clock.BuildConfig
import com.bnyro.clock.R
import com.bnyro.clock.ui.model.SettingsModel
import com.bnyro.clock.ui.prefs.ButtonGroupPref
import com.bnyro.clock.ui.prefs.CheckboxPref
import com.bnyro.clock.ui.prefs.IconPreference
import com.bnyro.clock.ui.prefs.SettingsCategory
import com.bnyro.clock.ui.prefs.SwitchPref
import com.bnyro.clock.util.IntentHelper
import com.bnyro.clock.util.Preferences

Expand All @@ -35,10 +33,9 @@ fun SettingsScreen(
Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 5.dp)
.padding(horizontal = 16.dp)
.verticalScroll(scrollState)
) {
Spacer(modifier = Modifier.height(10.dp))
SettingsCategory(stringResource(R.string.appearance))
ButtonGroupPref(
preferenceKey = Preferences.themeKey,
Expand All @@ -51,12 +48,12 @@ fun SettingsScreen(
) {
settingsModel.themeMode = it
}
CheckboxPref(
SwitchPref(
prefKey = Preferences.showSecondsKey,
title = stringResource(R.string.show_seconds),
defaultValue = true
)
CheckboxPref(
SwitchPref(
prefKey = Preferences.timerUsePickerKey,
title = stringResource(R.string.timer_useTimePicker),
defaultValue = false
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/bnyro/clock/ui/screens/TimerScreen.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.bnyro.clock.ui.screens

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -96,7 +95,7 @@ fun TimerScreen(timerModel: TimerModel) {
NumberPicker(
modifier = Modifier
.weight(1f)
.padding(start = 16.dp, end = 16.dp),
.padding(horizontal = 16.dp),
textStyle = MaterialTheme.typography.displayLarge,
value = timerModel.getMinutes(),
onValueChanged = timerModel::addMinutes,
Expand Down

0 comments on commit 4d274db

Please sign in to comment.