Vaani/lib/router/constants.dart

60 lines
1.2 KiB
Dart
Raw Normal View History

2024-05-09 00:41:19 -04:00
// to store names of routes
part of 'router.dart';
class Routes {
static const home = _SimpleRoute(
pathName: '',
name: 'home',
);
static const onboarding = _SimpleRoute(
pathName: 'login',
name: 'onboarding',
);
2024-05-09 00:41:19 -04:00
static const library = _SimpleRoute(
pathName: 'library',
pathParamName: 'libraryId',
name: 'library',
);
static const libraryItem = _SimpleRoute(
pathName: 'item',
pathParamName: 'itemId',
name: 'libraryItem',
);
static const settings = _SimpleRoute(
pathName: 'config',
name: 'settings',
);
2024-06-05 12:08:44 -04:00
static const search = _SimpleRoute(
pathName: 'search',
name: 'search',
// parentRoute: library,
);
static const explore = _SimpleRoute(
pathName: 'explore',
name: 'explore',
);
2024-05-09 00:41:19 -04:00
}
// a class to store path
class _SimpleRoute {
const _SimpleRoute({
required this.pathName,
this.pathParamName,
2024-05-09 00:41:19 -04:00
required this.name,
2024-06-05 12:08:44 -04:00
this.parentRoute,
2024-05-09 00:41:19 -04:00
});
final String pathName;
final String? pathParamName;
2024-05-09 00:41:19 -04:00
final String name;
2024-06-05 12:08:44 -04:00
final _SimpleRoute? parentRoute;
2024-05-09 00:41:19 -04:00
String get path =>
2024-06-05 12:08:44 -04:00
'${parentRoute?.path ?? ''}${parentRoute != null ? '/' : ''}$localPath';
String get localPath =>
'/$pathName${pathParamName != null ? '/:$pathParamName' : ''}';
2024-05-09 00:41:19 -04:00
}