mirror of
https://github.com/git-touch/git-touch
synced 2025-02-02 08:56:54 +01:00
refactor: use go_router
This commit is contained in:
parent
dc40206576
commit
3261db8fee
24
lib/app.dart
24
lib/app.dart
@ -1,11 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/home.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||
import 'package:git_touch/router.dart';
|
||||
import 'package:intl/locale.dart' as l;
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
@ -49,14 +49,19 @@ class MyApp extends StatelessWidget {
|
||||
return Container(
|
||||
key: auth.rootKey,
|
||||
child: theme.theme == AppThemeType.cupertino
|
||||
? CupertinoApp(
|
||||
? CupertinoApp.router(
|
||||
routeInformationProvider: router.routeInformationProvider,
|
||||
routeInformationParser: router.routeInformationParser,
|
||||
routerDelegate: router.routerDelegate,
|
||||
theme: CupertinoThemeData(brightness: theme.brightness),
|
||||
home: Home(),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localeListResolutionCallback: localeListResolutionCallback,
|
||||
)
|
||||
: MaterialApp(
|
||||
: MaterialApp.router(
|
||||
routeInformationProvider: router.routeInformationProvider,
|
||||
routeInformationParser: router.routeInformationParser,
|
||||
routerDelegate: router.routerDelegate,
|
||||
theme: ThemeData(
|
||||
brightness: theme.brightness,
|
||||
primaryColor:
|
||||
@ -66,9 +71,10 @@ class MyApp extends StatelessWidget {
|
||||
builders: {
|
||||
TargetPlatform.android: ZoomPageTransitionsBuilder(),
|
||||
},
|
||||
), colorScheme: ColorScheme.fromSwatch().copyWith(secondary: theme.palette.primary),
|
||||
),
|
||||
colorScheme: ColorScheme.fromSwatch()
|
||||
.copyWith(secondary: theme.palette.primary),
|
||||
),
|
||||
home: Home(),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localeListResolutionCallback: localeListResolutionCallback,
|
||||
|
@ -1,33 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/notification.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/bb_explore.dart';
|
||||
import 'package:git_touch/screens/bb_teams.dart';
|
||||
import 'package:git_touch/screens/bb_user.dart';
|
||||
import 'package:git_touch/screens/ge_search.dart';
|
||||
import 'package:git_touch/screens/ge_user.dart';
|
||||
import 'package:git_touch/screens/gh_news.dart';
|
||||
import 'package:git_touch/screens/gh_notification.dart';
|
||||
import 'package:git_touch/screens/gh_search.dart';
|
||||
import 'package:git_touch/screens/gh_trending.dart';
|
||||
import 'package:git_touch/screens/gh_user.dart';
|
||||
import 'package:git_touch/screens/gl_explore.dart';
|
||||
import 'package:git_touch/screens/gl_groups.dart';
|
||||
import 'package:git_touch/screens/gl_search.dart';
|
||||
import 'package:git_touch/screens/gl_user.dart';
|
||||
import 'package:git_touch/screens/go_search.dart';
|
||||
import 'package:git_touch/screens/go_user.dart';
|
||||
import 'package:git_touch/screens/gt_orgs.dart';
|
||||
import 'package:git_touch/screens/gt_user.dart';
|
||||
import 'package:git_touch/screens/gl_explore.dart';
|
||||
import 'package:git_touch/screens/gl_groups.dart';
|
||||
import 'package:git_touch/screens/gl_user.dart';
|
||||
import 'package:git_touch/screens/login.dart';
|
||||
import 'package:git_touch/screens/gh_notification.dart';
|
||||
import 'package:git_touch/screens/gh_user.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:github/github.dart';
|
||||
import 'package:launch_review/launch_review.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/screens/gh_news.dart';
|
||||
import 'package:git_touch/screens/gh_search.dart';
|
||||
import 'package:git_touch/screens/gh_trending.dart';
|
||||
import 'package:git_touch/screens/ge_search.dart';
|
||||
import 'package:github/github.dart';
|
||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
import 'package:universal_io/io.dart';
|
||||
|
||||
|
@ -1,14 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:git_touch/app.dart';
|
||||
import 'package:git_touch/models/code.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/code.dart';
|
||||
import 'package:git_touch/models/notification.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/models/notification.dart';
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
void main() async {
|
||||
@ -31,34 +29,6 @@ void main() async {
|
||||
codeModel.init(),
|
||||
]);
|
||||
|
||||
for (var screen in CommonRouter.routes) {
|
||||
themeModel.router.define(CommonRouter.prefix + screen.path,
|
||||
handler: Handler(handlerFunc: screen.handler));
|
||||
}
|
||||
for (var screen in GitlabRouter.routes) {
|
||||
themeModel.router.define(GitlabRouter.prefix + screen.path,
|
||||
handler: Handler(handlerFunc: screen.handler));
|
||||
}
|
||||
for (var screen in GiteaRouter.routes) {
|
||||
themeModel.router.define(GiteaRouter.prefix + screen.path,
|
||||
handler: Handler(handlerFunc: screen.handler));
|
||||
}
|
||||
for (var screen in BitbucketRouter.routes) {
|
||||
themeModel.router.define(BitbucketRouter.prefix + screen.path,
|
||||
handler: Handler(handlerFunc: screen.handler));
|
||||
}
|
||||
for (var screen in GithubRouter.routes) {
|
||||
themeModel.router.define(GithubRouter.prefix + screen.path,
|
||||
handler: Handler(handlerFunc: screen.handler));
|
||||
}
|
||||
for (var screen in GiteeRouter.routes) {
|
||||
themeModel.router.define(GiteeRouter.prefix + screen.path,
|
||||
handler: Handler(handlerFunc: screen.handler));
|
||||
}
|
||||
for (var screen in GogsRouter.routes) {
|
||||
themeModel.router.define(GogsRouter.prefix + screen.path,
|
||||
handler: Handler(handlerFunc: screen.handler));
|
||||
}
|
||||
// To match status bar color to app bar color
|
||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
|
@ -1,15 +1,16 @@
|
||||
import 'package:universal_io/io.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fimber/fimber.dart';
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/action_button.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/action_button.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:universal_io/io.dart';
|
||||
|
||||
class AppThemeType {
|
||||
static const material = 0;
|
||||
@ -177,8 +178,6 @@ class ThemeModel with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
final router = FluroRouter();
|
||||
|
||||
final paletteLight = Palette(
|
||||
primary: PrimerColors.blue500,
|
||||
text: Colors.black,
|
||||
@ -250,14 +249,11 @@ class ThemeModel with ChangeNotifier {
|
||||
push(BuildContext context, String url, {bool replace = false}) {
|
||||
// Fimber.d(url);
|
||||
if (url.startsWith('/')) {
|
||||
return router.navigateTo(
|
||||
context,
|
||||
url,
|
||||
transition: theme == AppThemeType.cupertino
|
||||
? TransitionType.cupertino
|
||||
: TransitionType.material,
|
||||
replace: replace,
|
||||
);
|
||||
if (replace) {
|
||||
context.replace(url);
|
||||
} else {
|
||||
context.push(url);
|
||||
}
|
||||
} else {
|
||||
launchStringUrl(url);
|
||||
}
|
||||
|
1483
lib/router.dart
1483
lib/router.dart
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,16 @@
|
||||
import 'package:ferry/ferry.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||
import 'package:git_touch/graphql/__generated__/github.data.gql.dart';
|
||||
import 'package:git_touch/graphql/__generated__/github.req.gql.dart';
|
||||
import 'package:git_touch/graphql/__generated__/github.var.gql.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/object_tree.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||
|
||||
class GhGistsFilesScreen extends StatelessWidget {
|
||||
final String id;
|
||||
|
14
pubspec.lock
14
pubspec.lock
@ -260,13 +260,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
fluro:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fluro
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -350,6 +343,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
go_router:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: go_router
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.4.1"
|
||||
google_fonts:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -37,7 +37,6 @@ dependencies:
|
||||
file_icon:
|
||||
filesize:
|
||||
fimber:
|
||||
fluro:
|
||||
flutter_highlight:
|
||||
flutter_markdown:
|
||||
flutter_svg:
|
||||
@ -67,6 +66,7 @@ dependencies:
|
||||
sentry_flutter:
|
||||
pub_semver:
|
||||
google_fonts:
|
||||
go_router:
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
x
Reference in New Issue
Block a user