diff --git a/app/src/main/java/com/starry/greenstash/ui/screens/settings/SettingsViewModel.kt b/app/src/main/java/com/starry/greenstash/ui/screens/settings/SettingsViewModel.kt index 2835da90..d56a611b 100644 --- a/app/src/main/java/com/starry/greenstash/ui/screens/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/starry/greenstash/ui/screens/settings/SettingsViewModel.kt @@ -36,10 +36,21 @@ import com.starry.greenstash.utils.PreferenceUtil import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject +/** + * Enum class for the theme mode of the app. + * [ThemeMode.Light] - Light theme + * [ThemeMode.Dark] - Dark theme + * [ThemeMode.Auto] - Follow system theme + */ enum class ThemeMode { Light, Dark, Auto } +/** + * Sealed class for the date style of the app. + * [DateStyle.DateMonthYear] - Date in the format dd/MM/yyyy + * [DateStyle.YearMonthDate] - Date in the format yyyy/MM/dd + */ sealed class DateStyle(val pattern: String) { data object DateMonthYear : DateStyle("dd/MM/yyyy") data object YearMonthDate : DateStyle("yyyy/MM/dd") @@ -118,6 +129,12 @@ class SettingsViewModel @Inject constructor( PreferenceUtil.APP_LOCK_BOOL, false ) + /** + * Get the current theme of the app, regardless of the system theme. + * This will always return either [ThemeMode.Light] or [ThemeMode.Dark]. + * If user has set the theme to Auto it will return the system theme, + * again Light or Dark instead of [ThemeMode.Auto]. + */ @Composable fun getCurrentTheme(): ThemeMode { return if (theme.value == ThemeMode.Auto) { diff --git a/app/src/main/java/com/starry/greenstash/widget/configuration/WidgetConfigActivity.kt b/app/src/main/java/com/starry/greenstash/widget/configuration/WidgetConfigActivity.kt index b70f640f..8ed43bd3 100644 --- a/app/src/main/java/com/starry/greenstash/widget/configuration/WidgetConfigActivity.kt +++ b/app/src/main/java/com/starry/greenstash/widget/configuration/WidgetConfigActivity.kt @@ -91,9 +91,11 @@ import com.starry.greenstash.ui.screens.settings.ThemeMode import com.starry.greenstash.ui.theme.GreenStashTheme import com.starry.greenstash.ui.theme.greenstashFont import com.starry.greenstash.widget.GoalWidget +import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.delay +@AndroidEntryPoint class WidgetConfigActivity : AppCompatActivity() { private val viewModel: WidgetConfigViewModel by viewModels()