Skip to content

Commit cacc729

Browse files
committed
+breaking: Clean up and refactor
1 parent 1fbc5be commit cacc729

24 files changed

+304
-210
lines changed

bin/test_project/analysis_options.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

bin/test_project/lib/main.dart

Lines changed: 0 additions & 1 deletion
This file was deleted.

bin/test_project/lib/screens/example_screen/_controller.dart

Lines changed: 0 additions & 5 deletions
This file was deleted.

bin/test_project/lib/screens/example_screen/_state.dart

Lines changed: 0 additions & 18 deletions
This file was deleted.

bin/test_project/lib/screens/welcome_screen/_controller.dart

Lines changed: 0 additions & 5 deletions
This file was deleted.

bin/test_project/lib/screens/welcome_screen/_state.dart

Lines changed: 0 additions & 18 deletions
This file was deleted.
File renamed without changes.

example/example.dart

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/lib/main.dart

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import 'package:flutter/material.dart';
2+
3+
import 'package:df_screen/df_screen.dart';
4+
5+
import 'screens/_access.g.dart';
6+
import 'screens/_index.g.dart';
7+
8+
void main() {
9+
runApp(const MainWidget());
10+
}
11+
12+
/// Create a route manager to manage the app's navigation.
13+
final routeManager = ScreenRouteManger(
14+
// Define the condition that determines if the route manager considers
15+
// the app state as logged in or logged out.
16+
isLoggedIn: () => true,
17+
// Define the condition that determines if the route manager considers
18+
// the app state as verified and also logged in.
19+
isVerified: () => true,
20+
// Specify the function responsible for finding screens based on the
21+
// ModelScreenConfiguration passed when routing.
22+
findScreen: findScreenFromConfigurationAndAuthService,
23+
// Pass the GoRouter routes for each screen to the ScreenRouteManger.
24+
generatedScreenRoutes: generatedScreenRoutes,
25+
// Specify default screen to show when logged in.
26+
defaultOnLoginScreenConfiguration: HomeScreenConfiguration(),
27+
// Specify default screen to show when logged out.
28+
defaultOnLogoutScreenConfiguration: LoginScreenConfiguration(),
29+
);
30+
31+
class MainWidget extends StatefulWidget {
32+
const MainWidget({super.key});
33+
34+
@override
35+
State<MainWidget> createState() => _MainWidgetState();
36+
}
37+
38+
class _MainWidgetState extends State<MainWidget> {
39+
@override
40+
Widget build(BuildContext context) {
41+
return MaterialApp.router(
42+
// Pass the router config to the MaterialApp.
43+
routerConfig: routeManager.router,
44+
debugShowCheckedModeBanner: false,
45+
builder: (context, body) {
46+
// Draw each screen in a Scaffold.
47+
return Scaffold(
48+
body: body,
49+
);
50+
},
51+
);
52+
}
53+
}

bin/test_project/lib/screens/_access.g.dart renamed to example/lib/screens/_access.g.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
88
//.title~
99

10+
// ignore_for_file: constant_identifier_names
11+
1012
// ignore: depend_on_referenced_packages
1113
import 'package:df_screen/df_screen.dart';
1214

@@ -19,16 +21,16 @@ import '_index.g.dart';
1921

2022
/// A list of all screen routes in the app.
2123
final generatedScreenRoutes = [
22-
generatedExampleScreenRoute,
23-
generatedExampleScreenRoute,
24+
generatedLoginScreenRoute,
25+
generatedHomeScreenRoute,
2426
];
2527

2628
/// A list of function references. Each function returns a corresponding [Screen]
2729
/// for a given [ModelScreenConfiguration] or `null` if the given configuration
2830
/// does not match or access is denied to the screen.
2931
const SCREEN_MAKERS = [
30-
makerExampleScreen,
31-
makerExampleScreen,
32+
makerLoginScreen,
33+
makerHomeScreen,
3234
];
3335

3436
/// Finds the screen that corresponds to [configuration]. It iterates through

0 commit comments

Comments
 (0)