Skip to content

Commit

Permalink
[Jetlagged] Add edge-to-edge support (#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
JolandaVerhoef authored Nov 21, 2023
2 parents 9810c90 + 99074a1 commit 2feda1a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 46 deletions.
2 changes: 1 addition & 1 deletion JetLagged/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ dependencies {
implementation(libs.androidx.lifecycle.viewModelCompose)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.constraintlayout.compose)
implementation(libs.google.android.material)

implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.foundation)
Expand All @@ -117,7 +118,6 @@ dependencies {
implementation(libs.androidx.compose.ui.tooling.preview)
debugImplementation(libs.androidx.compose.ui.tooling)

implementation(libs.accompanist.systemuicontroller)
implementation(libs.accompanist.flowlayout)

implementation(libs.coil.kt.compose)
Expand Down
4 changes: 2 additions & 2 deletions JetLagged/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.JetLagged"
android:exported="true">
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package com.example.jetlagged
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.view.WindowCompat
import androidx.activity.enableEdgeToEdge
import com.example.jetlagged.ui.theme.JetLaggedTheme

class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
JetLaggedTheme {
HomeScreenDrawer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@

package com.example.jetlagged.ui.theme

import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Shapes
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

private val LightColorScheme = lightColorScheme(
primary = Yellow,
Expand All @@ -45,26 +38,10 @@ private val shapes: Shapes
fun JetLaggedTheme(
content: @Composable () -> Unit,
) {

val view = LocalView.current
val context = LocalContext.current
if (!view.isInEditMode) {
SideEffect {
WindowCompat.getInsetsController(context.findActivity().window, view)
.isAppearanceLightStatusBars = true
}
}

MaterialTheme(
colorScheme = LightColorScheme,
typography = Typography,
shapes = shapes,
content = content
)
}
private tailrec fun Context.findActivity(): Activity =
when (this) {
is Activity -> this
is ContextWrapper -> this.baseContext.findActivity()
else -> throw IllegalArgumentException("Could not find activity!")
}
10 changes: 0 additions & 10 deletions JetLagged/app/src/main/res/values-v23/themes.xml

This file was deleted.

9 changes: 1 addition & 8 deletions JetLagged/app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,5 @@
the License.
-->
<resources>

<style name="Theme.JetLagged" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
</style>


<style name="Theme.JetLagged" parent="Theme.MaterialComponents.DayNight"/>
</resources>

0 comments on commit 2feda1a

Please sign in to comment.