Improves Preview Utilities

This commit is contained in:
Vitor Pamplona
2024-03-09 11:32:08 -05:00
parent dd81c51fab
commit 0f69030cdf
10 changed files with 49 additions and 124 deletions
@@ -57,10 +57,7 @@ import com.vitorpamplona.amethyst.ui.theme.placeholderText
@Composable @Composable
@Preview @Preview
fun LeftPictureLayoutPreview() { fun LeftPictureLayoutPreview() {
ThemeComparisonColumn( ThemeComparisonColumn { LeftPictureLayoutPreviewCard() }
onDark = { LeftPictureLayoutPreviewCard() },
onLight = { LeftPictureLayoutPreviewCard() },
)
} }
@Composable @Composable
@@ -54,10 +54,7 @@ import kotlinx.collections.immutable.persistentSetOf
@Composable @Composable
@Preview @Preview
fun BlankNotePreview() { fun BlankNotePreview() {
ThemeComparisonColumn( ThemeComparisonColumn { BlankNote() }
onDark = { BlankNote() },
onLight = { BlankNote() },
)
} }
@Composable @Composable
@@ -106,15 +103,7 @@ fun HiddenNotePreview() {
val nav: (String) -> Unit = {} val nav: (String) -> Unit = {}
ThemeComparisonColumn( ThemeComparisonColumn(
onDark = { toPreview = {
HiddenNote(
reports = persistentSetOf<Note>(),
isHiddenAuthor = true,
accountViewModel = accountViewModel,
nav = nav,
) {}
},
onLight = {
HiddenNote( HiddenNote(
reports = persistentSetOf<Note>(), reports = persistentSetOf<Note>(),
isHiddenAuthor = true, isHiddenAuthor = true,
@@ -194,8 +183,7 @@ fun HiddenNote(
@Composable @Composable
fun HiddenNoteByMePreview() { fun HiddenNoteByMePreview() {
ThemeComparisonColumn( ThemeComparisonColumn(
onDark = { HiddenNoteByMe {} }, toPreview = { HiddenNoteByMe {} },
onLight = { HiddenNoteByMe {} },
) )
} }
@@ -186,22 +186,13 @@ fun ZapTheDevsCardPreview() {
accountViewModel, accountViewModel,
) { releaseNote -> ) { releaseNote ->
if (releaseNote != null) { if (releaseNote != null) {
ThemeComparisonColumn( ThemeComparisonColumn {
onDark = { ZapTheDevsCard(
ZapTheDevsCard( releaseNote,
releaseNote, accountViewModel,
accountViewModel, nav = {},
nav = {}, )
) }
},
onLight = {
ZapTheDevsCard(
releaseNote,
accountViewModel,
nav = {},
)
},
)
} }
} }
} }
@@ -40,34 +40,19 @@ import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
@Composable @Composable
@Preview @Preview
fun AddButtonPreview() { fun AddButtonPreview() {
ThemeComparisonColumn( ThemeComparisonColumn {
onDark = { Row {
Row { Column {
Column { AddButton(isActive = true) {}
AddButton(isActive = true) {} AddButton(isActive = false) {}
AddButton(isActive = false) {}
}
Column {
RemoveButton(isActive = true) {}
RemoveButton(isActive = false) {}
}
} }
},
onLight = {
Row {
Column {
AddButton(isActive = true) {}
AddButton(isActive = false) {}
}
Column { Column {
RemoveButton(isActive = true) {} RemoveButton(isActive = true) {}
RemoveButton(isActive = false) {} RemoveButton(isActive = false) {}
}
} }
}, }
) }
} }
@Composable @Composable
@@ -34,8 +34,7 @@ import com.vitorpamplona.amethyst.ui.theme.lessImportantLink
@Preview @Preview
fun DisplayPoWPreview() { fun DisplayPoWPreview() {
ThemeComparisonColumn( ThemeComparisonColumn(
onDark = { DisplayPoW(pow = 24) }, toPreview = { DisplayPoW(pow = 24) },
onLight = { DisplayPoW(pow = 24) },
) )
} }
@@ -872,48 +872,26 @@ private fun RenderWikiHeaderForThreadPreview() {
} }
LoadNote(baseNoteHex = "277f982a4cd3f67cc47ad9282176acabee1713848f547d6021e0c155572078e1", accountViewModel = accountViewModel) { baseNote -> LoadNote(baseNoteHex = "277f982a4cd3f67cc47ad9282176acabee1713848f547d6021e0c155572078e1", accountViewModel = accountViewModel) { baseNote ->
ThemeComparisonColumn( ThemeComparisonColumn {
onDark = { val bg = MaterialTheme.colorScheme.background
val bg = MaterialTheme.colorScheme.background val backgroundColor =
val backgroundColor = remember {
remember { mutableStateOf(bg)
mutableStateOf(bg)
}
Column {
RenderWikiHeaderForThread(noteEvent = event, accountViewModel = accountViewModel, nav)
RenderTextEvent(
baseNote!!,
false,
true,
backgroundColor,
editState,
accountViewModel,
nav,
)
} }
},
onLight = {
val bg = MaterialTheme.colorScheme.background
val backgroundColor =
remember {
mutableStateOf(bg)
}
Column { Column {
RenderWikiHeaderForThread(noteEvent = event, accountViewModel = accountViewModel, nav) RenderWikiHeaderForThread(noteEvent = event, accountViewModel = accountViewModel, nav)
RenderTextEvent( RenderTextEvent(
baseNote!!, baseNote!!,
false, false,
true, true,
backgroundColor, backgroundColor,
editState, editState,
accountViewModel, accountViewModel,
nav, nav,
) )
} }
}, }
)
} }
} }
@@ -228,8 +228,7 @@ fun HomeFeeds(
@Composable @Composable
fun HomeFeedEmptyPreview() { fun HomeFeedEmptyPreview() {
ThemeComparisonRow( ThemeComparisonRow(
onDark = { HomeFeedEmpty {} }, toPreview = { HomeFeedEmpty {} },
onLight = { HomeFeedEmpty {} },
) )
} }
@@ -115,10 +115,7 @@ fun LoginPage() {
val accountViewModel: AccountStateViewModel = viewModel() val accountViewModel: AccountStateViewModel = viewModel()
ThemeComparisonRow( ThemeComparisonRow(
onDark = { toPreview = {
LoginPage(accountViewModel, true) {}
},
onLight = {
LoginPage(accountViewModel, true) {} LoginPage(accountViewModel, true) {}
}, },
) )
@@ -83,10 +83,7 @@ fun SignUpPage() {
val accountViewModel: AccountStateViewModel = viewModel() val accountViewModel: AccountStateViewModel = viewModel()
ThemeComparisonRow( ThemeComparisonRow(
onDark = { toPreview = {
SignUpPage(accountViewModel) {}
},
onLight = {
SignUpPage(accountViewModel) {} SignUpPage(accountViewModel) {}
}, },
) )
@@ -451,16 +451,13 @@ fun AmethystTheme(
} }
@Composable @Composable
fun ThemeComparisonColumn( fun ThemeComparisonColumn(toPreview: @Composable () -> Unit) {
onDark: @Composable () -> Unit,
onLight: @Composable () -> Unit,
) {
Column { Column {
Box { Box {
val darkTheme: SharedPreferencesViewModel = viewModel() val darkTheme: SharedPreferencesViewModel = viewModel()
darkTheme.updateTheme(ThemeType.DARK) darkTheme.updateTheme(ThemeType.DARK)
AmethystTheme(darkTheme) { AmethystTheme(darkTheme) {
Surface(color = MaterialTheme.colorScheme.background) { onDark() } Surface(color = MaterialTheme.colorScheme.background) { toPreview() }
} }
} }
@@ -468,23 +465,20 @@ fun ThemeComparisonColumn(
val lightTheme: SharedPreferencesViewModel = viewModel() val lightTheme: SharedPreferencesViewModel = viewModel()
lightTheme.updateTheme(ThemeType.LIGHT) lightTheme.updateTheme(ThemeType.LIGHT)
AmethystTheme(lightTheme) { AmethystTheme(lightTheme) {
Surface(color = MaterialTheme.colorScheme.background) { onLight() } Surface(color = MaterialTheme.colorScheme.background) { toPreview() }
} }
} }
} }
} }
@Composable @Composable
fun ThemeComparisonRow( fun ThemeComparisonRow(toPreview: @Composable () -> Unit) {
onDark: @Composable () -> Unit,
onLight: @Composable () -> Unit,
) {
Row { Row {
Box(modifier = Modifier.weight(1f)) { Box(modifier = Modifier.weight(1f)) {
val darkTheme: SharedPreferencesViewModel = viewModel() val darkTheme: SharedPreferencesViewModel = viewModel()
darkTheme.updateTheme(ThemeType.DARK) darkTheme.updateTheme(ThemeType.DARK)
AmethystTheme(darkTheme) { AmethystTheme(darkTheme) {
Surface(color = MaterialTheme.colorScheme.background) { onDark() } Surface(color = MaterialTheme.colorScheme.background) { toPreview() }
} }
} }
@@ -492,7 +486,7 @@ fun ThemeComparisonRow(
val lightTheme: SharedPreferencesViewModel = viewModel() val lightTheme: SharedPreferencesViewModel = viewModel()
lightTheme.updateTheme(ThemeType.LIGHT) lightTheme.updateTheme(ThemeType.LIGHT)
AmethystTheme(lightTheme) { AmethystTheme(lightTheme) {
Surface(color = MaterialTheme.colorScheme.background) { onLight() } Surface(color = MaterialTheme.colorScheme.background) { toPreview() }
} }
} }
} }