datangyun 11 ماه پیش
والد
کامیت
bbbc81644b
1فایلهای تغییر یافته به همراه75 افزوده شده و 0 حذف شده
  1. 75 0
      lib/main.dart

+ 75 - 0
lib/main.dart

@@ -0,0 +1,75 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutterappfuyou/code/version3/YSPerfectChapterInfo.dart';
+import 'package:fluwx/fluwx.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+import 'YSPage.dart';
+import 'package:flutter_localizations/flutter_localizations.dart';
+import 'code/YSMeans.dart';
+import 'code/YSWomanBody.dart';
+import 'code/YSlogin.dart';
+import 'code/base/YSLocalizationsDelegate.dart';
+
+void main() async{
+  WidgetsFlutterBinding.ensureInitialized();
+  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: Colors.transparent,statusBarIconBrightness: Brightness.light),);
+  SystemChrome.setPreferredOrientations([
+    DeviceOrientation.portraitUp,
+    DeviceOrientation.portraitDown
+  ]);
+  SharedPreferences prefs = await SharedPreferences.getInstance();
+  String token = prefs.getString('token');
+  bool isLogin = token==null?false:true;
+  int chapters = prefs.getInt('chapters')??99;
+  bool isMeans = prefs.getBool('isMeans')??false;
+  // bool isFirst = prefs.get('first')??false;
+  registerWxApi(appId: "wx6a9788c655738c6e",universalLink: "https://xian_muzishouce/app/");
+  runApp(MyApp(isLogin: isLogin,chapters: chapters,isMeans: isMeans,));
+  // runApp(MyApp(isLogin: false,));
+}
+
+
+
+class MyApp extends StatelessWidget {
+  // This widget is the root of your application.
+  final bool isLogin;
+  final bool isMeans;
+  final int chapters;
+  const MyApp({Key key, this.isLogin, this.chapters, this.isMeans}) : super(key: key);
+  @override
+  Widget build(BuildContext context) {
+    return MaterialApp(
+      title: '西安母子手册',
+      color: Colors.white,
+      routes: {
+        'YSMeans': (v) => YSMeans(),
+        'YSBody': (v) => YSWomanBody(),
+        "YSMeans": (context) => YSMeans(),
+      },
+      debugShowCheckedModeBanner: false,
+      theme: ThemeData(
+        primaryColor: Color(0xFFDB5278),
+        visualDensity: VisualDensity.adaptivePlatformDensity,
+      ),
+      localeListResolutionCallback:
+          (List<Locale> locales, Iterable<Locale> supportedLocales) {
+        return Locale('zh');
+      },
+      localeResolutionCallback:
+          (Locale locale, Iterable<Locale> supportedLocales) {
+        return Locale('zh');
+      },
+      localizationsDelegates: [
+        ZhCupertinoLocalizations.delegate,
+        GlobalMaterialLocalizations.delegate,
+        GlobalWidgetsLocalizations.delegate,
+        GlobalCupertinoLocalizations.delegate,
+      ],
+      supportedLocales: [
+        const Locale('zh', 'CH'),
+        const Locale('en', 'US'),
+      ],
+      home: isLogin==false?YSLogin():chapters==99?YSPerfectChapterInfo(isFirst: true,):isMeans==false?YSMeans(isFirst: true,):YSPage(),
+    );
+  }
+}