Konsist: add test to ensure filename match top level Composable View, and fix existing issue

This commit is contained in:
Benoit Marty 2023-10-10 14:37:01 +02:00
parent 675f77bfa4
commit 308a0c0f57
103 changed files with 1137 additions and 760 deletions

View file

@ -26,7 +26,6 @@ import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.remember
@ -138,27 +137,7 @@ fun ElementTheme(
}
}
/**
* Can be used to force a composable in dark theme.
* It will automatically change the system ui colors back to normal when leaving the composition.
*/
@Composable
fun ForcedDarkElementTheme(
lightStatusBar: Boolean = false,
content: @Composable () -> Unit,
) {
val systemUiController = rememberSystemUiController()
val colorScheme = MaterialTheme.colorScheme
val wasDarkTheme = !ElementTheme.colors.isLight
DisposableEffect(Unit) {
onDispose {
systemUiController.applyTheme(colorScheme, wasDarkTheme)
}
}
ElementTheme(darkTheme = true, lightStatusBar = lightStatusBar, content = content)
}
private fun SystemUiController.applyTheme(
internal fun SystemUiController.applyTheme(
colorScheme: ColorScheme,
darkTheme: Boolean,
) {

View file

@ -0,0 +1,42 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.theme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import com.google.accompanist.systemuicontroller.rememberSystemUiController
/**
* Can be used to force a composable in dark theme.
* It will automatically change the system ui colors back to normal when leaving the composition.
*/
@Composable
fun ForcedDarkElementTheme(
lightStatusBar: Boolean = false,
content: @Composable () -> Unit,
) {
val systemUiController = rememberSystemUiController()
val colorScheme = MaterialTheme.colorScheme
val wasDarkTheme = !ElementTheme.colors.isLight
DisposableEffect(Unit) {
onDispose {
systemUiController.applyTheme(colorScheme, wasDarkTheme)
}
}
ElementTheme(darkTheme = true, lightStatusBar = lightStatusBar, content = content)
}

View file

@ -91,7 +91,7 @@ internal val materialColorSchemeDark = darkColorScheme(
@Preview
@Composable
internal fun ColorsSchemePreviewLight() = ColorsSchemePreview(
internal fun ColorsSchemeLightPreview() = ColorsSchemePreview(
Color.Black,
Color.White,
materialColorSchemeLight,
@ -99,7 +99,7 @@ internal fun ColorsSchemePreviewLight() = ColorsSchemePreview(
@Preview
@Composable
internal fun ColorsSchemePreviewDark() = ColorsSchemePreview(
internal fun ColorsSchemeDarkPreview() = ColorsSchemePreview(
Color.White,
Color.Black,
materialColorSchemeDark,