Skip to content

Commit

Permalink
feat: update checklist items, e.g. via sync
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasn committed Nov 18, 2024
1 parent 864c518 commit 38b4dbb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion lib/features/tasks/state/checklist_item_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ChecklistItemController extends _$ChecklistItemController {
return res;
}

void toggleChecked({required bool checked}) {
void updateChecked({required bool checked}) {
final current = state.value;
final data = current?.data;
if (current != null && data != null) {
Expand Down
13 changes: 7 additions & 6 deletions lib/features/tasks/ui/checkbox_item_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ class _CheckboxItemWidgetState extends State<CheckboxItemWidget> {
}

@override
void didChangeDependencies() {
setState(() {
_isChecked = widget.isChecked;
});

super.didChangeDependencies();
void didUpdateWidget(CheckboxItemWidget oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.isChecked != widget.isChecked) {
setState(() {
_isChecked = widget.isChecked;
});
}
}

@override
Expand Down
5 changes: 2 additions & 3 deletions lib/features/tasks/ui/checkbox_item_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ class CheckboxItemWrapper extends ConsumerWidget {
return CheckboxItemWidget(
title: item.data.title,
isChecked: item.data.isChecked,
onChanged: (checked) => ref.read(provider.notifier).toggleChecked(
checked: checked,
),
onChanged: (checked) =>
ref.read(provider.notifier).updateChecked(checked: checked),
onTitleChange: ref.read(provider.notifier).updateTitle,
);
},
Expand Down
18 changes: 0 additions & 18 deletions lib/widgets/create/add_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,6 @@ class _RadialAddActionButtonsState extends State<RadialAddActionButtons> {
),
);

final linkedItem = widget.linked;
if (linkedItem is Task) {
items.add(
FloatingActionButton(
heroTag: 'Checklist',
tooltip: context.messages.addActionAddChecklist,
onPressed: () async {
rebuild();
await createChecklist(task: linkedItem);
},
child: const Icon(
Icons.checklist_rounded,
size: actionIconSize,
),
),
);
}

return Padding(
padding: const EdgeInsets.only(right: 1, bottom: 1.5),
child: CircleFloatingButton.floatingActionButton(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: lotti
description: Achieve your goals and keep your data private with Lotti.
publish_to: 'none'
version: 0.9.532+2736
version: 0.9.532+2737

msix_config:
display_name: LottiApp
Expand Down

0 comments on commit 38b4dbb

Please sign in to comment.