Skip to content

Commit

Permalink
#refactor rename my_app_meta to my_app_routes
Browse files Browse the repository at this point in the history
plus some fixups
  • Loading branch information
X-Wei committed Jul 28, 2019
1 parent 4094ee6 commit 1d304df
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
37 changes: 18 additions & 19 deletions lib/my_app_meta.dart → lib/my_app_routes.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// This file declares "metadata" (or "structure") of the app, in a const
// List<Tuple2> object. And it provides functions to get app's routing table or
// app's navigation drawer menu items from the declared metadata.
// This file declares routes of this app, in particular it declares the
// "structure" of the group of example routes, in a const List<Tuple2> object.
import 'package:flutter/material.dart';

import './constants.dart';
Expand Down Expand Up @@ -65,6 +64,22 @@ import './routes/widgets_text_ex.dart';
import './routes/widgets_textfield_ex.dart';
import './routes/widgets_textformfield_ex.dart';

const kHomeRoute = MyRoute(
child: MyHomePage(),
sourceFilePath: 'lib/routes/home.dart',
title: APP_NAME,
routeName: Navigator.defaultRouteName,
);

const kAboutRoute = MyRoute(
child: MyAboutRoute(),
sourceFilePath: 'lib/routes/about.dart',
title: 'About',
links: {
'Doc': 'https://docs.flutter.io/flutter/material/showAboutDialog.html'
},
);

// The structure of app's navigation drawer items is a 2-level menu, its schema
// is the following:
// [ MyRouteGroup{
Expand Down Expand Up @@ -672,19 +687,3 @@ const kMyAppRoutesStructure = <MyRouteGroup>[
];

final kAllRoutes = kMyAppRoutesStructure.expand((group) => group.routes);

const kAboutRoute = MyRoute(
child: MyAboutRoute(),
sourceFilePath: 'lib/routes/about.dart',
title: 'About',
links: {
'Doc': 'https://docs.flutter.io/flutter/material/showAboutDialog.html'
},
);

const kHomeRoute = MyRoute(
child: MyHomePage(),
sourceFilePath: 'lib/routes/home.dart',
title: APP_NAME,
routeName: Navigator.defaultRouteName,
);
2 changes: 1 addition & 1 deletion lib/my_app_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';

import './my_route.dart';
import './my_app_meta.dart' show kAllRoutes;
import './my_app_routes.dart' show kAllRoutes;

class MyAppSettings extends ChangeNotifier {
static const _kBookmarkedRoutesPreferenceKey = 'BOOKMARKED_ROUTES';
Expand Down
2 changes: 1 addition & 1 deletion lib/my_main_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';

import './constants.dart' show kAppIcon;
import './my_app_meta.dart' show kAllRoutes, kAboutRoute, kHomeRoute;
import './my_app_routes.dart' show kAllRoutes, kAboutRoute, kHomeRoute;
import './my_app_settings.dart';
import './themes.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/routes/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:provider/provider.dart';

import '../my_app_settings.dart';
import '../my_route.dart';
import '../my_app_meta.dart'
import '../my_app_routes.dart'
show MyRouteGroup, kAboutRoute, kMyAppRoutesStructure;

class MyHomePage extends StatelessWidget {
Expand Down

0 comments on commit 1d304df

Please sign in to comment.