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

Fixed #2713 #2714

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open

Fixed #2713 #2714

wants to merge 4 commits into from

Conversation

yashc18
Copy link

@yashc18 yashc18 commented Oct 5, 2024

Fixes #Issue_Number

Please Add Screenshots If there are any UI changes.

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Apply the AndroidStyle.xml style template to your code in Android Studio.

  • Run the unit tests with ./gradlew check to make sure you didn't break anything

  • If you have multiple commits please combine them into one commit by squashing them.

UI Changes
Screenshot 2024-10-05 010028
Screenshot 2024-10-05 010048

… theme, ensuring consistency between the UI and the status bar.
… theme, ensuring consistency between the UI and the status bar.
… theme, ensuring consistency between the UI and the status bar.
… theme, ensuring consistency between the UI and the status bar.
@@ -144,4 +144,9 @@ dependencies {
androidTestImplementation(libs.hilt.android.testing)

debugApi(libs.androidx.compose.ui.tooling)

implementation("com.google.accompanist:accompanist-systemuicontroller:0.34.0")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accompanist system UI controller has been deprecated, we should migrate to EdgeToEdge Api

@@ -63,7 +72,6 @@ fun MifosApp(

Scaffold(
modifier = Modifier.semantics {
testTagsAsResourceId = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep as it is, useful for testing


// Apply the status bar color
LaunchedEffect(Unit) {
systemUiController.setStatusBarColor(color = statusBarColor)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migrate to EdgeToEdge Api

@niyajali
Copy link
Collaborator

niyajali commented Oct 5, 2024

we no need to configuring it manually this should be provided by EnableEdgeToEdge Api, you could configure theme for night & dark mode like below

update splash.xml

<resources xmlns:tools="http://schemas.android.com/tools">

    <!-- Allows us to override night specific attributes in the
     values-night folder. -->
    <style name="NightAdjusted.Theme" parent="android:Theme.Material.Light.NoActionBar">
        <item name="android:statusBarColor">@color/status_bar</item>
    </style>

    <!-- The final theme we use -->
    <style name="Theme.Mifos" parent="NightAdjusted.Theme" />

    <style name="NightAdjusted.Theme.Splash" parent="Theme.SplashScreen">
        <item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>
    </style>

    <style name="Theme.Mifos.Splash" parent="NightAdjusted.Theme.Splash">
        <item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
        <item name="postSplashScreenTheme">@style/Theme.Mifos</item>
    </style>

</resources>

create values-night folder and create theme.xml, colors.xml file
values-night/theme.xml would be look like this

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">

    <style name="NightAdjusted.Theme" parent="android:Theme.Material.NoActionBar">
        <item name="android:statusBarColor">@color/status_bar</item>
    </style>

    <style name="NightAdjusted.Theme.Splash" parent="Theme.SplashScreen">
        <item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
    </style>

</resources>

color.xml

<color name="status_bar">#FFFEFBFF</color> // light/color.xml
<color name="status_bar">#FF1B1B1F</color> // dark/color.xml

HomeActivity.kt

       setContent {
            val darkTheme = isSystemInDarkTheme()

            // Update the dark content of the system bars to match the theme
            DisposableEffect(darkTheme) {
                enableEdgeToEdge(
                    statusBarStyle = SystemBarStyle.auto(
                        Color.TRANSPARENT,
                        Color.TRANSPARENT,
                    ) { darkTheme },
                    navigationBarStyle = SystemBarStyle.auto(
                        lightScrim,
                        darkScrim,
                    ) { darkTheme },
                )

                onDispose {}
            }
     }

you may need to configure TopAppBar colors as well, update DarkThemeColors
surface = BackgroundDark

you may need to do some small tweaks to match these StatusBar, NavigationBar and Surface colors to same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants