@@ -42,57 +42,56 @@ import kotlinx.coroutines.launch
4242import java.time.MonthDay
4343import kotlin.time.Duration
4444
45- private val hideWinterEasterEgg = booleanPreferencesKey(" hideWinterEasterEgg" )
45+ private val hideSnowfall = booleanPreferencesKey(" hideWinterEasterEgg" )
4646
47- fun Context.hideWinterEasterEggFlow (): Flow <Boolean > = dataStore.data.map { it[hideWinterEasterEgg ] ? : false }
48- suspend fun Context.hideWinterEasterEgg (hide : Boolean ) {
47+ fun Context.hideSnowfall (): Flow <Boolean > = dataStore.data.map { it[hideSnowfall ] ? : false }
48+ suspend fun Context.hideSnowfall (hide : Boolean ) {
4949 // save setting
50- dataStore.edit { it[hideWinterEasterEgg ] = hide }
50+ dataStore.edit { it[hideSnowfall ] = hide }
5151}
5252
5353/* *
54- * Determines whether the winter easter egg should be displayed.
54+ * Determines whether snowfall ( the winter easter egg) should be displayed.
5555 *
56- * It is displayed from December 20th to December 31st.
56+ * It is active from December 20th to December 31st.
5757 */
58- fun displayWinterEasterEgg (): Boolean {
59- // return true // Uncomment for testing
58+ fun inSnowySeason (): Boolean {
6059 val now = MonthDay .now()
6160 return now >= MonthDay .of(12 , 20 ) && now <= MonthDay .of(12 , 31 )
6261}
6362
6463@Composable
6564fun WinterEasterEggToggleButton () {
66- val shouldDisplay = remember { displayWinterEasterEgg () }
67- if (! shouldDisplay ) return
65+ val inSnowySeason = remember { inSnowySeason () }
66+ if (! inSnowySeason ) return
6867
6968 val context = LocalContext .current
7069 val scope = rememberCoroutineScope()
7170
72- val easterEggDisabled by context.hideWinterEasterEggFlow ().collectAsState(false )
71+ val snowfallDisabled by context.hideSnowfall ().collectAsState(false )
7372
7473 IconButton (
7574 onClick = {
7675 scope.launch(Dispatchers .IO ) {
77- context.hideWinterEasterEgg( ! easterEggDisabled )
76+ context.hideSnowfall( ! snowfallDisabled )
7877 }
7978 }
8079 ) {
8180 Icon (
82- if (easterEggDisabled ) Icons .Rounded .AcUnit else Icons .Rounded .ModeCoolOff ,
83- stringResource(if (easterEggDisabled ) R .string.winter_easter_egg_enable else R .string.winter_easter_egg_disable )
81+ if (snowfallDisabled ) Icons .Rounded .AcUnit else Icons .Rounded .ModeCoolOff ,
82+ stringResource(if (snowfallDisabled ) R .string.snowfall_enable else R .string.snowfall_disable )
8483 )
8584 }
8685}
8786
8887@Composable
8988fun WinterEasterEgg () {
90- val shouldDisplay = remember { displayWinterEasterEgg () }
89+ val shouldDisplay = remember { inSnowySeason () }
9190 if (! shouldDisplay) return
9291
9392 val context = LocalContext .current
94- val easterEggDisabled by context.hideWinterEasterEggFlow ().collectAsState(false )
95- if (easterEggDisabled ) return
93+ val snowfallDisabled by context.hideSnowfall ().collectAsState(false )
94+ if (snowfallDisabled ) return
9695
9796 ConfettiKit (
9897 modifier = Modifier
0 commit comments