Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system status bar, system navigation bar 색상 변경, 가로모드 block #75

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dependencies {

implementation(libs.bundles.android.base)

val composeBom = platform("androidx.compose:compose-bom:2023.01.00")
val composeBom = platform("androidx.compose:compose-bom:2024.05.00")
implementation(composeBom)
androidTestImplementation(composeBom)

Expand All @@ -77,7 +77,7 @@ dependencies {
implementation("androidx.compose.material3:material3-window-size-class")

// Optional - Integration with activities
implementation("androidx.activity:activity-compose:1.7.1")
implementation("androidx.activity:activity-compose:1.9.0")
// Optional - Integration with ViewModels
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1")

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat"
android:screenOrientation="portrait"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/whyranoid/walkie/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.annotation.RequiresApi
import com.whyranoid.presentation.screens.AppScreen
import com.whyranoid.presentation.theme.WalkieTheme
Expand All @@ -13,6 +14,9 @@ class MainActivity : ComponentActivity() {
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

enableEdgeToEdge()

setContent {
WalkieTheme {
AppManageDialog()
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]

androidx-navigation = "2.5.3"
androidx-core = "1.9.0"
androidx-core = "1.13.1"
androidx-appcompat = "1.6.1"
androidx-constraintlayout = "2.1.4"
naver-maps-android-sdk = "3.16.2"
Expand Down
4 changes: 2 additions & 2 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ dependencies {

implementation(libs.bundles.android.base)

val composeBom = platform("androidx.compose:compose-bom:2023.01.00")
val composeBom = platform("androidx.compose:compose-bom:2024.05.00")
implementation(composeBom)
androidTestImplementation(composeBom)

Expand Down Expand Up @@ -88,7 +88,7 @@ dependencies {
implementation("androidx.compose.material3:material3-window-size-class")

// Optional - Integration with activities
implementation("androidx.activity:activity-compose:1.7.1")
implementation("androidx.activity:activity-compose:1.9.0")
// Optional - Integration with ViewModels
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.whyranoid.presentation.screens

import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.foundation.layout.size
import androidx.compose.material.BottomNavigation
import androidx.compose.material.BottomNavigationItem
Expand Down Expand Up @@ -70,6 +71,7 @@ fun AppScreenContent(
navController: NavHostController,
) {
Scaffold(
modifier = Modifier.safeDrawingPadding(),
bottomBar = {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.whyranoid.presentation.theme

import android.app.Activity
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

// TODO: Dark Theme
private val DarkColorScheme = darkColorScheme(
Expand Down Expand Up @@ -41,33 +47,26 @@ fun WalkieTheme(
dynamicColor: Boolean = true,
content: @Composable () -> Unit,
) {
val view = LocalView.current
val statusBarColor by remember { mutableIntStateOf(Color.White.toArgb()) }
val systemNavigationBarColor by remember { mutableIntStateOf(Color.White.toArgb()) }

if (view.isInEditMode.not()) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = statusBarColor
window.navigationBarColor = systemNavigationBarColor
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = true
WindowCompat.getInsetsController(window, view).isAppearanceLightNavigationBars = true
}
}

// TODO : Dynamic Color
val colorScheme = when {
darkTheme -> DarkColorScheme
else -> LightColorScheme
}

// Remember a SystemUiController
val systemUiController = rememberSystemUiController()

DisposableEffect(systemUiController, darkTheme) {

systemUiController.setSystemBarsColor(
color = Color.Transparent,
darkIcons = darkTheme.not()
)

systemUiController.setStatusBarColor(
color = colorScheme.surface,
darkIcons = darkTheme.not()
) { requestedColor ->
requestedColor
}

onDispose {}
}

MaterialTheme(
colorScheme = LightColorScheme,
content = content,
Expand Down
Loading