From 36754ba47da7a3277d5be183a523c912a1dc4cef Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 31 三月 2022 15:07:08 +0800
Subject: [PATCH] service服务bug修复

---
 src/main/resources/code/flutter_module/lib/main.dart |  449 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 354 insertions(+), 95 deletions(-)

diff --git a/src/main/resources/code/flutter_module/lib/main.dart b/src/main/resources/code/flutter_module/lib/main.dart
index 358c6ce..4f939d7 100644
--- a/src/main/resources/code/flutter_module/lib/main.dart
+++ b/src/main/resources/code/flutter_module/lib/main.dart
@@ -1,112 +1,371 @@
+import 'dart:convert';
+
+import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_boost/flutter_boost.dart';
 
-void main() => runApp(const MyApp());
+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';
 
-class MyApp extends StatelessWidget {
-  const MyApp({Key? key}) : super(key: key);
+// void main() {
+//   runApp(getBasePage(
+//     AboutUsPage(title: ""),
+//   ));
+// }
 
-  // This widget is the root of your application.
+void main() {
+  ///娣诲姞鍏ㄥ眬鐢熷懡鍛ㄦ湡鐩戝惉绫�
+  PageVisibilityBinding.instance.addGlobalObserver(AppLifecycleObserver());
+  CustomFlutterBinding();
+  //window.defaultRouteName
+  runApp(MyApp());
+}
+
+class CustomFlutterBinding extends WidgetsFlutterBinding
+    with BoostFlutterBinding {}
+
+class MyApp extends StatefulWidget {
   @override
-  Widget build(BuildContext context) {
+  _MyAppState createState() => _MyAppState();
+}
+
+class _MyAppState extends State<MyApp> {
+  /// 鐢变簬寰堝鍚屽璇存病鏈夎烦杞姩鐢伙紝杩欓噷鏄洜涓轰箣鍓峞xmaple閲岄潰鐢ㄧ殑鏄� [PageRouteBuilder]锛�
+  /// 鍏跺疄杩欓噷鏄彲浠ヨ嚜瀹氫箟鐨勶紝鍜孊oost娌″お澶氬叧绯伙紝姣斿鎴戞兂鐢ㄧ被浼糹OS骞冲彴鐨勫姩鐢伙紝
+  /// 閭d箞鍙渶瑕佸儚涓嬮潰杩欐牱鍐欐垚 [CupertinoPageRoute] 鍗冲彲
+  /// (杩欓噷鍏ㄥ啓鎴怺MaterialPageRoute]涔熻锛岃繖閲屽彧涓嶈繃鐢╗CupertinoPageRoute]涓句緥瀛�)
+  ///
+  /// 娉ㄦ剰锛屽鏋滈渶瑕乸ush鐨勬椂鍊欙紝涓や釜椤甸潰閮介渶瑕佸姩鐨勮瘽锛�
+  /// 锛堝氨鏄儚iOS native閭f牱锛屽湪push鐨勬椂鍊欙紝鍓嶉潰涓�涓〉闈篃浼氬悜宸︽帹涓�娈佃窛绂伙級
+  /// 閭d箞鍓嶅悗涓や釜椤甸潰閮藉繀椤绘槸閬靛惊CupertinoRouteTransitionMixin鐨勮矾鐢�
+  /// 绠�鍗曟潵璇达紝灏变袱涓〉闈㈤兘鏄疌upertinoPageRoute灏卞ソ
+  /// 濡傛灉鐢∕aterialPageRoute鐨勮瘽鍚岀悊
+  static Route<dynamic>? _getSimpleRoute(
+      RouteSettings settings, String? uniqueId, Widget page) {
+    return CupertinoPageRoute(
+        settings: settings,
+        builder: (_) {
+          return page;
+        });
+  }
+
+  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: "",
+            );
+          });
+    },
+    "PersonInfoPage": (RouteSettings settings, String? uniqueId) {
+      return _getSimpleRoute(settings, uniqueId, PersonInfoPage(title: ""));
+    },
+    "SettingPage": (RouteSettings settings, String? uniqueId) {
+      return _getSimpleRoute(settings, uniqueId, SettingPage(title: ""));
+    },
+    "EmailLoginPage": (RouteSettings settings, String? uniqueId) {
+      return _getSimpleRoute(settings, uniqueId, EmailLoginPage(title: ""));
+    },
+    "LoginPage": (RouteSettings settings, String? uniqueId) {
+      return _getSimpleRoute(settings, uniqueId, LoginPage(title: ""));
+    },
+    "AdvicePage": (RouteSettings settings, String? uniqueId) {
+      return _getSimpleRoute(settings, uniqueId, AdvicePage(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;
+      }
+      Map<String, dynamic> params = settings.arguments as Map<String, dynamic>;
+      return CupertinoPageRoute(
+          settings: settings,
+          builder: (_) {
+            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) {
+    print("璺敱鏋勯��:${settings}");
+    FlutterBoostRouteFactory? func = routerMap[settings.name!];
+    if (func == null) {
+      return null;
+    }
+    return func(settings, uniqueId);
+  }
+
+  Widget appBuilder(Widget home) {
     return MaterialApp(
-      title: 'Flutter Demo',
-      theme: ThemeData(
-        // This is the theme of your application.
-        //
-        // Try running your application with "flutter run". You'll see the
-        // application has a blue toolbar. Then, without quitting the app, try
-        // changing the primarySwatch below to Colors.green and then invoke
-        // "hot reload" (press "r" in the console where you ran "flutter run",
-        // or press Run > Flutter Hot Reload in a Flutter IDE). Notice that the
-        // counter didn't reset back to zero; the application is not restarted.
-        primarySwatch: Colors.blue,
-      ),
-      home: const MyHomePage(title: 'Flutter Demo Home Page'),
+      home: home,
+      debugShowCheckedModeBanner: true,
+
+      ///蹇呴』鍔犱笂builder鍙傛暟锛屽惁鍒檚howDialog绛変細鍑洪棶棰�
+      builder: (_, __) {
+        return home;
+      },
     );
   }
-}
-
-class MyHomePage extends StatefulWidget {
-  const MyHomePage({Key? key, required this.title}) : super(key: key);
-
-  // This widget is the home page of your application. It is stateful, meaning
-  // that it has a State object (defined below) that contains fields that affect
-  // how it looks.
-
-  // This class is the configuration for the state. It holds the values (in this
-  // case the title) provided by the parent (in this case the App widget) and
-  // used by the build method of the State. Fields in a Widget subclass are
-  // always marked "final".
-
-  final String title;
 
   @override
-  State<MyHomePage> createState() => _MyHomePageState();
-}
-
-class _MyHomePageState extends State<MyHomePage> {
-  int _counter = 0;
-
-  void _incrementCounter() {
-    setState(() {
-      // This call to setState tells the Flutter framework that something has
-      // changed in this State, which causes it to rerun the build method below
-      // so that the display can reflect the updated values. If we changed
-      // _counter without calling setState(), then the build method would not be
-      // called again, and so nothing would appear to happen.
-      _counter++;
-    });
+  void initState() {
+    super.initState();
   }
 
   @override
   Widget build(BuildContext context) {
-    // This method is rerun every time setState is called, for instance as done
-    // by the _incrementCounter method above.
-    //
-    // The Flutter framework has been optimized to make rerunning build methods
-    // fast, so that you can just rebuild anything that needs updating rather
-    // than having to individually change instances of widgets.
-    return Scaffold(
-      appBar: AppBar(
-        // Here we take the value from the MyHomePage object that was created by
-        // the App.build method, and use it to set our appbar title.
-        title: Text(widget.title),
-      ),
-      body: Center(
-        // Center is a layout widget. It takes a single child and positions it
-        // in the middle of the parent.
-        child: Column(
-          // Column is also a layout widget. It takes a list of children and
-          // arranges them vertically. By default, it sizes itself to fit its
-          // children horizontally, and tries to be as tall as its parent.
-          //
-          // Invoke "debug painting" (press "p" in the console, choose the
-          // "Toggle Debug Paint" action from the Flutter Inspector in Android
-          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
-          // to see the wireframe for each widget.
-          //
-          // Column has various properties to control how it sizes itself and
-          // how it positions its children. Here we use mainAxisAlignment to
-          // center the children vertically; the main axis here is the vertical
-          // axis because Columns are vertical (the cross axis would be
-          // horizontal).
-          mainAxisAlignment: MainAxisAlignment.center,
-          children: <Widget>[
-            const Text(
-              'You have pushed the button this many times:',
-            ),
-            Text(
-              '$_counter',
-              style: Theme.of(context).textTheme.headline4,
-            ),
-          ],
-        ),
-      ),
-      floatingActionButton: FloatingActionButton(
-        onPressed: _incrementCounter,
-        tooltip: 'Increment',
-        child: const Icon(Icons.add),
-      ), // This trailing comma makes auto-formatting nicer for build methods.
+    return FlutterBoostApp(
+      routeFactory,
+      appBuilder: appBuilder,
     );
   }
 }
+
+Widget widgetForRoute(String route) {
+  print("flutter page: $route");
+  Map<String, dynamic> json = jsonDecode(route);
+  String page = json["page"];
+  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 SettingPage(title: "");
+    case "EmailLoginPage":
+      return EmailLoginPage(title: "");
+    case "LoginPage":
+      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"]);
+      }
+  }
+
+  return Container();
+}
+
+///鍏ㄥ眬鐢熷懡鍛ㄦ湡鐩戝惉绀轰緥
+class AppLifecycleObserver with GlobalPageVisibilityObserver {
+  @override
+  void onBackground(Route route) {
+    super.onBackground(route);
+    print("AppLifecycleObserver - ${route.settings.name} - onBackground");
+  }
+
+  @override
+  void onForeground(Route route) {
+    super.onForeground(route);
+    print("AppLifecycleObserver ${route.settings.name} - onForground");
+  }
+
+  @override
+  void onPagePush(Route route) {
+    super.onPagePush(route);
+    print("AppLifecycleObserver - ${route.settings.name}- onPagePush");
+  }
+
+  @override
+  void onPagePop(Route route) {
+    super.onPagePop(route);
+    print("AppLifecycleObserver - ${route.settings.name}- onPagePop");
+  }
+
+  @override
+  void onPageHide(Route route) {
+    super.onPageHide(route);
+    print("AppLifecycleObserver - ${route.settings.name}- onPageHide");
+  }
+
+  @override
+  void onPageShow(Route route) {
+    super.onPageShow(route);
+    print("AppLifecycleObserver - ${route.settings.name}- onPageShow");
+  }
+}

--
Gitblit v1.8.0