From e1662b8d7bc47cce6e4f5cdb41e45df8dd3de567 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Fri, 22 Dec 2023 20:46:37 +0200 Subject: [PATCH 01/24] Start migrating to Material 3 --- app/build.gradle.kts | 1 + app/src/main/java/f/cking/software/TheApp.kt | 6 ++ .../java/f/cking/software/ui/MainActivity.kt | 85 ++++++++++-------- .../ui/devicedetails/DeviceDetailsScreen.kt | 24 ++--- .../ui/devicelist/DeviceListScreen.kt | 88 ++++++++----------- .../cking/software/ui/filter/FilterScreen.kt | 4 +- .../software/ui/filter/SelectFilterScreen.kt | 30 ++++--- .../ui/filter/SelectFilterTypeScreen.kt | 4 +- .../software/ui/journal/JournalScreen.kt | 11 +-- .../software/ui/journal/JournalViewModel.kt | 12 ++- .../f/cking/software/ui/main/MainScreen.kt | 59 ++++++++----- .../ui/profiledetails/ProfileDetailsScreen.kt | 32 +++---- .../ui/profileslist/ProfilesListScreen.kt | 31 +++---- .../ui/selectdevice/SelectDeviceScreen.kt | 4 +- .../ui/selectlocation/SelectLocationScreen.kt | 42 ++++----- .../SelectManufacturerScreen.kt | 18 ++-- .../software/ui/settings/SettingsScreen.kt | 18 ++-- .../cking/software/ui/tagdialog/TagDialog.kt | 10 +-- .../utils/graphic/ComposeFunctions.kt | 16 ++-- .../utils/graphic/GlassNavigationbar.kt | 6 +- app/src/main/res/values-night/colors.xml | 35 -------- app/src/main/res/values-night/themes.xml | 28 +++--- app/src/main/res/values/colors.xml | 32 ++++--- app/src/main/res/values/themes.xml | 28 +++--- gradle/libs.versions.toml | 2 + 25 files changed, 321 insertions(+), 305 deletions(-) delete mode 100644 app/src/main/res/values-night/colors.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1982f76..35be381 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -150,6 +150,7 @@ dependencies { implementation(libs.ktx) debugImplementation(libs.compose.tooling) implementation(libs.compose.tooling.preview) + implementation(libs.compose.material3) // room implementation(libs.room.runtime) diff --git a/app/src/main/java/f/cking/software/TheApp.kt b/app/src/main/java/f/cking/software/TheApp.kt index 97469b6..3fb8b40 100644 --- a/app/src/main/java/f/cking/software/TheApp.kt +++ b/app/src/main/java/f/cking/software/TheApp.kt @@ -1,6 +1,7 @@ package f.cking.software import android.app.Application +import com.google.android.material.color.DynamicColors import f.cking.software.data.DataModule import f.cking.software.domain.interactor.InteractorsModule import f.cking.software.domain.interactor.SaveFirstAppLaunchTimeInteractor @@ -16,11 +17,16 @@ class TheApp : Application() { override fun onCreate() { super.onCreate() instance = this + applyDynamicColors() initDi() initTimber() saveFirstLaunchTime() } + private fun applyDynamicColors() { + DynamicColors.applyToActivitiesIfAvailable(this) + } + private fun saveFirstLaunchTime() { getKoin().get().execute() } diff --git a/app/src/main/java/f/cking/software/ui/MainActivity.kt b/app/src/main/java/f/cking/software/ui/MainActivity.kt index 845d3c8..2d81bff 100644 --- a/app/src/main/java/f/cking/software/ui/MainActivity.kt +++ b/app/src/main/java/f/cking/software/ui/MainActivity.kt @@ -3,23 +3,19 @@ package f.cking.software.ui import android.content.Intent import android.content.SharedPreferences import android.graphics.Color +import android.os.Build import android.os.Bundle import androidx.activity.SystemBarStyle import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.statusBars -import androidx.compose.foundation.layout.windowInsetsTopHeight -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Typography -import androidx.compose.ui.Modifier +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Typography +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.colorResource import androidx.lifecycle.ViewModel @@ -67,20 +63,45 @@ class MainActivity : AppCompatActivity() { setContent { val focusManager = LocalFocusManager.current + val dynamicColorsAreSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S + val darkMode = isSystemInDarkTheme() + val colors = when { + dynamicColorsAreSupported && darkMode -> dynamicDarkColorScheme(this) + dynamicColorsAreSupported && !darkMode -> dynamicLightColorScheme(this) + darkMode -> darkColorScheme( + primary = colorResource(id = R.color.theme_dark_primary), + primaryContainer = colorResource(id = R.color.theme_dark_primary_variant), + onPrimary = colorResource(id = R.color.theme_dark_on_primary), + surface = colorResource(id = R.color.theme_dark_surface_color), + surfaceVariant = colorResource(id = R.color.theme_dark_primary_variant), + onSurface = colorResource(id = R.color.theme_dark_on_surface), + secondary = colorResource(id = R.color.theme_dark_secondary), + secondaryContainer = colorResource(id = R.color.theme_dark_secondary_variant), + onSecondary = colorResource(id = R.color.theme_dark_on_secondary), + error = colorResource(id = R.color.theme_dark_error), + onError = colorResource(id = R.color.theme_dark_on_error), + ) + !darkMode -> darkColorScheme( + primary = colorResource(id = R.color.theme_light_primary), + primaryContainer = colorResource(id = R.color.theme_light_primary_variant), + onPrimary = colorResource(id = R.color.theme_light_on_primary), + surface = colorResource(id = R.color.theme_light_surface_color), + surfaceVariant = colorResource(id = R.color.theme_light_primary_variant), + onSurface = colorResource(id = R.color.theme_light_on_surface), + secondary = colorResource(id = R.color.theme_light_secondary), + secondaryContainer = colorResource(id = R.color.theme_light_secondary_variant), + onSecondary = colorResource(id = R.color.theme_light_on_secondary), + error = colorResource(id = R.color.theme_light_error), + onError = colorResource(id = R.color.theme_light_on_error), + ) + else -> throw IllegalStateException("This state is unreachable") + } MaterialTheme( - colors = MaterialTheme.colors.copy( - primary = colorResource(id = R.color.primary), - primaryVariant = colorResource(id = R.color.primary_variant), - onPrimary = colorResource(id = R.color.on_primary), - secondary = colorResource(id = R.color.secondary), - secondaryVariant = colorResource(id = R.color.secondary_variant), - onSecondary = colorResource(id = R.color.on_secondary), - surface = colorResource(id = R.color.surface_color), - onSurface = colorResource(id = R.color.on_surface), - ), + colorScheme = colors, typography = Typography( - body1 = MaterialTheme.typography.body1.copy(color = colorResource(id = R.color.on_surface)), - body2 = MaterialTheme.typography.body2.copy(color = colorResource(id = R.color.on_surface)), + bodyMedium = MaterialTheme.typography.bodyMedium.copy(color = colors.onSurface), + bodyLarge = MaterialTheme.typography.bodyLarge.copy(color = colors.onSurface), + bodySmall = MaterialTheme.typography.bodySmall.copy(color = colors.onSurface), ) ) { val stack = viewModel.navigator.stack @@ -88,22 +109,8 @@ class MainActivity : AppCompatActivity() { finish() } else { focusManager.clearFocus(true) - Column { - Box( - modifier = Modifier - .windowInsetsTopHeight(WindowInsets.statusBars) - .fillMaxWidth() - .background(MaterialTheme.colors.primary) - ) - Box( - modifier = Modifier - .fillMaxWidth() - .fillMaxHeight() - ) { - stack.forEach { screen -> - screen() - } - } + stack.forEach { screen -> + screen() } } } diff --git a/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt b/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt index 519ecde..ae4b9e1 100644 --- a/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt @@ -23,7 +23,6 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.IconButton import androidx.compose.material.LinearProgressIndicator -import androidx.compose.material.MaterialTheme import androidx.compose.material.Scaffold import androidx.compose.material.Text import androidx.compose.material.TopAppBar @@ -32,6 +31,7 @@ import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Edit +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope @@ -81,7 +81,7 @@ object DeviceDetailsScreen { Scaffold( modifier = Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .fillMaxWidth() .fillMaxHeight(), topBar = { @@ -91,7 +91,7 @@ object DeviceDetailsScreen { GlassSystemNavbar { Content( modifier = Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .padding(it), viewModel = viewModel, ) @@ -116,7 +116,7 @@ object DeviceDetailsScreen { Icon( imageVector = ImageVector.vectorResource(id = iconId), contentDescription = text, - tint = MaterialTheme.colors.onPrimary, + tint = MaterialTheme.colorScheme.onPrimary, ) } } @@ -126,7 +126,7 @@ object DeviceDetailsScreen { Icon( imageVector = Icons.Filled.ArrowBack, contentDescription = stringResource(R.string.back), - tint = MaterialTheme.colors.onPrimary + tint = MaterialTheme.colorScheme.onPrimary ) } } @@ -282,9 +282,9 @@ object DeviceDetailsScreen { buttons = { negativeButton( text = stringResource(R.string.cancel), - textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant) + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) ) { dialogState.hide() } - positiveButton(text = stringResource(R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { + positiveButton(text = stringResource(R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { dialogState.hide() viewModel.onRemoveTagClick(deviceData, name) } @@ -310,12 +310,12 @@ object DeviceDetailsScreen { } Chip( colors = ChipDefaults.chipColors( - backgroundColor = MaterialTheme.colors.secondary, - contentColor = MaterialTheme.colors.onSecondary, + backgroundColor = MaterialTheme.colorScheme.secondary, + contentColor = MaterialTheme.colorScheme.onSecondary, ), onClick = { addTagDialog.show() }, leadingIcon = { - Icon(imageVector = Icons.Default.Add, contentDescription = null, tint = MaterialTheme.colors.onSurface) + Icon(imageVector = Icons.Default.Add, contentDescription = null, tint = MaterialTheme.colorScheme.onSurface) } ) { Text(text = stringResource(R.string.add_tag)) } } @@ -331,7 +331,7 @@ object DeviceDetailsScreen { buttons = { negativeButton( stringResource(R.string.cancel), - textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant) + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) ) { dialog.hide() } }, ) { @@ -392,7 +392,7 @@ object DeviceDetailsScreen { Image( modifier = Modifier.size(24.dp), imageVector = Icons.Default.Edit, - colorFilter = ColorFilter.tint(MaterialTheme.colors.onSurface), + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface), contentDescription = stringResource(R.string.change) ) } diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt index 9ed7bb4..a924344 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalMaterial3Api::class) + package f.cking.software.ui.devicelist import androidx.compose.foundation.ExperimentalFoundationApi @@ -15,21 +17,21 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.material.Button -import androidx.compose.material.Chip -import androidx.compose.material.ChipDefaults -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Icon -import androidx.compose.material.LinearProgressIndicator -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.TextField import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Search +import androidx.compose.material3.Button +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.FilterChip +import androidx.compose.material3.Icon +import androidx.compose.material3.LinearProgressIndicator +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.SuggestionChip +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.material3.TextField import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember @@ -42,7 +44,6 @@ import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalFocusManager -import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp @@ -62,7 +63,7 @@ object DeviceListScreen { @OptIn(ExperimentalFoundationApi::class) @Composable fun Screen() { - val modifier = Modifier.background(MaterialTheme.colors.surface) + val modifier = Modifier.background(MaterialTheme.colorScheme.background) val viewModel: DeviceListViewModel = koinViewModel() val focusManager = LocalFocusManager.current val nestedScroll = remember { @@ -83,7 +84,7 @@ object DeviceListScreen { modifier = Modifier .fillMaxWidth() .height(4.dp), - color = MaterialTheme.colors.onPrimary + color = MaterialTheme.colorScheme.onPrimary ) } } else { @@ -101,7 +102,7 @@ object DeviceListScreen { modifier = Modifier .fillMaxWidth() .height(4.dp), - color = MaterialTheme.colors.onPrimary + color = MaterialTheme.colorScheme.onPrimary ) } } @@ -192,13 +193,12 @@ object DeviceListScreen { } } - @OptIn(ExperimentalMaterialApi::class) @Composable private fun Filters(viewModel: DeviceListViewModel) { - Surface(elevation = 4.dp) { + Surface(shadowElevation = 4.dp) { Column( modifier = Modifier - .background(colorResource(id = R.color.primary_surface)) + .background(MaterialTheme.colorScheme.surfaceVariant) .fillMaxWidth() ) { LazyRow( @@ -211,18 +211,8 @@ object DeviceListScreen { allFilters.forEach { item { val isSelected = viewModel.appliedFilter.contains(it) - val colors = if (isSelected) { - ChipDefaults.chipColors( - backgroundColor = MaterialTheme.colors.primaryVariant, - contentColor = MaterialTheme.colors.onPrimary, - leadingIconContentColor = MaterialTheme.colors.onPrimary, - ) - } else { - ChipDefaults.chipColors() - } - Chip( - colors = colors, + FilterChip( onClick = { viewModel.onFilterClick(it) }, leadingIcon = { if (isSelected) { @@ -232,10 +222,12 @@ object DeviceListScreen { modifier = Modifier.size(24.dp) ) } + }, + selected = isSelected, + label = { + Text(text = it.displayName) } - ) { - Text(text = it.displayName) - } + ) Spacer(modifier = Modifier.width(8.dp)) } } @@ -258,7 +250,6 @@ object DeviceListScreen { } } - @OptIn(ExperimentalMaterialApi::class) @Composable private fun AddFilterChip(viewModel: DeviceListViewModel) { @@ -277,39 +268,30 @@ object DeviceListScreen { }) } - Chip( - leadingIcon = { + SuggestionChip( + icon = { Icon(Icons.Filled.Add, contentDescription = stringResource(R.string.delete), modifier = Modifier.size(24.dp)) }, onClick = { selectFilterDialog.show() }, - ) { - Text(text = stringResource(R.string.add_filter)) - } + label = { + Text(text = stringResource(R.string.add_filter)) + } + ) } - @OptIn(ExperimentalMaterialApi::class) @Composable private fun SearchChip(viewModel: DeviceListViewModel) { - val colors = if (viewModel.isSearchMode) { - ChipDefaults.chipColors( - backgroundColor = MaterialTheme.colors.primaryVariant, - contentColor = MaterialTheme.colors.onPrimary, - leadingIconContentColor = MaterialTheme.colors.onPrimary, - ) - } else { - ChipDefaults.chipColors() - } - - Chip( - colors = colors, + FilterChip( leadingIcon = { val icon = if (viewModel.isSearchMode) Icons.Filled.Delete else Icons.Filled.Search Icon(icon, contentDescription = stringResource(R.string.delete), modifier = Modifier.size(24.dp)) }, onClick = { viewModel.onOpenSearchClick() }, - ) { - Text(text = viewModel.searchQuery?.takeIf { it.isNotBlank() } ?: stringResource(R.string.search)) - } + selected = viewModel.isSearchMode, + label = { + Text(text = viewModel.searchQuery?.takeIf { it.isNotBlank() } ?: stringResource(R.string.search)) + } + ) } @Composable diff --git a/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt b/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt index 5e4ff18..f9f1a9b 100644 --- a/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt +++ b/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt @@ -20,7 +20,6 @@ import androidx.compose.material.ChipDefaults import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.material.TextField import androidx.compose.material.icons.Icons @@ -28,6 +27,7 @@ import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Clear import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.List +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -188,7 +188,7 @@ object FilterScreen { if (tag == null) { Chip( colors = ChipDefaults.chipColors( - backgroundColor = MaterialTheme.colors.primary, + backgroundColor = MaterialTheme.colorScheme.primary, contentColor = Color.White, ), onClick = { addTagDialog.show() }, diff --git a/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt b/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt index dbdca4a..ced5215 100644 --- a/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt +++ b/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt @@ -7,17 +7,18 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Scaffold -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.TopAppBar import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext @@ -41,7 +42,7 @@ object SelectFilterScreen { topBar = { AppBar { router.navigate(BackCommand) } }, content = { paddings -> Column(modifier = Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .padding(paddings)) { LazyColumn( Modifier @@ -63,10 +64,10 @@ object SelectFilterScreen { } } - Surface(elevation = 12.dp) { + Surface(shadowElevation = 12.dp) { Column( modifier = Modifier - .background(MaterialTheme.colors.primary) + .background(MaterialTheme.colorScheme.primary) .fillMaxWidth(), ) { val context = LocalContext.current @@ -74,7 +75,7 @@ object SelectFilterScreen { modifier = Modifier .fillMaxWidth() .padding(16.dp), - colors = ButtonDefaults.buttonColors(backgroundColor = MaterialTheme.colors.primaryVariant), + colors = ButtonDefaults.buttonColors(contentColor = MaterialTheme.colorScheme.primaryContainer), onClick = { val filter = initialFilterState .takeIf { it.isCorrect() } @@ -88,7 +89,7 @@ object SelectFilterScreen { } } ) { - Text(text = stringResource(R.string.confirm), color = MaterialTheme.colors.onPrimary) + Text(text = stringResource(R.string.confirm), color = MaterialTheme.colorScheme.onPrimary) } SystemNavbarSpacer() @@ -99,6 +100,7 @@ object SelectFilterScreen { ) } + @OptIn(ExperimentalMaterial3Api::class) @Composable private fun AppBar(onBackClick: () -> Unit) { TopAppBar( diff --git a/app/src/main/java/f/cking/software/ui/filter/SelectFilterTypeScreen.kt b/app/src/main/java/f/cking/software/ui/filter/SelectFilterTypeScreen.kt index a1c98a0..8ae42da 100644 --- a/app/src/main/java/f/cking/software/ui/filter/SelectFilterTypeScreen.kt +++ b/app/src/main/java/f/cking/software/ui/filter/SelectFilterTypeScreen.kt @@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource @@ -28,7 +28,7 @@ object SelectFilterTypeScreen { MaterialDialog( dialogState = dialogState, buttons = { - negativeButton(stringResource(R.string.cancel), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { dialogState.hide() } + negativeButton(stringResource(R.string.cancel), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { dialogState.hide() } } ) { LazyColumn { diff --git a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt index 1c48bbe..bf84543 100644 --- a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt +++ b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt @@ -14,15 +14,14 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.Chip import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier -import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow @@ -40,7 +39,7 @@ object JournalScreen { fun Screen() { val viewModel: JournalViewModel = koinViewModel() val journal = viewModel.journal - val modifier = Modifier.background(MaterialTheme.colors.surface) + val modifier = Modifier.background(MaterialTheme.colorScheme.surface) if (journal.isEmpty()) { ContentPlaceholder(text = stringResource(R.string.journal_placeholder), modifier = modifier) } else { @@ -64,7 +63,7 @@ object JournalScreen { Box( modifier = Modifier .fillMaxWidth() - .background(colorResource(id = uiModel.color)) + .background(uiModel.color()) .clickable { viewModel.onEntryClick(uiModel.journalEntry) } ) { Column( @@ -79,9 +78,10 @@ object JournalScreen { fontWeight = FontWeight.Bold, maxLines = 4, overflow = TextOverflow.Ellipsis, + color = uiModel.colorForeground() ) Spacer(modifier = Modifier.width(4.dp)) - Text(text = uiModel.dateTime, fontWeight = FontWeight.Thin) + Text(text = uiModel.dateTime, fontWeight = FontWeight.Thin, color = uiModel.colorForeground()) } Spacer(modifier = Modifier.height(4.dp)) var isExpanded by remember { mutableStateOf(false) } @@ -95,6 +95,7 @@ object JournalScreen { fontWeight = FontWeight.Normal, maxLines = if (isExpanded) Int.MAX_VALUE else 5, overflow = TextOverflow.Ellipsis, + color = uiModel.colorForeground() ) } diff --git a/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt b/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt index 7f1db2f..28f99f6 100644 --- a/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt +++ b/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt @@ -2,9 +2,12 @@ package f.cking.software.ui.journal import android.app.Application import android.widget.Toast +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue +import androidx.compose.ui.graphics.Color import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import f.cking.software.R @@ -75,7 +78,8 @@ class JournalViewModel( } return JournalEntryUiModel( dateTime = journalEntry.timestamp.formattedDate(), - color = R.color.error_background, + color = { MaterialTheme.colorScheme.error }, + colorForeground = { MaterialTheme.colorScheme.onError }, title = title, subtitle = description, journalEntry = journalEntry, @@ -89,7 +93,8 @@ class JournalViewModel( ): JournalEntryUiModel { return JournalEntryUiModel( dateTime = journalEntry.timestamp.formattedDate(), - color = R.color.profile_report_background, + color = { MaterialTheme.colorScheme.surface }, + colorForeground = { MaterialTheme.colorScheme.onSurface }, title = context.getString(R.string.journal_profile_detected, getProfileName(report.profileId)), subtitle = null, journalEntry = journalEntry, @@ -116,7 +121,8 @@ class JournalViewModel( data class JournalEntryUiModel( val dateTime: String, - val color: Int, + val color: @Composable () -> Color, + val colorForeground: @Composable () -> Color, val title: String, val subtitle: String?, val items: List?, diff --git a/app/src/main/java/f/cking/software/ui/main/MainScreen.kt b/app/src/main/java/f/cking/software/ui/main/MainScreen.kt index 28484bf..434187d 100644 --- a/app/src/main/java/f/cking/software/ui/main/MainScreen.kt +++ b/app/src/main/java/f/cking/software/ui/main/MainScreen.kt @@ -8,9 +8,19 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Refresh +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ExtendedFloatingActionButton +import androidx.compose.material3.FabPosition +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -49,19 +59,26 @@ object MainScreen { content = { innerPaddings -> GlassNavigationbar( modifier = Modifier - .padding(innerPaddings) .fillMaxWidth() .fillMaxHeight(), - overlayColor = MaterialTheme.colors.primaryVariant.copy(alpha = 0.3f), + overlayColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f), + fallbackColor = MaterialTheme.colorScheme.surfaceVariant, navBarContent = { - BottomNavigationBar(Modifier, viewModel) + Column { + Spacer(modifier = Modifier.height(pxToDp(GlobalUiState.navbarOffsetPx.value).dp)) + } }, content = { - viewModel.tabs.firstOrNull { it.selected }?.screen?.invoke() + Box(Modifier.padding(top = innerPaddings.calculateTopPadding())) { + viewModel.tabs.firstOrNull { it.selected }?.screen?.invoke() + } }, ) }, floatingActionButtonPosition = FabPosition.Center, + bottomBar = { + BottomNavigationBar(Modifier, viewModel) + }, floatingActionButton = { ScanFab(viewModel) }, @@ -75,8 +92,8 @@ object MainScreen { MaterialDialog( dialogState = viewModel.showLocationDisabledDialog, buttons = { - negativeButton(stringResource(R.string.cancel), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) - positiveButton(stringResource(R.string.turn_on), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { + negativeButton(stringResource(R.string.cancel), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) + positiveButton(stringResource(R.string.turn_on), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { viewModel.onTurnOnLocationClick() } }, @@ -94,8 +111,8 @@ object MainScreen { MaterialDialog( dialogState = viewModel.showBluetoothDisabledDialog, buttons = { - negativeButton(stringResource(R.string.cancel), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) - positiveButton(stringResource(R.string.turn_on), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { + negativeButton(stringResource(R.string.cancel), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) + positiveButton(stringResource(R.string.turn_on), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { viewModel.onTurnOnBluetoothClick() } }, @@ -148,11 +165,11 @@ object MainScreen { Image( painter = painterResource(id = icon), contentDescription = targetTab.text, - colorFilter = ColorFilter.tint(MaterialTheme.colors.onPrimary.copy(alpha = 0.7f)), + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f)), modifier = Modifier.size(32.dp), ) Spacer(modifier = Modifier.height(2.dp)) - Text(text = targetTab.text, fontSize = 12.sp, fontWeight = font, color = MaterialTheme.colors.onPrimary.copy(alpha = 0.7f)) + Text(text = targetTab.text, fontSize = 12.sp, fontWeight = font, color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f)) } } @@ -181,10 +198,10 @@ object MainScreen { ) ExtendedFloatingActionButton( + containerColor = MaterialTheme.colorScheme.secondary, modifier = Modifier - .padding(bottom = pxToDp(px = GlobalUiState.navbarOffsetPx.value).dp) .onGloballyPositioned { GlobalUiState.setBottomOffset(fabOffset = it.size.height.toFloat()) }, - text = { Text(text = text, fontWeight = FontWeight.Bold, color = MaterialTheme.colors.onSecondary) }, + text = { Text(text = text, fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.onSecondary) }, onClick = { if (viewModel.needToShowPermissionsIntro()) { permissionsIntro.show() @@ -196,7 +213,7 @@ object MainScreen { Image( painter = painterResource(id = icon), contentDescription = text, - colorFilter = ColorFilter.tint(color = MaterialTheme.colors.onSecondary) + colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onSecondary) ) } ) @@ -211,11 +228,11 @@ object MainScreen { MaterialDialog( dialogState = state, buttons = { - positiveButton(stringResource(id = R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { + positiveButton(stringResource(id = R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { state.hide() onPassed.invoke() } - negativeButton(stringResource(id = R.string.decline), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { + negativeButton(stringResource(id = R.string.decline), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { state.hide() onDeclined.invoke() } @@ -292,16 +309,16 @@ object MainScreen { } } + @OptIn(ExperimentalMaterial3Api::class) @Composable private fun TopBar(viewModel: MainViewModel) { TopAppBar( - title = { - Text(text = stringResource(R.string.app_name), color = MaterialTheme.colors.onPrimary) - }, + colors = TopAppBarDefaults.topAppBarColors(containerColor = MaterialTheme.colorScheme.surfaceVariant), + title = { Text(text = stringResource(R.string.app_name), color = MaterialTheme.colorScheme.onSurfaceVariant) }, actions = { if (viewModel.scanStarted && viewModel.bgServiceIsActive) { CircularProgressIndicator( - color = MaterialTheme.colors.onPrimary, + color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier .size(24.dp) ) @@ -314,7 +331,7 @@ object MainScreen { .size(24.dp), imageVector = Icons.Filled.Refresh, contentDescription = stringResource(R.string.refresh), - colorFilter = ColorFilter.tint(MaterialTheme.colors.onPrimary) + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurfaceVariant) ) } } diff --git a/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt b/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt index 27d0fbf..1f93763 100644 --- a/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt @@ -13,19 +13,20 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.Button -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Scaffold -import androidx.compose.material.Switch -import androidx.compose.material.Text -import androidx.compose.material.TextField -import androidx.compose.material.TopAppBar import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Done +import androidx.compose.material3.Button +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Switch +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -61,7 +62,7 @@ object ProfileDetailsScreen { content = { GlassSystemNavbar { Box(modifier = Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .fillMaxSize() .padding(it)) { Content(viewModel) @@ -71,6 +72,7 @@ object ProfileDetailsScreen { ) } + @OptIn(ExperimentalMaterial3Api::class) @Composable private fun AppBar(viewModel: ProfileDetailsViewModel) { @@ -80,9 +82,9 @@ object ProfileDetailsScreen { buttons = { negativeButton( stringResource(R.string.stay), - textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant) + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) ) { discardChangesDialog.hide() } - positiveButton(stringResource(R.string.discard_changes), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { + positiveButton(stringResource(R.string.discard_changes), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { discardChangesDialog.hide() viewModel.back() } @@ -119,13 +121,13 @@ object ProfileDetailsScreen { Icon( imageVector = Icons.Filled.Delete, contentDescription = stringResource(R.string.delete), - tint = MaterialTheme.colors.onPrimary + tint = MaterialTheme.colorScheme.onPrimary ) } Spacer(modifier = Modifier.width(8.dp)) } IconButton(onClick = { viewModel.onSaveClick() }) { - Icon(imageVector = Icons.Filled.Done, contentDescription = stringResource(R.string.save), tint = MaterialTheme.colors.onPrimary) + Icon(imageVector = Icons.Filled.Done, contentDescription = stringResource(R.string.save), tint = MaterialTheme.colorScheme.onPrimary) } }, navigationIcon = { @@ -139,7 +141,7 @@ object ProfileDetailsScreen { Icon( imageVector = Icons.Filled.ArrowBack, contentDescription = stringResource(R.string.back), - tint = MaterialTheme.colors.onPrimary + tint = MaterialTheme.colorScheme.onPrimary ) } } diff --git a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt index 3861cbe..9a5f860 100644 --- a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt @@ -14,15 +14,13 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.material.Chip -import androidx.compose.material.ChipDefaults -import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.SuggestionChip import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -46,7 +44,7 @@ object ProfilesListScreen { val viewModel: ProfilesListViewModel = koinViewModel() Column( Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .fillMaxWidth() .fillMaxHeight() ) { @@ -69,7 +67,6 @@ object ProfilesListScreen { } } - @OptIn(ExperimentalMaterialApi::class) @Composable private fun Header(viewModel: ProfilesListViewModel) { Surface( @@ -79,21 +76,18 @@ object ProfilesListScreen { ) { LazyRow( modifier = Modifier - .background(colorResource(id = R.color.primary_surface)) + .background(MaterialTheme.colorScheme.surface) .padding(vertical = 8.dp), ) { item { Spacer(modifier = Modifier.width(8.dp)) - Chip( - colors = ChipDefaults.chipColors( - backgroundColor = MaterialTheme.colors.primaryVariant, - contentColor = MaterialTheme.colors.onPrimary, - ), + SuggestionChip( onClick = { viewModel.createNewClick() }, - leadingIcon = { + icon = { Icon(imageVector = Icons.Default.Add, contentDescription = null) - } - ) { Text(text = stringResource(R.string.create_new)) } + }, + label = { Text(text = stringResource(R.string.create_new)) } + ) Spacer(modifier = Modifier.width(8.dp)) } @@ -107,12 +101,11 @@ object ProfilesListScreen { } } - @OptIn(ExperimentalMaterialApi::class) @Composable private fun DefaultFilterChip(filter: ProfilesListViewModel.FilterTemplate, viewModel: ProfilesListViewModel) { - Chip(onClick = { viewModel.selectFilterTemplate(filter) }) { + SuggestionChip(onClick = { viewModel.selectFilterTemplate(filter) }, label = { Text(text = stringResource(filter.displayNameRes)) - } + }) } @Composable @@ -131,7 +124,7 @@ object ProfilesListScreen { Spacer(modifier = Modifier.height(4.dp)) val activeText = if (profile.isActive) stringResource(R.string.profile_is_active) else stringResource(R.string.profile_is_not_active) - val color = if (profile.isActive) colorResource(id = R.color.green_600) else MaterialTheme.colors.onSurface + val color = if (profile.isActive) colorResource(id = R.color.green_600) else MaterialTheme.colorScheme.onSurface Row(verticalAlignment = Alignment.CenterVertically) { Icon( modifier = Modifier.size(12.dp), diff --git a/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt b/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt index c420fc5..0e861b4 100644 --- a/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt +++ b/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt @@ -7,13 +7,13 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.Divider import androidx.compose.material.Icon import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme import androidx.compose.material.Scaffold import androidx.compose.material.Text import androidx.compose.material.TextField import androidx.compose.material.TopAppBar import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -61,7 +61,7 @@ object SelectDeviceScreen { ) { LazyColumn( modifier = Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .fillMaxSize() ) { val list = viewModel.devices.asSequence() diff --git a/app/src/main/java/f/cking/software/ui/selectlocation/SelectLocationScreen.kt b/app/src/main/java/f/cking/software/ui/selectlocation/SelectLocationScreen.kt index a366f7e..c8ab324 100644 --- a/app/src/main/java/f/cking/software/ui/selectlocation/SelectLocationScreen.kt +++ b/app/src/main/java/f/cking/software/ui/selectlocation/SelectLocationScreen.kt @@ -12,19 +12,20 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.AbsoluteCutCornerShape -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Scaffold -import androidx.compose.material.Slider -import androidx.compose.material.SliderDefaults -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.TopAppBar import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Slider +import androidx.compose.material3.SliderDefaults +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -54,6 +55,7 @@ import org.koin.androidx.compose.getKoin import org.osmdroid.util.GeoPoint import org.osmdroid.views.MapView +@OptIn(ExperimentalMaterial3Api::class) object SelectLocationScreen { @Composable @@ -65,14 +67,14 @@ object SelectLocationScreen { ) { Scaffold( modifier = Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .fillMaxWidth() .fillMaxHeight(), topBar = { AppBar(onCloseClick) }, content = { paddings -> Content( modifier = Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .padding(paddings), onSelected = onSelected, initialLocationModel = initialLocationModel, @@ -148,7 +150,7 @@ object SelectLocationScreen { contentScale = ContentScale.FillWidth, painter = painter, contentDescription = null, - colorFilter = ColorFilter.tint(MaterialTheme.colors.secondary) + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.secondary) ) } } @@ -164,10 +166,10 @@ object SelectLocationScreen { ) { val radiusMeters = remember { mutableStateOf(initialRadius ?: TheAppConfig.DEFAULT_LOCATION_FILTER_RADIUS) } - Surface(elevation = 12.dp) { + Surface(shadowElevation = 12.dp) { Column( modifier = Modifier - .background(MaterialTheme.colors.primary) + .background(MaterialTheme.colorScheme.primary) .fillMaxWidth(), ) { Spacer(modifier = Modifier.height(16.dp)) @@ -180,8 +182,8 @@ object SelectLocationScreen { onValueChange = { value -> radiusMeters.value = value }, valueRange = 5f..1000f, colors = SliderDefaults.colors( - thumbColor = MaterialTheme.colors.secondary, - activeTrackColor = MaterialTheme.colors.secondary, + thumbColor = MaterialTheme.colorScheme.secondary, + activeTrackColor = MaterialTheme.colorScheme.secondary, ) ) Spacer(modifier = Modifier.height(16.dp)) @@ -189,7 +191,7 @@ object SelectLocationScreen { modifier = Modifier .fillMaxWidth() .padding(horizontal = 16.dp), - colors = ButtonDefaults.buttonColors(backgroundColor = MaterialTheme.colors.primaryVariant), + colors = ButtonDefaults.buttonColors(contentColor = MaterialTheme.colorScheme.primaryContainer), enabled = map != null, onClick = { val cameraCenter = map!!.mapCenter @@ -199,7 +201,7 @@ object SelectLocationScreen { ) } ) { - Text(text = stringResource(R.string.confirm), color = MaterialTheme.colors.onPrimary) + Text(text = stringResource(R.string.confirm), color = MaterialTheme.colorScheme.onPrimary) } Spacer(modifier = Modifier.height(16.dp)) SystemNavbarSpacer() diff --git a/app/src/main/java/f/cking/software/ui/selectmanufacturer/SelectManufacturerScreen.kt b/app/src/main/java/f/cking/software/ui/selectmanufacturer/SelectManufacturerScreen.kt index f64a1f6..610617a 100644 --- a/app/src/main/java/f/cking/software/ui/selectmanufacturer/SelectManufacturerScreen.kt +++ b/app/src/main/java/f/cking/software/ui/selectmanufacturer/SelectManufacturerScreen.kt @@ -6,14 +6,15 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.TopAppBar import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource @@ -35,14 +36,14 @@ object SelectManufacturerScreen { val viewModel: SelectManufacturerViewModel = koinViewModel() Scaffold( modifier = Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .fillMaxWidth() .fillMaxWidth(), topBar = { AppBar(viewModel) }, content = { paddings -> GlassSystemNavbar { LazyColumn(modifier = Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .padding(paddings)) { viewModel.manufacturers.forEach { type -> item { @@ -59,6 +60,7 @@ object SelectManufacturerScreen { ) } + @OptIn(ExperimentalMaterial3Api::class) @Composable private fun AppBar(viewModel: SelectManufacturerViewModel) { TopAppBar( diff --git a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt index 1395d84..7092f6c 100644 --- a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt @@ -14,9 +14,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.Button -import androidx.compose.material.MaterialTheme import androidx.compose.material.Switch import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -45,7 +45,7 @@ object SettingsScreen { val viewModel: SettingsViewModel = koinViewModel() LazyColumn( modifier = Modifier - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) .fillMaxWidth() .fillMaxHeight(), ) { @@ -142,9 +142,9 @@ object SettingsScreen { buttons = { negativeButton( text = stringResource(R.string.cancel), - textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant) + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) ) { dialogState.hide() } - positiveButton(text = stringResource(R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { + positiveButton(text = stringResource(R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { dialogState.hide() viewModel.onRestoreDBClick() } @@ -174,9 +174,9 @@ object SettingsScreen { buttons = { negativeButton( text = stringResource(R.string.cancel), - textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant) + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) ) { dialogState.hide() } - positiveButton(text = stringResource(R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { + positiveButton(text = stringResource(R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { dialogState.hide() viewModel.onBackupDBClick() } @@ -207,7 +207,7 @@ object SettingsScreen { .align(Alignment.CenterHorizontally) .alpha(0.3f) .width(30.dp), - colorFilter = ColorFilter.tint(MaterialTheme.colors.onSurface), + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface), painter = painterResource(id = R.drawable.cat_footprint), contentDescription = null ) @@ -234,9 +234,9 @@ object SettingsScreen { buttons = { negativeButton( text = stringResource(R.string.cancel), - textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant) + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) ) { dialogState.hide() } - positiveButton(text = stringResource(R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { + positiveButton(text = stringResource(R.string.confirm), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { dialogState.hide() viewModel.onClearLocationsClick() } diff --git a/app/src/main/java/f/cking/software/ui/tagdialog/TagDialog.kt b/app/src/main/java/f/cking/software/ui/tagdialog/TagDialog.kt index 87ffbf6..971b2dd 100644 --- a/app/src/main/java/f/cking/software/ui/tagdialog/TagDialog.kt +++ b/app/src/main/java/f/cking/software/ui/tagdialog/TagDialog.kt @@ -7,10 +7,10 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.Button -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.material.TextField +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextField import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.mutableStateOf @@ -41,7 +41,7 @@ object TagDialog { MaterialDialog( dialogState = dialog, buttons = { - negativeButton("Cancel", textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { dialog.hide() } + negativeButton("Cancel", textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { dialog.hide() } }, onCloseRequest = { dialog.hide() }, ) { diff --git a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt index e8c55e8..54ee700 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt @@ -22,11 +22,11 @@ import androidx.compose.material.Chip import androidx.compose.material.ChipDefaults import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.material.TextField import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Star +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.mutableStateOf @@ -79,10 +79,10 @@ fun rememberDateDialog( MaterialDialog( dialogState = dialogState, buttons = { - positiveButton(stringResource(R.string.ok), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { dialogState.hide() } + positiveButton(stringResource(R.string.ok), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { dialogState.hide() } negativeButton( stringResource(R.string.cancel), - textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant) + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) ) { dialogState.hide() } }, ) { @@ -102,10 +102,10 @@ fun rememberTimeDialog( MaterialDialog( dialogState = dialogState, buttons = { - positiveButton(stringResource(R.string.ok), textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant)) { dialogState.hide() } + positiveButton(stringResource(R.string.ok), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { dialogState.hide() } negativeButton( stringResource(R.string.cancel), - textStyle = TextStyle(color = MaterialTheme.colors.secondaryVariant) + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) ) { dialogState.hide() } }, ) { @@ -170,7 +170,7 @@ fun DeviceListItem( Icon( imageVector = Icons.Filled.Star, contentDescription = stringResource(R.string.is_favorite), - tint = MaterialTheme.colors.onSurface + tint = MaterialTheme.colorScheme.onSurface ) Spacer(modifier = Modifier.width(8.dp)) } @@ -318,7 +318,7 @@ fun RoundedBox( Column( Modifier .fillMaxWidth() - .background(color = MaterialTheme.colors.primaryVariant, shape = shape) + .background(color = MaterialTheme.colorScheme.primaryContainer, shape = shape) .clip(shape = shape) .padding(internalPaddings) ) { boxContent(this) } @@ -363,7 +363,7 @@ fun TagChip( leadingIconContentColor = Color.Black, ), onClick = onClick, - leadingIcon = { tagIcon?.let { Icon(imageVector = it, contentDescription = null, tint = MaterialTheme.colors.onSurface) } }, + leadingIcon = { tagIcon?.let { Icon(imageVector = it, contentDescription = null, tint = MaterialTheme.colorScheme.onSurface) } }, ) { Text(text = tagName) } diff --git a/app/src/main/java/f/cking/software/utils/graphic/GlassNavigationbar.kt b/app/src/main/java/f/cking/software/utils/graphic/GlassNavigationbar.kt index 0e64742..9d85474 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/GlassNavigationbar.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/GlassNavigationbar.kt @@ -10,7 +10,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -54,8 +54,8 @@ fun GlassNavigationbar( blur: Float = 3f, glassCurveSizeDp: Float = 3f, zIndex: Float = 1f, - fallbackColor: Color = MaterialTheme.colors.primary, - overlayColor: Color = MaterialTheme.colors.primary.copy(alpha = 0.3f), + fallbackColor: Color = MaterialTheme.colorScheme.primary, + overlayColor: Color = MaterialTheme.colorScheme.primary.copy(alpha = 0.3f), navBarContent: @Composable () -> Unit, content: @Composable () -> Unit, ) { diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml deleted file mode 100644 index 4aebdb1..0000000 --- a/app/src/main/res/values-night/colors.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - #464237 - @color/white_90 - - #6B5B39 - #685F45 - #7F7150 - @color/white_90 - - #A95C0E - @color/secondary - @color/white_90 - - #80DEEA - #A5D6A7 - #B39DDB - #FFE082 - #FFAB91 - #F48FB1 - #80CBC4 - #EF9A9A - #90CAF9 - #FFCC80 - #E6EE9C - #CE93D8 - #FFFFFF - #FFAB91 - #E6EE9C - #80CBC4 - #0000 - - #9B5C5C - \ No newline at end of file diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index feb32b5..ef6ead2 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -1,20 +1,28 @@ - \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index fcc1981..f6b82a5 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -15,17 +15,29 @@ #E64A19 #D84315 - #FDF7E9 - @color/black_90 + #FDF7E9 + @color/black_90 + #FFF1CF + #F8EED7 + #F1DEAD + @color/black_90 + #F57C00 + @color/theme_light_secondary + @color/white + #B71C1C + @color/white_90 - #FFF1CF - #F8EED7 - #F1DEAD - @color/black_90 - - #F57C00 - @color/secondary - @color/white + #464237 + @color/white_90 + #6B5B39 + #685F45 + #7F7150 + @color/white_90 + #A95C0E + @color/theme_dark_secondary + @color/white_90 + #9B5C5C + @color/white_90 #80DEEA #A5D6A7 diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index c978eed..a6b78c1 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,20 +1,28 @@ - \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9d1faa7..5daca77 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,6 +15,7 @@ compose-compiler = "1.5.6" compose-accompanist = "0.28.0" compose-constraint = "1.0.1" compose-navigation = "2.5.2" +compose-material3 = "1.1.2" horologist = "0.1.13" serialization-json = "1.4.0" wear = "1.2.0" @@ -103,6 +104,7 @@ datastore = { module = "androidx.datastore:datastore", version.ref = "datastore" compose-activity = { module = "androidx.activity:activity-compose", version.ref = "ktx-activity" } material = { module = "com.google.android.material:material", version.ref = "material" } compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } +compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" } compose-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } compose-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } From 4e2368fbaad9eaabe0359f720877f63403434aa9 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Fri, 22 Dec 2023 20:57:28 +0200 Subject: [PATCH 02/24] Migrate DeviceList screen --- .../ui/devicelist/DeviceListScreen.kt | 4 +- .../f/cking/software/ui/main/MainScreen.kt | 4 +- .../utils/graphic/ComposeFunctions.kt | 39 +++++++++++-------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt index a924344..75424fc 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt @@ -84,7 +84,7 @@ object DeviceListScreen { modifier = Modifier .fillMaxWidth() .height(4.dp), - color = MaterialTheme.colorScheme.onPrimary + color = MaterialTheme.colorScheme.onSurfaceVariant ) } } else { @@ -102,7 +102,7 @@ object DeviceListScreen { modifier = Modifier .fillMaxWidth() .height(4.dp), - color = MaterialTheme.colorScheme.onPrimary + color = MaterialTheme.colorScheme.onSurfaceVariant ) } } diff --git a/app/src/main/java/f/cking/software/ui/main/MainScreen.kt b/app/src/main/java/f/cking/software/ui/main/MainScreen.kt index 434187d..7d6756c 100644 --- a/app/src/main/java/f/cking/software/ui/main/MainScreen.kt +++ b/app/src/main/java/f/cking/software/ui/main/MainScreen.kt @@ -165,11 +165,11 @@ object MainScreen { Image( painter = painterResource(id = icon), contentDescription = targetTab.text, - colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f)), + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurfaceVariant), modifier = Modifier.size(32.dp), ) Spacer(modifier = Modifier.height(2.dp)) - Text(text = targetTab.text, fontSize = 12.sp, fontWeight = font, color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f)) + Text(text = targetTab.text, fontSize = 12.sp, fontWeight = font, color = MaterialTheme.colorScheme.onSurfaceVariant) } } diff --git a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt index 54ee700..d81b146 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt @@ -18,15 +18,14 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.windowInsetsBottomHeight import androidx.compose.foundation.shape.CornerSize import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Chip -import androidx.compose.material.ChipDefaults -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Icon -import androidx.compose.material.Text -import androidx.compose.material.TextField import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Star +import androidx.compose.material3.AssistChip +import androidx.compose.material3.AssistChipDefaults +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextField import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.mutableStateOf @@ -79,7 +78,10 @@ fun rememberDateDialog( MaterialDialog( dialogState = dialogState, buttons = { - positiveButton(stringResource(R.string.ok), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { dialogState.hide() } + positiveButton( + stringResource(R.string.ok), + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) + ) { dialogState.hide() } negativeButton( stringResource(R.string.cancel), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) @@ -102,7 +104,10 @@ fun rememberTimeDialog( MaterialDialog( dialogState = dialogState, buttons = { - positiveButton(stringResource(R.string.ok), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { dialogState.hide() } + positiveButton( + stringResource(R.string.ok), + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) + ) { dialogState.hide() } negativeButton( stringResource(R.string.cancel), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) @@ -349,24 +354,26 @@ fun colorByHash(hash: Int): Color { return colors[abs(hash % colors.size)] } -@OptIn(ExperimentalMaterialApi::class) @Composable fun TagChip( tagName: String, tagIcon: ImageVector? = null, onClick: () -> Unit = {}, ) { - Chip( - colors = ChipDefaults.chipColors( - backgroundColor = colorByHash(tagName.hashCode()), - contentColor = Color.Black, + AssistChip( + colors = AssistChipDefaults.assistChipColors( + containerColor = colorByHash(tagName.hashCode()), + labelColor = Color.Black, leadingIconContentColor = Color.Black, ), + border = null, + shape = RoundedCornerShape(corner = CornerSize(Int.MAX_VALUE.dp)), onClick = onClick, leadingIcon = { tagIcon?.let { Icon(imageVector = it, contentDescription = null, tint = MaterialTheme.colorScheme.onSurface) } }, - ) { - Text(text = tagName) - } + label = { + Text(text = tagName) + } + ) } @Composable From 338356b6570762993eee465f9082cf7b7d1dd660 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Fri, 22 Dec 2023 21:02:38 +0200 Subject: [PATCH 03/24] Migrate DeviceList screen --- .../software/ui/profileslist/ProfilesListScreen.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt index 9a5f860..043f198 100644 --- a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt @@ -14,13 +14,13 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.material.Icon -import androidx.compose.material.Surface -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SuggestionChip +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -44,7 +44,7 @@ object ProfilesListScreen { val viewModel: ProfilesListViewModel = koinViewModel() Column( Modifier - .background(MaterialTheme.colorScheme.surface) + .background(MaterialTheme.colorScheme.background) .fillMaxWidth() .fillMaxHeight() ) { @@ -72,11 +72,11 @@ object ProfilesListScreen { Surface( modifier = Modifier .fillMaxWidth(), - elevation = 4.dp, + shadowElevation = 4.dp, ) { LazyRow( modifier = Modifier - .background(MaterialTheme.colorScheme.surface) + .background(MaterialTheme.colorScheme.surfaceVariant) .padding(vertical = 8.dp), ) { item { @@ -124,7 +124,7 @@ object ProfilesListScreen { Spacer(modifier = Modifier.height(4.dp)) val activeText = if (profile.isActive) stringResource(R.string.profile_is_active) else stringResource(R.string.profile_is_not_active) - val color = if (profile.isActive) colorResource(id = R.color.green_600) else MaterialTheme.colorScheme.onSurface + val color = if (profile.isActive) colorResource(id = R.color.green_600) else MaterialTheme.colorScheme.onBackground Row(verticalAlignment = Alignment.CenterVertically) { Icon( modifier = Modifier.size(12.dp), From 14fd106c5ab83e6897ea8a4597e1baefd0f42289 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Fri, 22 Dec 2023 21:15:33 +0200 Subject: [PATCH 04/24] Refactor glass navbar --- .../ui/devicelist/DeviceListScreen.kt | 4 +- .../software/ui/journal/JournalScreen.kt | 4 +- .../f/cking/software/ui/main/MainScreen.kt | 16 ++----- .../ui/profileslist/ProfilesListScreen.kt | 4 +- .../software/ui/settings/SettingsScreen.kt | 4 +- .../utils/graphic/ComposeFunctions.kt | 10 ++++- ...ssNavigationbar.kt => GlassBottomSpace.kt} | 44 ++++++++++++++----- 7 files changed, 54 insertions(+), 32 deletions(-) rename app/src/main/java/f/cking/software/utils/graphic/{GlassNavigationbar.kt => GlassBottomSpace.kt} (82%) diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt index 75424fc..45f562c 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt @@ -51,7 +51,7 @@ import com.vanpra.composematerialdialogs.rememberMaterialDialogState import f.cking.software.R import f.cking.software.ui.ScreenNavigationCommands import f.cking.software.ui.filter.SelectFilterTypeScreen -import f.cking.software.utils.graphic.BottomSpacer +import f.cking.software.utils.graphic.BottomOffsetWithFAB import f.cking.software.utils.graphic.ContentPlaceholder import f.cking.software.utils.graphic.DeviceListItem import f.cking.software.utils.graphic.Divider @@ -130,7 +130,7 @@ object DeviceListScreen { } item { - BottomSpacer() + BottomOffsetWithFAB() } } } diff --git a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt index bf84543..8e18b1b 100644 --- a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt +++ b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt @@ -28,7 +28,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.google.accompanist.flowlayout.FlowRow import f.cking.software.R -import f.cking.software.utils.graphic.BottomSpacer +import f.cking.software.utils.graphic.BottomOffsetWithFAB import f.cking.software.utils.graphic.ContentPlaceholder import f.cking.software.utils.graphic.Divider import org.koin.androidx.compose.koinViewModel @@ -52,7 +52,7 @@ object JournalScreen { item { JournalEntry(uiModel = it, viewModel) } item { Divider() } } - item { BottomSpacer() } + item { BottomOffsetWithFAB() } } } } diff --git a/app/src/main/java/f/cking/software/ui/main/MainScreen.kt b/app/src/main/java/f/cking/software/ui/main/MainScreen.kt index 7d6756c..dbab72b 100644 --- a/app/src/main/java/f/cking/software/ui/main/MainScreen.kt +++ b/app/src/main/java/f/cking/software/ui/main/MainScreen.kt @@ -40,9 +40,8 @@ import com.vanpra.composematerialdialogs.MaterialDialogState import com.vanpra.composematerialdialogs.rememberMaterialDialogState import f.cking.software.R import f.cking.software.ui.GlobalUiState -import f.cking.software.utils.graphic.GlassNavigationbar +import f.cking.software.utils.graphic.GlassBottomNavBar import f.cking.software.utils.graphic.SystemNavbarSpacer -import f.cking.software.utils.graphic.pxToDp import org.koin.androidx.compose.koinViewModel object MainScreen { @@ -57,17 +56,8 @@ object MainScreen { TopBar(viewModel) }, content = { innerPaddings -> - GlassNavigationbar( - modifier = Modifier - .fillMaxWidth() - .fillMaxHeight(), - overlayColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f), - fallbackColor = MaterialTheme.colorScheme.surfaceVariant, - navBarContent = { - Column { - Spacer(modifier = Modifier.height(pxToDp(GlobalUiState.navbarOffsetPx.value).dp)) - } - }, + GlassBottomNavBar( + modifier = Modifier.fillMaxSize(), content = { Box(Modifier.padding(top = innerPaddings.calculateTopPadding())) { viewModel.tabs.firstOrNull { it.selected }?.screen?.invoke() diff --git a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt index 043f198..af30038 100644 --- a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt @@ -33,7 +33,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import f.cking.software.R import f.cking.software.domain.model.RadarProfile -import f.cking.software.utils.graphic.BottomSpacer +import f.cking.software.utils.graphic.BottomOffsetWithFAB import f.cking.software.utils.graphic.ContentPlaceholder import org.koin.androidx.compose.koinViewModel @@ -58,7 +58,7 @@ object ProfilesListScreen { ) { profiles.map { item { ListItem(profile = it, viewModel = viewModel) } } item { - BottomSpacer() + BottomOffsetWithFAB() } } } else { diff --git a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt index 7092f6c..49fe01c 100644 --- a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt @@ -34,7 +34,7 @@ import com.vanpra.composematerialdialogs.rememberMaterialDialogState import f.cking.software.BuildConfig import f.cking.software.R import f.cking.software.dateTimeStringFormat -import f.cking.software.utils.graphic.BottomSpacer +import f.cking.software.utils.graphic.BottomOffsetWithFAB import f.cking.software.utils.graphic.RoundedBox import org.koin.androidx.compose.koinViewModel @@ -69,7 +69,7 @@ object SettingsScreen { Spacer(modifier = Modifier.height(8.dp)) AppInfo() SecretCatPhoto() - BottomSpacer() + BottomOffsetWithFAB() } } } diff --git a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt index d81b146..6a53878 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt @@ -387,7 +387,15 @@ fun pxToDp(px: Float): Float { } @Composable -fun BottomSpacer() { +fun NavbarOffset() { + val bottomOffset = remember { GlobalUiState.navbarOffsetPx } + Column { + Spacer(modifier = Modifier.height(pxToDp(bottomOffset.value).dp)) + } +} + +@Composable +fun BottomOffsetWithFAB() { val bottomOffset = remember { GlobalUiState.totalOffset } Column { Spacer(modifier = Modifier.height(pxToDp(bottomOffset.value).dp)) diff --git a/app/src/main/java/f/cking/software/utils/graphic/GlassNavigationbar.kt b/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt similarity index 82% rename from app/src/main/java/f/cking/software/utils/graphic/GlassNavigationbar.kt rename to app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt index 9d85474..7dd175e 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/GlassNavigationbar.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt @@ -29,35 +29,59 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.zIndex import f.cking.software.dpToPx +@Composable +fun GlassBottomNavBar( + modifier: Modifier = Modifier, + blur: Float = 3f, + glassCurveSizeDp: Float = 3f, + fallbackColor: Color = MaterialTheme.colorScheme.surfaceVariant, + overlayColor: Color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f), + content: @Composable () -> Unit, +) { + GlassBottomSpace( + modifier = modifier, + blur = blur, + glassCurveSizeDp = glassCurveSizeDp, + fallbackColor = fallbackColor, + overlayColor = overlayColor, + bottomContent = { NavbarOffset() } + ) { + content() + } +} + @Composable fun GlassSystemNavbar( modifier: Modifier = Modifier, blur: Float = 3f, glassCurveSizeDp: Float = 3f, + fallbackColor: Color = MaterialTheme.colorScheme.surfaceVariant, + overlayColor: Color = Color.Transparent, content: @Composable () -> Unit, ) { - GlassNavigationbar( + GlassBottomSpace( modifier = modifier, blur = blur, glassCurveSizeDp = glassCurveSizeDp, - fallbackColor = Color.Transparent, - navBarContent = { SystemNavbarSpacer() } + fallbackColor = fallbackColor, + overlayColor = overlayColor, + bottomContent = { SystemNavbarSpacer() } ) { content() } } @Composable -fun GlassNavigationbar( +fun GlassBottomSpace( modifier: Modifier = Modifier, height: Dp? = null, blur: Float = 3f, glassCurveSizeDp: Float = 3f, zIndex: Float = 1f, - fallbackColor: Color = MaterialTheme.colorScheme.primary, - overlayColor: Color = MaterialTheme.colorScheme.primary.copy(alpha = 0.3f), - navBarContent: @Composable () -> Unit, - content: @Composable () -> Unit, + fallbackColor: Color = MaterialTheme.colorScheme.surfaceVariant, + overlayColor: Color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f), + bottomContent: @Composable () -> Unit, + globalContent: @Composable () -> Unit, ) { Box(modifier = modifier) { val context = LocalContext.current @@ -72,7 +96,7 @@ fun GlassNavigationbar( } else it } ) { - content() + globalContent() } Box( modifier = Modifier @@ -96,7 +120,7 @@ fun GlassNavigationbar( } .align(Alignment.BottomCenter) ) { - navBarContent() + bottomContent() Box( Modifier From fcf8ef6581cbae1f73e56654060d597dcee956c4 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Fri, 22 Dec 2023 21:16:07 +0200 Subject: [PATCH 05/24] Refactor glass navbar --- .../java/f/cking/software/ui/devicelist/DeviceListScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt index 45f562c..e8816a9 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt @@ -1,4 +1,4 @@ -@file:OptIn(ExperimentalMaterial3Api::class) +@file:OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3Api::class) package f.cking.software.ui.devicelist From 12487b2618e5ad5a7ef5ad84aaa1b91dc20026a8 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Fri, 22 Dec 2023 21:46:22 +0200 Subject: [PATCH 06/24] Update material library --- .../java/f/cking/software/ui/MainActivity.kt | 2 ++ .../software/ui/devicelist/DeviceListScreen.kt | 2 +- .../f/cking/software/ui/main/MainScreen.kt | 18 +++++++++--------- .../ui/profileslist/ProfilesListScreen.kt | 2 +- .../software/ui/settings/SettingsScreen.kt | 8 ++++---- .../software/utils/graphic/ComposeFunctions.kt | 2 +- .../software/utils/graphic/GlassBottomSpace.kt | 10 +++++----- gradle/libs.versions.toml | 2 +- 8 files changed, 24 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/MainActivity.kt b/app/src/main/java/f/cking/software/ui/MainActivity.kt index 2d81bff..e487a62 100644 --- a/app/src/main/java/f/cking/software/ui/MainActivity.kt +++ b/app/src/main/java/f/cking/software/ui/MainActivity.kt @@ -74,6 +74,7 @@ class MainActivity : AppCompatActivity() { onPrimary = colorResource(id = R.color.theme_dark_on_primary), surface = colorResource(id = R.color.theme_dark_surface_color), surfaceVariant = colorResource(id = R.color.theme_dark_primary_variant), + surfaceContainer = colorResource(id = R.color.theme_light_primary_surface), onSurface = colorResource(id = R.color.theme_dark_on_surface), secondary = colorResource(id = R.color.theme_dark_secondary), secondaryContainer = colorResource(id = R.color.theme_dark_secondary_variant), @@ -87,6 +88,7 @@ class MainActivity : AppCompatActivity() { onPrimary = colorResource(id = R.color.theme_light_on_primary), surface = colorResource(id = R.color.theme_light_surface_color), surfaceVariant = colorResource(id = R.color.theme_light_primary_variant), + surfaceContainer = colorResource(id = R.color.theme_dark_primary_surface), onSurface = colorResource(id = R.color.theme_light_on_surface), secondary = colorResource(id = R.color.theme_light_secondary), secondaryContainer = colorResource(id = R.color.theme_light_secondary_variant), diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt index e8816a9..f20f816 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt @@ -198,7 +198,7 @@ object DeviceListScreen { Surface(shadowElevation = 4.dp) { Column( modifier = Modifier - .background(MaterialTheme.colorScheme.surfaceVariant) + .background(MaterialTheme.colorScheme.surfaceContainer) .fillMaxWidth() ) { LazyRow( diff --git a/app/src/main/java/f/cking/software/ui/main/MainScreen.kt b/app/src/main/java/f/cking/software/ui/main/MainScreen.kt index dbab72b..fe05b0f 100644 --- a/app/src/main/java/f/cking/software/ui/main/MainScreen.kt +++ b/app/src/main/java/f/cking/software/ui/main/MainScreen.kt @@ -58,6 +58,8 @@ object MainScreen { content = { innerPaddings -> GlassBottomNavBar( modifier = Modifier.fillMaxSize(), + fallbackColor = MaterialTheme.colorScheme.surfaceContainerHighest, + overlayColor = MaterialTheme.colorScheme.surfaceContainerHighest.copy(alpha = 0.3f), content = { Box(Modifier.padding(top = innerPaddings.calculateTopPadding())) { viewModel.tabs.firstOrNull { it.selected }?.screen?.invoke() @@ -188,10 +190,8 @@ object MainScreen { ) ExtendedFloatingActionButton( - containerColor = MaterialTheme.colorScheme.secondary, - modifier = Modifier - .onGloballyPositioned { GlobalUiState.setBottomOffset(fabOffset = it.size.height.toFloat()) }, - text = { Text(text = text, fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.onSecondary) }, + modifier = Modifier.onGloballyPositioned { GlobalUiState.setBottomOffset(fabOffset = it.size.height.toFloat()) }, + text = { Text(text = text, fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.onPrimaryContainer) }, onClick = { if (viewModel.needToShowPermissionsIntro()) { permissionsIntro.show() @@ -203,7 +203,7 @@ object MainScreen { Image( painter = painterResource(id = icon), contentDescription = text, - colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onSecondary) + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onPrimaryContainer) ) } ) @@ -303,12 +303,12 @@ object MainScreen { @Composable private fun TopBar(viewModel: MainViewModel) { TopAppBar( - colors = TopAppBarDefaults.topAppBarColors(containerColor = MaterialTheme.colorScheme.surfaceVariant), - title = { Text(text = stringResource(R.string.app_name), color = MaterialTheme.colorScheme.onSurfaceVariant) }, + colors = TopAppBarDefaults.topAppBarColors(containerColor = MaterialTheme.colorScheme.surfaceContainerHighest), + title = { Text(text = stringResource(R.string.app_name), color = MaterialTheme.colorScheme.onSurface) }, actions = { if (viewModel.scanStarted && viewModel.bgServiceIsActive) { CircularProgressIndicator( - color = MaterialTheme.colorScheme.onSurfaceVariant, + color = MaterialTheme.colorScheme.onSurface, modifier = Modifier .size(24.dp) ) @@ -321,7 +321,7 @@ object MainScreen { .size(24.dp), imageVector = Icons.Filled.Refresh, contentDescription = stringResource(R.string.refresh), - colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurfaceVariant) + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface) ) } } diff --git a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt index af30038..dd04ad4 100644 --- a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt @@ -76,7 +76,7 @@ object ProfilesListScreen { ) { LazyRow( modifier = Modifier - .background(MaterialTheme.colorScheme.surfaceVariant) + .background(MaterialTheme.colorScheme.surfaceContainer) .padding(vertical = 8.dp), ) { item { diff --git a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt index 49fe01c..730724c 100644 --- a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt @@ -13,10 +13,10 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.Button -import androidx.compose.material.Switch -import androidx.compose.material.Text +import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Switch +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -45,7 +45,7 @@ object SettingsScreen { val viewModel: SettingsViewModel = koinViewModel() LazyColumn( modifier = Modifier - .background(MaterialTheme.colorScheme.surface) + .background(MaterialTheme.colorScheme.background) .fillMaxWidth() .fillMaxHeight(), ) { diff --git a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt index 6a53878..ee1a514 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt @@ -323,7 +323,7 @@ fun RoundedBox( Column( Modifier .fillMaxWidth() - .background(color = MaterialTheme.colorScheme.primaryContainer, shape = shape) + .background(color = MaterialTheme.colorScheme.surfaceContainer, shape = shape) .clip(shape = shape) .padding(internalPaddings) ) { boxContent(this) } diff --git a/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt b/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt index 7dd175e..aa25e6a 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt @@ -34,8 +34,8 @@ fun GlassBottomNavBar( modifier: Modifier = Modifier, blur: Float = 3f, glassCurveSizeDp: Float = 3f, - fallbackColor: Color = MaterialTheme.colorScheme.surfaceVariant, - overlayColor: Color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f), + fallbackColor: Color = MaterialTheme.colorScheme.surfaceContainer, + overlayColor: Color = MaterialTheme.colorScheme.surfaceContainer.copy(alpha = 0.3f), content: @Composable () -> Unit, ) { GlassBottomSpace( @@ -55,7 +55,7 @@ fun GlassSystemNavbar( modifier: Modifier = Modifier, blur: Float = 3f, glassCurveSizeDp: Float = 3f, - fallbackColor: Color = MaterialTheme.colorScheme.surfaceVariant, + fallbackColor: Color = MaterialTheme.colorScheme.surfaceContainer, overlayColor: Color = Color.Transparent, content: @Composable () -> Unit, ) { @@ -78,8 +78,8 @@ fun GlassBottomSpace( blur: Float = 3f, glassCurveSizeDp: Float = 3f, zIndex: Float = 1f, - fallbackColor: Color = MaterialTheme.colorScheme.surfaceVariant, - overlayColor: Color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f), + fallbackColor: Color = MaterialTheme.colorScheme.surfaceContainer, + overlayColor: Color = MaterialTheme.colorScheme.surfaceContainer.copy(alpha = 0.3f), bottomContent: @Composable () -> Unit, globalContent: @Composable () -> Unit, ) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5daca77..10bd365 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ compose-compiler = "1.5.6" compose-accompanist = "0.28.0" compose-constraint = "1.0.1" compose-navigation = "2.5.2" -compose-material3 = "1.1.2" +compose-material3 = "1.2.0-beta01" horologist = "0.1.13" serialization-json = "1.4.0" wear = "1.2.0" From 3d84360cc29f9c440536424762951c8701dcd28f Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Fri, 22 Dec 2023 22:24:04 +0200 Subject: [PATCH 07/24] Update background colors --- .../ui/devicelist/DeviceListScreen.kt | 4 +- .../ui/profileslist/ProfilesListScreen.kt | 4 +- .../software/ui/settings/SettingsScreen.kt | 52 ++++++++----------- 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt index f20f816..38fa7a3 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt @@ -63,7 +63,7 @@ object DeviceListScreen { @OptIn(ExperimentalFoundationApi::class) @Composable fun Screen() { - val modifier = Modifier.background(MaterialTheme.colorScheme.background) + val modifier = Modifier.background(MaterialTheme.colorScheme.surface) val viewModel: DeviceListViewModel = koinViewModel() val focusManager = LocalFocusManager.current val nestedScroll = remember { @@ -198,7 +198,7 @@ object DeviceListScreen { Surface(shadowElevation = 4.dp) { Column( modifier = Modifier - .background(MaterialTheme.colorScheme.surfaceContainer) + .background(MaterialTheme.colorScheme.surfaceContainerHigh) .fillMaxWidth() ) { LazyRow( diff --git a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt index dd04ad4..c8c183f 100644 --- a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt @@ -44,7 +44,7 @@ object ProfilesListScreen { val viewModel: ProfilesListViewModel = koinViewModel() Column( Modifier - .background(MaterialTheme.colorScheme.background) + .background(MaterialTheme.colorScheme.surface) .fillMaxWidth() .fillMaxHeight() ) { @@ -76,7 +76,7 @@ object ProfilesListScreen { ) { LazyRow( modifier = Modifier - .background(MaterialTheme.colorScheme.surfaceContainer) + .background(MaterialTheme.colorScheme.surfaceContainerHigh) .padding(vertical = 8.dp), ) { item { diff --git a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt index 730724c..f161e85 100644 --- a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt @@ -7,12 +7,13 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Switch @@ -43,35 +44,28 @@ object SettingsScreen { @Composable fun Screen() { val viewModel: SettingsViewModel = koinViewModel() - LazyColumn( + Column( modifier = Modifier - .background(MaterialTheme.colorScheme.background) - .fillMaxWidth() - .fillMaxHeight(), + .background(MaterialTheme.colorScheme.surface) + .fillMaxSize() + .verticalScroll(rememberScrollState()) ) { - item { - Column( - modifier = Modifier.fillMaxWidth(), - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Spacer(modifier = Modifier.height(16.dp)) - ProjectGithub(viewModel = viewModel) - Spacer(modifier = Modifier.height(8.dp)) - ReportIssue(viewModel = viewModel) - Spacer(modifier = Modifier.height(8.dp)) - ClearDatabaseBlock(viewModel = viewModel) - Spacer(modifier = Modifier.height(8.dp)) - BackupDatabaseBlock(viewModel = viewModel) - Spacer(modifier = Modifier.height(8.dp)) - RunOnStartup(viewModel = viewModel) - Spacer(modifier = Modifier.height(8.dp)) - LocationBlock(viewModel = viewModel) - Spacer(modifier = Modifier.height(8.dp)) - AppInfo() - SecretCatPhoto() - BottomOffsetWithFAB() - } - } + Spacer(modifier = Modifier.height(16.dp)) + ProjectGithub(viewModel = viewModel) + Spacer(modifier = Modifier.height(8.dp)) + ReportIssue(viewModel = viewModel) + Spacer(modifier = Modifier.height(8.dp)) + ClearDatabaseBlock(viewModel = viewModel) + Spacer(modifier = Modifier.height(8.dp)) + BackupDatabaseBlock(viewModel = viewModel) + Spacer(modifier = Modifier.height(8.dp)) + RunOnStartup(viewModel = viewModel) + Spacer(modifier = Modifier.height(8.dp)) + LocationBlock(viewModel = viewModel) + Spacer(modifier = Modifier.height(8.dp)) + AppInfo() + SecretCatPhoto() + BottomOffsetWithFAB() } } From 1943b1812fde6b9afc524bf930db76d231be1600 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 02:00:51 +0200 Subject: [PATCH 08/24] Fix small issues --- .../ui/devicelist/DeviceListScreen.kt | 12 ++++----- .../software/ui/journal/JournalScreen.kt | 9 +++---- .../ui/profileslist/ProfilesListScreen.kt | 10 ++++---- .../software/ui/settings/SettingsScreen.kt | 25 +++++++++++-------- .../utils/graphic/ComposeFunctions.kt | 9 +++---- .../utils/graphic/GlassBottomSpace.kt | 2 +- 6 files changed, 32 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt index 38fa7a3..c3010ef 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt @@ -9,7 +9,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -51,10 +51,10 @@ import com.vanpra.composematerialdialogs.rememberMaterialDialogState import f.cking.software.R import f.cking.software.ui.ScreenNavigationCommands import f.cking.software.ui.filter.SelectFilterTypeScreen -import f.cking.software.utils.graphic.BottomOffsetWithFAB import f.cking.software.utils.graphic.ContentPlaceholder import f.cking.software.utils.graphic.DeviceListItem import f.cking.software.utils.graphic.Divider +import f.cking.software.utils.graphic.FABSpacer import f.cking.software.utils.graphic.RoundedBox import org.koin.androidx.compose.koinViewModel @@ -64,6 +64,7 @@ object DeviceListScreen { @Composable fun Screen() { val modifier = Modifier.background(MaterialTheme.colorScheme.surface) + .fillMaxSize() val viewModel: DeviceListViewModel = koinViewModel() val focusManager = LocalFocusManager.current val nestedScroll = remember { @@ -89,10 +90,7 @@ object DeviceListScreen { } } else { LazyColumn( - modifier = modifier - .fillMaxWidth() - .fillMaxHeight() - .nestedScroll(nestedScroll), + modifier = modifier.nestedScroll(nestedScroll), ) { stickyHeader { Box() { @@ -130,7 +128,7 @@ object DeviceListScreen { } item { - BottomOffsetWithFAB() + FABSpacer() } } } diff --git a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt index 8e18b1b..b0353e9 100644 --- a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt +++ b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt @@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -28,9 +28,9 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.google.accompanist.flowlayout.FlowRow import f.cking.software.R -import f.cking.software.utils.graphic.BottomOffsetWithFAB import f.cking.software.utils.graphic.ContentPlaceholder import f.cking.software.utils.graphic.Divider +import f.cking.software.utils.graphic.FABSpacer import org.koin.androidx.compose.koinViewModel object JournalScreen { @@ -40,19 +40,18 @@ object JournalScreen { val viewModel: JournalViewModel = koinViewModel() val journal = viewModel.journal val modifier = Modifier.background(MaterialTheme.colorScheme.surface) + .fillMaxSize() if (journal.isEmpty()) { ContentPlaceholder(text = stringResource(R.string.journal_placeholder), modifier = modifier) } else { LazyColumn( modifier = modifier - .fillMaxWidth() - .fillMaxHeight() ) { journal.map { item { JournalEntry(uiModel = it, viewModel) } item { Divider() } } - item { BottomOffsetWithFAB() } + item { FABSpacer() } } } } diff --git a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt index c8c183f..656d580 100644 --- a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -33,8 +34,8 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import f.cking.software.R import f.cking.software.domain.model.RadarProfile -import f.cking.software.utils.graphic.BottomOffsetWithFAB import f.cking.software.utils.graphic.ContentPlaceholder +import f.cking.software.utils.graphic.FABSpacer import org.koin.androidx.compose.koinViewModel object ProfilesListScreen { @@ -45,8 +46,7 @@ object ProfilesListScreen { Column( Modifier .background(MaterialTheme.colorScheme.surface) - .fillMaxWidth() - .fillMaxHeight() + .fillMaxSize() ) { Header(viewModel = viewModel) val profiles = viewModel.profiles @@ -58,11 +58,11 @@ object ProfilesListScreen { ) { profiles.map { item { ListItem(profile = it, viewModel = viewModel) } } item { - BottomOffsetWithFAB() + FABSpacer() } } } else { - ContentPlaceholder(stringResource(R.string.radar_profile_placeholder)) + ContentPlaceholder(stringResource(R.string.radar_profile_placeholder), Modifier.fillMaxSize()) } } } diff --git a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt index f161e85..7d687c2 100644 --- a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt @@ -35,7 +35,8 @@ import com.vanpra.composematerialdialogs.rememberMaterialDialogState import f.cking.software.BuildConfig import f.cking.software.R import f.cking.software.dateTimeStringFormat -import f.cking.software.utils.graphic.BottomOffsetWithFAB +import f.cking.software.utils.graphic.BottomNavigationSpacer +import f.cking.software.utils.graphic.FABSpacer import f.cking.software.utils.graphic.RoundedBox import org.koin.androidx.compose.koinViewModel @@ -65,7 +66,7 @@ object SettingsScreen { Spacer(modifier = Modifier.height(8.dp)) AppInfo() SecretCatPhoto() - BottomOffsetWithFAB() + FABSpacer() } } @@ -193,8 +194,8 @@ object SettingsScreen { @Composable private fun SecretCatPhoto() { - Column { - Spacer(modifier = Modifier.height(16.dp)) + Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) { + BottomNavigationSpacer() repeat(50) { Image( modifier = Modifier @@ -208,13 +209,15 @@ object SettingsScreen { Spacer(modifier = Modifier.height(4.dp)) } Spacer(modifier = Modifier.height(16.dp)) - Image( - painter = painterResource(id = R.drawable.appa), - contentDescription = stringResource(id = R.string.secret_cat), - contentScale = ContentScale.FillWidth - ) - Spacer(modifier = Modifier.height(4.dp)) - Text(text = stringResource(id = R.string.secret_cat), fontWeight = FontWeight.Light) + Column { + Image( + painter = painterResource(id = R.drawable.appa), + contentDescription = stringResource(id = R.string.secret_cat), + contentScale = ContentScale.FillWidth + ) + Spacer(modifier = Modifier.height(4.dp)) + Text(text = stringResource(id = R.string.secret_cat), fontWeight = FontWeight.Light) + } } } diff --git a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt index ee1a514..5e5720e 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt @@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.navigationBars @@ -292,9 +291,7 @@ fun ContentPlaceholder( icon: Painter = painterResource(R.drawable.ic_ghost), ) { Box( - modifier = modifier - .fillMaxWidth() - .fillMaxHeight(), + modifier = modifier, contentAlignment = Alignment.Center ) { Column(Modifier.padding(16.dp), horizontalAlignment = Alignment.CenterHorizontally) { @@ -387,7 +384,7 @@ fun pxToDp(px: Float): Float { } @Composable -fun NavbarOffset() { +fun BottomNavigationSpacer() { val bottomOffset = remember { GlobalUiState.navbarOffsetPx } Column { Spacer(modifier = Modifier.height(pxToDp(bottomOffset.value).dp)) @@ -395,7 +392,7 @@ fun NavbarOffset() { } @Composable -fun BottomOffsetWithFAB() { +fun FABSpacer() { val bottomOffset = remember { GlobalUiState.totalOffset } Column { Spacer(modifier = Modifier.height(pxToDp(bottomOffset.value).dp)) diff --git a/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt b/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt index aa25e6a..f021c9d 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt @@ -44,7 +44,7 @@ fun GlassBottomNavBar( glassCurveSizeDp = glassCurveSizeDp, fallbackColor = fallbackColor, overlayColor = overlayColor, - bottomContent = { NavbarOffset() } + bottomContent = { BottomNavigationSpacer() } ) { content() } From 7c8d051b7d24cf589a05d1c9822fa7a4f31fb5ce Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 02:13:24 +0200 Subject: [PATCH 09/24] Update journal --- .../f/cking/software/ui/journal/JournalScreen.kt | 13 ++++++------- .../f/cking/software/ui/journal/JournalViewModel.kt | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt index b0353e9..1619a1e 100644 --- a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt +++ b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt @@ -12,10 +12,10 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.Chip import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Text import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.SuggestionChip +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -90,7 +90,7 @@ object JournalScreen { modifier = Modifier.clickable { isExpanded = !isExpanded }, - text = uiModel.subtitle, + text = if (isExpanded) uiModel.subtitle else uiModel.subtitleCollapsed.orEmpty(), fontWeight = FontWeight.Normal, maxLines = if (isExpanded) Int.MAX_VALUE else 5, overflow = TextOverflow.Ellipsis, @@ -103,11 +103,10 @@ object JournalScreen { mainAxisSpacing = 8.dp, ) { items.forEach { item -> - Chip( + SuggestionChip( onClick = { viewModel.onJournalListItemClick(item.payload) }, - ) { - Text(text = item.displayName) - } + label = { Text(text = item.displayName) } + ) } } } diff --git a/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt b/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt index 28f99f6..432b43a 100644 --- a/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt +++ b/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt @@ -19,6 +19,7 @@ import f.cking.software.domain.model.JournalEntry import f.cking.software.ui.ScreenNavigationCommands import f.cking.software.utils.navigation.Router import kotlinx.coroutines.launch +import kotlin.math.min class JournalViewModel( private val journalRepository: JournalRepository, @@ -71,17 +72,14 @@ class JournalViewModel( } else { report.title } - val description = if (report.stackTrace.length > MAX_ERROR_DESCRIPTION_LENGTH) { - report.stackTrace.substring(0 until MAX_ERROR_DESCRIPTION_LENGTH) - } else { - report.stackTrace - } + val description = report.stackTrace return JournalEntryUiModel( dateTime = journalEntry.timestamp.formattedDate(), color = { MaterialTheme.colorScheme.error }, colorForeground = { MaterialTheme.colorScheme.onError }, title = title, subtitle = description, + subtitleCollapsed = description.substring(0 until min(MAX_ERROR_DESCRIPTION_COLLAPSED_LENGTH, description.length)), journalEntry = journalEntry, items = null, ) @@ -97,6 +95,7 @@ class JournalViewModel( colorForeground = { MaterialTheme.colorScheme.onSurface }, title = context.getString(R.string.journal_profile_detected, getProfileName(report.profileId)), subtitle = null, + subtitleCollapsed = null, journalEntry = journalEntry, items = mapListItems(report.deviceAddresses), ) @@ -125,6 +124,7 @@ class JournalViewModel( val colorForeground: @Composable () -> Color, val title: String, val subtitle: String?, + val subtitleCollapsed: String?, val items: List?, val journalEntry: JournalEntry, ) { @@ -136,6 +136,6 @@ class JournalViewModel( companion object { private const val MAX_ERROR_TITLE_LENGTH = 256 - private const val MAX_ERROR_DESCRIPTION_LENGTH = 10000 + private const val MAX_ERROR_DESCRIPTION_COLLAPSED_LENGTH = 500 } } \ No newline at end of file From 2517e6e56e69f4d87e6232a8f6270f5cb026f845 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 02:57:40 +0200 Subject: [PATCH 10/24] Migrate Device Details --- .../ui/devicedetails/DeviceDetailsScreen.kt | 194 +++++++++--------- .../ui/devicelist/DeviceListScreen.kt | 7 +- .../software/ui/journal/JournalScreen.kt | 2 - .../f/cking/software/ui/main/MainScreen.kt | 4 +- .../ui/profileslist/ProfilesListScreen.kt | 2 +- .../utils/graphic/ComposeFunctions.kt | 2 +- .../utils/graphic/GlassBottomSpace.kt | 10 +- 7 files changed, 105 insertions(+), 116 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt b/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt index ae4b9e1..f58c885 100644 --- a/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt @@ -8,30 +8,31 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Button -import androidx.compose.material.Chip -import androidx.compose.material.ChipDefaults -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.LinearProgressIndicator -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.TopAppBar +import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Add -import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Edit +import androidx.compose.material3.Button +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SuggestionChip +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope @@ -59,7 +60,6 @@ import f.cking.software.dpToPx import f.cking.software.frameRate import f.cking.software.ui.AsyncBatchProcessor import f.cking.software.ui.tagdialog.TagDialog -import f.cking.software.utils.graphic.GlassSystemNavbar import f.cking.software.utils.graphic.MapView import f.cking.software.utils.graphic.RoundedBox import f.cking.software.utils.graphic.SystemNavbarSpacer @@ -73,6 +73,7 @@ import org.osmdroid.views.MapView import org.osmdroid.views.overlay.Marker import timber.log.Timber +@OptIn(ExperimentalMaterial3Api::class) object DeviceDetailsScreen { @Composable @@ -82,20 +83,17 @@ object DeviceDetailsScreen { Scaffold( modifier = Modifier .background(MaterialTheme.colorScheme.surface) - .fillMaxWidth() - .fillMaxHeight(), + .fillMaxSize(), topBar = { AppBar(viewModel = viewModel) }, content = { - GlassSystemNavbar { - Content( - modifier = Modifier - .background(MaterialTheme.colorScheme.surface) - .padding(it), - viewModel = viewModel, - ) - } + Content( + modifier = Modifier + .background(MaterialTheme.colorScheme.surface) + .padding(it), + viewModel = viewModel, + ) } ) } @@ -116,7 +114,7 @@ object DeviceDetailsScreen { Icon( imageVector = ImageVector.vectorResource(id = iconId), contentDescription = text, - tint = MaterialTheme.colorScheme.onPrimary, + tint = MaterialTheme.colorScheme.onSurface, ) } } @@ -124,9 +122,9 @@ object DeviceDetailsScreen { navigationIcon = { IconButton(onClick = { viewModel.back() }) { Icon( - imageVector = Icons.Filled.ArrowBack, + imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.back), - tint = MaterialTheme.colorScheme.onPrimary + tint = MaterialTheme.colorScheme.onSurface ) } } @@ -149,9 +147,7 @@ object DeviceDetailsScreen { @Composable private fun Progress(modifier: Modifier = Modifier) { Box( - modifier = modifier - .fillMaxWidth() - .fillMaxHeight(), + modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center, ) { CircularProgressIndicator() @@ -166,21 +162,22 @@ object DeviceDetailsScreen { ) { Column( modifier = modifier - .fillMaxHeight() - .fillMaxWidth() + .padding(horizontal = 16.dp) + .fillMaxSize() ) { LocationHistory( modifier = Modifier .weight(1f) - .fillMaxWidth(), viewModel = viewModel + .fillMaxWidth(), + deviceData = deviceData, + viewModel = viewModel ) - LazyColumn( - modifier = Modifier - .fillMaxWidth() - .weight(1.5f) - ) { - item { DeviceContent(deviceData = deviceData, viewModel = viewModel) } - } + Spacer(modifier = Modifier.height(8.dp)) + Tags(deviceData = deviceData, viewModel = viewModel) + Spacer(modifier = Modifier.height(8.dp)) + DeviceContent(modifier = Modifier.weight(1.5f), deviceData = deviceData) + Spacer(modifier = Modifier.height(8.dp)) + SystemNavbarSpacer() } } @@ -188,62 +185,61 @@ object DeviceDetailsScreen { private fun DeviceContent( modifier: Modifier = Modifier, deviceData: DeviceData, - viewModel: DeviceDetailsViewModel, ) { - Column( + RoundedBox( modifier = modifier - .fillMaxWidth() - .padding(16.dp), + .fillMaxWidth(), + internalPaddings = 0.dp, ) { + Column( + Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp) + .verticalScroll(rememberScrollState()) + ) { + Spacer(modifier = Modifier.height(16.dp)) + Text( + text = deviceData.buildDisplayName(), + fontSize = 20.sp, + fontWeight = FontWeight.Bold, + ) + Spacer(modifier = Modifier.height(8.dp)) - HistoryPeriod(deviceData = deviceData, viewModel = viewModel) - Spacer(modifier = Modifier.height(8.dp)) - - Tags(deviceData = deviceData, viewModel = viewModel) - Spacer(modifier = Modifier.height(8.dp)) + Text(text = stringResource(R.string.device_details_name), fontWeight = FontWeight.Bold) + Text(text = deviceData.name ?: stringResource(R.string.not_applicable)) + Spacer(modifier = Modifier.height(8.dp)) - Text( - text = deviceData.buildDisplayName(), - fontSize = 20.sp, - fontWeight = FontWeight.Bold, - ) - Spacer(modifier = Modifier.height(8.dp)) + Text(text = stringResource(R.string.device_details_address), fontWeight = FontWeight.Bold) + Text(text = deviceData.address) + Spacer(modifier = Modifier.height(8.dp)) - Text(text = stringResource(R.string.device_details_name), fontWeight = FontWeight.Bold) - Text(text = deviceData.name ?: stringResource(R.string.not_applicable)) - Spacer(modifier = Modifier.height(8.dp)) + Text(text = stringResource(R.string.device_details_manufacturer), fontWeight = FontWeight.Bold) + Text(text = deviceData.manufacturerInfo?.name ?: stringResource(R.string.not_applicable)) + Spacer(modifier = Modifier.height(8.dp)) - Text(text = stringResource(R.string.device_details_address), fontWeight = FontWeight.Bold) - Text(text = deviceData.address) - Spacer(modifier = Modifier.height(8.dp)) + Row { + Text( + text = stringResource(R.string.device_details_detect_count), + fontWeight = FontWeight.Bold, + ) + Spacer(Modifier.width(4.dp)) + Text(text = deviceData.detectCount.toString()) + } + Spacer(modifier = Modifier.height(8.dp)) - Text(text = stringResource(R.string.device_details_manufacturer), fontWeight = FontWeight.Bold) - Text(text = deviceData.manufacturerInfo?.name ?: stringResource(R.string.not_applicable)) - Spacer(modifier = Modifier.height(8.dp)) + Text(text = stringResource(R.string.device_details_first_detection), fontWeight = FontWeight.Bold) + Text( + text = stringResource(R.string.time_ago, deviceData.firstDetectionPeriod(LocalContext.current)) + ) + Spacer(modifier = Modifier.height(8.dp)) - Row { + Text(text = stringResource(R.string.device_details_last_detection), fontWeight = FontWeight.Bold) Text( - text = stringResource(R.string.device_details_detect_count), - fontWeight = FontWeight.Bold, + text = stringResource(R.string.time_ago, deviceData.lastDetectionPeriod(LocalContext.current)) ) - Spacer(Modifier.width(4.dp)) - Text(text = deviceData.detectCount.toString()) + Spacer(modifier = Modifier.height(16.dp)) } - Spacer(modifier = Modifier.height(8.dp)) - - Text(text = stringResource(R.string.device_details_first_detection), fontWeight = FontWeight.Bold) - Text( - text = stringResource(R.string.time_ago, deviceData.firstDetectionPeriod(LocalContext.current)) - ) - Spacer(modifier = Modifier.height(8.dp)) - - Text(text = stringResource(R.string.device_details_last_detection), fontWeight = FontWeight.Bold) - Text( - text = stringResource(R.string.time_ago, deviceData.lastDetectionPeriod(LocalContext.current)) - ) - Spacer(modifier = Modifier.height(8.dp)) - SystemNavbarSpacer() } } @@ -299,7 +295,6 @@ object DeviceDetailsScreen { TagChip(tagName = name, tagIcon = Icons.Filled.Delete) { dialogState.show() } } - @OptIn(ExperimentalMaterialApi::class) @Composable fun AddTag( deviceData: DeviceData, @@ -308,16 +303,13 @@ object DeviceDetailsScreen { val addTagDialog = TagDialog.rememberDialog { viewModel.onNewTagSelected(deviceData, it) } - Chip( - colors = ChipDefaults.chipColors( - backgroundColor = MaterialTheme.colorScheme.secondary, - contentColor = MaterialTheme.colorScheme.onSecondary, - ), + SuggestionChip( onClick = { addTagDialog.show() }, - leadingIcon = { + icon = { Icon(imageVector = Icons.Default.Add, contentDescription = null, tint = MaterialTheme.colorScheme.onSurface) - } - ) { Text(text = stringResource(R.string.add_tag)) } + }, + label = { Text(text = stringResource(R.string.add_tag)) } + ) } @Composable @@ -401,13 +393,17 @@ object DeviceDetailsScreen { } @Composable - private fun LocationHistory(modifier: Modifier = Modifier, viewModel: DeviceDetailsViewModel) { - Box(modifier = modifier) { - Map( - viewModel = viewModel, - isLoading = { viewModel.markersInLoadingState = it } - ) - MapOverlay(viewModel = viewModel) + private fun LocationHistory(modifier: Modifier = Modifier, deviceData: DeviceData, viewModel: DeviceDetailsViewModel) { + RoundedBox(modifier = modifier, internalPaddings = 0.dp) { + Box(modifier = Modifier.fillMaxWidth()) { + Map( + viewModel = viewModel, + isLoading = { viewModel.markersInLoadingState = it } + ) + MapOverlay(viewModel = viewModel) + } + Spacer(modifier = Modifier.height(8.dp)) + HistoryPeriod(deviceData = deviceData, viewModel = viewModel) } } diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt index c3010ef..4dda408 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt @@ -1,5 +1,3 @@ -@file:OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3Api::class) - package f.cking.software.ui.devicelist import androidx.compose.foundation.ExperimentalFoundationApi @@ -23,7 +21,6 @@ import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Search import androidx.compose.material3.Button -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.FilterChip import androidx.compose.material3.Icon import androidx.compose.material3.LinearProgressIndicator @@ -58,9 +55,9 @@ import f.cking.software.utils.graphic.FABSpacer import f.cking.software.utils.graphic.RoundedBox import org.koin.androidx.compose.koinViewModel +@OptIn(ExperimentalFoundationApi::class) object DeviceListScreen { - @OptIn(ExperimentalFoundationApi::class) @Composable fun Screen() { val modifier = Modifier.background(MaterialTheme.colorScheme.surface) @@ -196,7 +193,7 @@ object DeviceListScreen { Surface(shadowElevation = 4.dp) { Column( modifier = Modifier - .background(MaterialTheme.colorScheme.surfaceContainerHigh) + .background(MaterialTheme.colorScheme.surfaceContainerHighest) .fillMaxWidth() ) { LazyRow( diff --git a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt index 1619a1e..185c2c5 100644 --- a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt +++ b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt @@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SuggestionChip import androidx.compose.material3.Text @@ -56,7 +55,6 @@ object JournalScreen { } } - @OptIn(ExperimentalMaterialApi::class) @Composable fun JournalEntry(uiModel: JournalViewModel.JournalEntryUiModel, viewModel: JournalViewModel) { Box( diff --git a/app/src/main/java/f/cking/software/ui/main/MainScreen.kt b/app/src/main/java/f/cking/software/ui/main/MainScreen.kt index fe05b0f..891975f 100644 --- a/app/src/main/java/f/cking/software/ui/main/MainScreen.kt +++ b/app/src/main/java/f/cking/software/ui/main/MainScreen.kt @@ -44,6 +44,7 @@ import f.cking.software.utils.graphic.GlassBottomNavBar import f.cking.software.utils.graphic.SystemNavbarSpacer import org.koin.androidx.compose.koinViewModel +@OptIn(ExperimentalMaterial3Api::class) object MainScreen { @SuppressLint("NewApi") @@ -58,8 +59,6 @@ object MainScreen { content = { innerPaddings -> GlassBottomNavBar( modifier = Modifier.fillMaxSize(), - fallbackColor = MaterialTheme.colorScheme.surfaceContainerHighest, - overlayColor = MaterialTheme.colorScheme.surfaceContainerHighest.copy(alpha = 0.3f), content = { Box(Modifier.padding(top = innerPaddings.calculateTopPadding())) { viewModel.tabs.firstOrNull { it.selected }?.screen?.invoke() @@ -299,7 +298,6 @@ object MainScreen { } } - @OptIn(ExperimentalMaterial3Api::class) @Composable private fun TopBar(viewModel: MainViewModel) { TopAppBar( diff --git a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt index 656d580..b7e0cae 100644 --- a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt @@ -76,7 +76,7 @@ object ProfilesListScreen { ) { LazyRow( modifier = Modifier - .background(MaterialTheme.colorScheme.surfaceContainerHigh) + .background(MaterialTheme.colorScheme.surfaceContainerHighest) .padding(vertical = 8.dp), ) { item { diff --git a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt index 5e5720e..01050b4 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt @@ -262,6 +262,7 @@ fun MapView( Text( text = stringResource(R.string.osm_copyright), modifier = Modifier + .padding(start = 4.dp) .align(Alignment.BottomStart) .alpha(0.9f) .clickable { context.openUrl("https://www.openstreetmap.org/copyright") }, @@ -364,7 +365,6 @@ fun TagChip( leadingIconContentColor = Color.Black, ), border = null, - shape = RoundedCornerShape(corner = CornerSize(Int.MAX_VALUE.dp)), onClick = onClick, leadingIcon = { tagIcon?.let { Icon(imageVector = it, contentDescription = null, tint = MaterialTheme.colorScheme.onSurface) } }, label = { diff --git a/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt b/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt index f021c9d..440a697 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/GlassBottomSpace.kt @@ -34,8 +34,8 @@ fun GlassBottomNavBar( modifier: Modifier = Modifier, blur: Float = 3f, glassCurveSizeDp: Float = 3f, - fallbackColor: Color = MaterialTheme.colorScheme.surfaceContainer, - overlayColor: Color = MaterialTheme.colorScheme.surfaceContainer.copy(alpha = 0.3f), + fallbackColor: Color = MaterialTheme.colorScheme.surfaceContainerHighest, + overlayColor: Color = MaterialTheme.colorScheme.surfaceContainerHighest.copy(alpha = 0.3f), content: @Composable () -> Unit, ) { GlassBottomSpace( @@ -55,7 +55,7 @@ fun GlassSystemNavbar( modifier: Modifier = Modifier, blur: Float = 3f, glassCurveSizeDp: Float = 3f, - fallbackColor: Color = MaterialTheme.colorScheme.surfaceContainer, + fallbackColor: Color = MaterialTheme.colorScheme.surfaceContainerHighest, overlayColor: Color = Color.Transparent, content: @Composable () -> Unit, ) { @@ -78,8 +78,8 @@ fun GlassBottomSpace( blur: Float = 3f, glassCurveSizeDp: Float = 3f, zIndex: Float = 1f, - fallbackColor: Color = MaterialTheme.colorScheme.surfaceContainer, - overlayColor: Color = MaterialTheme.colorScheme.surfaceContainer.copy(alpha = 0.3f), + fallbackColor: Color = MaterialTheme.colorScheme.surfaceContainerHighest, + overlayColor: Color = MaterialTheme.colorScheme.surfaceContainerHighest.copy(alpha = 0.3f), bottomContent: @Composable () -> Unit, globalContent: @Composable () -> Unit, ) { From 25f8e296c155ab7b0192fd6f74565a7c550f1fb4 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 03:01:03 +0200 Subject: [PATCH 11/24] Fix buttons --- .../f/cking/software/ui/settings/SettingsScreen.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt index 7d687c2..6455f84 100644 --- a/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/settings/SettingsScreen.kt @@ -124,7 +124,7 @@ object SettingsScreen { onClick = { viewModel.onRemoveGarbageClick() }, enabled = !viewModel.garbageRemovingInProgress ) { - Text(text = stringResource(R.string.clear_garbage)) + Text(text = stringResource(R.string.clear_garbage), color = MaterialTheme.colorScheme.onPrimary) } } @@ -156,7 +156,7 @@ object SettingsScreen { onClick = { dialogState.show() }, enabled = !viewModel.backupDbInProgress ) { - Text(text = stringResource(R.string.settings_restore_database)) + Text(text = stringResource(R.string.settings_restore_database), color = MaterialTheme.colorScheme.onPrimary) } } @@ -188,7 +188,7 @@ object SettingsScreen { onClick = { dialogState.show() }, enabled = !viewModel.backupDbInProgress ) { - Text(text = stringResource(R.string.settings_backup_database)) + Text(text = stringResource(R.string.settings_backup_database), color = MaterialTheme.colorScheme.onPrimary) } } @@ -249,7 +249,7 @@ object SettingsScreen { onClick = { dialogState.show() }, enabled = !viewModel.locationRemovingInProgress ) { - Text(text = stringResource(R.string.settings_clear_all_location_history)) + Text(text = stringResource(R.string.settings_clear_all_location_history), color = MaterialTheme.colorScheme.onPrimary) } } @@ -281,7 +281,7 @@ object SettingsScreen { Text(text = stringResource(R.string.report_issue_title), fontWeight = FontWeight.SemiBold) Spacer(modifier = Modifier.height(4.dp)) Button(modifier = Modifier.fillMaxWidth(), onClick = { viewModel.opReportIssueClick() }) { - Text(text = stringResource(R.string.report)) + Text(text = stringResource(R.string.report), color = MaterialTheme.colorScheme.onPrimary) } } } @@ -305,7 +305,7 @@ object SettingsScreen { Text(text = stringResource(R.string.project_github_title, stringResource(id = R.string.app_name)), fontWeight = FontWeight.SemiBold) Spacer(modifier = Modifier.height(4.dp)) Button(modifier = Modifier.fillMaxWidth(), onClick = { viewModel.onGithubClick() }) { - Text(text = stringResource(R.string.open_github)) + Text(text = stringResource(R.string.open_github), color = MaterialTheme.colorScheme.onPrimary) } } } From fb2844cadf3406f59682312a38a3e57eef68be4b Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 03:33:59 +0200 Subject: [PATCH 12/24] Migrate profile details screen --- .../ui/profiledetails/ProfileDetailsScreen.kt | 77 +++++++++++-------- .../utils/graphic/ComposeFunctions.kt | 6 ++ 2 files changed, 52 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt b/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt index 1f93763..a7d834c 100644 --- a/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt @@ -6,15 +6,15 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Done import androidx.compose.material3.Button @@ -27,9 +27,12 @@ import androidx.compose.material3.Switch import androidx.compose.material3.Text import androidx.compose.material3.TextField import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight @@ -47,24 +50,29 @@ import f.cking.software.utils.graphic.SystemNavbarSpacer import org.koin.androidx.compose.koinViewModel import org.koin.core.parameter.parametersOf +@OptIn(ExperimentalMaterial3Api::class) object ProfileDetailsScreen { @Composable fun Screen(profileId: Int?, template: FilterUiState?, key: String) { val viewModel: ProfileDetailsViewModel = koinViewModel(key = key) { parametersOf(profileId, template) } + val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() + Scaffold( modifier = Modifier - .fillMaxWidth() - .fillMaxHeight(), + .nestedScroll(scrollBehavior.nestedScrollConnection) + .fillMaxSize(), topBar = { - AppBar(viewModel) + AppBar(viewModel, scrollBehavior) }, content = { - GlassSystemNavbar { - Box(modifier = Modifier - .background(MaterialTheme.colorScheme.surface) - .fillMaxSize() - .padding(it)) { + GlassSystemNavbar(Modifier.padding(top = it.calculateTopPadding())) { + Column( + modifier = Modifier + .fillMaxSize() + .verticalScroll(rememberScrollState()) + .background(MaterialTheme.colorScheme.surface) + ) { Content(viewModel) } } @@ -74,7 +82,7 @@ object ProfileDetailsScreen { @OptIn(ExperimentalMaterial3Api::class) @Composable - private fun AppBar(viewModel: ProfileDetailsViewModel) { + private fun AppBar(viewModel: ProfileDetailsViewModel, scrollBehavior: TopAppBarScrollBehavior) { val discardChangesDialog = rememberMaterialDialogState() MaterialDialog( @@ -84,7 +92,10 @@ object ProfileDetailsScreen { stringResource(R.string.stay), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) ) { discardChangesDialog.hide() } - positiveButton(stringResource(R.string.discard_changes), textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer)) { + positiveButton( + stringResource(R.string.discard_changes), + textStyle = TextStyle(color = MaterialTheme.colorScheme.secondaryContainer) + ) { discardChangesDialog.hide() viewModel.back() } @@ -112,6 +123,10 @@ object ProfileDetailsScreen { } TopAppBar( + scrollBehavior = scrollBehavior, + colors = TopAppBarDefaults.topAppBarColors( + scrolledContainerColor = MaterialTheme.colorScheme.surfaceContainerHighest, + ), title = { Text(text = stringResource(R.string.radar_profile_title)) }, @@ -121,13 +136,17 @@ object ProfileDetailsScreen { Icon( imageVector = Icons.Filled.Delete, contentDescription = stringResource(R.string.delete), - tint = MaterialTheme.colorScheme.onPrimary + tint = MaterialTheme.colorScheme.onSurface ) } Spacer(modifier = Modifier.width(8.dp)) } IconButton(onClick = { viewModel.onSaveClick() }) { - Icon(imageVector = Icons.Filled.Done, contentDescription = stringResource(R.string.save), tint = MaterialTheme.colorScheme.onPrimary) + Icon( + imageVector = Icons.Filled.Done, + contentDescription = stringResource(R.string.save), + tint = MaterialTheme.colorScheme.onSurface + ) } }, navigationIcon = { @@ -139,9 +158,9 @@ object ProfileDetailsScreen { } }) { Icon( - imageVector = Icons.Filled.ArrowBack, + imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.back), - tint = MaterialTheme.colorScheme.onPrimary + tint = MaterialTheme.colorScheme.onSurface ) } } @@ -150,22 +169,18 @@ object ProfileDetailsScreen { @Composable private fun Content(viewModel: ProfileDetailsViewModel) { - LazyColumn(Modifier.fillMaxWidth()) { - item { Header(viewModel) } - - val filter = viewModel.filter - if (filter != null) { - item { - Box(modifier = Modifier.padding(8.dp)) { - FilterScreen.Filter(filterState = filter, router = viewModel.router, onDeleteClick = { viewModel.filter = null }) - } - } - } else { - item { CreateFilter(viewModel = viewModel) } - } + Header(viewModel) - item { SystemNavbarSpacer() } + val filter = viewModel.filter + if (filter != null) { + Box(modifier = Modifier.padding(16.dp)) { + FilterScreen.Filter(filterState = filter, router = viewModel.router, onDeleteClick = { viewModel.filter = null }) + } + } else { + CreateFilter(viewModel = viewModel) } + + SystemNavbarSpacer() } @Composable diff --git a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt index 01050b4..5bde4c2 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt @@ -21,10 +21,12 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Star import androidx.compose.material3.AssistChip import androidx.compose.material3.AssistChipDefaults +import androidx.compose.material3.ColorScheme import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.TextField +import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.mutableStateOf @@ -403,4 +405,8 @@ fun FABSpacer() { @Composable fun SystemNavbarSpacer() { Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars)) +} + +fun ColorScheme.surfaceEvaluated(evaluation: Dp = 3.dp): Color { + return this.surfaceColorAtElevation(evaluation) } \ No newline at end of file From 1adf8ac527a9cdb6cf0c55f63ab89c179b6e452f Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 03:38:17 +0200 Subject: [PATCH 13/24] Migrate filters --- .../cking/software/ui/filter/FilterScreen.kt | 64 +++++++------------ 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt b/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt index f9f1a9b..4cea624 100644 --- a/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt +++ b/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt @@ -14,20 +14,18 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Checkbox -import androidx.compose.material.Chip -import androidx.compose.material.ChipDefaults import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.Text -import androidx.compose.material.TextField import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Clear import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.List -import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Checkbox +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.SuggestionChip +import androidx.compose.material3.Text +import androidx.compose.material3.TextField import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -168,7 +166,6 @@ object FilterScreen { } } - @OptIn(ExperimentalMaterialApi::class) @Composable private fun FilterTag( filter: FilterUiState.Tag, @@ -186,16 +183,13 @@ object FilterScreen { val tag = filter.tag if (tag == null) { - Chip( - colors = ChipDefaults.chipColors( - backgroundColor = MaterialTheme.colorScheme.primary, - contentColor = Color.White, - ), + SuggestionChip( onClick = { addTagDialog.show() }, - leadingIcon = { + icon = { Icon(imageVector = Icons.Default.Add, contentDescription = null) - } - ) { Text(text = stringResource(R.string.select_tag)) } + }, + label = { Text(text = stringResource(R.string.select_tag)) } + ) } else { TagChip(tagName = tag, tagIcon = Icons.Filled.Delete) { filter.tag = null } } @@ -586,8 +580,8 @@ object FilterScreen { Checkbox( checked = filter.defaultValueIfNoLocation, onCheckedChange = { - filter.defaultValueIfNoLocation = it - }) + filter.defaultValueIfNoLocation = it + }) Spacer(modifier = Modifier.width(16.dp)) } } @@ -639,19 +633,13 @@ object FilterScreen { if (filter.filter != null) { Filter(filter.filter!!, router = router, onDeleteClick = filter::delete) } else { - Chip( + SuggestionChip( onClick = { selectFilterDialog.show() }, - colors = ChipDefaults.chipColors( - backgroundColor = colorResource(R.color.filter_not), - contentColor = Color.Black, - leadingIconContentColor = Color.Black - ), - leadingIcon = { + icon = { Icon(imageVector = Icons.Default.Add, contentDescription = stringResource(R.string.add_filter)) - } - ) { - Text(text = stringResource(R.string.select)) - } + }, + label = { Text(text = stringResource(R.string.select)) }, + ) } } } @@ -719,19 +707,13 @@ object FilterScreen { Column { content.invoke() Spacer(modifier = Modifier.height(4.dp)) - Chip( + SuggestionChip( onClick = addClick, - colors = ChipDefaults.chipColors( - backgroundColor = color, - contentColor = Color.Black, - leadingIconContentColor = Color.Black - ), - leadingIcon = { + icon = { Icon(imageVector = Icons.Default.Add, contentDescription = addText) - } - ) { - Text(text = addText) - } + }, + label = { Text(text = addText) }, + ) } } } From 08f854797ba593f56c326498dca55cc6477cc0f2 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 03:40:01 +0200 Subject: [PATCH 14/24] Migrate filters --- app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt | 1 - .../f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt b/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt index 4cea624..61d36e0 100644 --- a/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt +++ b/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt @@ -693,7 +693,6 @@ object FilterScreen { } } - @OptIn(ExperimentalMaterialApi::class) @Composable private fun FilterGroup( title: String, diff --git a/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt b/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt index a7d834c..f61dc17 100644 --- a/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profiledetails/ProfileDetailsScreen.kt @@ -245,7 +245,7 @@ object ProfileDetailsScreen { selectFilterDialog.show() }, content = { - Text(text = stringResource(R.string.add_filter)) + Text(text = stringResource(R.string.add_filter), color = MaterialTheme.colorScheme.onPrimary) } ) } From 93b953cfa6cb39b6b346a26bf998c9b940be0b1b Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 04:05:27 +0200 Subject: [PATCH 15/24] Fix device details --- .../ui/devicedetails/DeviceDetailsScreen.kt | 69 +++++++++---------- .../software/ui/filter/SelectFilterScreen.kt | 29 ++++++-- 2 files changed, 54 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt b/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt index f58c885..6f91012 100644 --- a/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt @@ -172,11 +172,11 @@ object DeviceDetailsScreen { deviceData = deviceData, viewModel = viewModel ) - Spacer(modifier = Modifier.height(8.dp)) + Spacer(modifier = Modifier.height(16.dp)) Tags(deviceData = deviceData, viewModel = viewModel) - Spacer(modifier = Modifier.height(8.dp)) - DeviceContent(modifier = Modifier.weight(1.5f), deviceData = deviceData) - Spacer(modifier = Modifier.height(8.dp)) + Spacer(modifier = Modifier.height(16.dp)) + DeviceContent(modifier = Modifier.weight(1f), deviceData = deviceData) + Spacer(modifier = Modifier.height(16.dp)) SystemNavbarSpacer() } } @@ -353,41 +353,35 @@ object DeviceDetailsScreen { } } } - - RoundedBox( - modifier = Modifier.fillMaxWidth(), - internalPaddings = 0.dp + Box( + modifier = Modifier + .fillMaxWidth() + .clickable { dialog.show() }, ) { - Box( + Row( modifier = Modifier .fillMaxWidth() - .clickable { dialog.show() }, + .padding(horizontal = 16.dp, vertical = 8.dp), + verticalAlignment = Alignment.CenterVertically, ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - Column(modifier = Modifier.weight(1f)) { - Row { - Text(text = stringResource(R.string.device_details_history_period), fontSize = 18.sp) - Text(text = stringResource(viewModel.historyPeriod.displayNameRes), fontWeight = FontWeight.Bold, fontSize = 18.sp) - } - Spacer(modifier = Modifier.height(4.dp)) - Text( - text = stringResource(R.string.device_details_history_period_subtitle), - fontWeight = FontWeight.Light, - ) + Column(modifier = Modifier.weight(1f)) { + Row { + Text(text = stringResource(R.string.device_details_history_period), fontSize = 18.sp) + Text(text = stringResource(viewModel.historyPeriod.displayNameRes), fontWeight = FontWeight.Bold, fontSize = 18.sp) } - Spacer(modifier = Modifier.width(8.dp)) - Image( - modifier = Modifier.size(24.dp), - imageVector = Icons.Default.Edit, - colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface), - contentDescription = stringResource(R.string.change) + Spacer(modifier = Modifier.height(4.dp)) + Text( + text = stringResource(R.string.device_details_history_period_subtitle), + fontWeight = FontWeight.Light, ) } + Spacer(modifier = Modifier.width(8.dp)) + Image( + modifier = Modifier.size(24.dp), + imageVector = Icons.Default.Edit, + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface), + contentDescription = stringResource(R.string.change) + ) } } } @@ -395,14 +389,16 @@ object DeviceDetailsScreen { @Composable private fun LocationHistory(modifier: Modifier = Modifier, deviceData: DeviceData, viewModel: DeviceDetailsViewModel) { RoundedBox(modifier = modifier, internalPaddings = 0.dp) { - Box(modifier = Modifier.fillMaxWidth()) { + Box(modifier = Modifier + .fillMaxWidth() + .weight(1f)) { Map( + Modifier.fillMaxSize(), viewModel = viewModel, isLoading = { viewModel.markersInLoadingState = it } ) MapOverlay(viewModel = viewModel) } - Spacer(modifier = Modifier.height(8.dp)) HistoryPeriod(deviceData = deviceData, viewModel = viewModel) } } @@ -446,6 +442,7 @@ object DeviceDetailsScreen { @Composable private fun Map( + modifier: Modifier, viewModel: DeviceDetailsViewModel, isLoading: (isLoading: Boolean) -> Unit, ) { @@ -486,9 +483,7 @@ object DeviceDetailsScreen { } MapView( - modifier = Modifier - .fillMaxWidth() - .fillMaxHeight(), + modifier = modifier, onLoad = { map -> initMapState(map) }, onUpdate = { map -> refreshMap(map, viewModel, batchProcessor) } ) diff --git a/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt b/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt index ced5215..d656f4a 100644 --- a/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt +++ b/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt @@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ExperimentalMaterial3Api @@ -19,8 +19,11 @@ import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp @@ -30,6 +33,7 @@ import f.cking.software.utils.graphic.SystemNavbarSpacer import f.cking.software.utils.navigation.BackCommand import f.cking.software.utils.navigation.Router +@OptIn(ExperimentalMaterial3Api::class) object SelectFilterScreen { @Composable @@ -38,12 +42,19 @@ object SelectFilterScreen { router: Router, onConfirm: (filterState: RadarProfile.Filter) -> Unit ) { + + val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() Scaffold( - topBar = { AppBar { router.navigate(BackCommand) } }, + topBar = { + AppBar(scrollBehavior) { router.navigate(BackCommand) } + }, content = { paddings -> - Column(modifier = Modifier - .background(MaterialTheme.colorScheme.surface) - .padding(paddings)) { + Column( + modifier = Modifier + .nestedScroll(scrollBehavior.nestedScrollConnection) + .background(MaterialTheme.colorScheme.surface) + .padding(paddings) + ) { LazyColumn( Modifier .fillMaxWidth() @@ -102,14 +113,18 @@ object SelectFilterScreen { @OptIn(ExperimentalMaterial3Api::class) @Composable - private fun AppBar(onBackClick: () -> Unit) { + private fun AppBar(scrollBehavior: TopAppBarScrollBehavior, onBackClick: () -> Unit) { TopAppBar( + scrollBehavior = scrollBehavior, + colors = TopAppBarDefaults.topAppBarColors( + scrolledContainerColor = MaterialTheme.colorScheme.surfaceContainerHighest, + ), title = { Text(text = stringResource(R.string.create_filter)) }, navigationIcon = { IconButton(onClick = onBackClick) { - Icon(imageVector = Icons.Filled.ArrowBack, contentDescription = stringResource(R.string.back)) + Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.back)) } } ) From f91f98374f0d9762b1edaafa000aa41b88552f50 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 04:14:13 +0200 Subject: [PATCH 16/24] Migrate select filter screen --- .../software/ui/filter/SelectFilterScreen.kt | 91 +++++++++---------- 1 file changed, 42 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt b/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt index d656f4a..f2dc5e8 100644 --- a/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt +++ b/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt @@ -4,19 +4,19 @@ import android.widget.Toast import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.Button -import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold -import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults @@ -29,6 +29,8 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import f.cking.software.R import f.cking.software.domain.model.RadarProfile +import f.cking.software.utils.graphic.BottomNavigationSpacer +import f.cking.software.utils.graphic.GlassBottomSpace import f.cking.software.utils.graphic.SystemNavbarSpacer import f.cking.software.utils.navigation.BackCommand import f.cking.software.utils.navigation.Router @@ -49,64 +51,55 @@ object SelectFilterScreen { AppBar(scrollBehavior) { router.navigate(BackCommand) } }, content = { paddings -> - Column( - modifier = Modifier - .nestedScroll(scrollBehavior.nestedScrollConnection) - .background(MaterialTheme.colorScheme.surface) - .padding(paddings) - ) { - LazyColumn( - Modifier - .fillMaxWidth() - .weight(1f) - ) { - item { - Box( - modifier = Modifier - .fillMaxWidth() - .padding(16.dp), - ) { - FilterScreen.Filter( - filterState = initialFilterState, - router = router, - onDeleteClick = { router.navigate(BackCommand) } - ) + GlassBottomSpace( + modifier = Modifier.fillMaxSize(), + bottomContent = { + val context = LocalContext.current + Button( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), + onClick = { + val filter = initialFilterState + .takeIf { it.isCorrect() } + ?.let { FilterUiMapper.mapToDomain(it) } + + if (filter != null) { + router.navigate(BackCommand) + onConfirm.invoke(filter) + } else { + Toast.makeText(context, context.getString(R.string.filter_is_not_valid), Toast.LENGTH_SHORT).show() + } } + ) { + Text(text = stringResource(R.string.confirm), color = MaterialTheme.colorScheme.onPrimary) } - } - Surface(shadowElevation = 12.dp) { + SystemNavbarSpacer() + }, + globalContent = { Column( modifier = Modifier - .background(MaterialTheme.colorScheme.primary) - .fillMaxWidth(), + .fillMaxSize() + .nestedScroll(scrollBehavior.nestedScrollConnection) + .verticalScroll(rememberScrollState()) + .background(MaterialTheme.colorScheme.surface) + .padding(top = paddings.calculateTopPadding()) ) { - val context = LocalContext.current - Button( + Box( modifier = Modifier - .fillMaxWidth() .padding(16.dp), - colors = ButtonDefaults.buttonColors(contentColor = MaterialTheme.colorScheme.primaryContainer), - onClick = { - val filter = initialFilterState - .takeIf { it.isCorrect() } - ?.let { FilterUiMapper.mapToDomain(it) } - - if (filter != null) { - router.navigate(BackCommand) - onConfirm.invoke(filter) - } else { - Toast.makeText(context, context.getString(R.string.filter_is_not_valid), Toast.LENGTH_SHORT).show() - } - } ) { - Text(text = stringResource(R.string.confirm), color = MaterialTheme.colorScheme.onPrimary) + FilterScreen.Filter( + filterState = initialFilterState, + router = router, + onDeleteClick = { router.navigate(BackCommand) } + ) } - - SystemNavbarSpacer() + BottomNavigationSpacer() } } - } + ) } ) } From d148cea66ff3ffbca041a4ffa2f90fd463716477 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 04:27:10 +0200 Subject: [PATCH 17/24] Migrate device selector --- .../ui/devicedetails/DeviceDetailsScreen.kt | 2 +- .../ui/selectdevice/SelectDeviceScreen.kt | 79 ++++++++++--------- .../ui/selectdevice/SelectDeviceViewModel.kt | 35 +++++++- 3 files changed, 76 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt b/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt index 6f91012..fbc6787 100644 --- a/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicedetails/DeviceDetailsScreen.kt @@ -434,7 +434,7 @@ object DeviceDetailsScreen { modifier = Modifier .fillMaxWidth() .height(5.dp), - color = Color.Black + color = MaterialTheme.colorScheme.onSurface ) } } diff --git a/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt b/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt index 0e861b4..ef6b432 100644 --- a/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt +++ b/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt @@ -2,22 +2,29 @@ package f.cking.software.ui.selectdevice import androidx.compose.foundation.background import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.Scaffold -import androidx.compose.material.Text -import androidx.compose.material.TextField -import androidx.compose.material.TopAppBar import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material3.Divider +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color +import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp import f.cking.software.R import f.cking.software.domain.model.DeviceData import f.cking.software.utils.graphic.DeviceListItem @@ -25,29 +32,20 @@ import f.cking.software.utils.graphic.GlassSystemNavbar import f.cking.software.utils.graphic.SystemNavbarSpacer import org.koin.androidx.compose.koinViewModel +@OptIn(ExperimentalMaterial3Api::class) object SelectDeviceScreen { - private val generalComparator = Comparator { second, first -> - when { - first.lastDetectTimeMs != second.lastDetectTimeMs -> first.lastDetectTimeMs.compareTo(second.lastDetectTimeMs) - first.name != second.name -> first.name?.compareTo(second.name ?: return@Comparator 1) ?: -1 - first.manufacturerInfo?.name != second.manufacturerInfo?.name -> - first.manufacturerInfo?.name?.compareTo(second.manufacturerInfo?.name ?: return@Comparator 1) ?: -1 - - else -> first.address.compareTo(second.address) - } - } - @Composable fun Screen( onSelected: (deviceData: DeviceData) -> Unit ) { val viewModel: SelectDeviceViewModel = koinViewModel() + val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() Scaffold( - topBar = { AppBar(viewModel) }, + topBar = { AppBar(viewModel, scrollBehavior) }, content = { paddings -> GlassSystemNavbar { - Content(Modifier.padding(paddings), viewModel, onSelected) + Content(Modifier.padding(paddings), viewModel, onSelected, scrollBehavior) } } ) @@ -57,26 +55,29 @@ object SelectDeviceScreen { private fun Content( modifier: Modifier, viewModel: SelectDeviceViewModel, - onSelected: (deviceData: DeviceData) -> Unit + onSelected: (deviceData: DeviceData) -> Unit, + scrollBehavior: TopAppBarScrollBehavior, ) { LazyColumn( - modifier = Modifier + modifier = modifier .background(MaterialTheme.colorScheme.surface) + .nestedScroll(scrollBehavior.nestedScrollConnection) .fillMaxSize() ) { - val list = viewModel.devices.asSequence() - .filter { device -> - viewModel.searchStr.takeIf { it.isNotBlank() }?.let { searchStr -> - (device.name?.contains(searchStr, true) ?: false) - || (device.customName?.contains(searchStr, true) ?: false) - || (device.manufacturerInfo?.name?.contains(searchStr, true) ?: false) - || device.address.contains(searchStr, true) - } ?: true + if (viewModel.loading) { + item { + LinearProgressIndicator( + modifier = Modifier + .fillMaxWidth() + .height(2.dp), + color = MaterialTheme.colorScheme.onSurface + ) } - .sortedWith(generalComparator) - .toList() + } + val list = viewModel.devices list.forEachIndexed { index, device -> + item { DeviceListItem(device = device) { onSelected.invoke(device) @@ -93,18 +94,20 @@ object SelectDeviceScreen { } @Composable - private fun AppBar(viewModel: SelectDeviceViewModel) { + private fun AppBar(viewModel: SelectDeviceViewModel, scrollBehavior: TopAppBarScrollBehavior) { TopAppBar( + scrollBehavior = scrollBehavior, title = { TextField( value = viewModel.searchStr, - onValueChange = { viewModel.searchStr = it }, - placeholder = { Text(text = stringResource(R.string.search), color = Color.White) } + maxLines = 1, + onValueChange = { viewModel.searchRequest(it) }, + placeholder = { Text(text = stringResource(R.string.search)) } ) }, navigationIcon = { IconButton(onClick = { viewModel.back() }) { - Icon(imageVector = Icons.Filled.ArrowBack, contentDescription = stringResource(R.string.back)) + Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.back)) } } ) diff --git a/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceViewModel.kt b/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceViewModel.kt index 2c84f61..cc40057 100644 --- a/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceViewModel.kt +++ b/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceViewModel.kt @@ -17,14 +17,47 @@ class SelectDeviceViewModel( ) : ViewModel() { var devices: List by mutableStateOf(emptyList()) + var loading by mutableStateOf(false) var searchStr: String by mutableStateOf("") + private val generalComparator = Comparator { second, first -> + when { + first.lastDetectTimeMs != second.lastDetectTimeMs -> first.lastDetectTimeMs.compareTo(second.lastDetectTimeMs) + first.name != second.name -> first.name?.compareTo(second.name ?: return@Comparator 1) ?: -1 + first.manufacturerInfo?.name != second.manufacturerInfo?.name -> + first.manufacturerInfo?.name?.compareTo(second.manufacturerInfo?.name ?: return@Comparator 1) ?: -1 + + else -> first.address.compareTo(second.address) + } + } + init { + refreshDevices() + } + + private fun refreshDevices() { viewModelScope.launch { - devices = devicesRepository.getDevices() + loading = true + devices = devicesRepository.getDevices().asSequence() + .filter { device -> + searchStr.takeIf { it.isNotBlank() }?.let { searchStr -> + (device.name?.contains(searchStr, true) ?: false) + || (device.customName?.contains(searchStr, true) ?: false) + || (device.manufacturerInfo?.name?.contains(searchStr, true) ?: false) + || device.address.contains(searchStr, true) + } ?: true + } + .sortedWith(generalComparator) + .toList() + loading = false } } + fun searchRequest(str: String) { + searchStr = str + refreshDevices() + } + fun back() { router.navigate(BackCommand) } From d2d1c4d3e55b8dbc29ef5abbd5f19580bf5c3aef Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 04:35:33 +0200 Subject: [PATCH 18/24] Migrate SelectLocationScreen --- .../ui/selectlocation/SelectLocationScreen.kt | 146 +++++++++--------- 1 file changed, 69 insertions(+), 77 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/selectlocation/SelectLocationScreen.kt b/app/src/main/java/f/cking/software/ui/selectlocation/SelectLocationScreen.kt index c8ab324..b288ec6 100644 --- a/app/src/main/java/f/cking/software/ui/selectlocation/SelectLocationScreen.kt +++ b/app/src/main/java/f/cking/software/ui/selectlocation/SelectLocationScreen.kt @@ -5,7 +5,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -15,15 +15,12 @@ import androidx.compose.foundation.shape.AbsoluteCutCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material3.Button -import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Slider -import androidx.compose.material3.SliderDefaults -import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable @@ -47,6 +44,7 @@ import f.cking.software.data.helpers.LocationProvider import f.cking.software.domain.model.LocationModel import f.cking.software.ui.devicedetails.MapConfig import f.cking.software.utils.graphic.MapView +import f.cking.software.utils.graphic.RoundedBox import f.cking.software.utils.graphic.SystemNavbarSpacer import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.take @@ -68,14 +66,13 @@ object SelectLocationScreen { Scaffold( modifier = Modifier .background(MaterialTheme.colorScheme.surface) - .fillMaxWidth() - .fillMaxHeight(), + .fillMaxSize(), topBar = { AppBar(onCloseClick) }, content = { paddings -> Content( modifier = Modifier .background(MaterialTheme.colorScheme.surface) - .padding(paddings), + .padding(top = paddings.calculateTopPadding()), onSelected = onSelected, initialLocationModel = initialLocationModel, initialRadius = initialRadius @@ -109,49 +106,49 @@ object SelectLocationScreen { Column( modifier = modifier - .fillMaxHeight() - .fillMaxWidth() + .padding(horizontal = 16.dp) + .fillMaxSize() ) { - Box( + RoundedBox( modifier = Modifier .fillMaxWidth() .weight(1f), - contentAlignment = Alignment.Center, + internalPaddings = 0.dp, ) { - Map( - modifier = Modifier - .fillMaxWidth() - .fillMaxHeight(), - initialLocationModel = initialLocationModel, - onMapReady = { map.value = it } - ) - Box( - modifier = Modifier - .size(width = 20.dp, height = 10.dp) - .blur(2.dp), - contentAlignment = Alignment.Center, - ) { + Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Map( + modifier = Modifier.fillMaxSize(), + initialLocationModel = initialLocationModel, + onMapReady = { map.value = it } + ) Box( modifier = Modifier - .size(width = 10.dp, height = 5.dp) - .background(color = Color.DarkGray, shape = AbsoluteCutCornerShape(10.dp)) - ) - } - Column( - modifier = Modifier - .height(120.dp) - .width(60.dp) - ) { - val painter = painterResource(R.drawable.ic_location) - Image( + .size(width = 20.dp, height = 10.dp) + .blur(2.dp), + contentAlignment = Alignment.Center, + ) { + Box( + modifier = Modifier + .size(width = 10.dp, height = 5.dp) + .background(color = Color.DarkGray, shape = AbsoluteCutCornerShape(10.dp)) + ) + } + Column( modifier = Modifier - .fillMaxWidth() - .height(60.dp), - contentScale = ContentScale.FillWidth, - painter = painter, - contentDescription = null, - colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.secondary) - ) + .height(120.dp) + .width(60.dp) + ) { + val painter = painterResource(R.drawable.ic_location) + Image( + modifier = Modifier + .fillMaxWidth() + .height(60.dp), + contentScale = ContentScale.FillWidth, + painter = painter, + contentDescription = null, + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.primary) + ) + } } } BottomPanel(map.value, initialRadius, onSelected) @@ -166,46 +163,41 @@ object SelectLocationScreen { ) { val radiusMeters = remember { mutableStateOf(initialRadius ?: TheAppConfig.DEFAULT_LOCATION_FILTER_RADIUS) } - Surface(shadowElevation = 12.dp) { - Column( + Column( + modifier = Modifier + .fillMaxWidth(), + ) { + Spacer(modifier = Modifier.height(16.dp)) + Text( + modifier = Modifier.padding(horizontal = 16.dp), + text = stringResource(R.string.select_location_radius, radiusMeters.value), + fontWeight = FontWeight.SemiBold, + fontSize = 16.sp + ) + Slider( modifier = Modifier - .background(MaterialTheme.colorScheme.primary) .fillMaxWidth(), - ) { - Spacer(modifier = Modifier.height(16.dp)) - Text(modifier = Modifier.padding(horizontal = 16.dp), text = stringResource(R.string.select_location_radius, radiusMeters.value), fontWeight = FontWeight.SemiBold, fontSize = 16.sp) - Slider( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp), - value = radiusMeters.value, - onValueChange = { value -> radiusMeters.value = value }, - valueRange = 5f..1000f, - colors = SliderDefaults.colors( - thumbColor = MaterialTheme.colorScheme.secondary, - activeTrackColor = MaterialTheme.colorScheme.secondary, + value = radiusMeters.value, + onValueChange = { value -> radiusMeters.value = value }, + valueRange = 5f..1000f, + ) + Spacer(modifier = Modifier.height(16.dp)) + Button( + modifier = Modifier + .fillMaxWidth(), + enabled = map != null, + onClick = { + val cameraCenter = map!!.mapCenter + onSelected.invoke( + LocationModel(cameraCenter.latitude, cameraCenter.longitude, System.currentTimeMillis()), + radiusMeters.value ) - ) - Spacer(modifier = Modifier.height(16.dp)) - Button( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp), - colors = ButtonDefaults.buttonColors(contentColor = MaterialTheme.colorScheme.primaryContainer), - enabled = map != null, - onClick = { - val cameraCenter = map!!.mapCenter - onSelected.invoke( - LocationModel(cameraCenter.latitude, cameraCenter.longitude, System.currentTimeMillis()), - radiusMeters.value - ) - } - ) { - Text(text = stringResource(R.string.confirm), color = MaterialTheme.colorScheme.onPrimary) } - Spacer(modifier = Modifier.height(16.dp)) - SystemNavbarSpacer() + ) { + Text(text = stringResource(R.string.confirm), color = MaterialTheme.colorScheme.onPrimary) } + Spacer(modifier = Modifier.height(16.dp)) + SystemNavbarSpacer() } } From 31f891f5c25c737e774c1787f202a71a0b14d137 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 04:43:00 +0200 Subject: [PATCH 19/24] Migrate Manufacturers screen --- .../software/ui/filter/SelectFilterScreen.kt | 2 +- .../ui/selectdevice/SelectDeviceScreen.kt | 8 ++++--- .../SelectManufacturerScreen.kt | 23 +++++++++++++------ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt b/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt index f2dc5e8..7b967e7 100644 --- a/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt +++ b/app/src/main/java/f/cking/software/ui/filter/SelectFilterScreen.kt @@ -47,6 +47,7 @@ object SelectFilterScreen { val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() Scaffold( + modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), topBar = { AppBar(scrollBehavior) { router.navigate(BackCommand) } }, @@ -81,7 +82,6 @@ object SelectFilterScreen { Column( modifier = Modifier .fillMaxSize() - .nestedScroll(scrollBehavior.nestedScrollConnection) .verticalScroll(rememberScrollState()) .background(MaterialTheme.colorScheme.surface) .padding(top = paddings.calculateTopPadding()) diff --git a/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt b/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt index ef6b432..60342e0 100644 --- a/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt +++ b/app/src/main/java/f/cking/software/ui/selectdevice/SelectDeviceScreen.kt @@ -42,10 +42,11 @@ object SelectDeviceScreen { val viewModel: SelectDeviceViewModel = koinViewModel() val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() Scaffold( + modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), topBar = { AppBar(viewModel, scrollBehavior) }, content = { paddings -> GlassSystemNavbar { - Content(Modifier.padding(paddings), viewModel, onSelected, scrollBehavior) + Content(Modifier.padding(paddings), viewModel, onSelected) } } ) @@ -56,12 +57,10 @@ object SelectDeviceScreen { modifier: Modifier, viewModel: SelectDeviceViewModel, onSelected: (deviceData: DeviceData) -> Unit, - scrollBehavior: TopAppBarScrollBehavior, ) { LazyColumn( modifier = modifier .background(MaterialTheme.colorScheme.surface) - .nestedScroll(scrollBehavior.nestedScrollConnection) .fillMaxSize() ) { if (viewModel.loading) { @@ -97,6 +96,9 @@ object SelectDeviceScreen { private fun AppBar(viewModel: SelectDeviceViewModel, scrollBehavior: TopAppBarScrollBehavior) { TopAppBar( scrollBehavior = scrollBehavior, + colors = TopAppBarDefaults.topAppBarColors( + scrolledContainerColor = MaterialTheme.colorScheme.surfaceContainerHighest, + ), title = { TextField( value = viewModel.searchStr, diff --git a/app/src/main/java/f/cking/software/ui/selectmanufacturer/SelectManufacturerScreen.kt b/app/src/main/java/f/cking/software/ui/selectmanufacturer/SelectManufacturerScreen.kt index 610617a..31b9bc4 100644 --- a/app/src/main/java/f/cking/software/ui/selectmanufacturer/SelectManufacturerScreen.kt +++ b/app/src/main/java/f/cking/software/ui/selectmanufacturer/SelectManufacturerScreen.kt @@ -3,11 +3,12 @@ package f.cking.software.ui.selectmanufacturer import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -15,8 +16,11 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.TopAppBarScrollBehavior import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -27,6 +31,7 @@ import f.cking.software.utils.graphic.GlassSystemNavbar import f.cking.software.utils.graphic.SystemNavbarSpacer import org.koin.androidx.compose.koinViewModel +@OptIn(ExperimentalMaterial3Api::class) object SelectManufacturerScreen { @Composable @@ -34,12 +39,13 @@ object SelectManufacturerScreen { onSelected: (type: ManufacturerInfo) -> Unit ) { val viewModel: SelectManufacturerViewModel = koinViewModel() + val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior() Scaffold( modifier = Modifier + .nestedScroll(scrollBehavior.nestedScrollConnection) .background(MaterialTheme.colorScheme.surface) - .fillMaxWidth() - .fillMaxWidth(), - topBar = { AppBar(viewModel) }, + .fillMaxSize(), + topBar = { AppBar(viewModel, scrollBehavior) }, content = { paddings -> GlassSystemNavbar { LazyColumn(modifier = Modifier @@ -60,16 +66,19 @@ object SelectManufacturerScreen { ) } - @OptIn(ExperimentalMaterial3Api::class) @Composable - private fun AppBar(viewModel: SelectManufacturerViewModel) { + private fun AppBar(viewModel: SelectManufacturerViewModel, scrollBehavior: TopAppBarScrollBehavior) { TopAppBar( + scrollBehavior = scrollBehavior, + colors = TopAppBarDefaults.topAppBarColors( + scrolledContainerColor = MaterialTheme.colorScheme.surfaceContainerHighest, + ), title = { Text(text = stringResource(R.string.select_manufacturer)) }, navigationIcon = { IconButton(onClick = { viewModel.back() }) { - Icon(imageVector = Icons.Filled.ArrowBack, contentDescription = stringResource(R.string.back)) + Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.back)) } } ) From 0e9bd2d423ebb2edab17afc19ede4118ce4a3d43 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 05:11:18 +0200 Subject: [PATCH 20/24] Update local theme colors --- .../java/f/cking/software/ui/MainActivity.kt | 120 +++++++++++++----- app/src/main/res/values-night/themes.xml | 41 ++++-- app/src/main/res/values/colors.xml | 89 +++++++++---- app/src/main/res/values/themes.xml | 41 ++++-- 4 files changed, 206 insertions(+), 85 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/MainActivity.kt b/app/src/main/java/f/cking/software/ui/MainActivity.kt index e487a62..7106418 100644 --- a/app/src/main/java/f/cking/software/ui/MainActivity.kt +++ b/app/src/main/java/f/cking/software/ui/MainActivity.kt @@ -11,11 +11,14 @@ import androidx.activity.enableEdgeToEdge import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.ColorScheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Typography import androidx.compose.material3.darkColorScheme import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.colorResource import androidx.lifecycle.ViewModel @@ -63,41 +66,7 @@ class MainActivity : AppCompatActivity() { setContent { val focusManager = LocalFocusManager.current - val dynamicColorsAreSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S - val darkMode = isSystemInDarkTheme() - val colors = when { - dynamicColorsAreSupported && darkMode -> dynamicDarkColorScheme(this) - dynamicColorsAreSupported && !darkMode -> dynamicLightColorScheme(this) - darkMode -> darkColorScheme( - primary = colorResource(id = R.color.theme_dark_primary), - primaryContainer = colorResource(id = R.color.theme_dark_primary_variant), - onPrimary = colorResource(id = R.color.theme_dark_on_primary), - surface = colorResource(id = R.color.theme_dark_surface_color), - surfaceVariant = colorResource(id = R.color.theme_dark_primary_variant), - surfaceContainer = colorResource(id = R.color.theme_light_primary_surface), - onSurface = colorResource(id = R.color.theme_dark_on_surface), - secondary = colorResource(id = R.color.theme_dark_secondary), - secondaryContainer = colorResource(id = R.color.theme_dark_secondary_variant), - onSecondary = colorResource(id = R.color.theme_dark_on_secondary), - error = colorResource(id = R.color.theme_dark_error), - onError = colorResource(id = R.color.theme_dark_on_error), - ) - !darkMode -> darkColorScheme( - primary = colorResource(id = R.color.theme_light_primary), - primaryContainer = colorResource(id = R.color.theme_light_primary_variant), - onPrimary = colorResource(id = R.color.theme_light_on_primary), - surface = colorResource(id = R.color.theme_light_surface_color), - surfaceVariant = colorResource(id = R.color.theme_light_primary_variant), - surfaceContainer = colorResource(id = R.color.theme_dark_primary_surface), - onSurface = colorResource(id = R.color.theme_light_on_surface), - secondary = colorResource(id = R.color.theme_light_secondary), - secondaryContainer = colorResource(id = R.color.theme_light_secondary_variant), - onSecondary = colorResource(id = R.color.theme_light_on_secondary), - error = colorResource(id = R.color.theme_light_error), - onError = colorResource(id = R.color.theme_light_on_error), - ) - else -> throw IllegalStateException("This state is unreachable") - } + val colors = themeColorScheme() MaterialTheme( colorScheme = colors, typography = Typography( @@ -132,6 +101,7 @@ class MainActivity : AppCompatActivity() { @Deprecated("Deprecated in Java") override fun onBackPressed() { + super.onBackPressed() router.navigate(BackCommand) } @@ -144,4 +114,84 @@ class MainActivity : AppCompatActivity() { private class MainActivityViewModel : ViewModel() { val navigator: Navigator = Navigator(root = ScreenNavigationCommands.OpenMainScreen) } + + @Composable + private fun themeColorScheme(): ColorScheme { + val dynamicColorsAreSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S + val darkMode = isSystemInDarkTheme() + val colors = when { + dynamicColorsAreSupported && darkMode -> dynamicDarkColorScheme(this) + dynamicColorsAreSupported && !darkMode -> dynamicLightColorScheme(this) + darkMode -> darkColorScheme( + primary = colorResource(id = R.color.md_theme_dark_primary), + onPrimary = colorResource(id = R.color.md_theme_dark_onPrimary), + primaryContainer = colorResource(id = R.color.md_theme_dark_primaryContainer), + onPrimaryContainer = colorResource(id = R.color.md_theme_dark_onPrimaryContainer), + secondary = colorResource(id = R.color.md_theme_dark_secondary), + onSecondary = colorResource(id = R.color.md_theme_dark_onSecondary), + secondaryContainer = colorResource(id = R.color.md_theme_dark_secondaryContainer), + onSecondaryContainer = colorResource(id = R.color.md_theme_dark_onSecondaryContainer), + tertiary = colorResource(id = R.color.md_theme_dark_tertiary), + onTertiary = colorResource(id = R.color.md_theme_dark_onTertiary), + tertiaryContainer = colorResource(id = R.color.md_theme_dark_tertiaryContainer), + onTertiaryContainer = colorResource(id = R.color.md_theme_dark_onTertiaryContainer), + error = colorResource(id = R.color.md_theme_dark_error), + errorContainer = colorResource(id = R.color.md_theme_dark_errorContainer), + onError = colorResource(id = R.color.md_theme_dark_onError), + onErrorContainer = colorResource(id = R.color.md_theme_dark_onErrorContainer), + background = colorResource(id = R.color.md_theme_dark_background), + onBackground = colorResource(id = R.color.md_theme_dark_onBackground), + surface = colorResource(id = R.color.md_theme_dark_surface), + surfaceContainer = colorResource(id = R.color.md_theme_dark_surfaceContainer), + surfaceContainerHigh = colorResource(id = R.color.md_theme_dark_surfaceContainerHigh), + surfaceContainerHighest = colorResource(id = R.color.md_theme_dark_surfaceContainerHighest), + onSurface = colorResource(id = R.color.md_theme_dark_onSurface), + surfaceVariant = colorResource(id = R.color.md_theme_dark_surfaceVariant), + onSurfaceVariant = colorResource(id = R.color.md_theme_dark_onSurfaceVariant), + outline = colorResource(id = R.color.md_theme_dark_outline), + inverseOnSurface = colorResource(id = R.color.md_theme_dark_inverseOnSurface), + inverseSurface = colorResource(id = R.color.md_theme_dark_inverseSurface), + inversePrimary = colorResource(id = R.color.md_theme_dark_inversePrimary), + surfaceTint = colorResource(id = R.color.md_theme_dark_surfaceTint), + outlineVariant = colorResource(id = R.color.md_theme_dark_outlineVariant), + scrim = colorResource(id = R.color.md_theme_dark_scrim), + ) + !darkMode -> lightColorScheme( + primary = colorResource(id = R.color.md_theme_light_primary), + onPrimary = colorResource(id = R.color.md_theme_light_onPrimary), + primaryContainer = colorResource(id = R.color.md_theme_light_primaryContainer), + onPrimaryContainer = colorResource(id = R.color.md_theme_light_onPrimaryContainer), + secondary = colorResource(id = R.color.md_theme_light_secondary), + onSecondary = colorResource(id = R.color.md_theme_light_onSecondary), + secondaryContainer = colorResource(id = R.color.md_theme_light_secondaryContainer), + onSecondaryContainer = colorResource(id = R.color.md_theme_light_onSecondaryContainer), + tertiary = colorResource(id = R.color.md_theme_light_tertiary), + onTertiary = colorResource(id = R.color.md_theme_light_onTertiary), + tertiaryContainer = colorResource(id = R.color.md_theme_light_tertiaryContainer), + onTertiaryContainer = colorResource(id = R.color.md_theme_light_onTertiaryContainer), + error = colorResource(id = R.color.md_theme_light_error), + errorContainer = colorResource(id = R.color.md_theme_light_errorContainer), + onError = colorResource(id = R.color.md_theme_light_onError), + onErrorContainer = colorResource(id = R.color.md_theme_light_onErrorContainer), + background = colorResource(id = R.color.md_theme_light_background), + onBackground = colorResource(id = R.color.md_theme_light_onBackground), + surface = colorResource(id = R.color.md_theme_light_surface), + surfaceContainer = colorResource(id = R.color.md_theme_light_surfaceContainer), + surfaceContainerHigh = colorResource(id = R.color.md_theme_light_surfaceContainerHigh), + surfaceContainerHighest = colorResource(id = R.color.md_theme_light_surfaceContainerHighest), + onSurface = colorResource(id = R.color.md_theme_light_onSurface), + surfaceVariant = colorResource(id = R.color.md_theme_light_surfaceVariant), + onSurfaceVariant = colorResource(id = R.color.md_theme_light_onSurfaceVariant), + outline = colorResource(id = R.color.md_theme_light_outline), + inverseOnSurface = colorResource(id = R.color.md_theme_light_inverseOnSurface), + inverseSurface = colorResource(id = R.color.md_theme_light_inverseSurface), + inversePrimary = colorResource(id = R.color.md_theme_light_inversePrimary), + surfaceTint = colorResource(id = R.color.md_theme_light_surfaceTint), + outlineVariant = colorResource(id = R.color.md_theme_light_outlineVariant), + scrim = colorResource(id = R.color.md_theme_light_scrim), + ) + else -> throw IllegalStateException("This state is unreachable") + } + return colors + } } diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index ef6ead2..ce054e5 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -2,19 +2,32 @@ \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index f6b82a5..4d1b877 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -15,29 +15,74 @@ #E64A19 #D84315 - #FDF7E9 - @color/black_90 - #FFF1CF - #F8EED7 - #F1DEAD - @color/black_90 - #F57C00 - @color/theme_light_secondary - @color/white - #B71C1C - @color/white_90 + #ff9b4b + #944B00 + #FFFFFF + #FFDCC5 + #301400 + #8D4F00 + #FFFFFF + #FFDCC0 + #2D1600 + #5D6300 + #FFFFFF + #E2EA74 + #1B1D00 + #BA1A1A + #FFDAD6 + #FFFFFF + #410002 + #FFFBFF + #201A17 + #FFFFF3E7 + #F6E3D0 + #F3D4B5 + #EFCFAF + #201A17 + #E4D0BC + #52443B + #84746A + #FBEEE8 + #362F2B + #FFB783 + #000000 + #944B00 + #D6C3B7 + #000000 - #464237 - @color/white_90 - #6B5B39 - #685F45 - #7F7150 - @color/white_90 - #A95C0E - @color/theme_dark_secondary - @color/white_90 - #9B5C5C - @color/white_90 + #FFB783 + #4F2500 + #703700 + #FFDCC5 + #FFB876 + #4B2700 + #6B3B00 + #FFDCC0 + #C5CE5C + #303300 + #464A00 + #E2EA74 + #FFB4AB + #93000A + #690005 + #FFDAD6 + #201A17 + #ECE0DA + #201D17 + #574C39 + #706147 + #8C7C61 + #ECE0DA + #52443B + #D6C3B7 + #9F8D83 + #201A17 + #ECE0DA + #944B00 + #000000 + #FFB783 + #52443B + #000000 #80DEEA #A5D6A7 diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index a6b78c1..ae843b8 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -2,19 +2,32 @@ \ No newline at end of file From a4a038b2652beed83113436f1d30fa405bbaa1c7 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 05:14:50 +0200 Subject: [PATCH 21/24] Update local theme colors --- app/src/main/java/f/cking/software/ui/MainActivity.kt | 3 ++- app/src/main/res/values/colors.xml | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/MainActivity.kt b/app/src/main/java/f/cking/software/ui/MainActivity.kt index 7106418..52c4a60 100644 --- a/app/src/main/java/f/cking/software/ui/MainActivity.kt +++ b/app/src/main/java/f/cking/software/ui/MainActivity.kt @@ -1,5 +1,6 @@ package f.cking.software.ui +import android.annotation.SuppressLint import android.content.Intent import android.content.SharedPreferences import android.graphics.Color @@ -99,9 +100,9 @@ class MainActivity : AppCompatActivity() { intentHelper.handleActivityResult(requestCode, resultCode, data) } + @SuppressLint("MissingSuperCall") @Deprecated("Deprecated in Java") override fun onBackPressed() { - super.onBackPressed() router.navigate(BackCommand) } diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4d1b877..489d2f4 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -69,9 +69,9 @@ #201A17 #ECE0DA #201D17 - #574C39 - #706147 - #8C7C61 + #50422C + #554833 + #635640 #ECE0DA #52443B #D6C3B7 From df4f29058039268a1746cb26a6fda0c2499d4b55 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 05:26:14 +0200 Subject: [PATCH 22/24] Update tags colors --- .../cking/software/ui/filter/FilterScreen.kt | 9 +++---- .../utils/graphic/ComposeFunctions.kt | 27 +++++++++++++++++-- app/src/main/res/values-night/colors.xml | 21 +++++++++++++++ 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/values-night/colors.xml diff --git a/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt b/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt index 61d36e0..3482fba 100644 --- a/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt +++ b/app/src/main/java/f/cking/software/ui/filter/FilterScreen.kt @@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Clear @@ -23,6 +22,7 @@ import androidx.compose.material.icons.filled.List import androidx.compose.material3.Checkbox import androidx.compose.material3.Icon import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SuggestionChip import androidx.compose.material3.Text import androidx.compose.material3.TextField @@ -613,7 +613,6 @@ object FilterScreen { } } - @OptIn(ExperimentalMaterialApi::class) @Composable private fun FilterNot( filter: FilterUiState.Not, @@ -661,13 +660,13 @@ object FilterScreen { ) { Box(Modifier.clickable { minimize.value = !minimize.value }) { Row(Modifier.padding(8.dp), verticalAlignment = Alignment.CenterVertically) { - Text(text = title, fontSize = 20.sp, fontWeight = FontWeight.Bold, color = Color.Black) + Text(text = title, fontSize = 20.sp, fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.onSurface) val icon = if (!minimize.value) painterResource(R.drawable.ic_drop_down) else painterResource(R.drawable.ic_drop_up) Icon( painter = icon, contentDescription = stringResource(R.string.delete), modifier = Modifier.size(24.dp), - tint = Color.Black, + tint = MaterialTheme.colorScheme.onSurface, ) Spacer(Modifier.weight(1f)) IconButton(onClick = onDeleteButtonClick) { @@ -675,7 +674,7 @@ object FilterScreen { imageVector = Icons.Filled.Delete, contentDescription = stringResource(R.string.delete), modifier = Modifier.size(24.dp), - tint = Color.Black, + tint = MaterialTheme.colorScheme.onSurface, ) } } diff --git a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt index 5bde4c2..d6c2a3b 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt @@ -2,6 +2,7 @@ package f.cking.software.utils.graphic import androidx.compose.foundation.background import androidx.compose.foundation.clickable +import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope @@ -330,7 +331,7 @@ fun RoundedBox( } } -private val colors = listOf( +private val colorsLight = listOf( Color(0xFFE57373), Color(0xFFF06292), Color(0xFFBA68C8), @@ -350,7 +351,29 @@ private val colors = listOf( Color(0xFF90A4AE), ) +private val colorsDark = listOf( + Color(0xFF813535), + Color(0xFF742A43), + Color(0xFF5E2F66), + Color(0xFF443066), + Color(0xFF363E69), + Color(0xFF2F5574), + Color(0xFF275A70), + Color(0xFF2D6A72), + Color(0xFF235E58), + Color(0xFF457047), + Color(0xFF546D37), + Color(0xFF885241), + Color(0xFF6A7030), + Color(0xFF776426), + Color(0xFF7C643F), + Color(0xFF7A5446), + Color(0xFF3D545F), +) + +@Composable fun colorByHash(hash: Int): Color { + val colors = if (isSystemInDarkTheme()) colorsDark else colorsLight return colors[abs(hash % colors.size)] } @@ -370,7 +393,7 @@ fun TagChip( onClick = onClick, leadingIcon = { tagIcon?.let { Icon(imageVector = it, contentDescription = null, tint = MaterialTheme.colorScheme.onSurface) } }, label = { - Text(text = tagName) + Text(text = tagName, color = MaterialTheme.colorScheme.onSurface) } ) } diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml new file mode 100644 index 0000000..8d79a03 --- /dev/null +++ b/app/src/main/res/values-night/colors.xml @@ -0,0 +1,21 @@ + + + #006064 + #004D40 + #371165 + #CD5C04 + #815244 + #8F576A + #56958F + #C17D7D + #4E718E + #C19D68 + #7E8541 + #7D4E85 + #616161 + #9F5E5E + #875647 + #575C27 + #376561 + #0000 + \ No newline at end of file From 9c1d8ddc1ce86042e0626998dae5cdf1c40f1721 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 05:26:44 +0200 Subject: [PATCH 23/24] Update app version --- app/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 35be381..6a94983 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -24,7 +24,7 @@ android { minSdk = 29 targetSdk = 34 versionCode = (System.currentTimeMillis() / 1000).toInt() - versionName = "0.20.3-beta" + versionName = "0.21.0-beta" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" From a67b2af13a46c0742a19f0623df2c8cc334b6386 Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Sat, 23 Dec 2023 05:39:23 +0200 Subject: [PATCH 24/24] Add loading state for the journal --- .../ui/devicelist/DeviceListScreen.kt | 14 +++---- .../software/ui/journal/JournalScreen.kt | 37 +++++++++++++------ .../software/ui/journal/JournalViewModel.kt | 5 +++ .../ui/profileslist/ProfilesListScreen.kt | 9 ++++- .../utils/graphic/ComposeFunctions.kt | 2 +- 5 files changed, 47 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt index 4dda408..9953c8f 100644 --- a/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/devicelist/DeviceListScreen.kt @@ -201,7 +201,12 @@ object DeviceListScreen { ) { val allFilters = (viewModel.quickFilters + viewModel.appliedFilter).toSet() - item { Spacer(modifier = Modifier.width(8.dp)) } + item { Spacer(modifier = Modifier.width(16.dp)) } + + item { + SearchChip(viewModel) + Spacer(modifier = Modifier.width(8.dp)) + } allFilters.forEach { item { @@ -227,14 +232,9 @@ object DeviceListScreen { } } - item { - SearchChip(viewModel) - Spacer(modifier = Modifier.width(8.dp)) - } - item { AddFilterChip(viewModel) - Spacer(modifier = Modifier.width(8.dp)) + Spacer(modifier = Modifier.width(16.dp)) } } diff --git a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt index 185c2c5..a297acc 100644 --- a/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt +++ b/app/src/main/java/f/cking/software/ui/journal/JournalScreen.kt @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SuggestionChip import androidx.compose.material3.Text @@ -38,19 +39,33 @@ object JournalScreen { fun Screen() { val viewModel: JournalViewModel = koinViewModel() val journal = viewModel.journal - val modifier = Modifier.background(MaterialTheme.colorScheme.surface) + val modifier = Modifier + .background(MaterialTheme.colorScheme.surface) .fillMaxSize() - if (journal.isEmpty()) { - ContentPlaceholder(text = stringResource(R.string.journal_placeholder), modifier = modifier) - } else { - LazyColumn( - modifier = modifier - ) { - journal.map { - item { JournalEntry(uiModel = it, viewModel) } - item { Divider() } + Box(modifier = modifier) { + if (journal.isEmpty()) { + ContentPlaceholder( + modifier = Modifier.fillMaxSize(), + text = stringResource(R.string.journal_placeholder) + ) + } else { + LazyColumn( + modifier = Modifier.fillMaxSize(), + ) { + journal.map { + item { JournalEntry(uiModel = it, viewModel) } + item { Divider() } + } + item { FABSpacer() } } - item { FABSpacer() } + } + if (viewModel.loading) { + LinearProgressIndicator( + modifier = Modifier + .fillMaxWidth() + .height(4.dp), + color = MaterialTheme.colorScheme.onSurface + ) } } } diff --git a/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt b/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt index 432b43a..efa829d 100644 --- a/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt +++ b/app/src/main/java/f/cking/software/ui/journal/JournalViewModel.kt @@ -18,6 +18,7 @@ import f.cking.software.dateTimeStringFormat import f.cking.software.domain.model.JournalEntry import f.cking.software.ui.ScreenNavigationCommands import f.cking.software.utils.navigation.Router +import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.launch import kotlin.math.min @@ -30,6 +31,7 @@ class JournalViewModel( ) : ViewModel() { var journal: List by mutableStateOf(emptyList()) + var loading by mutableStateOf(true) init { observeJournal() @@ -50,8 +52,11 @@ class JournalViewModel( private fun observeJournal() { viewModelScope.launch { journalRepository.observe() + .onStart { loading = true } .collect { update -> + loading = true journal = update.sortedBy { it.timestamp }.reversed().map { map(it) } + loading = false } } } diff --git a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt index b7e0cae..7228588 100644 --- a/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt +++ b/app/src/main/java/f/cking/software/ui/profileslist/ProfilesListScreen.kt @@ -20,6 +20,7 @@ import androidx.compose.material.icons.filled.Add import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SuggestionChip +import androidx.compose.material3.SuggestionChipDefaults import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -79,10 +80,15 @@ object ProfilesListScreen { .background(MaterialTheme.colorScheme.surfaceContainerHighest) .padding(vertical = 8.dp), ) { + item { Spacer(modifier = Modifier.width(16.dp)) } item { - Spacer(modifier = Modifier.width(8.dp)) SuggestionChip( onClick = { viewModel.createNewClick() }, + colors = SuggestionChipDefaults.suggestionChipColors( + containerColor = MaterialTheme.colorScheme.primaryContainer, + iconContentColor = MaterialTheme.colorScheme.onPrimaryContainer, + labelColor = MaterialTheme.colorScheme.onPrimaryContainer, + ), icon = { Icon(imageVector = Icons.Default.Add, contentDescription = null) }, @@ -97,6 +103,7 @@ object ProfilesListScreen { Spacer(modifier = Modifier.width(8.dp)) } } + item { Spacer(modifier = Modifier.width(8.dp)) } } } } diff --git a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt index d6c2a3b..19bd1f0 100644 --- a/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt +++ b/app/src/main/java/f/cking/software/utils/graphic/ComposeFunctions.kt @@ -283,7 +283,7 @@ fun Divider() { modifier = Modifier .height(1.dp) .fillMaxWidth() - .background(Color.LightGray) + .background(MaterialTheme.colorScheme.onSurface.copy(alpha = 0.2f)) ) } }