-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite SystemUiController to edgeToEdge
- Loading branch information
Showing
8 changed files
with
43 additions
and
27 deletions.
There are no files selected for viewing
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
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
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
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
37 changes: 31 additions & 6 deletions
37
catalog/src/main/java/kiwi/orbit/compose/catalog/MainActivity.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 |
---|---|---|
@@ -1,18 +1,43 @@ | ||
package kiwi.orbit.compose.catalog | ||
|
||
import android.app.UiModeManager | ||
import android.graphics.Color | ||
import android.os.Build | ||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.SystemBarStyle | ||
import androidx.activity.compose.setContent | ||
import androidx.core.view.WindowCompat | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.appcompat.app.AppCompatDelegate | ||
import androidx.core.content.getSystemService | ||
|
||
class MainActivity : ComponentActivity() { | ||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
WindowCompat.setDecorFitsSystemWindows(window, false) | ||
|
||
enableEdgeToEdge() | ||
setContent { | ||
CatalogApplication() | ||
CatalogApplication(this) | ||
} | ||
} | ||
|
||
internal fun setUiMode(isLight: Boolean) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
val uiModeManager = getSystemService<UiModeManager>()!! | ||
uiModeManager.setApplicationNightMode( | ||
if (isLight) UiModeManager.MODE_NIGHT_NO else UiModeManager.MODE_NIGHT_YES, | ||
) | ||
} else { | ||
AppCompatDelegate.setDefaultNightMode( | ||
if (isLight) AppCompatDelegate.MODE_NIGHT_NO else AppCompatDelegate.MODE_NIGHT_YES, | ||
) | ||
} | ||
enableEdgeToEdge( | ||
statusBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { !isLight }, | ||
navigationBarStyle = SystemBarStyle.auto(DefaultLightScrim, DefaultDarkScrim) { !isLight }, | ||
) | ||
} | ||
|
||
private val DefaultLightScrim = Color.argb(0xe6, 0xFF, 0xFF, 0xFF) | ||
private val DefaultDarkScrim = Color.argb(0x80, 0x1b, 0x1b, 0x1b) | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<resources> | ||
|
||
<style name="Theme.Catalog" parent="android:Theme.Material.NoActionBar" /> | ||
<style name="Theme.Catalog" parent="Theme.AppCompat.NoActionBar"/> | ||
|
||
</resources> |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<resources> | ||
|
||
<style name="Theme.Catalog" parent="android:Theme.Material.Light.NoActionBar" /> | ||
<style name="Theme.Catalog" parent="Theme.AppCompat.Light.NoActionBar" /> | ||
|
||
</resources> |
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