diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt index 666757574..645a61cc7 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/NotificationScreen.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.padding import androidx.compose.material.Divider +import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -56,6 +57,7 @@ import com.vitorpamplona.amethyst.ui.screen.RefresheableCardView import com.vitorpamplona.amethyst.ui.screen.ScrollStateKeys import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange import com.vitorpamplona.amethyst.ui.theme.RoyalBlue +import com.vitorpamplona.amethyst.ui.theme.chartStyle import java.math.BigDecimal import java.math.RoundingMode import java.text.DecimalFormat @@ -192,26 +194,10 @@ fun SummaryBar(model: UserReactionsViewModel) { .padding(vertical = 10.dp, horizontal = 20.dp) .clickable(onClick = { showChart = !showChart }) ) { - ProvideChartStyle() { - val axisModel by model.axisLabels.collectAsState() - val chartModel by model.chartModel.collectAsState() - chartModel?.let { - Chart( - chart = remember(lineChartCount, lineChartZaps) { - lineChartCount.plus(lineChartZaps) - }, - model = it, - startAxis = startAxis( - valueFormatter = CountAxisValueFormatter() - ), - endAxis = endAxis( - valueFormatter = AmountAxisValueFormatter() - ), - bottomAxis = bottomAxis( - valueFormatter = LabelValueFormatter(axisModel) - ) - ) - } + ProvideChartStyle( + chartStyle = MaterialTheme.colors.chartStyle + ) { + ObserveAndShowChart(model, lineChartCount, lineChartZaps) } } } @@ -221,6 +207,33 @@ fun SummaryBar(model: UserReactionsViewModel) { ) } +@Composable +private fun ObserveAndShowChart( + model: UserReactionsViewModel, + lineChartCount: LineChart, + lineChartZaps: LineChart +) { + val axisModel by model.axisLabels.collectAsState() + val chartModel by model.chartModel.collectAsState() + chartModel?.let { + Chart( + chart = remember(lineChartCount, lineChartZaps) { + lineChartCount.plus(lineChartZaps) + }, + model = it, + startAxis = startAxis( + valueFormatter = CountAxisValueFormatter() + ), + endAxis = endAxis( + valueFormatter = AmountAxisValueFormatter() + ), + bottomAxis = bottomAxis( + valueFormatter = LabelValueFormatter(axisModel) + ) + ) + } +} + @Stable class LabelValueFormatter(val axisLabels: List) : AxisValueFormatter { override fun formatValue( diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt index 0f8e61333..42a6331c6 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt @@ -28,6 +28,8 @@ import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp import com.halilibo.richtext.ui.RichTextStyle import com.halilibo.richtext.ui.resolveDefaults +import com.patrykandpatrick.vico.compose.style.ChartStyle +import com.patrykandpatrick.vico.core.DefaultColors import com.vitorpamplona.amethyst.ui.screen.ThemeViewModel private val DarkColorPalette = darkColors( @@ -302,6 +304,22 @@ val Colors.replyModifier: Modifier val Colors.innerPostModifier: Modifier get() = if (isLight) LightInnerPostBorderModifier else DarkInnerPostBorderModifier +val Colors.chartStyle: ChartStyle + get() { + val defaultColors = if (isLight) DefaultColors.Light else DefaultColors.Dark + return ChartStyle.fromColors( + axisLabelColor = Color(defaultColors.axisLabelColor), + axisGuidelineColor = Color(defaultColors.axisGuidelineColor), + axisLineColor = Color(defaultColors.axisLineColor), + entityColors = listOf( + defaultColors.entity1Color, + defaultColors.entity2Color, + defaultColors.entity3Color + ).map(::Color), + elevationOverlayColor = Color(defaultColors.elevationOverlayColor) + ) + } + @Composable fun AmethystTheme(themeViewModel: ThemeViewModel, content: @Composable () -> Unit) { val theme = themeViewModel.theme.observeAsState()