Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigator 2.0 with riverpod and freezed #5

Merged
merged 22 commits into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8cda75f
Inject router delegate and parser with riverpod in provider_dependenc…
FabianVarela Sep 8, 2021
2e84ab2
Change StatefulWidget by ConsumerWidget on TodoListApp in main.dart
FabianVarela Sep 8, 2021
dbba339
Change crud_todo_config.dart using freezed package
FabianVarela Sep 8, 2021
752f9e3
Update crud_todo_router_delegate.dart and crud_todo_information_parse…
FabianVarela Sep 8, 2021
e858b62
Merge branch 'navigator2' into navigator2_riverpod_freezed
FabianVarela Sep 8, 2021
d9035ea
Merge branch 'navigator2' into navigator2_riverpod_freezed
FabianVarela Sep 8, 2021
79a9ac7
Update coverage_badge.svg
FabianVarela Sep 8, 2021
f7a3218
Change conditional if by freezed's when
FabianVarela Sep 8, 2021
decbfb8
Change conditional if by freezed's when
FabianVarela Sep 9, 2021
f7b89cc
Merge with navigator2 branch
FabianVarela Sep 9, 2021
a5592a2
Merge branch 'navigator2' into navigator2_riverpod_freezed
FabianVarela Sep 9, 2021
f5b4b19
Merge branch 'navigator2' into navigator2_riverpod_freezed
FabianVarela Sep 11, 2021
977a11c
Merge branch 'navigator2' into navigator2_riverpod_freezed
FabianVarela Sep 12, 2021
c964216
Merge with navigator2 branch
FabianVarela Sep 12, 2021
046c0ee
Update coverage_badge.svg
FabianVarela Sep 12, 2021
cf2fa77
Merge branch 'navigator2' into navigator2_riverpod_freezed
FabianVarela Sep 12, 2021
f86edfc
Update coverage_badge.svg
FabianVarela Sep 12, 2021
287ac25
merge with navigator2 branch
FabianVarela Oct 12, 2021
d8b813f
Update coverage_badge.svg
FabianVarela Oct 12, 2021
1bb5d43
Merge from master
FabianVarela May 29, 2022
a5704db
Inject route delegate and info parser
FabianVarela May 29, 2022
f0f119b
Fix lint issues
FabianVarela May 29, 2022
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
8 changes: 4 additions & 4 deletions coverage_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 5 additions & 11 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:crud_todo_app/common/adaptive_contextual_layout.dart';
import 'package:crud_todo_app/navigator/crud_todo_information_parser.dart';
import 'package:crud_todo_app/navigator/crud_todo_router_delegate.dart';
import 'package:crud_todo_app/provider_dependency.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
Expand All @@ -19,19 +18,14 @@ Future<void> main() async {
runApp(const ProviderScope(child: TodoListApp()));
}

class TodoListApp extends StatefulWidget {
class TodoListApp extends ConsumerWidget {
const TodoListApp({Key? key}) : super(key: key);

@override
_TodoListAppState createState() => _TodoListAppState();
}

class _TodoListAppState extends State<TodoListApp> {
final _todoRouterDelegate = CrudTodoRouterDelegate();
final _todoInfoParser = CrudTodoInformationParser();
Widget build(BuildContext context, WidgetRef ref) {
final _todoRouterDelegate = ref.watch(crudTodoRouterDelegateProvider);
final _todoInfoParser = ref.watch(crudTodoInformationParserProvider);

@override
Widget build(BuildContext context) {
return MaterialApp.router(
debugShowCheckedModeBanner: false,
theme: ThemeData(
Expand Down
88 changes: 12 additions & 76 deletions lib/navigator/config/crud_todo_config.dart
Original file line number Diff line number Diff line change
@@ -1,83 +1,19 @@
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

class CrudTodoConfig extends Equatable {
const CrudTodoConfig.categoryList()
: currentCategoryId = null,
currentTodoId = null,
isTodoNew = false,
isTodoUpdate = false,
isUnknown = false;
part 'crud_todo_config.freezed.dart';

const CrudTodoConfig.todoList({String? categoryId})
: currentCategoryId = categoryId,
currentTodoId = null,
isTodoNew = false,
isTodoUpdate = false,
isUnknown = false;
@freezed
class CrudTodoConfig with _$CrudTodoConfig {
const factory CrudTodoConfig.categoryList() = CrudTodoConfigCategoryList;

const CrudTodoConfig.addTodo({String? categoryId})
: currentCategoryId = categoryId,
currentTodoId = null,
isTodoNew = true,
isTodoUpdate = false,
isUnknown = false;
const factory CrudTodoConfig.todoList(String categoryId) =
CrudTodoConfigTodoList;

const CrudTodoConfig.updateTodo({String? categoryId, String? todoId})
: currentCategoryId = categoryId,
currentTodoId = todoId,
isTodoNew = false,
isTodoUpdate = true,
isUnknown = false;
const factory CrudTodoConfig.addTodo(String categoryId) =
CrudTodoConfigAddTodo;

const CrudTodoConfig.unknown()
: currentCategoryId = null,
currentTodoId = null,
isTodoNew = false,
isTodoUpdate = false,
isUnknown = true;
const factory CrudTodoConfig.updateTodo(String categoryId, String todoId) =
CrudTodoConfigUpdateTodo;

final String? currentCategoryId;
final String? currentTodoId;
final bool isTodoNew;
final bool isTodoUpdate;
final bool isUnknown;

bool get isPageUnknown => isUnknown;

bool get isCategoryListPage =>
currentCategoryId == null &&
currentTodoId == null &&
!isTodoNew &&
!isTodoUpdate &&
!isUnknown;

bool get isTodoListPage =>
currentCategoryId != null &&
currentTodoId == null &&
!isTodoNew &&
!isTodoUpdate &&
!isUnknown;

bool get isAddTodoPage =>
currentCategoryId != null &&
currentTodoId == null &&
isTodoNew &&
!isTodoUpdate &&
!isUnknown;

bool get isUpdateTodoPage =>
currentCategoryId != null &&
currentTodoId != null &&
!isTodoNew &&
isTodoUpdate &&
!isUnknown;

@override
List<Object?> get props => [
currentCategoryId,
currentTodoId,
isTodoNew,
isTodoUpdate,
isUnknown,
];
const factory CrudTodoConfig.unknown() = CrudTodoConfigUnknown;
}
Loading