forked from DroidKaigi/conference-app-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request DroidKaigi#790 from mannodermaus/feature/inverted-…
…system-bar-content-on-profile-card Invert the system bar appearance on the ProfileCardScreen, matching its light background
- Loading branch information
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...io/github/droidkaigi/confsched/profilecard/component/InvertSystemBarAppearance.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.github.droidkaigi.confsched.profilecard.component | ||
|
||
import android.app.Activity | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.DisposableEffect | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.core.view.WindowCompat | ||
|
||
@Composable | ||
internal actual fun InvertSystemBarAppearance() { | ||
val activity = LocalContext.current as Activity | ||
val insetsController = WindowCompat.getInsetsController(activity.window, activity.window.decorView) | ||
|
||
val originalIsAppearanceLight = remember { insetsController.isAppearanceLightStatusBars } | ||
|
||
DisposableEffect(Unit) { | ||
insetsController.isAppearanceLightStatusBars = !originalIsAppearanceLight | ||
|
||
onDispose { | ||
insetsController.isAppearanceLightStatusBars = originalIsAppearanceLight | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
.../kotlin/io/github/droidkaigi/confsched/profilecard/component/InvertSystemBarAppearance.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.github.droidkaigi.confsched.profilecard.component | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
internal expect fun InvertSystemBarAppearance() |
29 changes: 29 additions & 0 deletions
29
...lin/io/github/droidkaigi/confsched/profilecard/component/InvertSystemBarAppearance.ios.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.github.droidkaigi.confsched.profilecard.component | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.DisposableEffect | ||
import androidx.compose.runtime.remember | ||
import platform.UIKit.UIApplication | ||
import platform.UIKit.UIUserInterfaceStyle.UIUserInterfaceStyleDark | ||
import platform.UIKit.UIUserInterfaceStyle.UIUserInterfaceStyleLight | ||
import platform.UIKit.UIWindow | ||
import platform.UIKit.UIWindowScene | ||
|
||
@Composable | ||
internal actual fun InvertSystemBarAppearance() { | ||
val application = UIApplication.sharedApplication | ||
val scene = application.connectedScenes.firstOrNull() as? UIWindowScene | ||
val window = scene?.windows?.firstOrNull() as? UIWindow ?: return | ||
|
||
val originalUserInterfaceStyle = remember { window.overrideUserInterfaceStyle } | ||
|
||
DisposableEffect(Unit) { | ||
window.overrideUserInterfaceStyle = if (originalUserInterfaceStyle == UIUserInterfaceStyleDark) { | ||
UIUserInterfaceStyleLight | ||
} else { | ||
UIUserInterfaceStyleDark | ||
} | ||
|
||
onDispose { window.overrideUserInterfaceStyle = originalUserInterfaceStyle } | ||
} | ||
} |