Skip to content
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

Add example timers #99

Merged
merged 7 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 17 additions & 22 deletions app/src/main/java/com/bnyro/clock/ui/common/ExampleTimers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,21 @@ data class ExampleTimer(

return "%02d:%02d:%02d".format(hours, minutes, seconds);
}
}


val EXAMPLE_TIMERS = listOf<ExampleTimer>(
// 1 Minute
ExampleTimer(seconds = 60),
// 2 Minutes
ExampleTimer(seconds = 60 * 2),
// 5 Minutes
ExampleTimer(seconds = 60 * 5),
// 10 Minutes
ExampleTimer(seconds = 60 * 10),
// 15 Minutes
ExampleTimer(seconds = 60 * 15),
// 20 Minutes
ExampleTimer(seconds = 60 * 20),
// 30 Minutes
ExampleTimer(seconds = 60 * 30),
// 60 Minutes
ExampleTimer(seconds = 60 * 60),
// 90 Minutes
ExampleTimer(seconds = 60 * 90),
)
companion object {
val exampleTimers: List<ExampleTimer>
get() = listOf<Int>(
60,
60 * 2,
60 * 5,
60 * 10,
60 * 13,
60 * 15,
60 * 20,
60 * 30,
60 * 60,
60 * 90,
60 * 120,
).map { ExampleTimer(it) }
}
}
43 changes: 21 additions & 22 deletions app/src/main/java/com/bnyro/clock/ui/screens/TimerScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ import com.bnyro.clock.R
import com.bnyro.clock.extensions.addZero
import com.bnyro.clock.obj.NumberKeypadOperation
import com.bnyro.clock.obj.WatchState
import com.bnyro.clock.ui.common.EXAMPLE_TIMERS
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ButtonDefaults
import com.bnyro.clock.ui.common.ExampleTimer
import com.bnyro.clock.ui.components.ClickableIcon
import com.bnyro.clock.ui.components.DialogButton
import com.bnyro.clock.ui.components.FormattedTimerTime
Expand Down Expand Up @@ -136,26 +135,6 @@ fun TimerScreen(timerModel: TimerModel) {
}
}
Spacer(modifier = Modifier.height(16.dp))
LazyRow(
contentPadding = PaddingValues(horizontal = 16.dp),
horizontalArrangement = Arrangement.spacedBy(16.dp),
) {
items(EXAMPLE_TIMERS) { timer ->
Button(
onClick = {
timerModel.setSeconds(timer.seconds)
createNew = false
timerModel.startTimer(context)
},
colors = ButtonDefaults.filledTonalButtonColors(),
) {
Text(
timer.formattedTime,
)
}
}
}
Spacer(modifier = Modifier.height(16.dp))
Row(
modifier = Modifier.padding(bottom = 16.dp)
) {
Expand All @@ -177,6 +156,26 @@ fun TimerScreen(timerModel: TimerModel) {
Icon(imageVector = Icons.Default.PlayArrow, contentDescription = null)
}
}
LazyRow(
contentPadding = PaddingValues(horizontal = 16.dp),
horizontalArrangement = Arrangement.spacedBy(16.dp),
) {
items(ExampleTimer.exampleTimers) { timer ->
Button(
onClick = {
timerModel.setSeconds(timer.seconds)
createNew = false
timerModel.startTimer(context)
},
colors = ButtonDefaults.filledTonalButtonColors(),
) {
Text(
timer.formattedTime,
)
}
}
}
Spacer(modifier = Modifier.height(32.dp))
}
} else {
LazyColumn(
Expand Down