mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 22:38:25 +00:00
Cleanup Themes
This commit is contained in:
parent
b26c98af68
commit
821327569e
@ -43,6 +43,7 @@ import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@ -73,7 +74,8 @@ import org.thoughtcrime.securesms.ui.CellWithPaddingAndMargin
|
||||
import org.thoughtcrime.securesms.ui.Divider
|
||||
import org.thoughtcrime.securesms.ui.HorizontalPagerIndicator
|
||||
import org.thoughtcrime.securesms.ui.ItemButton
|
||||
import org.thoughtcrime.securesms.ui.Theme
|
||||
import org.thoughtcrime.securesms.ui.PreviewTheme
|
||||
import org.thoughtcrime.securesms.ui.ThemeResPreviewParameterProvider
|
||||
import org.thoughtcrime.securesms.ui.blackAlpha40
|
||||
import org.thoughtcrime.securesms.ui.colorDestructive
|
||||
import org.thoughtcrime.securesms.ui.destructiveButtonColors
|
||||
@ -352,8 +354,10 @@ fun ExpandButton(modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewFileDetails() {
|
||||
Theme(R.style.Ocean_Dark) {
|
||||
fun PreviewFileDetails(
|
||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
||||
) {
|
||||
PreviewTheme(themeResId) {
|
||||
FileDetails(
|
||||
fileDetails = listOf(
|
||||
TitledText("File Id:", "Screen Shot 2023-07-06 at 11.35.50 am.png"),
|
||||
@ -365,6 +369,16 @@ fun PreviewFileDetails() {
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewMessageDetails(
|
||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
||||
) {
|
||||
PreviewTheme(themeResId) {
|
||||
PreviewMessageDetails()
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun FileDetails(attachments: List<Attachment>, pagerState: PagerState) {
|
||||
|
@ -23,16 +23,14 @@ import org.thoughtcrime.securesms.conversation.v2.PreviewMessageDetails
|
||||
|
||||
val LocalExtraColors = staticCompositionLocalOf<ExtraColors> { error("No Custom Attribute value provided") }
|
||||
|
||||
|
||||
data class ExtraColors(
|
||||
val settingsBackground: Color,
|
||||
)
|
||||
|
||||
fun Context.getColorFromTheme(@AttrRes attr: Int, defaultValue: Int = 0x0): Color = try {
|
||||
MaterialColors.getColor(this, attr, defaultValue).let(::Color)
|
||||
} catch (e: Exception) {
|
||||
colorDestructive
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts current Theme to Compose Theme.
|
||||
*/
|
||||
@Composable
|
||||
fun AppTheme(
|
||||
content: @Composable () -> Unit
|
||||
@ -50,25 +48,24 @@ fun AppTheme(
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewMessageDetails(
|
||||
@PreviewParameter(ThemeResPreviewParameterProvider::class) themeResId: Int
|
||||
) {
|
||||
Theme(themeResId) {
|
||||
Box(modifier = Modifier.background(color = MaterialTheme.colors.background)) {
|
||||
PreviewMessageDetails()
|
||||
}
|
||||
}
|
||||
}
|
||||
fun Context.getColorFromTheme(@AttrRes attr: Int, defaultValue: Int = 0x0): Color =
|
||||
MaterialColors.getColor(this, attr, defaultValue).let(::Color)
|
||||
|
||||
/**
|
||||
* Set the theme and a background for Compose Previews.
|
||||
*/
|
||||
@Composable
|
||||
fun Theme(@StyleRes themeResId: Int, content: @Composable () -> Unit) {
|
||||
fun PreviewTheme(
|
||||
themeResId: Int,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
CompositionLocalProvider(
|
||||
LocalContext provides ContextThemeWrapper(LocalContext.current, themeResId)
|
||||
) {
|
||||
AppTheme {
|
||||
content()
|
||||
Box(modifier = Modifier.background(color = MaterialTheme.colors.background)) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user