| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- import 'package:deus_app/page/login/login_page.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- /**
- * 导航栏
- * Created by guoshuyu
- * Date: 2018-07-16
- */
- class NavigatorUtils {
- ///替换
- static pushReplacementNamed(BuildContext context, String routeName) {
- Navigator.pushReplacementNamed(context, routeName);
- // if (navigator == null) {
- // try {
- // navigator = Navigator.of(context);
- // } catch (e) {
- // error = true;
- // }
- // }
- //
- // if (replace) {
- // ///如果可以返回,清空开始,然后塞入
- // if (!error && navigator.canPop()) {
- // navigator.pushAndRemoveUntil(
- // router,
- // ModalRoute.withName('/'),
- // );
- // } else {
- // ///如果不可返回,直接替换当前
- // navigator.pushReplacement(router);
- // }
- // } else {
- // navigator.push(router);
- // }
- }
- ///切换无参数页面
- static pushNamed(BuildContext context, String routeName) {
- Navigator.pushNamed(context, routeName);
- }
- // ///主页
- // static goHome(BuildContext context) {
- // Navigator.pushReplacementNamed(context, HomePage.sName);
- // }
- ///登录页
- static goLogin(BuildContext context) {
- Navigator.pushReplacementNamed(context, LoginPage.sName);
- }
- // ///图片预览
- // static gotoPhotoViewPage(BuildContext context, String? url) {
- // Navigator.pushNamed(context, PhotoViewPage.sName, arguments: url);
- // }
- //
- // ///个人中心
- // static goPerson(BuildContext context, String? userName) {
- // NavigatorRouter(context, new PersonPage(userName));
- // }
- //
- // ///请求数据调试页面
- // static goDebugDataPage(BuildContext context) {
- // return NavigatorRouter(context, new DebugDataPage());
- // }
- // ///仓库详情
- // static Future goReposDetail(
- // BuildContext context, String? userName, String? reposName) {
- // ///利用 SizeRoute 动画大小打开
- // return Navigator.push(
- // context,
- // PageRouteBuilder(
- // pageBuilder: (context, animation, secondaryAnimation) =>
- // RepositoryDetailPage(userName, reposName),
- // transitionsBuilder: (context, animation, secondaryAnimation, child) {
- // double begin = 0;
- // double end = 1;
- // var curve = Curves.ease;
- //
- // var tween =
- // Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
- //
- // return Align(
- // child: SizeTransition(
- // sizeFactor: animation.drive(tween),
- // child: NeverOverScrollIndicator(
- // needOverload: false,
- // child: child,
- // ),
- // ),
- // );
- // },
- // ));
- // }
- //
- // ///荣耀列表
- // static Future goHonorListPage(BuildContext context, List? list) {
- // return Navigator.push(
- // context,
- // PageRouteBuilder(
- // pageBuilder: (context, animation, secondaryAnimation) =>
- // HonorListPage(list),
- // transitionsBuilder: (context, animation, secondaryAnimation, child) {
- // double begin = 0;
- // double end = 1;
- // var curve = Curves.ease;
- //
- // var tween =
- // Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
- //
- // return Align(
- // child: SizeTransition(
- // sizeFactor: animation.drive(tween),
- // child: NeverOverScrollIndicator(
- // needOverload: false,
- // child: child,
- // ),
- // ),
- // );
- // },
- // ),
- // );
- // }
- //
- // ///仓库版本列表
- // static Future goReleasePage(BuildContext context, String? userName,
- // String? reposName, String releaseUrl, String tagUrl) {
- // return NavigatorRouter(
- // context,
- // new ReleasePage(
- // userName,
- // reposName,
- // releaseUrl,
- // tagUrl,
- // ));
- // }
- //
- // ///issue详情
- // static Future goIssueDetail(
- // BuildContext context, String? userName, String? reposName, String num,
- // {bool needRightLocalIcon = false}) {
- // return NavigatorRouter(
- // context,
- // new IssueDetailPage(
- // userName,
- // reposName,
- // num,
- // needHomeIcon: needRightLocalIcon,
- // ));
- // }
- //
- // ///通用列表
- // static gotoCommonList(
- // BuildContext context, String? title, String showType, CommonListDataType dataType,
- // {String? userName, String? reposName}) {
- // NavigatorRouter(
- // context,
- // new CommonListPage(
- // title,
- // showType,
- // dataType,
- // userName: userName,
- // reposName: reposName,
- // ));
- // }
- //
- // ///仓库详情通知
- // static Future goNotifyPage(BuildContext context) {
- // return NavigatorRouter(context, new NotifyPage());
- // }
- //
- // ///用户趋势
- // static Future goTrendUserPage(BuildContext context) {
- // return NavigatorRouter(context, new TrendUserPage());
- // }
- //
- // ///搜索
- // static Future goSearchPage(BuildContext context, Offset centerPosition) {
- // return showGeneralDialog(
- // context: context,
- // pageBuilder: (BuildContext buildContext, Animation<double> animation,
- // Animation<double> secondaryAnimation) {
- // return Builder(builder: (BuildContext context) {
- // return pageContainer(SearchPage(centerPosition), context);
- // });
- // },
- // barrierDismissible: false,
- // barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
- // barrierColor: Color(0x01000000),
- // transitionDuration: const Duration(milliseconds: 150),
- // transitionBuilder: (BuildContext context, Animation<double> animation,
- // Animation<double> secondaryAnimation, Widget child) {
- // return FadeTransition(
- // opacity: CurvedAnimation(
- // parent: animation,
- // curve: Curves.easeOut,
- // ),
- // child: child,
- // );
- // },
- // );
- // }
- //
- // ///提交详情
- // static Future goPushDetailPage(BuildContext context, String? userName,
- // String? reposName, String? sha, bool needHomeIcon) {
- // return NavigatorRouter(
- // context,
- // new PushDetailPage(
- // sha,
- // userName,
- // reposName,
- // needHomeIcon: needHomeIcon,
- // ));
- // }
- //
- // ///全屏Web页面
- // static Future goGSYWebView(BuildContext context, String url, String? title) {
- // return NavigatorRouter(context, new GSYWebView(url, title));
- // }
- //
- // ///登陆Web页面
- // static Future goLoginWebView(BuildContext context, String url, String title) {
- // return NavigatorRouter(context, new LoginWebView(url, title));
- // }
- //
- // ///文件代码详情Web
- // static gotoCodeDetailPageWeb(BuildContext context,
- // {String? title,
- // String? userName,
- // String? reposName,
- // String? path,
- // String? data,
- // String? branch,
- // String? htmlUrl}) {
- // NavigatorRouter(
- // context,
- // new CodeDetailPageWeb(
- // title: title,
- // userName: userName,
- // reposName: reposName,
- // path: path,
- // data: data,
- // branch: branch,
- // htmlUrl: htmlUrl,
- // ));
- // }
- //
- // ///根据平台跳转文件代码详情Web
- // static gotoCodeDetailPlatform(BuildContext context,
- // {String? title,
- // String? userName,
- // String? reposName,
- // String? path,
- // String? data,
- // String? branch,
- // String? htmlUrl}) {
- // NavigatorUtils.gotoCodeDetailPageWeb(
- // context,
- // title: title,
- // reposName: reposName,
- // userName: userName,
- // data: data,
- // path: path,
- // branch: branch,
- // );
- // }
- //
- // ///用户配置
- // static gotoUserProfileInfo(BuildContext context) {
- // NavigatorRouter(context, new UserProfileInfo());
- // }
- //
- // ///公共打开方式
- // static NavigatorRouter(BuildContext context, Widget widget) {
- // return Navigator.push(
- // context,
- // new CupertinoPageRoute(
- // builder: (context) => pageContainer(widget, context)));
- // }
- //
- // ///Page页面的容器,做一次通用自定义
- // static Widget pageContainer(widget, BuildContext context) {
- // return MediaQuery(
- //
- // ///不受系统字体缩放影响
- // data: MediaQuery.of(context).copyWith(textScaleFactor: 1),
- // child: NeverOverScrollIndicator(
- // needOverload: false,
- // child: widget,
- // ));
- // }
- //
- // ///弹出 dialog
- // static Future<T?> showGSYDialog<T>({
- // required BuildContext context,
- // bool barrierDismissible = true,
- // WidgetBuilder? builder,
- // }) {
- // return showDialog<T>(
- // context: context,
- // barrierDismissible: barrierDismissible,
- // builder: (context) {
- // return MediaQuery(
- //
- // ///不受系统字体缩放影响
- // data: MediaQueryData.fromView(WidgetsBinding.instance.platformDispatcher.views.first)
- // .copyWith(textScaleFactor: 1),
- // child: NeverOverScrollIndicator(
- // needOverload: false,
- // child: new SafeArea(child: builder!(context)),
- // ));
- // });
- // }
- }
|