diff --git a/.gitignore b/.gitignore index eb37f40..b863030 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ .cxx local.properties .idea/jarRepositories.xml +*.klib diff --git a/android/build.gradle.kts b/android/build.gradle.kts index dbb57f8..a860043 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -1,18 +1,20 @@ plugins { id("org.jetbrains.compose") + id("org.jetbrains.kotlin.plugin.compose") id("com.android.application") kotlin("android") } dependencies { implementation(project(":reorderable")) - implementation("androidx.compose.runtime:runtime:1.3.3") - implementation("androidx.compose.material:material:1.3.1") - implementation("androidx.activity:activity-compose:1.6.1") - implementation("com.google.android.material:material:1.8.0") - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1") - implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1") - implementation("androidx.navigation:navigation-compose:2.5.3") + implementation("androidx.compose.runtime:runtime:1.8.1") + implementation("androidx.compose.material3:material3:1.3.2") + implementation("androidx.activity:activity-compose:1.10.1") + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.0") + implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.9.0") + implementation("androidx.navigation:navigation-compose:2.9.0") + implementation("androidx.appcompat:appcompat:1.7.0") + implementation("androidx.appcompat:appcompat-resources:1.7.0") implementation("io.coil-kt:coil-compose:2.2.2") } @@ -38,7 +40,7 @@ android { } kotlinOptions { - jvmTarget = "1.8" + jvmTarget = "11" } namespace = "org.burnoutcrew.android" -} \ No newline at end of file +} diff --git a/android/src/main/kotlin/org/burnoutcrew/android/ui/Root.kt b/android/src/main/kotlin/org/burnoutcrew/android/ui/Root.kt index 52c6ba9..121b6b7 100644 --- a/android/src/main/kotlin/org/burnoutcrew/android/ui/Root.kt +++ b/android/src/main/kotlin/org/burnoutcrew/android/ui/Root.kt @@ -16,16 +16,17 @@ package org.burnoutcrew.android.ui import androidx.compose.foundation.layout.padding -import androidx.compose.material.BottomNavigation -import androidx.compose.material.BottomNavigationItem -import androidx.compose.material.Icon -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.List +import androidx.compose.material.icons.automirrored.filled.List import androidx.compose.material.icons.filled.Settings import androidx.compose.material.icons.filled.Star +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.NavigationBar +import androidx.compose.material3.NavigationBarItem +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.graphics.Color @@ -44,6 +45,7 @@ import org.burnoutcrew.android.ui.reorderlist.ReorderList import org.burnoutcrew.android.ui.theme.ReorderListTheme +@OptIn(ExperimentalMaterial3Api::class) @Composable fun Root() { ReorderListTheme { @@ -87,11 +89,11 @@ private fun Navigation(navController: NavHostController, modifier: Modifier) { @Composable private fun BottomNavigationBar(items: List, navController: NavController) { - BottomNavigation(contentColor = Color.White) { + NavigationBar (contentColor = Color.White) { val navBackStackEntry = navController.currentBackStackEntryAsState() val currentRoute = navBackStackEntry.value?.destination?.route items.forEach { item -> - BottomNavigationItem( + NavigationBarItem( icon = { Icon(item.icon, item.title) }, label = { Text(text = item.title) }, selected = currentRoute == item.route, @@ -112,7 +114,7 @@ private fun BottomNavigationBar(items: List, navController: NavC } private sealed class NavigationItem(var route: String, var icon: ImageVector, var title: String) { - object Lists : NavigationItem("lists", Icons.Default.List, "Lists") - object Grids : NavigationItem("grids", Icons.Default.Settings, "Grids") - object Fixed : NavigationItem("fixed", Icons.Default.Star, "Fixed") + data object Lists : NavigationItem("lists", Icons.AutoMirrored.Filled.List, "Lists") + data object Grids : NavigationItem("grids", Icons.Default.Settings, "Grids") + data object Fixed : NavigationItem("fixed", Icons.Default.Star, "Fixed") } diff --git a/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderGrid.kt b/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderGrid.kt index 24bc977..810739d 100644 --- a/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderGrid.kt +++ b/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderGrid.kt @@ -29,8 +29,8 @@ import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.LazyHorizontalGrid import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -78,7 +78,7 @@ private fun HorizontalGrid( modifier = Modifier .shadow(elevation.value) .aspectRatio(1f) - .background(MaterialTheme.colors.secondary) + .background(MaterialTheme.colorScheme.secondary) ) { Text(item.title) } @@ -107,7 +107,7 @@ private fun VerticalGrid( contentAlignment = Alignment.Center, modifier = Modifier .size(100.dp) - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) ) { Text(item.title) } @@ -120,7 +120,7 @@ private fun VerticalGrid( .detectReorderAfterLongPress(state) .shadow(elevation.value) .aspectRatio(1f) - .background(MaterialTheme.colors.primary) + .background(MaterialTheme.colorScheme.primary) ) { Text(item.title) } diff --git a/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderImageList.kt b/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderImageList.kt index 278f3d3..fbf4500 100644 --- a/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderImageList.kt +++ b/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderImageList.kt @@ -28,11 +28,11 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.List +import androidx.compose.material.icons.automirrored.filled.List +import androidx.compose.material3.HorizontalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -71,14 +71,14 @@ fun ReorderImageList( modifier = Modifier .shadow(elevation.value) .fillMaxWidth() - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) ) { Row(verticalAlignment = Alignment.CenterVertically) { Image( - Icons.Default.List, + Icons.AutoMirrored.Filled.List, "", - colorFilter = ColorFilter.tint(color = MaterialTheme.colors.onBackground), + colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onBackground), modifier = Modifier.detectReorder(state) ) Image( @@ -91,7 +91,7 @@ fun ReorderImageList( modifier = Modifier.padding(16.dp) ) } - Divider() + HorizontalDivider() } } } @@ -112,7 +112,7 @@ private fun HeaderFooter(title: String, url: String) { ) Text( title, - style = MaterialTheme.typography.h2, + style = MaterialTheme.typography.displayMedium, color = Color.White, modifier = Modifier.align(Alignment.Center) ) diff --git a/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderList.kt b/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderList.kt index ad788a0..02ee6e5 100644 --- a/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderList.kt +++ b/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderList.kt @@ -28,9 +28,9 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -86,13 +86,13 @@ private fun VerticalReorderList( .detectReorderAfterLongPress(state) .shadow(elevation.value) .fillMaxWidth() - .background(MaterialTheme.colors.surface) + .background(MaterialTheme.colorScheme.surface) ) { Text( text = item.title, modifier = Modifier.padding(16.dp) ) - Divider() + HorizontalDivider() } } } diff --git a/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Color.kt b/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Color.kt index 7a20431..3e8094b 100644 --- a/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Color.kt +++ b/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Color.kt @@ -2,7 +2,10 @@ package org.burnoutcrew.android.ui.theme import androidx.compose.ui.graphics.Color -val Purple200 = Color(0xFFBB86FC) -val Purple500 = Color(0xFF6200EE) -val Purple700 = Color(0xFF3700B3) -val Teal200 = Color(0xFF03DAC5) \ No newline at end of file +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) diff --git a/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Shape.kt b/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Shape.kt index d93c501..5ebfe48 100644 --- a/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Shape.kt +++ b/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Shape.kt @@ -1,7 +1,7 @@ package org.burnoutcrew.android.ui.theme import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Shapes +import androidx.compose.material3.Shapes import androidx.compose.ui.unit.dp val Shapes = Shapes( diff --git a/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Theme.kt b/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Theme.kt index c2b60ae..2bfba0b 100644 --- a/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Theme.kt +++ b/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Theme.kt @@ -1,33 +1,57 @@ package org.burnoutcrew.android.ui.theme + +import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.MaterialTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors +import androidx.compose.material3.MaterialTheme +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.LocalContext -private val DarkColorPalette = darkColors( - primary = Purple200, - primaryVariant = Purple700, - secondary = Teal200 +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 ) -private val LightColorPalette = lightColors( - primary = Purple500, - primaryVariant = Purple700, - secondary = Teal200 +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ ) @Composable -fun ReorderListTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { - val colors = if (darkTheme) { - DarkColorPalette - } else { - LightColorPalette +fun ReorderListTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme } MaterialTheme( - colors = colors, + colorScheme = colorScheme, typography = Typography, shapes = Shapes, content = content diff --git a/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Type.kt b/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Type.kt index 04b4102..d211032 100644 --- a/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Type.kt +++ b/android/src/main/kotlin/org/burnoutcrew/android/ui/theme/Type.kt @@ -1,6 +1,6 @@ package org.burnoutcrew.android.ui.theme -import androidx.compose.material.Typography +import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight @@ -8,9 +8,27 @@ import androidx.compose.ui.unit.sp // Set of Material typography styles to start with val Typography = Typography( - body1 = TextStyle( + bodyLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, - fontSize = 16.sp + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp ) -) \ No newline at end of file + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) diff --git a/android/src/main/res/values/colors.xml b/android/src/main/res/values/colors.xml new file mode 100644 index 0000000..ca1931b --- /dev/null +++ b/android/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + diff --git a/android/src/main/res/values/themes.xml b/android/src/main/res/values/themes.xml index 7e1fd88..d1d5560 100644 --- a/android/src/main/res/values/themes.xml +++ b/android/src/main/res/values/themes.xml @@ -1,7 +1,4 @@ - + - - \ No newline at end of file +