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

Issue 220 Fix inverse mode card when system is in dark mode #223

Merged
merged 4 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.airbnb.android.showkase.ui

import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -17,12 +18,14 @@ import androidx.compose.material.TextFieldDefaults
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.TextStyle
Expand Down Expand Up @@ -51,26 +54,31 @@ internal fun ShowkaseBrowserApp(
groupedTypographyMap: Map<String, List<ShowkaseBrowserTypography>>,
showkaseBrowserScreenMetadata: MutableState<ShowkaseBrowserScreenMetadata>
) {
val navController = rememberNavController()
Scaffold(
drawerContent = null,
topBar = {
ShowkaseAppBar(navController, showkaseBrowserScreenMetadata)
},
content = {
Column(
modifier = Modifier.fillMaxSize().background(color = SHOWKASE_COLOR_BACKGROUND),
) {
ShowkaseBodyContent(
navController,
groupedComponentMap,
groupedColorsMap,
groupedTypographyMap,
showkaseBrowserScreenMetadata
)
val lightModeConfiguration = Configuration(LocalConfiguration.current).apply {
uiMode = Configuration.UI_MODE_NIGHT_NO
}
CompositionLocalProvider(LocalConfiguration provides lightModeConfiguration) {
val navController = rememberNavController()
Scaffold(
drawerContent = null,
topBar = {
ShowkaseAppBar(navController, showkaseBrowserScreenMetadata)
},
content = {
Column(
modifier = Modifier.fillMaxSize().background(color = SHOWKASE_COLOR_BACKGROUND),
) {
ShowkaseBodyContent(
navController,
groupedComponentMap,
groupedColorsMap,
groupedTypographyMap,
showkaseBrowserScreenMetadata
)
}
}
}
)
)
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,23 @@ package com.airbnb.android.showkase.ui
import android.content.Context
import android.content.res.Configuration
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.*
Copy link
Collaborator

Choose a reason for hiding this comment

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

Avoid wildcard imports. Might need to update you Android Studio settings since its probably happening due to default values present locally

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like detekt also flagged this on CI, hence the build failure @marcorighini

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Card
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.ProvideTextStyle
import androidx.compose.material.Text
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowDown
import androidx.compose.material.icons.filled.KeyboardArrowUp
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.platform.*
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.unit.*
import androidx.navigation.NavHostController
import com.airbnb.android.showkase.R
import com.airbnb.android.showkase.models.ShowkaseBrowserComponent
Expand Down Expand Up @@ -181,12 +155,11 @@ private fun RTLComponentCard(metadata: ShowkaseBrowserComponent) {

@Composable
private fun DarkModeComponentCard(metadata: ShowkaseBrowserComponent) {
val customConfiguration = Configuration(LocalConfiguration.current).apply {
val darkModeConfiguration = Configuration(LocalConfiguration.current).apply {
uiMode = Configuration.UI_MODE_NIGHT_YES
}

ComponentCardTitle("${metadata.componentName} [Dark Mode]")
CompositionLocalProvider(LocalConfiguration provides customConfiguration) {
CompositionLocalProvider(LocalConfiguration provides darkModeConfiguration) {
ComponentCard(metadata)
}
}
Expand Down