Skip to content

Commit

Permalink
Merge pull request #110 from mubeen1519/work
Browse files Browse the repository at this point in the history
fix dark mode color and remove permission
  • Loading branch information
CrazyMarvin authored Sep 16, 2024
2 parents 33d8b49 + 52c26b1 commit 3582871
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 20 deletions.
3 changes: 0 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />

<application
android:name=".FucksGivenApplication"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MainActivity : ComponentActivity() {
AppTheme.DARK -> true
}
FucksGivenTheme(darkTheme = useDarkColors) {
NavGraph(navController = rememberNavController())
NavGraph(navController = rememberNavController(), themeSetting = themeSetting)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<LineDataPoint>,
xCount : Int
xCount : Int,
themeSetting: ThemeSetting

) {
val context1 = LocalContext.current
Expand All @@ -39,6 +45,7 @@ fun LineChartComposable(
}

val tf = ResourcesCompat.getFont(context1, R.font.opensans_regular)
val theme = themeSetting.themeFlow.collectAsState()
AndroidView(
modifier = Modifier
.fillMaxWidth()
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,6 +30,7 @@ import java.util.Locale
fun HorizontalPagerView(
pagerState: PagerState,
viewModel: StatsViewModel,
themeSetting: ThemeSetting

) {
val weeklyData by viewModel.weeklyData.observeAsState(emptyList())
Expand Down Expand Up @@ -197,7 +199,8 @@ fun HorizontalPagerView(

LineChartComposable(
lineDataPoints = weeklyLineDataPoints,
xCount = weeklyLineDataPoints.size
xCount = weeklyLineDataPoints.size,
themeSetting = themeSetting
)
}
}
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -264,7 +267,8 @@ fun HorizontalPagerView(
)
LineChartComposable(
lineDataPoints = yearlyLineDataPoints,
xCount = yearlyLineDataPoints.size
xCount = yearlyLineDataPoints.size,
themeSetting = themeSetting
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -138,7 +139,8 @@ fun StatsScreen(navController: NavHostController, viewModel: StatsViewModel) {

HorizontalPagerView(
pagerState = pager,
viewModel = viewModel
viewModel = viewModel,
themeSetting = themeSetting
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ val Pink40 = Color(0xFF7D5260)

val FuckGreen = Color(0xFF29A331)
val FuckSecondary = Color(0xFFEEF8EF)
val WatchGrey = Color(0xFFC8C8D0)
val WatchGrey = Color(0xFFC8C8D0)
val FuckSecondaryDark = Color(0xFF50CE58).copy(alpha = 0.4f)
val FuckGreenDark = Color(0xFF50CE58)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 3582871

Please sign in to comment.