Added some documentation for navigation and changed the status bar to transparent
This commit is contained in:
1 parent
910af0a86e
commit
127805bc70
16 files changed
+185
-33
No files matched your search
Generated
+123
@@ -0,0 +1,123 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<option name="FORCE_REARRANGE_MODE" value="1" />
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
Generated
+5
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="20" />
|
||||
<bytecodeTargetLevel target="17" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
-2
@@ -4,8 +4,6 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="openjdk-20" />
|
||||
<option name="modules">
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="20" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -3,27 +3,16 @@ 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.themes.LiveWallpaperTheme
|
||||
import com.anthonyla.livewallpaper.ui.LiveWallpaperApp
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
// Enable full screen app mode
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
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()
|
||||
}
|
||||
|
||||
@@ -8,8 +8,13 @@ import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import com.anthonyla.livewallpaper.R
|
||||
|
||||
/**
|
||||
* BottomNavScreens groups the different screens of the bottom navigation bar together.
|
||||
* Each object represents a screen and has a route for the NavController, the name of the route,
|
||||
* and a icon that is shown on the bottom navigation bar.
|
||||
*/
|
||||
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)
|
||||
object Configure : BottomNavScreens("configure", R.string.configure, Icons.Filled.Settings)
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
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
|
||||
@@ -15,6 +14,11 @@ import androidx.navigation.NavDestination.Companion.hierarchy
|
||||
import androidx.navigation.NavGraph.Companion.findStartDestination
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of the bottom navigation bar composable
|
||||
* Three screens = Wallpaper, Collection, Configure
|
||||
*/
|
||||
@Composable
|
||||
fun BottomNavigationBar(
|
||||
navController: NavController,
|
||||
|
||||
@@ -6,13 +6,17 @@ 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.Configure
|
||||
import com.anthonyla.livewallpaper.ui.Wallpaper
|
||||
|
||||
/**
|
||||
* The bottomNav graph builder links the routes for the different screens of the bottom navigation
|
||||
* bar together.
|
||||
*/
|
||||
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() }
|
||||
composable(BottomNavScreens.Configure.route) { Configure() }
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.anthonyla.livewallpaper.theming
|
||||
package com.anthonyla.livewallpaper.themes
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.anthonyla.livewallpaper.theming
|
||||
package com.anthonyla.livewallpaper.themes
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.anthonyla.livewallpaper.theming
|
||||
package com.anthonyla.livewallpaper.themes
|
||||
|
||||
import androidx.compose.material3.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
+2
-2
@@ -5,6 +5,6 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@Composable
|
||||
fun Setting(modifier: Modifier = Modifier) {
|
||||
Text(text = "setting")
|
||||
fun Configure(modifier: Modifier = Modifier) {
|
||||
Text(text = "configure")
|
||||
}
|
||||
@@ -4,28 +4,46 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
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
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun LiveWallpaperApp(modifier: Modifier = Modifier) {
|
||||
val navController = rememberNavController()
|
||||
// Transparent status bar
|
||||
val systemUiController = rememberSystemUiController()
|
||||
SideEffect {
|
||||
systemUiController.setStatusBarColor(
|
||||
color = Color.Transparent,
|
||||
// check if app is in dark mode or not
|
||||
darkIcons = false
|
||||
)
|
||||
}
|
||||
|
||||
// Bottom navigation
|
||||
val navController = rememberNavController()
|
||||
val bottomNavOptions = listOf(
|
||||
BottomNavScreens.Wallpaper,
|
||||
BottomNavScreens.Library,
|
||||
BottomNavScreens.Setting
|
||||
BottomNavScreens.Configure
|
||||
)
|
||||
Scaffold (
|
||||
bottomBar = { BottomNavigationBar(navController = navController, screens = bottomNavOptions) },
|
||||
) { innerPadding ->
|
||||
NavHost(navController, startDestination = "bottomNavigation", Modifier.padding(innerPadding)) {
|
||||
bottomBar = {
|
||||
BottomNavigationBar(navController = navController, screens = bottomNavOptions)
|
||||
},
|
||||
) {
|
||||
innerPadding -> NavHost (
|
||||
navController,
|
||||
startDestination = "bottomNavigation",
|
||||
Modifier.padding(innerPadding)
|
||||
) {
|
||||
bottomNav(navController)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">LiveWallpaper</string>
|
||||
<string name="library">Library</string>
|
||||
<string name="setting">Setting</string>
|
||||
<string name="configure">Configure</string>
|
||||
<string name="wallpaper">Wallpaper</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user