diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index ad396e0..cbc1a67 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -7,9 +7,6 @@ - true } FucksGivenTheme(darkTheme = useDarkColors) { - NavGraph(navController = rememberNavController()) + NavGraph(navController = rememberNavController(), themeSetting = themeSetting) } } } diff --git a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/component/Chart.kt b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/component/Chart.kt index a19fb59..6d796a8 100644 --- a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/component/Chart.kt +++ b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/component/Chart.kt @@ -1,12 +1,15 @@ package rocks.poopjournal.fucksgiven.presentation.component +import android.content.res.Configuration import android.graphics.Typeface import android.view.View import android.view.ViewGroup +import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb @@ -25,12 +28,15 @@ import com.github.mikephil.charting.formatter.IndexAxisValueFormatter import com.github.mikephil.charting.formatter.ValueFormatter import rocks.poopjournal.fucksgiven.R import rocks.poopjournal.fucksgiven.presentation.ui.theme.FuckGreen +import rocks.poopjournal.fucksgiven.presentation.ui.utils.AppTheme +import rocks.poopjournal.fucksgiven.presentation.ui.utils.ThemeSetting import java.util.Locale @Composable fun LineChartComposable( lineDataPoints: List, - xCount : Int + xCount : Int, + themeSetting: ThemeSetting ) { val context1 = LocalContext.current @@ -39,6 +45,7 @@ fun LineChartComposable( } val tf = ResourcesCompat.getFont(context1, R.font.opensans_regular) + val theme = themeSetting.themeFlow.collectAsState() AndroidView( modifier = Modifier .fillMaxWidth() @@ -49,19 +56,37 @@ fun LineChartComposable( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) - setBackgroundColor(Color.White.toArgb()) + xAxis.position = XAxis.XAxisPosition.BOTTOM axisRight.isEnabled = true axisLeft.isEnabled = false - axisRight.textColor = Color.Black.toArgb() - xAxis.textColor = Color.Black.toArgb() legend.isEnabled = false - // Customizing the Line Chart description.isEnabled = false setDrawGridBackground(false) // Data Setup + when (theme.value) { + AppTheme.DARK -> { + axisRight.textColor = Color.White.toArgb() + xAxis.textColor = Color.White.toArgb() + setBackgroundColor(Color.Black.toArgb()) + setGridBackgroundColor(Color.White.toArgb()) + } + AppTheme.LIGHT -> { + axisRight.textColor = Color.Black.toArgb() + xAxis.textColor = Color.Black.toArgb() + setBackgroundColor(Color.White.toArgb()) + setGridBackgroundColor(Color.Black.toArgb()) + + } + AppTheme.FOLLOW_SYSTEM -> { + axisRight.textColor = Color.White.toArgb() + xAxis.textColor = Color.White.toArgb() + setBackgroundColor(Color.Black.toArgb()) + setGridBackgroundColor(Color.White.toArgb()) + } + } val dataSet = LineDataSet(entries, "Label").apply { color = FuckGreen.toArgb() diff --git a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/component/Horizontal Pager.kt b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/component/Horizontal Pager.kt index 385447c..6281629 100644 --- a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/component/Horizontal Pager.kt +++ b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/component/Horizontal Pager.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import rocks.poopjournal.fucksgiven.R +import rocks.poopjournal.fucksgiven.presentation.ui.utils.ThemeSetting import rocks.poopjournal.fucksgiven.presentation.viewmodel.StatsViewModel import java.text.SimpleDateFormat import java.util.Calendar @@ -29,6 +30,7 @@ import java.util.Locale fun HorizontalPagerView( pagerState: PagerState, viewModel: StatsViewModel, + themeSetting: ThemeSetting ) { val weeklyData by viewModel.weeklyData.observeAsState(emptyList()) @@ -197,7 +199,8 @@ fun HorizontalPagerView( LineChartComposable( lineDataPoints = weeklyLineDataPoints, - xCount = weeklyLineDataPoints.size + xCount = weeklyLineDataPoints.size, + themeSetting = themeSetting ) } } @@ -230,7 +233,7 @@ fun HorizontalPagerView( modifier = Modifier.padding(end = 3.dp, bottom = 5.dp, start = 10.dp), style = MaterialTheme.typography.bodyLarge ) - LineChartComposable(lineDataPoints = monthlyLineDataPoints, xCount = 6) + LineChartComposable(lineDataPoints = monthlyLineDataPoints, xCount = 6, themeSetting = themeSetting) } } @@ -264,7 +267,8 @@ fun HorizontalPagerView( ) LineChartComposable( lineDataPoints = yearlyLineDataPoints, - xCount = yearlyLineDataPoints.size + xCount = yearlyLineDataPoints.size, + themeSetting = themeSetting ) } } diff --git a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/navigation/NavGraph.kt b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/navigation/NavGraph.kt index ab405db..42dc87d 100644 --- a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/navigation/NavGraph.kt +++ b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/navigation/NavGraph.kt @@ -12,12 +12,13 @@ import rocks.poopjournal.fucksgiven.presentation.viewmodel.HomeViewModel import rocks.poopjournal.fucksgiven.presentation.screens.HomeScreen import rocks.poopjournal.fucksgiven.presentation.screens.SettingScreen import rocks.poopjournal.fucksgiven.presentation.screens.StatsScreen +import rocks.poopjournal.fucksgiven.presentation.ui.utils.ThemeSetting import rocks.poopjournal.fucksgiven.presentation.viewmodel.SettingsViewModel import rocks.poopjournal.fucksgiven.presentation.viewmodel.StatsViewModel @RequiresApi(Build.VERSION_CODES.P) @Composable -fun NavGraph(navController: NavHostController){ +fun NavGraph(navController: NavHostController,themeSetting: ThemeSetting){ val viewModel : HomeViewModel = hiltViewModel() val statsViewModel : StatsViewModel = hiltViewModel() val settingsViewModel : SettingsViewModel = hiltViewModel() @@ -27,7 +28,7 @@ fun NavGraph(navController: NavHostController){ HomeScreen(navController,viewModel) } composable(route = STATS_SCREEN){ - StatsScreen(navController = navController, viewModel = statsViewModel) + StatsScreen(navController = navController, viewModel = statsViewModel,themeSetting) } composable(route = ABOUT_SCREEN){ diff --git a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/screens/StatsScreen.kt b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/screens/StatsScreen.kt index 3997d9a..d8bd71c 100644 --- a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/screens/StatsScreen.kt +++ b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/screens/StatsScreen.kt @@ -36,11 +36,12 @@ import rocks.poopjournal.fucksgiven.presentation.component.AppBar import rocks.poopjournal.fucksgiven.presentation.component.BottomBar import rocks.poopjournal.fucksgiven.presentation.component.BottomNavBar import rocks.poopjournal.fucksgiven.presentation.component.HorizontalPagerView +import rocks.poopjournal.fucksgiven.presentation.ui.utils.ThemeSetting import rocks.poopjournal.fucksgiven.presentation.viewmodel.StatsViewModel @OptIn(ExperimentalFoundationApi::class) @Composable -fun StatsScreen(navController: NavHostController, viewModel: StatsViewModel) { +fun StatsScreen(navController: NavHostController, viewModel: StatsViewModel,themeSetting: ThemeSetting) { val scope = rememberCoroutineScope() val pager = rememberPagerState(pageCount = { 3 @@ -138,7 +139,8 @@ fun StatsScreen(navController: NavHostController, viewModel: StatsViewModel) { HorizontalPagerView( pagerState = pager, - viewModel = viewModel + viewModel = viewModel, + themeSetting = themeSetting ) } } diff --git a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/ui/theme/Color.kt b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/ui/theme/Color.kt index 8f926c2..f879807 100644 --- a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/ui/theme/Color.kt +++ b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/ui/theme/Color.kt @@ -12,4 +12,6 @@ val Pink40 = Color(0xFF7D5260) val FuckGreen = Color(0xFF29A331) val FuckSecondary = Color(0xFFEEF8EF) -val WatchGrey = Color(0xFFC8C8D0) \ No newline at end of file +val WatchGrey = Color(0xFFC8C8D0) +val FuckSecondaryDark = Color(0xFF50CE58).copy(alpha = 0.4f) +val FuckGreenDark = Color(0xFF50CE58) \ No newline at end of file diff --git a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/ui/theme/Theme.kt b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/ui/theme/Theme.kt index 548d5dd..a35636b 100644 --- a/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/ui/theme/Theme.kt +++ b/android/app/src/main/java/rocks/poopjournal/fucksgiven/presentation/ui/theme/Theme.kt @@ -13,8 +13,8 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext val DarkColorScheme = darkColorScheme( - primary = FuckGreen, - secondary = FuckSecondary, + primary = FuckGreenDark, + secondary = FuckSecondaryDark, tertiary = Pink80, background = Color.Black, onBackground = Color.White, diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index 8ed72d0..87900b9 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -agp = "8.6.0" +agp = "8.5.2" kotlin = "1.9.0" coreKtx = "1.10.1" junit = "4.13.2"