diff --git a/lib/main.dart b/lib/main.dart index 2e492037..f24ce1e1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,16 +1,11 @@ -import 'package:akuCommunity/constants/config.dart'; -import 'package:firebase_core/firebase_core.dart'; -import 'package:firebase_crashlytics/firebase_crashlytics.dart'; +import 'package:akuCommunity/main_initialize.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:fluwx/fluwx.dart'; import 'package:get/get.dart'; -import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:provider/provider.dart'; import 'package:akuCommunity/constants/app_theme.dart'; @@ -22,47 +17,15 @@ import 'package:akuCommunity/utils/developer_util.dart'; import 'package:akuCommunity/utils/headers.dart'; void main() async { + DeveloperUtil.setDev(true); WidgetsFlutterBinding.ensureInitialized(); - await Firebase.initializeApp(); - FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); - Future.delayed(Duration(seconds: 5), () { - FirebaseCrashlytics.instance.log("Higgs-Boson detected! Bailing out"); - }); - FlutterError.onError = (detail) { - FirebaseCrashlytics.instance.recordFlutterError(detail); - }; - SystemChrome.setSystemUIOverlayStyle( - SystemUiOverlayStyle( - statusBarColor: Colors.transparent, - systemNavigationBarColor: Colors.white, - ), - ); - JPush jpush = new JPush(); - jpush.addEventHandler( - // 接收通知回调方法。 - onReceiveNotification: (Map message) async { - print("flutter onReceiveNotification: $message"); - }, - // 点击通知回调方法。 - onOpenNotification: (Map message) async { - print("flutter onOpenNotification: $message"); - }, - // 接收自定义消息回调方法。 - onReceiveMessage: (Map message) async { - print("flutter onReceiveMessage: $message"); - }, - ); - jpush.setup( - appKey: "6a2c6507e3e8b3187ac1c9f9", - channel: "developer-default", - production: false, - debug: true, // 设置是否打印 debug 日志 - ); - jpush.applyPushAuthority( - new NotificationSettingsIOS(sound: true, alert: true, badge: true)); - DeveloperUtil.setDev(true); - registerWxApi(appId: AppConfig.wechatAppId); + ///firebase crashlytics initalize + await MainInitialize.initFirebase(); + MainInitialize.initTheme(); + await MainInitialize.initJPush(); + MainInitialize.initWechat(); + runApp(MyApp()); } diff --git a/lib/main_initialize.dart b/lib/main_initialize.dart new file mode 100644 index 00000000..823916bd --- /dev/null +++ b/lib/main_initialize.dart @@ -0,0 +1,54 @@ +import 'package:akuCommunity/constants/app_theme.dart'; +import 'package:akuCommunity/constants/config.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:fluwx/fluwx.dart'; +import 'package:jpush_flutter/jpush_flutter.dart'; +import 'package:power_logger/power_logger.dart'; + +class MainInitialize { + ///初始化firebase + static Future initFirebase() async { + await Firebase.initializeApp(); + FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); + FlutterError.onError = (detail) { + FirebaseCrashlytics.instance.recordFlutterError(detail); + }; + } + + static initTheme() { + SystemChrome.setSystemUIOverlayStyle(SystemStyle.initial); + } + + static Future initJPush() async { + JPush jpush = new JPush(); + Function(Map message) jPushLogger(String type) { + return (Map message) async { + LoggerData.addData({ + 'type': type, + 'message': message, + }); + }; + } + + jpush.addEventHandler( + onReceiveNotification: jPushLogger('onReceiveNotification'), + onOpenNotification: jPushLogger('onOpenNotification'), + onReceiveMessage: jPushLogger('onReceiveMessage'), + ); + jpush.setup( + appKey: "6a2c6507e3e8b3187ac1c9f9", + channel: "developer-default", + production: false, + debug: true, + ); + String rID = await jpush.getRegistrationID(); + LoggerData.addData('RegistrationID:$rID'); + } + + static initWechat() { + registerWxApi(appId: AppConfig.wechatAppId); + } +} diff --git a/lib/pages/setting_page/settings_page.dart b/lib/pages/setting_page/settings_page.dart index b67830e1..ab6ae718 100644 --- a/lib/pages/setting_page/settings_page.dart +++ b/lib/pages/setting_page/settings_page.dart @@ -114,7 +114,7 @@ class _SettingsPageState extends State { // ), // ), _buildTile( - title: null, + title: '关于小蜜蜂智慧社区', onTap: () => Get.to(() => AboutPage()), ), //TODO 邀请注册 diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index 97c72c96..4ad1ab32 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -1,6 +1,5 @@ import 'dart:io'; -import 'package:akuCommunity/constants/app_theme.dart'; import 'package:akuCommunity/widget/picker/bee_house_picker.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart';