Skip to content

Commit fc7719e

Browse files
committed
Added swipe to remove restriction group
1 parent 710eb37 commit fc7719e

File tree

3 files changed

+202
-189
lines changed

3 files changed

+202
-189
lines changed

lib/ui/screens/home/dashboard/sliver_tips_and_tricks.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'package:mindful/core/extensions/ext_build_context.dart';
1616
import 'package:mindful/core/utils/widget_utils.dart';
1717
import 'package:mindful/ui/common/content_section_header.dart';
1818
import 'package:mindful/ui/common/default_list_tile.dart';
19+
import 'package:mindful/ui/common/styled_text.dart';
1920
import 'package:mindful/ui/controllers/tab_controller_provider.dart';
2021
import 'package:sliver_tools/sliver_tools.dart';
2122

@@ -57,7 +58,10 @@ class _SliverTipsAndTricksState extends State<SliverTipsAndTricks> {
5758
FluentIcons.sparkle_20_filled,
5859
color: Colors.primaries[index % Colors.primaries.length],
5960
),
60-
titleText: tip.key,
61+
title: StyledText(
62+
tip.key,
63+
fontSize: 14,
64+
),
6165
);
6266
},
6367
),

lib/ui/screens/restriction_groups/create_update_group_screen.dart

Lines changed: 15 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class _CreateUpdateRestrictionGroupState
7575

7676
@override
7777
Widget build(BuildContext context) {
78-
final isUpdating = widget.group != null;
7978
final timeSpent = ref
8079
.watch(todaysAppsUsageProvider.select(
8180
(v) => v.value?.entries
@@ -105,36 +104,21 @@ class _CreateUpdateRestrictionGroupState
105104
icon: FluentIcons.tab_desktop_bottom_20_regular,
106105
filledIcon: FluentIcons.tab_desktop_bottom_20_filled,
107106
titleText: _group.groupName,
108-
fab: Column(
109-
mainAxisAlignment: MainAxisAlignment.end,
110-
crossAxisAlignment: CrossAxisAlignment.end,
111-
children: [
112-
/// Create OR Update FAB
113-
DefaultFabButton(
114-
heroTag: widget.group == null
115-
? null
116-
: HeroTags.updateRestrictionGroupTag(_group.id),
117-
icon: widget.group == null
118-
? FluentIcons.add_20_filled
119-
: FluentIcons.arrow_upload_20_filled,
120-
label: widget.group == null
121-
? context.locale.create_button
122-
: context.locale.update_button,
123-
onPressed: widget.group == null
124-
? _createNewGroup
125-
: _updateCurrentGroup,
126-
),
127-
8.vBox,
128-
129-
/// Delete FAB
130-
if (isUpdating)
131-
DefaultFabButton(
132-
heroTag: HeroTags.removeRestrictionGroupTag(_group.id),
133-
icon: FluentIcons.delete_20_filled,
134-
label: context.locale.dialog_button_remove,
135-
onPressed: _deleteCurrentGroup,
136-
),
137-
],
107+
108+
/// Create OR Update FAB
109+
fab: DefaultFabButton(
110+
heroTag: widget.group == null
111+
? null
112+
: HeroTags.updateRestrictionGroupTag(_group.id),
113+
icon: widget.group == null
114+
? FluentIcons.add_20_filled
115+
: FluentIcons.arrow_upload_20_filled,
116+
label: widget.group == null
117+
? context.locale.create_button
118+
: context.locale.update_button,
119+
onPressed: widget.group == null
120+
? _createNewGroup
121+
: _updateCurrentGroup,
138122
),
139123
sliverBody: CustomScrollView(
140124
physics: const BouncingScrollPhysics(),
@@ -372,43 +356,6 @@ class _CreateUpdateRestrictionGroupState
372356
if (pop) _goBack();
373357
}
374358

375-
void _deleteCurrentGroup() async {
376-
/// Return if cannot delete
377-
if (!widget.canUpdateTimer || !widget.canUpdateActivePeriod) {
378-
context.showSnackAlert(
379-
context.locale.invincible_mode_snack_alert,
380-
);
381-
return;
382-
}
383-
384-
/// Confirm first
385-
final confirm = await showConfirmationDialog(
386-
context: context,
387-
heroTag: HeroTags.removeRestrictionGroupTag(_group.id),
388-
title: context.locale.remove_restriction_group_dialog_title,
389-
info:
390-
context.locale.remove_restriction_group_dialog_info(_group.groupName),
391-
icon: FluentIcons.delete_20_filled,
392-
positiveLabel: context.locale.dialog_button_remove,
393-
);
394-
395-
if (!confirm) return;
396-
397-
/// update associated apps and remove group
398-
await _updateAssociatedApps(
399-
{
400-
..._group.distractingApps,
401-
402-
/// if user modified the group before removing
403-
...widget.group?.distractingApps ?? [],
404-
}.toList(),
405-
null,
406-
);
407-
ref.read(restrictionGroupsProvider.notifier).removeGroup(group: _group);
408-
409-
_goBack();
410-
}
411-
412359
bool _checkIfGroupIsValid() {
413360
if (_group.distractingApps.isEmpty) {
414361
context

0 commit comments

Comments
 (0)