diff --git a/app/src/main/java/io/fixmyride/data/database/PrefsManager.kt b/app/src/main/java/io/fixmyride/data/database/PrefsManager.kt index 93fa5a8..9c64fbd 100644 --- a/app/src/main/java/io/fixmyride/data/database/PrefsManager.kt +++ b/app/src/main/java/io/fixmyride/data/database/PrefsManager.kt @@ -6,7 +6,6 @@ import android.content.SharedPreferences /** Provides access to SharedPreferences in a more convenient way. * * List of all keys: - * - "notifications_enabled" * - "notifications_days" * */ object PrefsManager { diff --git a/app/src/main/java/io/fixmyride/ui/components/ResultsBar.kt b/app/src/main/java/io/fixmyride/ui/components/ResultsBar.kt index c349dd9..9229a58 100644 --- a/app/src/main/java/io/fixmyride/ui/components/ResultsBar.kt +++ b/app/src/main/java/io/fixmyride/ui/components/ResultsBar.kt @@ -12,6 +12,8 @@ import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -30,8 +32,14 @@ fun ResultsBar( animationSpec: AnimationSpec = Measurements.scrollAnimation(), scrollState: ScrollState, ) { + val shouldBeShown = remember { + derivedStateOf { + scrollState.value > Measurements.scrollPositionToShowToolbar() + } + } + val offsetY = animateDpAsState( - targetValue = when (scrollState.value > Measurements.scrollPositionToShowToolbar()) { + targetValue = when (shouldBeShown.value) { true -> 0.dp false -> 150.dp }, diff --git a/app/src/main/java/io/fixmyride/ui/components/home/AddVehicleButton.kt b/app/src/main/java/io/fixmyride/ui/components/home/AddVehicleButton.kt index c6e0cc7..68252e9 100644 --- a/app/src/main/java/io/fixmyride/ui/components/home/AddVehicleButton.kt +++ b/app/src/main/java/io/fixmyride/ui/components/home/AddVehicleButton.kt @@ -20,7 +20,6 @@ import androidx.compose.material.icons.rounded.Notifications import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip diff --git a/app/src/main/java/io/fixmyride/ui/components/notifications/NotificationItem.kt b/app/src/main/java/io/fixmyride/ui/components/notifications/NotificationItem.kt index 22bead1..8c77138 100644 --- a/app/src/main/java/io/fixmyride/ui/components/notifications/NotificationItem.kt +++ b/app/src/main/java/io/fixmyride/ui/components/notifications/NotificationItem.kt @@ -58,8 +58,7 @@ fun NotificationItem(notification: Notification) { ) { Row { Box( - contentAlignment = Alignment.Center, - modifier = Modifier.background( + contentAlignment = Alignment.Center, modifier = Modifier.background( color = ColorPalette.primary, shape = Measurements.roundedShape, ) @@ -79,9 +78,7 @@ fun NotificationItem(notification: Notification) { Text( text = when { vehicle.value.model.length > 12 -> { - vehicle.value.model - .substring(0, 11) - .trim().plus("...") + vehicle.value.model.substring(0, 11).trim().plus("...") } else -> vehicle.value.model @@ -116,8 +113,7 @@ fun NotificationItem(notification: Notification) { @Composable fun TextWithBackground(text: String) { Box( - contentAlignment = Alignment.Center, - modifier = Modifier.background( + contentAlignment = Alignment.Center, modifier = Modifier.background( color = ColorPalette.tertiary, shape = RoundedCornerShape(7.5.dp), ) @@ -218,11 +214,10 @@ fun WarningsAndExpand( ) { Row( verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .padding( - horizontal = 5.dp, - vertical = 2.dp, - ), + modifier = Modifier.padding( + horizontal = 5.dp, + vertical = 2.dp, + ), ) { Text( text = "$expired ${if (hasOnlyExpirationsOrWarnings) stringResource(R.string.expirations) else ""}".trim(), @@ -256,11 +251,10 @@ fun WarningsAndExpand( ) { Row( verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .padding( - horizontal = 5.dp, - vertical = 2.dp, - ), + modifier = Modifier.padding( + horizontal = 5.dp, + vertical = 2.dp, + ), ) { Text( text = "$warnings ${if (hasOnlyExpirationsOrWarnings) stringResource(R.string.warnings) else ""}".trim(), @@ -288,8 +282,7 @@ fun WarningsAndExpand( @Composable fun StatusLabel(status: ExpirationStatus) { Box( - contentAlignment = Alignment.Center, - modifier = Modifier + contentAlignment = Alignment.Center, modifier = Modifier .background( color = when (status) { ExpirationStatus.EXPIRED -> ColorPalette.lightRed.copy(alpha = 0.1f) @@ -314,11 +307,10 @@ fun StatusLabel(status: ExpirationStatus) { ExpirationStatus.ACTIVE -> Typing.activeText ExpirationStatus.NOT_SET -> Typing.notSetText }, - modifier = Modifier - .padding( - horizontal = 5.dp, - vertical = 2.dp, - ), + modifier = Modifier.padding( + horizontal = 5.dp, + vertical = 2.dp, + ), ) } } \ No newline at end of file diff --git a/app/src/main/java/io/fixmyride/ui/screens/AddVehicleScreen.kt b/app/src/main/java/io/fixmyride/ui/screens/AddVehicleScreen.kt index 7797f21..a9f10a9 100644 --- a/app/src/main/java/io/fixmyride/ui/screens/AddVehicleScreen.kt +++ b/app/src/main/java/io/fixmyride/ui/screens/AddVehicleScreen.kt @@ -14,7 +14,6 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.rounded.Done import androidx.compose.material3.Surface import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource diff --git a/app/src/main/java/io/fixmyride/ui/screens/NotificationsScreen.kt b/app/src/main/java/io/fixmyride/ui/screens/NotificationsScreen.kt index b141792..c7b9fbc 100644 --- a/app/src/main/java/io/fixmyride/ui/screens/NotificationsScreen.kt +++ b/app/src/main/java/io/fixmyride/ui/screens/NotificationsScreen.kt @@ -94,7 +94,7 @@ fun NotificationsScreen(viewModel: NotificationsViewModel) { ResultsBar( results = viewModel.notifications.value.size, alignment = Alignment.BottomStart, - animationSpec = Measurements.scrollAnimation(delay = 250), + animationSpec = Measurements.scrollAnimation(delay = 120), scrollState = scrollState, ) } diff --git a/app/src/main/java/io/fixmyride/ui/screens/PreviewVehicleScreen.kt b/app/src/main/java/io/fixmyride/ui/screens/PreviewVehicleScreen.kt index c696804..09c858f 100644 --- a/app/src/main/java/io/fixmyride/ui/screens/PreviewVehicleScreen.kt +++ b/app/src/main/java/io/fixmyride/ui/screens/PreviewVehicleScreen.kt @@ -18,13 +18,13 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import io.fixmyride.R -import io.fixmyride.utils.DateConverter import io.fixmyride.ui.components.FloatingButton import io.fixmyride.ui.components.UniversalHeader import io.fixmyride.ui.components.previewvehicle.DataDisplayField import io.fixmyride.ui.theme.ColorPalette import io.fixmyride.ui.theme.Measurements import io.fixmyride.ui.viewmodels.PreviewVehicleViewModel +import io.fixmyride.utils.DateConverter import io.fixmyride.utils.Routes @RequiresApi(Build.VERSION_CODES.O) diff --git a/app/src/main/java/io/fixmyride/ui/viewmodels/AddVehicleViewModel.kt b/app/src/main/java/io/fixmyride/ui/viewmodels/AddVehicleViewModel.kt index 6c754c7..70dd860 100644 --- a/app/src/main/java/io/fixmyride/ui/viewmodels/AddVehicleViewModel.kt +++ b/app/src/main/java/io/fixmyride/ui/viewmodels/AddVehicleViewModel.kt @@ -7,9 +7,9 @@ import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import androidx.navigation.NavController -import io.fixmyride.utils.DateConverter import io.fixmyride.data.models.Vehicle import io.fixmyride.data.repositories.VehicleRepository +import io.fixmyride.utils.DateConverter import io.fixmyride.utils.ValidationUtils import kotlinx.coroutines.launch diff --git a/app/src/main/java/io/fixmyride/ui/viewmodels/EditVehicleViewModel.kt b/app/src/main/java/io/fixmyride/ui/viewmodels/EditVehicleViewModel.kt index 40c9b02..8147bc8 100644 --- a/app/src/main/java/io/fixmyride/ui/viewmodels/EditVehicleViewModel.kt +++ b/app/src/main/java/io/fixmyride/ui/viewmodels/EditVehicleViewModel.kt @@ -9,8 +9,8 @@ import androidx.lifecycle.viewModelScope import androidx.navigation.NavController import io.fixmyride.data.enums.Decision import io.fixmyride.data.models.Vehicle -import io.fixmyride.utils.DateConverter import io.fixmyride.data.repositories.VehicleRepository +import io.fixmyride.utils.DateConverter import io.fixmyride.utils.ValidationUtils import kotlinx.coroutines.launch diff --git a/app/src/main/java/io/fixmyride/ui/widgets/NotifWidgetProvider.kt b/app/src/main/java/io/fixmyride/ui/widgets/NotifWidgetProvider.kt index e4c440e..ea013a7 100644 --- a/app/src/main/java/io/fixmyride/ui/widgets/NotifWidgetProvider.kt +++ b/app/src/main/java/io/fixmyride/ui/widgets/NotifWidgetProvider.kt @@ -22,7 +22,7 @@ class NotifWidgetProvider : AppWidgetProvider() { ) { super.onUpdate(context, appWidgetManager, appWidgetIds) PrefsManager.initialize(context) - + val dao = Room.databaseBuilder( context.applicationContext, Database::class.java, diff --git a/app/src/main/res/xml/notif_widget_info.xml b/app/src/main/res/xml/notif_widget_info.xml index 77e1072..83766c5 100644 --- a/app/src/main/res/xml/notif_widget_info.xml +++ b/app/src/main/res/xml/notif_widget_info.xml @@ -3,5 +3,5 @@ android:minWidth="40dp" android:minHeight="40dp" android:resizeMode="none" - android:updatePeriodMillis="64800000" + android:updatePeriodMillis="86400000" android:widgetCategory="home_screen" />