Skip to content

Commit

Permalink
Fix crash on widget configuration
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam committed Apr 8, 2024
1 parent bf2d975 commit a1bf5dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a1bf5dd

Please sign in to comment.