Initial commit
This commit is contained in:
commit
910af0a86e
51 files changed
+1148
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package com.anthonyla.livewallpaper
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.core.view.WindowCompat
|
||||
import com.anthonyla.livewallpaper.theming.LiveWallpaperTheme
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import com.anthonyla.livewallpaper.ui.LiveWallpaperApp
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
|
||||
// Update the status bar to transparent
|
||||
val systemUiController = rememberSystemUiController()
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
DisposableEffect(systemUiController) {
|
||||
systemUiController.setSystemBarsColor(color = Color.Transparent)
|
||||
onDispose {}
|
||||
}
|
||||
systemUiController.setSystemBarsColor(color = Color.Transparent)
|
||||
|
||||
LiveWallpaperTheme {
|
||||
LiveWallpaperApp()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.anthonyla.livewallpaper.navigation
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Home
|
||||
import androidx.compose.material.icons.filled.List
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import com.anthonyla.livewallpaper.R
|
||||
|
||||
sealed class BottomNavScreens(val route: String, @StringRes val resourceId: Int, val icon: ImageVector) {
|
||||
object Wallpaper : BottomNavScreens("wallpaper", R.string.wallpaper, Icons.Filled.Home)
|
||||
object Library : BottomNavScreens("library", R.string.library, Icons.Filled.List)
|
||||
object Setting : BottomNavScreens("setting", R.string.setting, Icons.Filled.Settings)
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.anthonyla.livewallpaper.navigation
|
||||
|
||||
import androidx.compose.material.BottomNavigationItem
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.NavigationBar
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavDestination.Companion.hierarchy
|
||||
import androidx.navigation.NavGraph.Companion.findStartDestination
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
|
||||
@Composable
|
||||
fun BottomNavigationBar(
|
||||
navController: NavController,
|
||||
screens: List<BottomNavScreens>
|
||||
) {
|
||||
NavigationBar(
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
) {
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentDestination = navBackStackEntry?.destination
|
||||
screens.forEach { screen ->
|
||||
NavigationBarItem(
|
||||
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
|
||||
label = {
|
||||
Text(
|
||||
text = stringResource(id = screen.resourceId),
|
||||
fontWeight = FontWeight.SemiBold
|
||||
) },
|
||||
icon = {
|
||||
Icon(screen.icon,
|
||||
contentDescription = "${stringResource(id = screen.resourceId)} Icon",
|
||||
) },
|
||||
alwaysShowLabel = false,
|
||||
onClick = {
|
||||
navController.navigate(screen.route) {
|
||||
popUpTo(navController.graph.findStartDestination().id) {
|
||||
saveState = true
|
||||
}
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.anthonyla.livewallpaper.navigation
|
||||
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.navigation
|
||||
import com.anthonyla.livewallpaper.ui.Library
|
||||
import com.anthonyla.livewallpaper.ui.Setting
|
||||
import com.anthonyla.livewallpaper.ui.Wallpaper
|
||||
|
||||
fun NavGraphBuilder.bottomNav(navController: NavController, modifier: Modifier = Modifier) {
|
||||
navigation(startDestination = BottomNavScreens.Wallpaper.route, route = "bottomNavigation") {
|
||||
composable(BottomNavScreens.Wallpaper.route) { Wallpaper() }
|
||||
composable(BottomNavScreens.Library.route) { Library() }
|
||||
composable(BottomNavScreens.Setting.route) { Setting() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.anthonyla.livewallpaper.theming
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val Purple80 = Color(0xFFD0BCFF)
|
||||
val PurpleGrey80 = Color(0xFFCCC2DC)
|
||||
val Pink80 = Color(0xFFEFB8C8)
|
||||
|
||||
val Purple40 = Color(0xFF6650a4)
|
||||
val PurpleGrey40 = Color(0xFF625b71)
|
||||
val Pink40 = Color(0xFF7D5260)
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.anthonyla.livewallpaper.theming
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
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.runtime.SideEffect
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.WindowCompat
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = Purple80,
|
||||
secondary = PurpleGrey80,
|
||||
tertiary = Pink80
|
||||
)
|
||||
|
||||
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 LiveWallpaperTheme(
|
||||
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
|
||||
}
|
||||
val view = LocalView.current
|
||||
if (!view.isInEditMode) {
|
||||
SideEffect {
|
||||
val window = (view.context as Activity).window
|
||||
window.statusBarColor = colorScheme.primary.toArgb()
|
||||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
|
||||
}
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
typography = Typography,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.anthonyla.livewallpaper.theming
|
||||
|
||||
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
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
// Set of Material typography styles to start with
|
||||
val Typography = Typography(
|
||||
bodyLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
/* 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
|
||||
)
|
||||
*/
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.anthonyla.livewallpaper.ui
|
||||
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@Composable
|
||||
fun Library(modifier: Modifier = Modifier) {
|
||||
Text(text = "library")
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.anthonyla.livewallpaper.ui
|
||||
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.anthonyla.livewallpaper.navigation.BottomNavScreens
|
||||
import com.anthonyla.livewallpaper.navigation.BottomNavigationBar
|
||||
import com.anthonyla.livewallpaper.navigation.bottomNav
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun LiveWallpaperApp(modifier: Modifier = Modifier) {
|
||||
val navController = rememberNavController()
|
||||
|
||||
// Bottom navigation
|
||||
val bottomNavOptions = listOf(
|
||||
BottomNavScreens.Wallpaper,
|
||||
BottomNavScreens.Library,
|
||||
BottomNavScreens.Setting
|
||||
)
|
||||
Scaffold (
|
||||
bottomBar = { BottomNavigationBar(navController = navController, screens = bottomNavOptions) },
|
||||
) { innerPadding ->
|
||||
NavHost(navController, startDestination = "bottomNavigation", Modifier.padding(innerPadding)) {
|
||||
bottomNav(navController)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.anthonyla.livewallpaper.ui
|
||||
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@Composable
|
||||
fun Setting(modifier: Modifier = Modifier) {
|
||||
Text(text = "setting")
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.anthonyla.livewallpaper.ui
|
||||
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@Composable
|
||||
fun Wallpaper(modifier: Modifier = Modifier) {
|
||||
Text(text = "wallpaper")
|
||||
}
|
||||
Reference in new issue
Block a user