feat(ui): animate toolbar colors according to timer mode
This commit is contained in:
@@ -203,7 +203,7 @@ class TimerService : Service() {
|
|||||||
|
|
||||||
if (totalTime - time < lastSavedDuration)
|
if (totalTime - time < lastSavedDuration)
|
||||||
lastSavedDuration =
|
lastSavedDuration =
|
||||||
0 // Sanity check, prevents errors if service is force closed
|
0 // Sanity check, prevents bugs if service is force closed
|
||||||
if (totalTime - time - lastSavedDuration > 60000)
|
if (totalTime - time - lastSavedDuration > 60000)
|
||||||
saveTimeToDb()
|
saveTimeToDb()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import android.content.Intent
|
|||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.Crossfade
|
import androidx.compose.animation.Crossfade
|
||||||
import androidx.compose.animation.SharedTransitionLayout
|
import androidx.compose.animation.SharedTransitionLayout
|
||||||
|
import androidx.compose.animation.animateColorAsState
|
||||||
import androidx.compose.animation.expandHorizontally
|
import androidx.compose.animation.expandHorizontally
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
@@ -89,6 +90,7 @@ import org.nsh07.pomodoro.ui.settingsScreen.SettingsScreenRoot
|
|||||||
import org.nsh07.pomodoro.ui.statsScreen.StatsScreenRoot
|
import org.nsh07.pomodoro.ui.statsScreen.StatsScreenRoot
|
||||||
import org.nsh07.pomodoro.ui.timerScreen.AlarmDialog
|
import org.nsh07.pomodoro.ui.timerScreen.AlarmDialog
|
||||||
import org.nsh07.pomodoro.ui.timerScreen.TimerScreen
|
import org.nsh07.pomodoro.ui.timerScreen.TimerScreen
|
||||||
|
import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerMode
|
||||||
import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerViewModel
|
import org.nsh07.pomodoro.ui.timerScreen.viewModel.TimerViewModel
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
|
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
|
||||||
@@ -138,6 +140,20 @@ fun AppScreen(
|
|||||||
WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND
|
WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val primary by animateColorAsState(
|
||||||
|
if (uiState.timerMode == TimerMode.FOCUS) colorScheme.primary else colorScheme.tertiary
|
||||||
|
)
|
||||||
|
val onPrimary by animateColorAsState(
|
||||||
|
if (uiState.timerMode == TimerMode.FOCUS) colorScheme.onPrimary else colorScheme.onTertiary
|
||||||
|
)
|
||||||
|
val primaryContainer by animateColorAsState(
|
||||||
|
if (uiState.timerMode == TimerMode.FOCUS) colorScheme.primaryContainer else colorScheme.tertiaryContainer
|
||||||
|
)
|
||||||
|
val onPrimaryContainer by animateColorAsState(
|
||||||
|
if (uiState.timerMode == TimerMode.FOCUS) colorScheme.onPrimaryContainer else colorScheme.onTertiaryContainer
|
||||||
|
)
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@@ -151,8 +167,8 @@ fun AppScreen(
|
|||||||
expanded = true,
|
expanded = true,
|
||||||
scrollBehavior = toolbarScrollBehavior,
|
scrollBehavior = toolbarScrollBehavior,
|
||||||
colors = FloatingToolbarDefaults.vibrantFloatingToolbarColors(
|
colors = FloatingToolbarDefaults.vibrantFloatingToolbarColors(
|
||||||
toolbarContainerColor = colorScheme.primary,
|
toolbarContainerColor = primary,
|
||||||
toolbarContentColor = colorScheme.onPrimary
|
toolbarContentColor = onPrimary
|
||||||
),
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(
|
.padding(
|
||||||
@@ -183,10 +199,10 @@ fun AppScreen(
|
|||||||
{ if (backStack.size > 1) backStack.removeAt(1) }
|
{ if (backStack.size > 1) backStack.removeAt(1) }
|
||||||
},
|
},
|
||||||
colors = ToggleButtonDefaults.toggleButtonColors(
|
colors = ToggleButtonDefaults.toggleButtonColors(
|
||||||
containerColor = colorScheme.primary,
|
containerColor = primary,
|
||||||
contentColor = colorScheme.onPrimary,
|
contentColor = onPrimary,
|
||||||
checkedContainerColor = colorScheme.primaryContainer,
|
checkedContainerColor = primaryContainer,
|
||||||
checkedContentColor = colorScheme.onPrimaryContainer
|
checkedContentColor = onPrimaryContainer
|
||||||
),
|
),
|
||||||
shapes = ToggleButtonDefaults.shapes(
|
shapes = ToggleButtonDefaults.shapes(
|
||||||
CircleShape,
|
CircleShape,
|
||||||
|
|||||||
Reference in New Issue
Block a user