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

UI Improvements #104

Merged
merged 8 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
35 changes: 20 additions & 15 deletions app/src/main/java/com/bnyro/clock/ui/components/NumberKeypad.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import androidx.compose.material.icons.filled.Backspace
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.stringResource
Expand All @@ -32,36 +34,37 @@ fun NumberKeypad(

val buttonSize = (screenHeight / 8).dp
val buttonSpacing = 6.dp
val buttonColor = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp)

Column(
verticalArrangement = Arrangement.spacedBy(buttonSpacing)
) {
Row(
horizontalArrangement = Arrangement.spacedBy(buttonSpacing)
) {
Button(number = "1", buttonSize, onOperation)
Button(number = "2", buttonSize, onOperation)
Button(number = "3", buttonSize, onOperation)
Button(number = "1", buttonSize, buttonColor, onOperation)
Button(number = "2", buttonSize, buttonColor, onOperation)
Button(number = "3", buttonSize, buttonColor, onOperation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the buttonColor arguments everywhere here.

}
Row(
horizontalArrangement = Arrangement.spacedBy(buttonSpacing)
) {
Button(number = "4", buttonSize, onOperation)
Button(number = "5", buttonSize, onOperation)
Button(number = "6", buttonSize, onOperation)
Button(number = "4", buttonSize, buttonColor, onOperation)
Button(number = "5", buttonSize, buttonColor, onOperation)
Button(number = "6", buttonSize, buttonColor, onOperation)
}
Row(
horizontalArrangement = Arrangement.spacedBy(buttonSpacing)
) {
Button(number = "7", buttonSize, onOperation)
Button(number = "8", buttonSize, onOperation)
Button(number = "9", buttonSize, onOperation)
Button(number = "7", buttonSize, buttonColor, onOperation)
Button(number = "8", buttonSize, buttonColor, onOperation)
Button(number = "9", buttonSize, buttonColor, onOperation)
}
Row(
horizontalArrangement = Arrangement.spacedBy(buttonSpacing)
) {
Button(number = "00", buttonSize, onOperation)
Button(number = "0", buttonSize, onOperation)
Button(number = "00", buttonSize, buttonColor, onOperation)
Button(number = "0", buttonSize, buttonColor, onOperation)
SingleElementButton(
onClick = {
coroutineScope.launch {
Expand All @@ -77,13 +80,13 @@ fun NumberKeypad(

onOperation(NumberKeypadOperation.Clear)
},
color = MaterialTheme.colorScheme.primaryContainer,
color = MaterialTheme.colorScheme.secondaryContainer,
modifier = Modifier.size(buttonSize)
) {
Icon(
imageVector = Icons.Default.Backspace,
contentDescription = stringResource(R.string.delete),
tint = MaterialTheme.colorScheme.onPrimaryContainer
tint = MaterialTheme.colorScheme.onSecondaryContainer
)
}
}
Expand All @@ -94,6 +97,7 @@ fun NumberKeypad(
fun Button(
number: String,
buttonSize: Dp,
buttonColor: Color,
onOperation: (NumberKeypadOperation) -> Unit
) {
val view = LocalView.current
Expand All @@ -107,12 +111,13 @@ fun Button(

onOperation(NumberKeypadOperation.AddNumber(number))
},
modifier = Modifier.size(buttonSize)
modifier = Modifier.size(buttonSize),
color = buttonColor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
color = buttonColor
color = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp)

) {
Text(
text = number,
color = MaterialTheme.colorScheme.onSurface,
fontSize = MaterialTheme.typography.headlineLarge.fontSize
fontSize = MaterialTheme.typography.displaySmall.fontSize
)
}
}
6 changes: 3 additions & 3 deletions app/src/main/java/com/bnyro/clock/ui/nav/NavRoutes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.compose.material.icons.filled.Alarm
import androidx.compose.material.icons.filled.AvTimer
import androidx.compose.material.icons.filled.Schedule
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.Timer
import androidx.compose.material.icons.outlined.Timer
import androidx.compose.ui.graphics.vector.ImageVector
import com.bnyro.clock.R

Expand All @@ -17,7 +17,7 @@ sealed class NavRoutes(
) {
object Clock : NavRoutes("clock", R.string.clock, Icons.Default.Schedule)
object Alarm : NavRoutes("alarm", R.string.alarm, Icons.Default.Alarm)
object Timer : NavRoutes("timer", R.string.timer, Icons.Default.Timer)
object Stopwatch : NavRoutes("stopwatch", R.string.stopwatch, Icons.Default.AvTimer)
object Timer : NavRoutes("timer", R.string.timer, Icons.Default.AvTimer)
object Stopwatch : NavRoutes("stopwatch", R.string.stopwatch, Icons.Outlined.Timer)
object Settings : NavRoutes("settings", R.string.settings, Icons.Default.Settings)
}
7 changes: 3 additions & 4 deletions app/src/main/java/com/bnyro/clock/ui/screens/ClockScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ fun ClockScreen(clockModel: ClockModel) {
) {
Column(
modifier = Modifier
.padding(horizontal = 25.dp, vertical = 30.dp)
.padding(horizontal = 28.dp, vertical = 28.dp)
) {
val (date, time) = TimeHelper.formatDateTime(clockModel.currentDate)
Text(
text = time,
style = MaterialTheme.typography.headlineLarge,
fontSize = 40.sp
style = MaterialTheme.typography.displayMedium
)
Text(
text = date,
Expand Down Expand Up @@ -87,7 +86,7 @@ fun ClockScreen(clockModel: ClockModel) {
) {
Column(
modifier = Modifier
.padding(horizontal = 25.dp, vertical = 20.dp)
.padding(horizontal = 24.dp, vertical = 24.dp)
) {
Text(
text = timeZone.displayName.uppercase(),
Expand Down
17 changes: 9 additions & 8 deletions app/src/main/java/com/bnyro/clock/ui/screens/StopwatchScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ fun StopwatchScreen(stopwatchModel: StopwatchModel) {
) {
Box(
modifier = Modifier
.size(250.dp)
.border(2.dp, MaterialTheme.colorScheme.outlineVariant, CircleShape),
.size(320.dp)
.border(8.dp, MaterialTheme.colorScheme.surfaceVariant, CircleShape),
contentAlignment = Alignment.Center
) {
Row(
Expand All @@ -58,16 +58,17 @@ fun StopwatchScreen(stopwatchModel: StopwatchModel) {

Text(
text = minutes.toString(),
style = MaterialTheme.typography.headlineLarge
style = MaterialTheme.typography.displayLarge
)
Spacer(modifier = Modifier.width(5.dp))
Spacer(modifier = Modifier.width(6.dp))
Text(
text = seconds.addZero(),
style = MaterialTheme.typography.headlineLarge
style = MaterialTheme.typography.displayLarge
)
Spacer(modifier = Modifier.width(5.dp))
Spacer(modifier = Modifier.width(6.dp))
Text(
text = hundreds.addZero()
text = hundreds.addZero(),
style = MaterialTheme.typography.headlineMedium
)
}
}
Expand All @@ -84,7 +85,7 @@ fun StopwatchScreen(stopwatchModel: StopwatchModel) {
Row(
modifier = Modifier
.fillMaxWidth(0.6f)
.padding(vertical = 5.dp),
.padding(vertical = 6.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Text("#${index + 1}")
Expand Down
Loading