Added Material3 dependencies and Theme
This commit is contained in:
1 parent
7dca788c01
commit
0755b20cf0
5 files changed
+114
-35
No files matched your search
+14
-6
@@ -8,15 +8,18 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'com.rtbishop.look4sat'
|
||||
compileSdk 35
|
||||
compileSdk 34
|
||||
defaultConfig {
|
||||
applicationId "com.rtbishop.look4sat"
|
||||
minSdk 21
|
||||
targetSdk 35
|
||||
versionCode 323
|
||||
versionName '3.2.3'
|
||||
targetSdk 34
|
||||
versionCode 320
|
||||
versionName '3.2.0'
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
useSupportLibrary true
|
||||
}
|
||||
|
||||
kapt {
|
||||
arguments {
|
||||
@@ -51,8 +54,10 @@ android {
|
||||
animationsDisabled true
|
||||
unitTests.includeAndroidResources true
|
||||
}
|
||||
androidResources {
|
||||
generateLocaleConfig true
|
||||
packagingOptions {
|
||||
resources {
|
||||
excludes += '/META-INF/{AL2.0,LGPL2.1}'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,9 +96,12 @@ dependencies {
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
|
||||
implementation "androidx.compose.material:material:$compose_material_version"
|
||||
implementation "androidx.compose.material:material-icons-extended:$compose_material_version"
|
||||
implementation "androidx.compose.material3:material3:$material3_version"
|
||||
implementation "androidx.compose.material3:material3-window-size-class:$material3_version"
|
||||
implementation "com.google.android.material:compose-theme-adapter:$material_adapter_version"
|
||||
|
||||
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
|
||||
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
|
||||
debugImplementation "androidx.fragment:fragment-testing:$fragment_test_version"
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import androidx.navigation.ui.NavigationUiSaveStateControl
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.databinding.ActivityMainBinding
|
||||
import com.rtbishop.look4sat.presentation.bottomNav.MainScreenView
|
||||
import com.rtbishop.look4sat.presentation.theme.Look4SatTheme
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
@@ -54,7 +53,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val host = supportFragmentManager.findFragmentById(R.id.nav_host) as NavHostFragment
|
||||
NavigationUI.setupWithNavController(binding.navBar, host.navController, false)
|
||||
setContentView(binding.root)
|
||||
// setContent { Look4SatTheme { MainScreenView() } }
|
||||
// setContent { MainTheme { MainScreenView() } }
|
||||
}
|
||||
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.rtbishop.look4sat.presentation
|
||||
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Typography
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
private val Yellow = Color(0xFFFFE082)
|
||||
private val TextWhite = Color(0xCCFFFFFF)
|
||||
private val TextGrey = Color(0x66FFFFFF)
|
||||
private val TextBlack = Color(0xFF000000)
|
||||
private val ButtonGrey = Color(0xFF2A2A2A)
|
||||
private val SurfaceGrey = Color(0xFF1C1C1C)
|
||||
private val Background = Color(0xFF121212)
|
||||
private val Transparent = Color(0x00000000)
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = SurfaceGrey,
|
||||
secondary = Yellow,
|
||||
tertiary = ButtonGrey,
|
||||
background = Background,
|
||||
surface = SurfaceGrey,
|
||||
onPrimary = TextWhite,
|
||||
onSecondary = TextBlack,
|
||||
onTertiary = TextWhite,
|
||||
onBackground = TextWhite,
|
||||
onSurface = TextWhite
|
||||
)
|
||||
|
||||
private val Typography = Typography(
|
||||
bodyLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
), 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
|
||||
)
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun MainTheme(
|
||||
// darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
// dynamicColor: Boolean = false,
|
||||
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
|
||||
// }
|
||||
val colorScheme = DarkColorScheme
|
||||
// val view = LocalView.current
|
||||
// if (!view.isInEditMode) {
|
||||
// SideEffect {
|
||||
// (view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
|
||||
// ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = darkTheme
|
||||
// }
|
||||
// }
|
||||
MaterialTheme(colorScheme = colorScheme, typography = Typography, content = content)
|
||||
}
|
||||
+18
-27
@@ -1,25 +1,23 @@
|
||||
package com.rtbishop.look4sat.presentation.bottomNav
|
||||
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.presentation.theme.Yellow
|
||||
import com.rtbishop.look4sat.presentation.theme.Look4SatTheme
|
||||
import com.rtbishop.look4sat.presentation.theme.TextWhite
|
||||
import com.rtbishop.look4sat.presentation.MainTheme
|
||||
|
||||
@Composable
|
||||
fun BottomNavView(navController: NavController) {
|
||||
fun BottomNavBar(navController: NavController) {
|
||||
val items = listOf(
|
||||
BottomNavItem.Satellites,
|
||||
BottomNavItem.Passes,
|
||||
@@ -27,27 +25,19 @@ fun BottomNavView(navController: NavController) {
|
||||
BottomNavItem.Settings,
|
||||
BottomNavItem.About
|
||||
)
|
||||
BottomNavigation(backgroundColor = colorResource(id = R.color.bottomBar)) {
|
||||
NavigationBar(modifier = Modifier.height(56.dp)) {
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = navBackStackEntry?.destination?.route
|
||||
items.forEach { item ->
|
||||
BottomNavigationItem(icon = {
|
||||
Icon(painterResource(id = item.icon), contentDescription = item.title)
|
||||
},
|
||||
label = { Text(text = item.title, fontSize = 9.sp) },
|
||||
selectedContentColor = Yellow,
|
||||
unselectedContentColor = TextWhite.copy(0.4f),
|
||||
alwaysShowLabel = true,
|
||||
selected = currentRoute == item.screen_route,
|
||||
onClick = {
|
||||
navController.navigate(item.screen_route) {
|
||||
navController.graph.startDestinationRoute?.let { screen_route ->
|
||||
popUpTo(screen_route) { saveState = true }
|
||||
}
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
NavigationBarItem(selected = currentRoute == item.screen_route, onClick = {
|
||||
navController.navigate(item.screen_route) {
|
||||
navController.graph.startDestinationRoute?.let { screen_route ->
|
||||
popUpTo(screen_route) { saveState = false }
|
||||
}
|
||||
})
|
||||
launchSingleTop = true
|
||||
restoreState = false
|
||||
}
|
||||
}, icon = { Icon(painterResource(id = item.icon), contentDescription = item.title) })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,10 +53,11 @@ fun NavigationGraph(navController: NavHostController) {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun MainScreenView() {
|
||||
val navController = rememberNavController()
|
||||
Scaffold(bottomBar = { BottomNavView(navController = navController) }) {
|
||||
Scaffold(bottomBar = { BottomNavBar(navController = navController) }) {
|
||||
NavigationGraph(navController = navController)
|
||||
it.calculateBottomPadding()
|
||||
}
|
||||
@@ -75,5 +66,5 @@ fun MainScreenView() {
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun DefaultPreview() {
|
||||
Look4SatTheme { MainScreenView() }
|
||||
MainTheme { MainScreenView() }
|
||||
}
|
||||
@@ -18,6 +18,7 @@ buildscript {
|
||||
compose_foundation_version = '1.3.1'
|
||||
activity_compose_version = '1.6.1'
|
||||
compose_material_version = '1.3.1'
|
||||
material3_version = '1.0.1'
|
||||
material_adapter_version = '1.2.1'
|
||||
fragment_test_version = '1.5.5'
|
||||
leakcanary_version = '2.9.1'
|
||||
|
||||
Reference in new issue
Block a user