@@ -92,6 +92,8 @@ import com.sameerasw.essentials.ui.components.sheets.AddRepoBottomSheet
9292import com.sameerasw.essentials.ui.components.sheets.GitHubAuthSheet
9393import com.sameerasw.essentials.ui.components.sheets.InstructionsBottomSheet
9494import com.sameerasw.essentials.ui.components.sheets.UpdateBottomSheet
95+ import com.sameerasw.essentials.ui.components.menus.SegmentedDropdownMenu
96+ import com.sameerasw.essentials.ui.components.menus.SegmentedDropdownMenuItem
9597import com.sameerasw.essentials.ui.composables.DIYScreen
9698import com.sameerasw.essentials.ui.composables.FreezeGridUI
9799import com.sameerasw.essentials.ui.composables.SetupFeatures
@@ -233,6 +235,7 @@ class MainActivity : FragmentActivity() {
233235 val updateInfo by viewModel.updateInfo
234236
235237 var showGitHubAuthSheet by remember { mutableStateOf(false ) }
238+ var showNewAutomationSheet by remember { mutableStateOf(false ) }
236239 val gitHubToken by viewModel.gitHubToken
237240 val gitHubUser by gitHubAuthViewModel.currentUser
238241
@@ -426,8 +429,8 @@ class MainActivity : FragmentActivity() {
426429 subtitle = currentTab.subtitle,
427430 hasBack = false ,
428431 hasSearch = true ,
429- hasSettings = true ,
430- hasHelp = currentTab != DIYTabs .APPS ,
432+ hasSettings = currentTab == DIYTabs . ESSENTIALS || currentTab == DIYTabs . FREEZE ,
433+ hasHelp = currentTab == DIYTabs .ESSENTIALS ,
431434 helpIconRes = R .drawable.rounded_help_24,
432435 helpContentDescription = R .string.action_help_guide,
433436 onSearchClick = { searchRequested = true },
@@ -453,32 +456,136 @@ class MainActivity : FragmentActivity() {
453456 showInstructionsSheet = true
454457 },
455458 actions = {
456- if (currentTab == DIYTabs .APPS ) {
457- IconButton (
458- onClick = {
459- HapticUtil .performVirtualKeyHaptic(view)
460- updatesViewModel.checkForUpdates(context)
461- },
462- enabled = refreshingRepoIds.isEmpty(),
463- colors = IconButtonDefaults .iconButtonColors(
464- containerColor = MaterialTheme .colorScheme.surfaceBright
465- ),
466- modifier = Modifier .size(40 .dp)
467- ) {
468- if (refreshingRepoIds.isNotEmpty()) {
469- CircularWavyProgressIndicator (
470- progress = { animatedProgress },
471- modifier = Modifier .size(24 .dp)
459+ when (currentTab) {
460+ DIYTabs .FREEZE -> {
461+ var showFreezeMenu by remember { mutableStateOf(false ) }
462+ Box {
463+ IconButton (
464+ onClick = {
465+ HapticUtil .performVirtualKeyHaptic(view)
466+ showFreezeMenu = true
467+ },
468+ colors = IconButtonDefaults .iconButtonColors(
469+ containerColor = MaterialTheme .colorScheme.surfaceBright
470+ )
471+ ) {
472+ Icon (
473+ painter = painterResource(id = R .drawable.rounded_mode_cool_24),
474+ contentDescription = stringResource(R .string.tab_freeze)
475+ )
476+ }
477+
478+ SegmentedDropdownMenu (
479+ expanded = showFreezeMenu,
480+ onDismissRequest = { showFreezeMenu = false }
481+ ) {
482+ SegmentedDropdownMenuItem (
483+ text = { Text (stringResource(R .string.action_freeze_all)) },
484+ onClick = {
485+ showFreezeMenu = false
486+ viewModel.freezeAllApps(context)
487+ },
488+ leadingIcon = {
489+ Icon (
490+ painter = painterResource(id = R .drawable.rounded_mode_cool_24),
491+ contentDescription = null
492+ )
493+ }
494+ )
495+ SegmentedDropdownMenuItem (
496+ text = { Text (stringResource(R .string.action_unfreeze_all)) },
497+ onClick = {
498+ showFreezeMenu = false
499+ viewModel.unfreezeAllApps(context)
500+ },
501+ leadingIcon = {
502+ Icon (
503+ painter = painterResource(id = R .drawable.rounded_mode_cool_off_24),
504+ contentDescription = null
505+ )
506+ }
507+ )
508+ SegmentedDropdownMenuItem (
509+ text = { Text (" Freeze Automatic" ) },
510+ onClick = {
511+ showFreezeMenu = false
512+ viewModel.freezeAutomaticApps(context)
513+ },
514+ leadingIcon = {
515+ Icon (
516+ painter = painterResource(id = R .drawable.rounded_nest_farsight_cool_24),
517+ contentDescription = null
518+ )
519+ }
520+ )
521+ }
522+ }
523+ Spacer (modifier = Modifier .width(8 .dp))
524+ }
525+
526+ DIYTabs .DIY -> {
527+ IconButton (
528+ onClick = {
529+ HapticUtil .performVirtualKeyHaptic(view)
530+ showNewAutomationSheet = true
531+ },
532+ colors = IconButtonDefaults .iconButtonColors(
533+ containerColor = MaterialTheme .colorScheme.surfaceBright
472534 )
473- } else {
535+ ) {
536+ Icon (
537+ painter = painterResource(id = R .drawable.rounded_add_24),
538+ contentDescription = stringResource(R .string.diy_editor_new_title)
539+ )
540+ }
541+ Spacer (modifier = Modifier .width(8 .dp))
542+ }
543+
544+ DIYTabs .APPS -> {
545+ IconButton (
546+ onClick = {
547+ HapticUtil .performVirtualKeyHaptic(view)
548+ showAddRepoSheet = true
549+ },
550+ colors = IconButtonDefaults .iconButtonColors(
551+ containerColor = MaterialTheme .colorScheme.surfaceBright
552+ )
553+ ) {
474554 Icon (
475- painter = painterResource(id = R .drawable.rounded_refresh_24),
476- contentDescription = stringResource(R .string.action_refresh),
477- modifier = Modifier .size(24 .dp)
555+ painter = painterResource(id = R .drawable.rounded_add_24),
556+ contentDescription = stringResource(R .string.action_add_repo)
478557 )
479558 }
559+ Spacer (modifier = Modifier .width(8 .dp))
560+
561+ IconButton (
562+ onClick = {
563+ HapticUtil .performVirtualKeyHaptic(view)
564+ updatesViewModel.checkForUpdates(context)
565+ },
566+ enabled = refreshingRepoIds.isEmpty(),
567+ colors = IconButtonDefaults .iconButtonColors(
568+ containerColor = MaterialTheme .colorScheme.surfaceBright
569+ ),
570+ modifier = Modifier .size(40 .dp)
571+ ) {
572+ if (refreshingRepoIds.isNotEmpty()) {
573+ CircularWavyProgressIndicator (
574+ progress = { animatedProgress },
575+ modifier = Modifier .size(24 .dp)
576+ )
577+ } else {
578+ Icon (
579+ painter = painterResource(id = R .drawable.rounded_refresh_24),
580+ contentDescription = stringResource(R .string.action_refresh),
581+ modifier = Modifier .size(24 .dp)
582+ )
583+ }
584+ }
585+ Spacer (modifier = Modifier .width(8 .dp))
480586 }
481- Spacer (modifier = Modifier .width(8 .dp))
587+
588+ else -> {}
482589 }
483590 },
484591 hasUpdateAvailable = isUpdateAvailable,
@@ -545,7 +652,9 @@ class MainActivity : FragmentActivity() {
545652
546653 DIYTabs .DIY -> {
547654 DIYScreen (
548- modifier = Modifier .padding(innerPadding)
655+ modifier = Modifier .padding(innerPadding),
656+ showNewAutomationSheet = showNewAutomationSheet,
657+ onDismissNewAutomationSheet = { showNewAutomationSheet = false }
549658 )
550659 }
551660
@@ -816,29 +925,9 @@ class MainActivity : FragmentActivity() {
816925 }
817926 }
818927
819- // FAB
820- FloatingActionButton (
821- onClick = {
822- HapticUtil .performMediumHaptic(view)
823- showAddRepoSheet = true
824- },
825- modifier = Modifier
826- .align(Alignment .BottomEnd )
827- .padding(
828- bottom = 150 .dp,
829- end = 32 .dp
830- ),
831- containerColor = MaterialTheme .colorScheme.primaryContainer,
832- contentColor = MaterialTheme .colorScheme.onPrimaryContainer
833- ) {
834- Icon (
835- painter = painterResource(id = R .drawable.rounded_add_24),
836- contentDescription = stringResource(R .string.action_add_repo)
837- )
838928 }
839929 }
840930 }
841- }
842931 }
843932 }
844933 }
0 commit comments