-
Notifications
You must be signed in to change notification settings - Fork 22
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 #533 from nimblehq/feature/define-basescreen-compo…
…nent [#553] Define BaseScreen composable for all screens
- Loading branch information
Showing
11 changed files
with
72 additions
and
5 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
21 changes: 21 additions & 0 deletions
21
sample-compose/app/src/main/java/co/nimblehq/sample/compose/ui/base/BaseScreen.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,21 @@ | ||
package co.nimblehq.sample.compose.ui.base | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.colorResource | ||
import co.nimblehq.sample.compose.R | ||
import co.nimblehq.sample.compose.util.setStatusBarColor | ||
|
||
@Composable | ||
fun BaseScreen( | ||
isDarkStatusBarIcons: Boolean? = null, | ||
content: @Composable () -> Unit, | ||
) { | ||
if (isDarkStatusBarIcons != null) { | ||
setStatusBarColor( | ||
color = colorResource(id = R.color.statusBarColor), | ||
darkIcons = isDarkStatusBarIcons, | ||
) | ||
} | ||
|
||
content() | ||
} |
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
22 changes: 22 additions & 0 deletions
22
sample-compose/app/src/main/java/co/nimblehq/sample/compose/util/ComposableUtil.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,22 @@ | ||
package co.nimblehq.sample.compose.util | ||
|
||
import android.annotation.SuppressLint | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.ui.graphics.Color | ||
import com.google.accompanist.systemuicontroller.rememberSystemUiController | ||
|
||
@SuppressLint("ComposableNaming") | ||
@Composable | ||
fun setStatusBarColor( | ||
color: Color, | ||
darkIcons: Boolean, | ||
) { | ||
val systemUiController = rememberSystemUiController() | ||
LaunchedEffect(key1 = darkIcons) { | ||
systemUiController.setStatusBarColor( | ||
color = color, | ||
darkIcons = darkIcons, | ||
) | ||
} | ||
} |
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,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="greenChristi">#FF669900</color> | ||
<color name="statusBarColor">#FF669900</color> | ||
</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,6 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | ||
<item name="android:statusBarColor">@color/greenChristi</item> | ||
<item name="android:statusBarColor">@color/statusBarColor</item> | ||
</style> | ||
</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
13 changes: 13 additions & 0 deletions
13
template-compose/app/src/main/java/co/nimblehq/template/compose/ui/base/BaseScreen.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,13 @@ | ||
package co.nimblehq.template.compose.ui.base | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
fun BaseScreen( | ||
// TODO Base parameters to request on all screens here | ||
content: @Composable () -> Unit, | ||
) { | ||
// TODO Base logic for all screens here | ||
|
||
content() | ||
} |
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