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
6 changes: 4 additions & 2 deletions lib/domain/tasks_comparator_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ abstract class TasksComparatorUseCase {
@Injectable(as: TasksComparatorUseCase)
class TasksComparatorUseCaseImpl extends TasksComparatorUseCase {
@override
bool areThemEqual(
{required List<Task> oldList, required List<Task> newList}) {
bool areThemEqual({
required List<Task> oldList,
required List<Task> newList,
}) {
if (oldList.length == newList.length) {
if (oldList.isEmpty && newList.isEmpty) {
return true;
Expand Down
1 change: 0 additions & 1 deletion lib/domain/tasks_sorter_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ class TasksSorterUseCaseImpl implements TasksSorterUseCase {
return 0;
}
}

}
55 changes: 38 additions & 17 deletions lib/ui/components/widgets/card_wrapper_widget.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,50 @@
import 'package:flutter/material.dart';

class CardWrapperWidget extends StatelessWidget {
final Color backgroundColor;
final Function()? onTap;
final Widget child;
final ShapeBorder? shapeBorder;
final double? elevation;
final bool? isSelected;

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

@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,
if (isSelected == true) {
return Card(
elevation: 0,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12),
bottomLeft: Radius.circular(12),
topRight: Radius.circular(12),
),
),
color: Theme.of(context).colorScheme.tertiaryContainer,
clipBehavior: Clip.hardEdge,
child: child,
),
);
);
} else {
return Card(
elevation: 2,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
clipBehavior: Clip.hardEdge,
color: Theme.of(context).colorScheme.surfaceBright,
child: InkWell(
onTap: onTap,
child: child,
),
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,9 @@ class ChecklistItemWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
Color backgroundColor = Theme.of(context).colorScheme.surfaceBright;

if (isSelected == true) {
backgroundColor = Theme.of(context).colorScheme.tertiaryContainer;
}

return CardWrapperWidget(
isSelected: isSelected,
onTap: () => onSelectChecklist(checklist),
backgroundColor: backgroundColor,
child: _internalContent(context, checklist),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ class ChecklistFabMenuItem extends StatelessWidget {
final IconData icon;
final Function() onPressed;

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

@override
Widget build(BuildContext context) {
Expand Down
1 change: 0 additions & 1 deletion lib/ui/components/widgets/task/task_cell_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class TaskCellWidget extends StatelessWidget {
Widget build(BuildContext context) {
return CardWrapperWidget(
onTap: null,
backgroundColor: Theme.of(context).colorScheme.surfaceBright,
child: ListTile(
leading: IconButton(
onPressed: () => {onRemoveTask(task)},
Expand Down
31 changes: 23 additions & 8 deletions lib/ui/screens/checklist/checklist_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,29 @@ class ChecklistScreen extends StatelessWidget {
}
}

class ChecklistScreenScaffold extends StatelessWidget {
final TextEditingController _checklistEditingController =
TextEditingController();
class ChecklistScreenScaffold extends StatefulWidget {
final Function(String) onAddNewChecklist;
final _formKey = GlobalKey<FormState>();
final FormScreenValidator formScreenValidator;
final NavigatorProvider navigatorProvider;

ChecklistScreenScaffold({
const ChecklistScreenScaffold({
super.key,
required this.onAddNewChecklist,
required this.formScreenValidator,
required this.navigatorProvider,
});

@override
State<ChecklistScreenScaffold> createState() =>
_ChecklistScreenScaffoldState();
}

class _ChecklistScreenScaffoldState extends State<ChecklistScreenScaffold> {
final TextEditingController _checklistEditingController =
TextEditingController();

final _formKey = GlobalKey<FormState>();

@override
Widget build(BuildContext context) {
final localizations = AppLocalizations.of(context)!;
Expand All @@ -59,11 +67,11 @@ class ChecklistScreenScaffold extends StatelessWidget {
return;
}

await onAddNewChecklist(
await widget.onAddNewChecklist(
_checklistEditingController.text,
);
if (context.mounted) {
navigatorProvider.onPop(context, true);
widget.navigatorProvider.onPop(context, true);
}
},
child: const Icon(Icons.save),
Expand All @@ -74,10 +82,17 @@ class ChecklistScreenScaffold extends StatelessWidget {
formKey: _formKey,
checklistLabel: localizations.checklist_name,
checklistErrorMessage: localizations.checklist_name_required,
formScreenValidator: formScreenValidator,
formScreenValidator: widget.formScreenValidator,
checklistEditingController: _checklistEditingController,
),
),
);
}

@override
void dispose() {
_checklistEditingController.dispose();

super.dispose();
}
}
41 changes: 25 additions & 16 deletions lib/ui/screens/startup/startup_screen.dart
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:todoapp/ui/screens/startup/startup_viewmodel.dart';
import 'package:todoapp/ui/todo_app_router_config.gr.dart';
import 'package:todoapp/util/di/dependency_startup_launcher.dart';

@RoutePage()
class StartupScreen extends StatelessWidget {
class StartupScreen extends StatefulWidget {
const StartupScreen({super.key});

@override
State<StartupScreen> createState() => _StartupScreenState();
}

class _StartupScreenState extends State<StartupScreen> {
StackRouter? _stackRouter;

@override
void initState() {
super.initState();
_loadDependencies();
}

Future<void> _loadDependencies() async {
await GetItStartupHandlerWrapper.init();
_stackRouter?.replace(const ChecklistsRoute());
}

@override
Widget build(BuildContext context) {
final viewModel = StartupViewmodel();
return BlocProvider(
create: (_) => viewModel,
child: BlocBuilder<StartupViewmodel, bool>(
builder: (context, uiState) => StartupContainer(
isLoading: uiState,
),
),
_stackRouter = AutoRouter.of(context);
return const StartupContainer(
isLoading: true,
);
}
}

class StartupContainer extends StatelessWidget {
final bool isLoading;

const StartupContainer({super.key,
const StartupContainer({
super.key,
required this.isLoading,
});

@override
Widget build(BuildContext context) {
if (isLoading == false) {
AutoRouter.of(context).replace(const ChecklistsRoute());
}

return Container(
color: Theme.of(context).colorScheme.primaryContainer,
child: Center(
Expand Down
15 changes: 0 additions & 15 deletions lib/ui/screens/startup/startup_viewmodel.dart

This file was deleted.

45 changes: 33 additions & 12 deletions lib/ui/screens/task/task_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,43 @@ class TaskScreen extends StatelessWidget {
}
}

class TaskScreenScaffold extends StatelessWidget {
final TextEditingController _taskEditingController = TextEditingController();
class TaskScreenScaffold extends StatefulWidget {
final Future<bool> Function(String) addTaskOrUpdate;
final FormScreenValidator formScreenValidator;
final _formKey = GlobalKey<FormState>();
final NavigatorProvider navigatorProvider;
final IconData floatingActionIcon;
final String? taskTitle;

TaskScreenScaffold({
const TaskScreenScaffold({
super.key,
String? taskTitle,
this.taskTitle,
required this.floatingActionIcon,
required this.addTaskOrUpdate,
required this.formScreenValidator,
required this.navigatorProvider,
}) {
_taskEditingController.text = taskTitle ?? '';
});

@override
State<TaskScreenScaffold> createState() => _TaskScreenScaffoldState();
}

class _TaskScreenScaffoldState extends State<TaskScreenScaffold> {
late TextEditingController _taskEditingController;

final _formKey = GlobalKey<FormState>();

@override
void initState() {
super.initState();

_taskEditingController = TextEditingController(
text: widget.taskTitle ?? ''
);
}

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

return Scaffold(
appBar: CustomAppBarWidget(
title: localizations.task,
Expand All @@ -75,14 +89,14 @@ class TaskScreenScaffold extends StatelessWidget {
return;
}

final result = await addTaskOrUpdate(
final result = await widget.addTaskOrUpdate(
_taskEditingController.text,
);
if (context.mounted) {
navigatorProvider.onPop(context, result);
widget.navigatorProvider.onPop(context, result);
}
},
child: Icon(floatingActionIcon),
child: Icon(widget.floatingActionIcon),
),
body: Padding(
padding: const EdgeInsets.all(12),
Expand All @@ -91,9 +105,16 @@ class TaskScreenScaffold extends StatelessWidget {
taskLabel: localizations.task,
taskErrorMessage: localizations.task_name_required,
taskEditingController: _taskEditingController,
formScreenValidator: formScreenValidator,
formScreenValidator: widget.formScreenValidator,
),
),
);
}

@override
void dispose() {
_taskEditingController.dispose();

super.dispose();
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+15
version: 1.0.0+16

environment:
sdk: ^3.5.0
Expand Down