Skip to content

Commit

Permalink
Update status bar colour of the app
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed Jul 23, 2024
1 parent 91fa0e4 commit 6a78682
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
20 changes: 20 additions & 0 deletions android/src/main/java/org/hisp/dhis/android/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ package org.hisp.dhis.android
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalContext
import androidx.core.view.WindowCompat
import org.hisp.dhis.common.App

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val res = LocalContext.current.resources
SetStatusBarColor()
App(
imageBitmapLoader = {
BitmapFactory.decodeResource(
Expand All @@ -27,3 +32,18 @@ class MainActivity : AppCompatActivity() {
}
}
}

@Composable
fun SetStatusBarColor() {
val context = LocalContext.current
val window = (context as? ComponentActivity)?.window

SideEffect {
window?.let {
WindowCompat.getInsetsController(it, it.decorView).apply {
isAppearanceLightStatusBars = true
}
it.statusBarColor = 0xFFE2F2FF.toInt()
}
}
}
7 changes: 6 additions & 1 deletion common/src/commonMain/kotlin/org/hisp/dhis/common/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import org.hisp.dhis.common.screens.Groups
import org.hisp.dhis.common.screens.NoComponentSelectedScreen
Expand All @@ -33,6 +34,7 @@ import org.hisp.dhis.mobile.ui.designsystem.component.DropdownItem
import org.hisp.dhis.mobile.ui.designsystem.component.InputDropDown
import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.theme.DHIS2Theme
import org.hisp.dhis.mobile.ui.designsystem.theme.Shape
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor

Expand Down Expand Up @@ -95,7 +97,10 @@ fun Main(
Groups.NO_GROUP_SELECTED -> NoComponentSelectedScreen()
}
} else {
NoComponentSelectedScreen {
NoComponentSelectedScreen(
modifier = Modifier
.background(Color.White, Shape.NoRounding)
) {
isComponentSelected = !isComponentSelected
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor

@Composable
fun NoComponentSelectedScreen(
modifier: Modifier = Modifier,
onClick: (() -> Unit)? = null,
) {
ColumnScreenContainer(
modifier = modifier,
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally,
) {
Expand Down

0 comments on commit 6a78682

Please sign in to comment.