-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
19 feature notify users to change battery permission settings #22
Changes from 9 commits
c67c644
c236f7b
b4b81ba
940585f
8aa5810
e36e8a6
ecc1cb9
9b9c746
da43e9d
74417d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,26 +139,6 @@ fun NavigationComponent( | |
startDestination: String | ||
) { | ||
val clockPageViewModel = viewModel.clockPage | ||
val clockEnabled = clockPageViewModel.clockButtonEnabled | ||
val isRunning = clockPageViewModel.isClockRunning | ||
val dropdownExpanded = clockPageViewModel.dropdownExpanded | ||
// observe changes on autofillTaskNames to allow filteredTaskNames to function properly | ||
clockPageViewModel.autofillTaskNames.observeAsState() | ||
val filteredTaskNames = clockPageViewModel.filteredEventNames | ||
val taskTextFieldValue = clockPageViewModel.taskTextFieldValue | ||
val currSeconds = clockPageViewModel.currSeconds | ||
val onTaskNameChange = clockPageViewModel::onTaskNameChange | ||
val onTaskNameDonePressed = clockPageViewModel::onTaskNameDonePressed | ||
val onDismissDropdown = clockPageViewModel::onDismissDropdown | ||
val onDropdownMenuItemClick = clockPageViewModel::onDropdownMenuItemClick | ||
val startClock = clockPageViewModel::startClock | ||
val stopClock = clockPageViewModel::stopClock | ||
val onTimerAnimationFinished = clockPageViewModel::resetCurrSeconds | ||
val countdownEnabled = clockPageViewModel.countDownTimerEnabled | ||
val onCountdownIconClicked = clockPageViewModel::switchCountDownTimer | ||
val hoursTextFieldValue = clockPageViewModel.hoursTextFieldValue | ||
val minutesTextFieldValue = clockPageViewModel.minutesTextFieldValue | ||
val secondsTextFieldValue = clockPageViewModel.secondsTextFieldValue | ||
Comment on lines
-142
to
-161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Want to only pass the ViewModel into components now, instead of a giant pile of parameters. However, this takes away the ability to view the ClockPage's compose mockup, which is not a big deal since I don't see it changing soon. I am going to play around with different ways to pass state parameters and functions into these higher order components, to see how things will be tested the easiest. |
||
|
||
val listPageViewModel = viewModel.listPage | ||
val groupedEvents = listPageViewModel.groupedEventsByDate.observeAsState().value | ||
|
@@ -190,25 +170,7 @@ fun NavigationComponent( | |
) { | ||
composable(clockRoute) { | ||
ClockPage( | ||
viewModel = clockPageViewModel, | ||
clockEnabled = clockEnabled, | ||
isRunning = isRunning, | ||
dropdownExpanded = dropdownExpanded, | ||
filteredTaskNames = filteredTaskNames, | ||
taskTextFieldValue = taskTextFieldValue, | ||
currSeconds = currSeconds, | ||
onTaskNameChange = onTaskNameChange, | ||
onTaskNameDonePressed = onTaskNameDonePressed, | ||
onDismissDropdown = onDismissDropdown, | ||
onDropdownMenuItemClick = onDropdownMenuItemClick, | ||
startClock = startClock, | ||
stopClock = stopClock, | ||
timerAnimationFinishedListener = onTimerAnimationFinished, | ||
onCountdownIconClicked = onCountdownIconClicked, | ||
countdownEnabled = countdownEnabled, | ||
hoursTextFieldValue = hoursTextFieldValue, | ||
minutesTextFieldValue = minutesTextFieldValue, | ||
secondsTextFieldValue = secondsTextFieldValue | ||
viewModel = clockPageViewModel | ||
) | ||
} | ||
composable(listRoute) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,12 @@ data class UserPreferences( | |
val countDownEndTime: Long | ||
) | ||
|
||
class UserPreferencesRepository(private val dataStore: DataStore<Preferences>) { | ||
object PreferenceKeys { | ||
val COUNT_DOWN_END_TIME = longPreferencesKey("count_down_end_time") | ||
val COUNT_DOWN_ENABLED = booleanPreferencesKey("count_down_enabled") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can move this back into the class for now if I want. For simplicity of testing, I wanted to see if I can make updating these preferences generic, which meant I moved these keys out of the class so I can reference them elsewhere. |
||
|
||
// list of keys that are used to maintain state in the app | ||
private object PreferenceKeys { | ||
val COUNT_DOWN_END_TIME = longPreferencesKey("count_down_end_time") | ||
val COUNT_DOWN_ENABLED = booleanPreferencesKey("count_down_enabled") | ||
} | ||
class UserPreferencesRepository(private val dataStore: DataStore<Preferences>) { | ||
|
||
val userPreferencesFlow: Flow<UserPreferences> = dataStore.data | ||
.catch { exception -> | ||
|
@@ -43,15 +42,15 @@ class UserPreferencesRepository(private val dataStore: DataStore<Preferences>) { | |
return UserPreferences(countDownEnabled, countDownEndTime) | ||
} | ||
|
||
suspend fun updateCountDownEnabled(enabled: Boolean) { | ||
suspend fun updateCountDownEndTime(endTime: Long) { | ||
dataStore.edit { | ||
it[PreferenceKeys.COUNT_DOWN_ENABLED] = enabled | ||
it[PreferenceKeys.COUNT_DOWN_END_TIME] = endTime | ||
} | ||
} | ||
|
||
suspend fun updateCountDownEndTime(endTime: Long) { | ||
suspend fun updateCountDownEnabled(enabled: Boolean) { | ||
dataStore.edit { | ||
it[PreferenceKeys.COUNT_DOWN_END_TIME] = endTime | ||
it[PreferenceKeys.COUNT_DOWN_ENABLED] = enabled | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.nickspatties.timeclock.ui.components | ||
|
||
import androidx.compose.material.AlertDialog | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.nickspatties.timeclock.R | ||
|
||
@Composable | ||
@Preview | ||
fun BatteryWarningDialog( | ||
confirmFunction: () -> Unit = {}, | ||
dismissFunction: () -> Unit = {} | ||
) { | ||
AlertDialog( | ||
modifier = Modifier, | ||
onDismissRequest = dismissFunction, | ||
title = { Text(stringResource(id = R.string.battery_warning_dialog_title)) }, | ||
text = { Text(stringResource(id = R.string.battery_warning_dialog_body)) }, | ||
confirmButton = { | ||
TextButton(onClick = confirmFunction) { | ||
Text(text = stringResource(id = R.string.battery_warning_dialog_action).uppercase()) | ||
} | ||
}, | ||
dismissButton = null | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant label removed