Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions lib/ui/components/widgets/card_wrapper_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';

class CardWrapperWidget extends StatelessWidget {
final Color backgroundColor;
final Function()? onTap;
final Widget child;

const CardWrapperWidget(
{super.key,
required this.child,
required this.onTap,
required this.backgroundColor});

@override
Widget build(BuildContext context) {
return Card(
elevation: 2,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
color: backgroundColor,
clipBehavior: Clip.hardEdge,
child: InkWell(
onTap: onTap,
child: child,
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:todoapp/ui/components/form_validator.dart';
import 'package:todoapp/ui/components/widgets/form/form_field_widget.dart';

class ChecklistFormWidget extends StatelessWidget {
final Key formKey;
Expand All @@ -24,21 +25,15 @@ class ChecklistFormWidget extends StatelessWidget {
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Column(
children: [
TextFormField(
autofocus: true,
controller: checklistEditingController,
decoration: InputDecoration(
FormFieldWidget(
labelText: checklistLabel,
labelStyle: Theme.of(context).textTheme.titleMedium,
border: const OutlineInputBorder(),
),
validator: (value) {
if (formScreenValidator.validateValue(value) == false) {
return checklistErrorMessage;
}
return null;
},
),
controller: checklistEditingController,
validator: (value) {
if (formScreenValidator.validateValue(value) == false) {
return checklistErrorMessage;
}
return null;
}),
],
),
);
Expand Down
11 changes: 11 additions & 0 deletions lib/ui/components/widgets/checklist/checklist_full_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ class ChecklistsListFullWidgetState extends State<ChecklistsListFullWidget> {
}
}

void onSortTasks() {
_tasksViewModel.onSort();
}

Future<void> onShareTasks() async {
final checklistName = selected?.title;
if (checklistName != null) {
await _tasksViewModel.shareTasks(checklistName: checklistName);
}
}

Widget _buildTaskList(BuildContext context) {
final localizations = AppLocalizations.of(context)!;
return Row(
Expand Down
26 changes: 5 additions & 21 deletions lib/ui/components/widgets/checklist/checklist_item_widget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';

import 'package:todoapp/data/model/checklist.dart';
import 'package:todoapp/ui/components/widgets/card_wrapper_widget.dart';

class ChecklistItemWidget extends StatelessWidget {
final Checklist checklist;
Expand Down Expand Up @@ -43,27 +44,10 @@ class ChecklistItemWidget extends StatelessWidget {
backgroundColor = Theme.of(context).colorScheme.tertiaryContainer;
}

return Card(
elevation: 2,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(12),
),
),
color: backgroundColor,
clipBehavior: Clip.hardEdge,
child: InkWell(
onTap: () => onSelectChecklist(checklist),
child: Padding(
padding: const EdgeInsets.only(
left: 8,
right: 8,
top: 16,
bottom: 16,
),
child: _internalContent(context, checklist),
),
),
return CardWrapperWidget(
onTap: () => onSelectChecklist(checklist),
backgroundColor: backgroundColor,
child: _internalContent(context, checklist),
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import 'package:flutter/material.dart';
import 'package:flutter_expandable_fab/flutter_expandable_fab.dart';
import 'package:todoapp/ui/components/widgets/checklist/fabmenu/checklist_fabmenu_item.dart';
import 'package:todoapp/ui/l10n/app_localizations.dart';

class ChecklistExpandableFabMenu extends StatefulWidget {
final Function() onNewChecklistPressed;
final Function() onNewTaskPressed;
final Function() onSharePressed;
final Function() onSortPressed;

const ChecklistExpandableFabMenu({
super.key,
required this.onNewChecklistPressed,
required this.onNewTaskPressed,
required this.onSharePressed,
required this.onSortPressed,
});

@override
State<ChecklistExpandableFabMenu> createState() =>
_ChecklistExpandableFabMenuState();
}

class _ChecklistExpandableFabMenuState
extends State<ChecklistExpandableFabMenu> {
final _key = GlobalKey<ExpandableFabState>();

@override
Widget build(BuildContext context) {
final localizations = AppLocalizations.of(context)!;

return ExpandableFab(
key: _key,
type: ExpandableFabType.side,
overlayStyle: const ExpandableFabOverlayStyle(
blur: 1.0,
),
children: [
ChecklistFabMenuItem(
heroTag: 'new_task',
onPressed: () => {
_key.currentState?.close(),
widget.onNewTaskPressed(),
},
label: localizations.task,
icon: Icons.add_task,
),
ChecklistFabMenuItem(
heroTag: 'new_checklist',
onPressed: () => {
_key.currentState?.close(),
widget.onNewChecklistPressed(),
},
label: localizations.checklist,
icon: Icons.plus_one,
),
ChecklistFabMenuItem(
heroTag: 'share',
onPressed: () => {
_key.currentState?.close(),
widget.onSharePressed(),
},
label: localizations.share,
icon: Icons.share,
),
ChecklistFabMenuItem(
heroTag: 'sort',
onPressed: () => {
_key.currentState?.close(),
widget.onSortPressed(),
},
label: localizations.sort,
icon: Icons.sort,
)
],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';

class ChecklistFabMenuItem extends StatelessWidget {
final String heroTag;
final String label;
final IconData icon;
final Function() onPressed;

const ChecklistFabMenuItem(
{super.key,
required this.label,
required this.onPressed,
required this.icon,
required this.heroTag});

@override
Widget build(BuildContext context) {
return Column(
children: [
FloatingActionButton.small(
heroTag: heroTag,
onPressed: onPressed,
child: Icon(icon),
),
const SizedBox(height: 8),
Text(label),
],
);
}
}
29 changes: 29 additions & 0 deletions lib/ui/components/widgets/form/form_field_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';

class FormFieldWidget extends StatelessWidget {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increase the input text field to be more a kind of text area

final String labelText;
final TextEditingController controller;
final String? Function(String?)? validator;

const FormFieldWidget({
super.key,
required this.labelText,
required this.controller,
this.validator,
});

@override
Widget build(BuildContext context) {
return TextFormField(
autofocus: true,
maxLines: 3,
controller: controller,
decoration: InputDecoration(
labelText: labelText,
labelStyle: Theme.of(context).textTheme.titleMedium,
border: const OutlineInputBorder(),
),
validator: validator,
);
}
}
11 changes: 4 additions & 7 deletions lib/ui/components/widgets/task/task_cell_widget.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:todoapp/data/model/task.dart';
import 'package:todoapp/ui/components/widgets/card_wrapper_widget.dart';
import 'package:todoapp/ui/components/widgets/task/task_title_widget.dart';

class TaskCellWidget extends StatelessWidget {
Expand All @@ -20,13 +21,9 @@ class TaskCellWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
const cardShape = RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8)),
);

return Card(
elevation: 4,
shape: cardShape,
return CardWrapperWidget(
onTap: null,
backgroundColor: Theme.of(context).colorScheme.surfaceBright,
child: ListTile(
leading: IconButton(
onPressed: () => {onRemoveTask(task)},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';

import 'package:todoapp/ui/components/form_validator.dart';
import 'package:todoapp/ui/components/widgets/form/form_field_widget.dart';

class TaskFormWidget extends StatelessWidget {
final Key formKey;
Expand All @@ -25,14 +26,9 @@ class TaskFormWidget extends StatelessWidget {
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Column(
children: [
TextFormField(
autofocus: true,
FormFieldWidget(
labelText: taskLabel,
controller: taskEditingController,
decoration: InputDecoration(
labelText: taskLabel,
labelStyle: Theme.of(context).textTheme.titleMedium,
border: const OutlineInputBorder(),
),
validator: (value) {
if (formScreenValidator.validateValue(value) == false) {
return taskErrorMessage;
Expand Down
4 changes: 3 additions & 1 deletion lib/ui/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
"checklist": "Checklist",
"checklist_name": "Checklist name",
"remove": "Remove",
"sort_message": "It is sorted"
"sort_message": "It is sorted",
"share": "Share",
"sort": "Sort"
}
4 changes: 3 additions & 1 deletion lib/ui/l10n/app_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
"checklist": "Checklist",
"checklist_name": "Nome do Checklist",
"remove": "Deletar",
"sort_message": "Está ordenado"
"sort_message": "Está ordenado",
"share": "Compartilhar",
"sort": "Ordenar"
}
2 changes: 1 addition & 1 deletion lib/ui/screens/checklist/checklist_screen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:todoapp/ui/components/form_validator.dart';
import 'package:todoapp/ui/components/widgets/checklist_form_widget.dart';
import 'package:todoapp/ui/components/widgets/checklist/checklist_form_widget.dart';
import 'package:todoapp/ui/components/widgets/custom_app_bar_widget.dart';
import 'package:todoapp/ui/l10n/app_localizations.dart';
import 'package:todoapp/ui/screens/checklist/checklist_viewmodel.dart';
Expand Down
Loading