| | |
| | | |
| | | import 'package:flutter/cupertino.dart'; |
| | | import 'package:flutter/material.dart'; |
| | | import 'package:flutter/services.dart'; |
| | | import 'package:flutter_boost/flutter_boost.dart'; |
| | | |
| | | import '../../home.dart'; |
| | | import '../../model/video/video_model.dart'; |
| | | import '../../ui/common/browser.dart'; |
| | | import '../../ui/demo_page.dart'; |
| | | import '../../ui/mine/email_login.dart'; |
| | | import '../../ui/mine/login.dart'; |
| | | import '../../ui/mine/person_info.dart'; |
| | | import '../../ui/mine/settings.dart'; |
| | | import '../../ui/video/video_collected_list.dart'; |
| | | import '../../ui/video/video_detail.dart'; |
| | | import '../../ui/video/video_list.dart'; |
| | | import '../../ui/video/video_scan_record_list.dart'; |
| | | import 'mine.dart'; |
| | | import 'ui/mine/about_us.dart'; |
| | | import 'ui/mine/advice.dart'; |
| | | import 'ui/search/search.dart'; |
| | | import 'ui/video/video_attention_list.dart'; |
| | | import 'ui/video/video_download_list.dart'; |
| | | import 'ui/video/video_player_browser.dart'; |
| | | import 'utils/ui_constant.dart'; |
| | | import 'utils/ui_utils.dart'; |
| | | |
| | | // void main() { |
| | | // runApp(getBasePage( |
| | | // AboutUsPage(title: ""), |
| | | // MinePage(title: ""), |
| | | // )); |
| | | // } |
| | | |
| | | void main() { |
| | | void _runNative() { |
| | | ///添加全局生命周期监听类 |
| | | PageVisibilityBinding.instance.addGlobalObserver(AppLifecycleObserver()); |
| | | CustomFlutterBinding(); |
| | | //window.defaultRouteName |
| | | runApp(MyApp()); |
| | | } |
| | | |
| | | void _runLocal() { |
| | | runApp(getBasePage( |
| | | MinePage( |
| | | title: "", |
| | | ), |
| | | )); |
| | | } |
| | | |
| | | void main() { |
| | | if (Constant.NATIVE) { |
| | | _runNative(); |
| | | } else { |
| | | _runLocal(); |
| | | } |
| | | } |
| | | |
| | | class CustomFlutterBinding extends WidgetsFlutterBinding |
| | |
| | | } |
| | | |
| | | Map<String, FlutterBoostRouteFactory> routerMap = { |
| | | '/': (RouteSettings settings, String? uniqueId) { |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | // Map<String, Object> map = settings.arguments as Map<String, Object> ; |
| | | // String data = map['data'] as String; |
| | | return HomePage( |
| | | title: "", |
| | | ); |
| | | }); |
| | | }, |
| | | 'home': (RouteSettings settings, String? uniqueId) { |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | // Map<String, Object> map = settings.arguments as Map<String, Object> ; |
| | | // String data = map['data'] as String; |
| | | return HomePage( |
| | | title: "", |
| | | ); |
| | | }); |
| | | }, |
| | | 'mine': (RouteSettings settings, String? uniqueId) { |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | return MinePage( |
| | | title: "", |
| | | ); |
| | | }); |
| | | }, |
| | | 'VideoDetailPage': (RouteSettings settings, String? uniqueId) { |
| | | if (settings.arguments == null) { |
| | | return null; |
| | | } |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | Map<String, dynamic> params = |
| | | settings.arguments as Map<String, dynamic>; |
| | | int position = params["position"] ?? 0; |
| | | return VideoDetailPage( |
| | | videoInfo: VideoInfoModel.fromJson(params["video"]), |
| | | position: position, |
| | | ); |
| | | }); |
| | | }, |
| | | 'VideoCollectedPage': (RouteSettings settings, String? uniqueId) { |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | return VideoCollectedPage( |
| | | title: "", |
| | | ); |
| | | }); |
| | | }, |
| | | 'VideoAttentionPage': (RouteSettings settings, String? uniqueId) { |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | return VideoAttentionPage( |
| | | title: "", |
| | | ); |
| | | }); |
| | | }, |
| | | 'VideoScanRecordPage': (RouteSettings settings, String? uniqueId) { |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | return VideoScanRecordPage( |
| | | title: "", |
| | | ); |
| | | }); |
| | | }, |
| | | 'VideoDownloadPage': (RouteSettings settings, String? uniqueId) { |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | return VideoDownloadPage( |
| | | title: "", |
| | | ); |
| | | }); |
| | |
| | | "AboutUsPage": (RouteSettings settings, String? uniqueId) { |
| | | return _getSimpleRoute(settings, uniqueId, AboutUsPage(title: "")); |
| | | }, |
| | | 'SearchPage': (RouteSettings settings, String? uniqueId) { |
| | | if (settings.arguments == null) { |
| | | return null; |
| | | } |
| | | Map<String, dynamic> params = settings.arguments as Map<String, dynamic>; |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | return SearchPage( |
| | | title: params["title"] ?? "", |
| | | ); |
| | | }); |
| | | }, |
| | | 'VideoListPage': (RouteSettings settings, String? uniqueId) { |
| | | if (settings.arguments == null) { |
| | | return null; |
| | | } |
| | | Map<String, dynamic> params = settings.arguments as Map<String, dynamic>; |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | String kw = params["kw"]!; |
| | | String title = params["title"] ?? ""; |
| | | return VideoListPage( |
| | | title: title, |
| | | kw: kw, |
| | | ); |
| | | }); |
| | | }, |
| | | 'BrowserPage': (RouteSettings settings, String? uniqueId) { |
| | | if (settings.arguments == null) { |
| | | return null; |
| | |
| | | String title = params["title"] ?? ""; |
| | | return BrowserPage(title: title, url: params["url"]); |
| | | }); |
| | | }, |
| | | 'VideoPlayerWebPage': (RouteSettings settings, String? uniqueId) { |
| | | if (settings.arguments == null) { |
| | | return null; |
| | | } |
| | | Map<String, dynamic> params = settings.arguments as Map<String, dynamic>; |
| | | return CupertinoPageRoute( |
| | | settings: settings, |
| | | builder: (_) { |
| | | String title = params["title"] ?? ""; |
| | | return VideoPlayerWebPage(title: title, url: params["url"]); |
| | | }); |
| | | }, |
| | | } |
| | | }; |
| | | |
| | | Route<dynamic>? routeFactory(RouteSettings settings, String? uniqueId) { |
| | |
| | | return MaterialApp( |
| | | home: home, |
| | | debugShowCheckedModeBanner: true, |
| | | theme: ThemeData(primaryColor: ColorConstant.theme), |
| | | |
| | | ///必须加上builder参数,否则showDialog等会出问题 |
| | | builder: (_, __) { |
| | |
| | | dynamic params = json["params"]; |
| | | |
| | | switch (page) { |
| | | case "DemoPage": |
| | | return DemoPage( |
| | | title: '', |
| | | ); |
| | | case "home": |
| | | return HomePage( |
| | | title: '', |
| | | ); |
| | | case "mine": |
| | | return MinePage(title: ""); |
| | | case "VideoCollectedPage": |
| | | return VideoCollectedPage(title: ""); |
| | | case "VideoAttentionPage": |
| | | return VideoAttentionPage(title: ""); |
| | | case "VideoScanRecordPage": |
| | | return VideoScanRecordPage(title: ""); |
| | | case "VideoDownloadPage": |
| | | return VideoDownloadPage(title: ""); |
| | | case "PersonInfoPage": |
| | | return PersonInfoPage(title: ""); |
| | | case "SettingPage": |
| | |
| | | return LoginPage(title: ""); |
| | | case "AdvicePage": |
| | | return AdvicePage(title: ""); |
| | | case "SearchPage": |
| | | return SearchPage(title: params!["title"]); |
| | | case "AboutUsPage": |
| | | return AboutUsPage(title: ""); |
| | | case "VideoDetailPage": |
| | | { |
| | | int position = params!["position"] ?? 0; |
| | | return VideoDetailPage( |
| | | videoInfo: VideoInfoModel.fromJson(params!["video"]), |
| | | position: position, |
| | | ); |
| | | } |
| | | |
| | | case "VideoListPage": |
| | | { |
| | | String kw = params!["kw"]!; |
| | | String title = params!["title"] ?? ""; |
| | | return VideoListPage( |
| | | title: title, |
| | | kw: kw, |
| | | ); |
| | | } |
| | | case "BrowserPage": |
| | | { |
| | | String title = params!["title"] ?? ""; |
| | | return BrowserPage(title: title, url: params!["url"]); |
| | | } |
| | | case "VideoPlayerWebPage": |
| | | { |
| | | String title = params!["title"] ?? ""; |
| | | return VideoPlayerWebPage(title: title, url: params!["url"]); |
| | | } |
| | | } |
| | | |