Browse Source

no message

xiaobai 1 month ago
parent
commit
0c692108e2

+ 8 - 23
.metadata

@@ -1,11 +1,11 @@
 # This file tracks properties of this Flutter project.
 # Used by Flutter tool to assess capabilities and perform upgrades etc.
 #
-# This file should be version controlled.
+# This file should be version controlled and should not be manually edited.
 
 version:
-  revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-  channel: stable
+  revision: "4ebf41aeff1498cd12ddb647c5776d80aa7754ae"
+  channel: "[user-branch]"
 
 project_type: app
 
@@ -13,26 +13,11 @@ project_type: app
 migration:
   platforms:
     - platform: root
-      create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-      base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-    - platform: android
-      create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-      base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-    - platform: ios
-      create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-      base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-    - platform: linux
-      create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-      base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-    - platform: macos
-      create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-      base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-    - platform: web
-      create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-      base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-    - platform: windows
-      create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
-      base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
+      create_revision: 4ebf41aeff1498cd12ddb647c5776d80aa7754ae
+      base_revision: 4ebf41aeff1498cd12ddb647c5776d80aa7754ae
+    - platform: ohos
+      create_revision: 4ebf41aeff1498cd12ddb647c5776d80aa7754ae
+      base_revision: 4ebf41aeff1498cd12ddb647c5776d80aa7754ae
 
   # User provided section
 

+ 220 - 219
lib/main.dart

@@ -12,6 +12,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:fluwx/fluwx.dart';
 import 'package:get/get.dart';
 import 'package:iquokka/pages/guide_page.dart';
+import 'package:iquokka/utils/tips_dialog.dart';
 import 'package:logger/logger.dart';
 // import 'package:macos_ui/macos_ui.dart';
 import 'package:home_widget/home_widget.dart';
@@ -31,6 +32,7 @@ import 'package:iquokka/utils/hex_color.dart';
 import 'package:iquokka/utils/toast_utils.dart';
 import 'package:pull_to_refresh/pull_to_refresh.dart';
 import 'package:share_plus/share_plus.dart';
+import 'package:shared_preferences/shared_preferences.dart';
 import 'package:sp_util/sp_util.dart';
 import 'package:umeng_common_sdk/umeng_common_sdk.dart';
 import 'package:universal_platform/universal_platform.dart';
@@ -40,98 +42,105 @@ import 'common/AC.dart';
 import 'common/LanguagePack.dart';
 import 'constant/wx_constant.dart';
 import 'module/app_service.dart';
+import 'module/shared_prefs_util.dart';
 import 'module/user_service.dart';
 import 'pages/today/main/page/sentence_list_page.dart';
 
-@pragma("vm:entry-point")
-Future<void> backgroundCallback(Uri? data) async {
-  if (data?.host == "recordMood") {
-    if (await UserService().isLoginToLoginPage()) {
-      Get.to(() => MoodChoosePage(),
-          binding: MoodRecordBinding(), arguments: {"recordType": 1});
-    }
-  }
-}
-
-@pragma('vm:entry-point')
-void workManagerCallback() {
-  Workmanager().executeTask((task, inputData) async {
-    if (task == 'dayUpdate') {
-      await SpUtil.getInstance();
-      await HomeWidgetService().scheduleUpdateSentenceWidget();
-      await HomeWidgetService().scheduleUpdateRecordMoodWeekWidget();
-      await HomeWidgetService().scheduleUpdateRecordMoodMonthWidget();
-    }
-    return Future.value(true);
-  });
-}
+// @pragma("vm:entry-point")
+// Future<void> backgroundCallback(Uri? data) async {
+//   if (data?.host == "recordMood") {
+//     if (await UserService().isLoginToLoginPage()) {
+//       Get.to(() => MoodChoosePage(),
+//           binding: MoodRecordBinding(), arguments: {"recordType": 1});
+//     }
+//   }
+// }
+//
+// @pragma('vm:entry-point')
+// void workManagerCallback() {
+//   Workmanager().executeTask((task, inputData) async {
+//     if (task == 'dayUpdate') {
+//       await SpUtil.getInstance();
+//       await HomeWidgetService().scheduleUpdateSentenceWidget();
+//       await HomeWidgetService().scheduleUpdateRecordMoodWeekWidget();
+//       await HomeWidgetService().scheduleUpdateRecordMoodMonthWidget();
+//     }
+//     return Future.value(true);
+//   });
+// }
 
 void main() async {
-  // 禁用自动剪贴板读取
-  // SystemChannels.textInput.invokeMethod('TextInput.setDataTransferEnabled', false);
 
   WidgetsFlutterBinding.ensureInitialized();
-  await SpUtil.getInstance();
-
-  SystemChannels.lifecycle.setMessageHandler((msg) async {
-    Logger().d('SystemChannels> $msg');
-    /// msg是个字符串,是下面的值
-    /// AppLifecycleState.resumed
-    /// AppLifecycleState.inactive
-    /// AppLifecycleState.paused
-    /// AppLifecycleState.detached
-    if (msg == "AppLifecycleState.resumed") { //进入前台
-      Logger().d("===================== app进入前台 =====================");
-      AppEvent.getInstance()?.fire(AppEnterForegroundEvent());
-      if (AppService().getThemeMode() == 0) { //跟随系统
-        if (HexColor.isDarkMode != (PlatformDispatcher.instance.platformBrightness==Brightness.dark)) { //系统模式改变
-          HexColor.reload();
-          AC.reload();
-          Get.forceAppUpdate();
-          // ToastUtil.settingEasyLoading();
-        }
-      }
-    }
-    else if (msg == "AppLifecycleState.inactive") { //进入非活跃状态
-      Logger().d("===================== app进入非活跃状态 =====================");
-    }
-    else if (msg == "AppLifecycleState.paused") { //进入后台
-      Logger().d("===================== app进入后台 =====================");
-      AppEvent.getInstance()?.fire(AppPasswordLockEvent());
-    }
-    else if (msg == "AppLifecycleState.detached") { //app被杀死
-      Logger().d("===================== app被杀死 =====================");
-    }
-    return msg;
-  });
-
-  Duration delay;
-  DateTime now = DateTime.now();
-  DateTime targetTime = DateTime(now.year, now.month, now.day, 1, 0, 0);
-
-  if (now.isBefore(targetTime)) {
-    delay = targetTime.difference(now);
-  } else {
-    targetTime = targetTime.add(Duration(days: 1));
-    delay = targetTime.difference(now);
-  }
-
-  Workmanager().initialize(
-      workManagerCallback, // The top level function, aka callbackDispatcher
-      isInDebugMode: false // If enabled it will post a notification whenever the task is running. Handy for debugging tasks
-  );
-  Workmanager().registerPeriodicTask(
-    "dayUpdate",
-    "dayUpdate",
-    initialDelay: delay,
-    constraints: Constraints(
-      networkType: NetworkType.connected,
-    ),
-    backoffPolicy: BackoffPolicy.linear,
-    existingWorkPolicy: ExistingWorkPolicy.replace,
-    frequency: Duration(days: 1),
-    backoffPolicyDelay: Duration(hours: 4)
-  );
+  // await SpUtil.getInstance();
+  await SharedPrefsUtil.getInstance();
+
+  // Future.delayed(Duration(seconds: 1), () async {
+  //   // await SpUtil.getInstance();
+  //   await SharedPrefsUtil.getInstance();
+  // });
+
+  // await SharedPrefsUtil.getInstance();
+
+  // SystemChannels.lifecycle.setMessageHandler((msg) async {
+  //   Logger().d('SystemChannels> $msg');
+  //   /// msg是个字符串,是下面的值
+  //   /// AppLifecycleState.resumed
+  //   /// AppLifecycleState.inactive
+  //   /// AppLifecycleState.paused
+  //   /// AppLifecycleState.detached
+  //   if (msg == "AppLifecycleState.resumed") { //进入前台
+  //     Logger().d("===================== app进入前台 =====================");
+  //     AppEvent.getInstance()?.fire(AppEnterForegroundEvent());
+  //     if (AppService().getThemeMode() == 0) { //跟随系统
+  //       if (HexColor.isDarkMode != (PlatformDispatcher.instance.platformBrightness==Brightness.dark)) { //系统模式改变
+  //         HexColor.reload();
+  //         AC.reload();
+  //         Get.forceAppUpdate();
+  //         // ToastUtil.settingEasyLoading();
+  //       }
+  //     }
+  //   }
+  //   else if (msg == "AppLifecycleState.inactive") { //进入非活跃状态
+  //     Logger().d("===================== app进入非活跃状态 =====================");
+  //   }
+  //   else if (msg == "AppLifecycleState.paused") { //进入后台
+  //     Logger().d("===================== app进入后台 =====================");
+  //     AppEvent.getInstance()?.fire(AppPasswordLockEvent());
+  //   }
+  //   else if (msg == "AppLifecycleState.detached") { //app被杀死
+  //     Logger().d("===================== app被杀死 =====================");
+  //   }
+  //   return msg;
+  // });
+  //
+  // Duration delay;
+  // DateTime now = DateTime.now();
+  // DateTime targetTime = DateTime(now.year, now.month, now.day, 1, 0, 0);
+  //
+  // if (now.isBefore(targetTime)) {
+  //   delay = targetTime.difference(now);
+  // } else {
+  //   targetTime = targetTime.add(Duration(days: 1));
+  //   delay = targetTime.difference(now);
+  // }
+  //
+  // Workmanager().initialize(
+  //     workManagerCallback, // The top level function, aka callbackDispatcher
+  //     isInDebugMode: false // If enabled it will post a notification whenever the task is running. Handy for debugging tasks
+  // );
+  // Workmanager().registerPeriodicTask(
+  //   "dayUpdate",
+  //   "dayUpdate",
+  //   initialDelay: delay,
+  //   constraints: Constraints(
+  //     networkType: NetworkType.connected,
+  //   ),
+  //   backoffPolicy: BackoffPolicy.linear,
+  //   existingWorkPolicy: ExistingWorkPolicy.replace,
+  //   frequency: Duration(days: 1),
+  //   backoffPolicyDelay: Duration(hours: 4)
+  // );
 
   runApp(const MyApp());
 }
@@ -147,100 +156,110 @@ class MyApp extends StatefulWidget {
 
 class _MyAppState extends State<MyApp> {
 
-  StreamSubscription<Uri>? _linkSubscription;
-
-  Future<void> _launchedFromWidget(Uri? uri) async {
-    if (uri?.host == "record") {
-      if (await UserService().isLoginToLoginPage()) {
-        Get.to(() => MoodChoosePage(),
-            binding: MoodRecordBinding(), arguments: {"recordType": 1});
-      }
-    } else if (uri?.host == "footprint") {
-      AppEvent.getInstance()?.fire(BottomNaviBarToIndexEvent(2));
-    } else if (uri?.host == "goodthing") {
-      Get.to(()=>ExamPage(), binding: ExamBinding(), arguments: {
-        "id": 32,
-        "type": 1,
-        "title": "每天三件开心事".tr,
-        "doneNumber": 0,
-        "doneType": 0,
-        "isVip": false,
-        "isPay": false
-      });
-    } else if (uri?.host == "sentence") {
-      Get.to(() => SentenceListPage(type: 1,));
-    }
-  }
-
-  @override
-  void didChangeDependencies() {
-    super.didChangeDependencies();
-    HomeWidget.initiallyLaunchedFromHomeWidget().then(_launchedFromWidget);
-    HomeWidget.widgetClicked.listen(_launchedFromWidget);
-  }
+  // StreamSubscription<Uri>? _linkSubscription;
+  //
+  // Future<void> _launchedFromWidget(Uri? uri) async {
+  //   if (uri?.host == "record") {
+  //     if (await UserService().isLoginToLoginPage()) {
+  //       Get.to(() => MoodChoosePage(),
+  //           binding: MoodRecordBinding(), arguments: {"recordType": 1});
+  //     }
+  //   } else if (uri?.host == "footprint") {
+  //     AppEvent.getInstance()?.fire(BottomNaviBarToIndexEvent(2));
+  //   } else if (uri?.host == "goodthing") {
+  //     Get.to(()=>ExamPage(), binding: ExamBinding(), arguments: {
+  //       "id": 32,
+  //       "type": 1,
+  //       "title": "每天三件开心事".tr,
+  //       "doneNumber": 0,
+  //       "doneType": 0,
+  //       "isVip": false,
+  //       "isPay": false
+  //     });
+  //   } else if (uri?.host == "sentence") {
+  //     Get.to(() => SentenceListPage(type: 1,));
+  //   }
+  // }
+  //
+  // @override
+  // void didChangeDependencies() {
+  //   super.didChangeDependencies();
+  //   HomeWidget.initiallyLaunchedFromHomeWidget().then(_launchedFromWidget);
+  //   HomeWidget.widgetClicked.listen(_launchedFromWidget);
+  // }
 
   @override
   void initState() {
     super.initState();
 
-    _registerWechatApi();
-    HomeWidget.registerInteractivityCallback(backgroundCallback);
-
-    initDeepLinks();
+    // _registerWechatApi();
+    // HomeWidget.registerInteractivityCallback(backgroundCallback);
+    //
+    // initDeepLinks();
 
     //更新语言
-    WidgetsBinding.instance.addPostFrameCallback((_) {
-      Get.updateLocale(Localizations.localeOf(Get.context!));
-    });
+    // WidgetsBinding.instance.addPostFrameCallback((_) async {
+    //   // Get.updateLocale(Localizations.localeOf(Get.context!));
+    //   try {
+    //     SharedPreferences? prefs = await SharedPrefsUtil.getInstance();
+    //     if (prefs != null) {
+    //       TipsDialog.showDialog(title: "SharedPreferences初始化成功");
+    //     } else {
+    //       TipsDialog.showDialog(title: "SharedPreferences初始化失败");
+    //     }
+    //   } catch (e) {
+    //     TipsDialog.showDialog(title: e.toString());
+    //   }
+    // });
   }
 
-  Future<void> initDeepLinks() async {
-    AppLinks().stringLinkStream.listen((scheme) {
-      print("schemescheme = "+scheme);
-      if (scheme == "iquokka-MoodRecordPage") {
-        Get.to(()=>MoodChoosePage(), binding: MoodRecordBinding(), arguments: {"recordType": 1});
-      }
-      else if (scheme == "iquokka-FootprintPage") {
-        AppEvent.getInstance()?.fire(BottomNaviBarToIndexEvent(2));
-      }
-      else if (scheme == "iquokka-RecordGoodThingPage") {
-        Get.to(()=>ExamPage(), binding: ExamBinding(), arguments: {
-          "id": 32,
-          "type": 1,
-          "title": "每天三件开心事".tr,
-          "doneNumber": 0,
-          "doneType": 0,
-          "isVip": false,
-          "isPay": false
-        });
-      }
-      else if (scheme == "https://h5.iquokka.cn/.well-known/apple-app-site-association/explore") {
-        AppEvent.getInstance()?.fire(BottomNaviBarToIndexEvent(1));
-      }
-    });
-  }
+  // Future<void> initDeepLinks() async {
+  //   AppLinks().stringLinkStream.listen((scheme) {
+  //     print("schemescheme = "+scheme);
+  //     if (scheme == "iquokka-MoodRecordPage") {
+  //       Get.to(()=>MoodChoosePage(), binding: MoodRecordBinding(), arguments: {"recordType": 1});
+  //     }
+  //     else if (scheme == "iquokka-FootprintPage") {
+  //       AppEvent.getInstance()?.fire(BottomNaviBarToIndexEvent(2));
+  //     }
+  //     else if (scheme == "iquokka-RecordGoodThingPage") {
+  //       Get.to(()=>ExamPage(), binding: ExamBinding(), arguments: {
+  //         "id": 32,
+  //         "type": 1,
+  //         "title": "每天三件开心事".tr,
+  //         "doneNumber": 0,
+  //         "doneType": 0,
+  //         "isVip": false,
+  //         "isPay": false
+  //       });
+  //     }
+  //     else if (scheme == "https://h5.iquokka.cn/.well-known/apple-app-site-association/explore") {
+  //       AppEvent.getInstance()?.fire(BottomNaviBarToIndexEvent(1));
+  //     }
+  //   });
+  // }
 
   @override
   Widget build(BuildContext context) {
 
-    ///禁用横屏
-    SystemChrome.setPreferredOrientations([
-      DeviceOrientation.portraitUp, //只能纵向
-      DeviceOrientation.portraitDown, //只能纵向
-    ]);
-
-    if (Platform.isAndroid) {
-      /// 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后,是为了在渲染后进行set赋值,覆盖状态栏,写在渲染之前MaterialApp组件会覆盖掉这个值。
-      /// SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(statusBarColor: Colors.transparent);
-      /// SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
-      SystemChrome.setSystemUIOverlayStyle(
-          const SystemUiOverlayStyle(
-            statusBarColor: Colors.transparent,
-            systemNavigationBarColor: Colors.white,
-            systemNavigationBarDividerColor: Colors.white,
-          )
-      );
-    }
+    // ///禁用横屏
+    // SystemChrome.setPreferredOrientations([
+    //   DeviceOrientation.portraitUp, //只能纵向
+    //   DeviceOrientation.portraitDown, //只能纵向
+    // ]);
+    //
+    // if (Platform.isAndroid) {
+    //   /// 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后,是为了在渲染后进行set赋值,覆盖状态栏,写在渲染之前MaterialApp组件会覆盖掉这个值。
+    //   /// SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(statusBarColor: Colors.transparent);
+    //   /// SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
+    //   SystemChrome.setSystemUIOverlayStyle(
+    //       const SystemUiOverlayStyle(
+    //         statusBarColor: Colors.transparent,
+    //         systemNavigationBarColor: Colors.white,
+    //         systemNavigationBarDividerColor: Colors.white,
+    //       )
+    //   );
+    // }
 
     return ScreenUtilInit(
       splitScreenMode: true,
@@ -353,24 +372,6 @@ class _MyAppState extends State<MyApp> {
 
   Widget _getRootWidget() {
 
-    // bool isShowGuide = AppService().isShowGuide();
-    // if (UniversalPlatform.isIOS || UniversalPlatform.isAndroid) {
-    //   if (!isShowGuide) { //展示引导页
-    //     return GuidePage();
-    //   }
-    //   else {
-    //     if (!UserService().isLogin()) { //展示登录页
-    //       return LoginPage();
-    //     }
-    //     else {
-    //       return MainPage();
-    //     }
-    //   }
-    // }
-    // else {
-    //   return MainPage();
-    // }
-
     if (!UserService().isLogin()) { //展示登录页
       return LoginPage();
     }
@@ -379,43 +380,43 @@ class _MyAppState extends State<MyApp> {
     }
   }
 
-  void _registerWechatApi() {
-    // registerWxApi(
-    //     appId: WxConstant.appId, universalLink: WxConstant.universalLink);
-
-    if (AppService().getLoginDialog()) {
-      Fluwx fluwx = Fluwx();
-      fluwx.registerApi(
-        appId: WxConstant.appId,
-        universalLink: WxConstant.universalLink,
-      );
-    }
-  }
+  // void _registerWechatApi() {
+  //   // registerWxApi(
+  //   //     appId: WxConstant.appId, universalLink: WxConstant.universalLink);
+  //
+  //   if (AppService().getLoginDialog()) {
+  //     Fluwx fluwx = Fluwx();
+  //     fluwx.registerApi(
+  //       appId: WxConstant.appId,
+  //       universalLink: WxConstant.universalLink,
+  //     );
+  //   }
+  // }
 }
 
-class GetObserver extends NavigatorObserver {
-  @override
-  void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
-    super.didPush(route, previousRoute);
-    String routerName = route.settings.name??"";
-    if (routerName.contains("?")) {
-      int index = routerName.indexOf("?");
-      routerName = routerName.substring(0, index);
-    }
-    UmengCommonSdk.onPageStart(routerName);
-  }
-
-  @override
-  void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
-    super.didPop(route, previousRoute);
-    String routerName = route.settings.name??"";
-    if (routerName.contains("?")) {
-      int index = routerName.indexOf("?");
-      routerName = routerName.substring(0, index);
-    }
-    UmengCommonSdk.onPageEnd(routerName);
-  }
-}
+// class GetObserver extends NavigatorObserver {
+//   @override
+//   void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
+//     super.didPush(route, previousRoute);
+//     String routerName = route.settings.name??"";
+//     if (routerName.contains("?")) {
+//       int index = routerName.indexOf("?");
+//       routerName = routerName.substring(0, index);
+//     }
+//     UmengCommonSdk.onPageStart(routerName);
+//   }
+//
+//   @override
+//   void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
+//     super.didPop(route, previousRoute);
+//     String routerName = route.settings.name??"";
+//     if (routerName.contains("?")) {
+//       int index = routerName.indexOf("?");
+//       routerName = routerName.substring(0, index);
+//     }
+//     UmengCommonSdk.onPageEnd(routerName);
+//   }
+// }
 
 
 

+ 43 - 43
lib/module/app_service.dart

@@ -2,8 +2,8 @@
 import 'package:iquokka/common/AC.dart';
 import 'package:iquokka/common/score_rule_model.dart';
 import 'package:iquokka/module/home_widget_service.dart';
+import 'package:iquokka/module/shared_prefs_util.dart';
 import 'package:iquokka/utils/hex_color.dart';
-import 'package:sp_util/sp_util.dart';
 
 import '../pages/today/main/model/update_tips_model.dart';
 
@@ -40,120 +40,120 @@ class AppService {
   AppService._internal();
 
   isFirstLaunch() {
-    return SpUtil.getBool(spFirstLaunch, defValue: true);
+    return SharedPrefsUtil.getBool(spFirstLaunch, defValue: true);
   }
 
   setLaunch() {
-    SpUtil.putBool(spFirstLaunch, false);
+    SharedPrefsUtil.putBool(spFirstLaunch, false);
   }
 
   isAgreeAgreement() {
-    return SpUtil.getBool(spAgreeAgreement, defValue: false);
+    return SharedPrefsUtil.getBool(spAgreeAgreement, defValue: false);
   }
 
   setAgreeAgreement() {
-    SpUtil.putBool(spAgreeAgreement, true);
+    SharedPrefsUtil.putBool(spAgreeAgreement, true);
   }
 
   isShowGuide() {
-    return SpUtil.getBool(spIsShowGuide, defValue: false);
+    return SharedPrefsUtil.getBool(spIsShowGuide, defValue: false);
   }
 
   setShowGuide() {
-    SpUtil.putBool(spIsShowGuide, true);
+    SharedPrefsUtil.putBool(spIsShowGuide, true);
   }
 
   isPersonalRecommend() {
-    return SpUtil.getBool(spIsPersonalRecommend, defValue: false);
+    return SharedPrefsUtil.getBool(spIsPersonalRecommend, defValue: false);
   }
 
   setPersonalRecommend(bool value) {
-    SpUtil.putBool(spIsPersonalRecommend, value);
+    SharedPrefsUtil.putBool(spIsPersonalRecommend, value);
   }
 
   setPracticeFont(int font) {
-    SpUtil.putInt(spIsPracticeFont, font);
+    SharedPrefsUtil.putInt(spIsPracticeFont, font);
   }
 
   int isPracticeFont() {
-    return SpUtil.getInt(spIsPracticeFont, defValue: 0)??0;
+    return SharedPrefsUtil.getInt(spIsPracticeFont, defValue: 0)??0;
   }
 
   setPwdLock(String password) {
-    SpUtil.putString(spPwdLock, password);
+    SharedPrefsUtil.putString(spPwdLock, password);
   }
 
   String getPwdLock() {
-    return SpUtil.getString(spPwdLock, defValue: "")??"";
+    return SharedPrefsUtil.getString(spPwdLock, defValue: "")??"";
   }
 
   setSentenceBg(int bg) {
-    SpUtil.putInt(spSentenceBg, bg);
+    SharedPrefsUtil.putInt(spSentenceBg, bg);
     HomeWidgetService().updateWidgetSentenceBg();
   }
 
   void setSentenceSlideGuide(bool isShow) {
-    SpUtil.putBool(spSentenceSlideGuide, isShow);
+    SharedPrefsUtil.putBool(spSentenceSlideGuide, isShow);
   }
 
   bool getSentenceSlideGuide() {
-    return SpUtil.getBool(spSentenceSlideGuide, defValue: true)??true;
+    return SharedPrefsUtil.getBool(spSentenceSlideGuide, defValue: true)??true;
   }
 
   int getSentenceBg() {
-    return SpUtil.getInt(spSentenceBg, defValue: 1)??1;
+    return SharedPrefsUtil.getInt(spSentenceBg, defValue: 1)??1;
   }
 
   int getThemeMode() {
-    return SpUtil.getInt(spThemeMode, defValue: 0)??0;
+    return SharedPrefsUtil.getInt(spThemeMode, defValue: 0)??0;
   }
 
   // 设置主题模式, 0跟随系统,1浅色模式,2深色模式
   setThemeMode(int modeType) {
-    SpUtil.putInt(spThemeMode, modeType);
+    SharedPrefsUtil.putInt(spThemeMode, modeType);
     HexColor.reload();
     AC.reload();
     HomeWidgetService().updateWidgetTheme();
   }
 
   void setLoginDialog(bool isShow) {
-    SpUtil.putBool(spLoginDialog, isShow);
+    SharedPrefsUtil.putBool(spLoginDialog, isShow);
   }
 
   bool getLoginDialog() {
-    return SpUtil.getBool(spLoginDialog, defValue: false)??false;
+    return SharedPrefsUtil.getBool(spLoginDialog, defValue: false)??false;
   }
 
   void setIsInitMood(bool isInit) {
-    SpUtil.putBool(spIsInitMood, isInit);
+    SharedPrefsUtil.putBool(spIsInitMood, isInit);
   }
 
   bool getIsInitMood() {
-    return SpUtil.getBool(spIsInitMood, defValue: false)??false;
+    return SharedPrefsUtil.getBool(spIsInitMood, defValue: false)??false;
   }
 
   void setTodayCloseBannerId(List<String> bannerIds) {
-    SpUtil.putStringList(spTodayCloseBannerId, bannerIds);
+    SharedPrefsUtil.putStringList(spTodayCloseBannerId, bannerIds);
   }
 
   List<String> getTodayCloseBannerIds() {
-    return SpUtil.getStringList(spTodayCloseBannerId) ?? [];
+    return SharedPrefsUtil.getStringList(spTodayCloseBannerId) ?? [];
   }
 
   void setCurrentDate(String password) {
-    SpUtil.putString(spCurrentDate, password);
+    SharedPrefsUtil.putString(spCurrentDate, password);
   }
 
   String getCurrentDate() {
-    return SpUtil.getString(spCurrentDate, defValue: "")??"";
+    return SharedPrefsUtil.getString(spCurrentDate, defValue: "")??"";
   }
 
   void setVersionUpdateTips(UpdateTipsModel tipsModel) {
-    SpUtil.putObject(spVersionUpdateTips, tipsModel);
+    SharedPrefsUtil.putObject(spVersionUpdateTips, tipsModel);
   }
 
   UpdateTipsModel getVersionUpdateTips() {
-    UpdateTipsModel tipsModel = SpUtil.getObj<UpdateTipsModel?>(spVersionUpdateTips, (v) {
+    UpdateTipsModel tipsModel = SharedPrefsUtil.getObj<UpdateTipsModel?>(spVersionUpdateTips, (v) {
       Map<String, dynamic> converted = {};
       for (var item in v.keys) {
         converted[item.toString()] = v[item];
@@ -165,11 +165,11 @@ class AppService {
   }
 
   void setCurrentVersionUpdateContentTips(UpdateTipsModel tipsModel) {
-    SpUtil.putObject(spCurrentVersionContentTips, tipsModel);
+    SharedPrefsUtil.putObject(spCurrentVersionContentTips, tipsModel);
   }
 
   UpdateTipsModel getCurrentVersionUpdateContentTips() {
-    UpdateTipsModel tipsModel = SpUtil.getObj<UpdateTipsModel?>(spCurrentVersionContentTips, (v) {
+    UpdateTipsModel tipsModel = SharedPrefsUtil.getObj<UpdateTipsModel?>(spCurrentVersionContentTips, (v) {
       Map<String, dynamic> converted = {};
       for (var item in v.keys) {
         converted[item.toString()] = v[item];
@@ -181,11 +181,11 @@ class AppService {
   }
 
   void setAppStoreScoreRule(ScoreRuleModel ruleModel) {
-    SpUtil.putObject(spAppStoreScoreRule, ruleModel);
+    SharedPrefsUtil.putObject(spAppStoreScoreRule, ruleModel);
   }
 
   ScoreRuleModel getAppStoreScoreRule() {
-    ScoreRuleModel ruleModel = SpUtil.getObj<ScoreRuleModel?>(spAppStoreScoreRule, (v) {
+    ScoreRuleModel ruleModel = SharedPrefsUtil.getObj<ScoreRuleModel?>(spAppStoreScoreRule, (v) {
       Map<String, dynamic> converted = {};
       for (var item in v.keys) {
         converted[item.toString()] = v[item];
@@ -197,43 +197,43 @@ class AppService {
   }
 
   void setFootprintHideAiRespond(bool isInit) {
-    SpUtil.putBool(spFootprintHideAiRespond, isInit);
+    SharedPrefsUtil.putBool(spFootprintHideAiRespond, isInit);
   }
 
   bool getFootprintHideAiRespond() {
-    return SpUtil.getBool(spFootprintHideAiRespond, defValue: false)??false;
+    return SharedPrefsUtil.getBool(spFootprintHideAiRespond, defValue: false)??false;
   }
 
   void setHideAiTips(bool isHide) {
-    SpUtil.putBool(spHideAiTips, isHide);
+    SharedPrefsUtil.putBool(spHideAiTips, isHide);
   }
 
   bool getHideAiTips() {
-    return SpUtil.getBool(spHideAiTips, defValue: false)??false;
+    return SharedPrefsUtil.getBool(spHideAiTips, defValue: false)??false;
   }
 
   void setSettingRedPoint(int type) {
-    SpUtil.putInt(spSettingRedPoint, type);
+    SharedPrefsUtil.putInt(spSettingRedPoint, type);
   }
 
   int getSettingRedPoint() {
-    return SpUtil.getInt(spSettingRedPoint, defValue: 0)??0;
+    return SharedPrefsUtil.getInt(spSettingRedPoint, defValue: 0)??0;
   }
 
   // void setSyncAppleHealth(bool isSync) {
-  //   SpUtil.putBool(spSyncAppleHealth, isSync);
+  //   SharedPrefsUtil.putBool(spSyncAppleHealth, isSync);
   // }
   //
   // bool getSyncAppleHealth() {
-  //   return SpUtil.getBool(spSyncAppleHealth, defValue: false)??false;
+  //   return SharedPrefsUtil.getBool(spSyncAppleHealth, defValue: false)??false;
   // }
 
   void setHealthAuthDialog(bool isAuth) {
-    SpUtil.putBool(spHealthAuthDialog, isAuth);
+    SharedPrefsUtil.putBool(spHealthAuthDialog, isAuth);
   }
 
   bool getHealthAuthDialog() {
-    return SpUtil.getBool(spHealthAuthDialog, defValue: false)??false;
+    return SharedPrefsUtil.getBool(spHealthAuthDialog, defValue: false)??false;
   }
 
 

+ 119 - 0
lib/module/shared_prefs_util.dart

@@ -0,0 +1,119 @@
+// lib/utils/shared_prefs_util.dart
+import 'dart:convert';
+import 'package:shared_preferences/shared_preferences.dart';
+
+class SharedPrefsUtil {
+  static SharedPreferences? _prefs;
+
+  // 初始化方法
+  static Future<SharedPreferences?> getInstance() async {
+    _prefs ??= await SharedPreferences.getInstance();
+    return _prefs;
+  }
+
+  // 获取布尔值
+  static bool? getBool(String key, {bool defValue = false}) {
+
+    if (_prefs == null) return defValue;
+    return _prefs!.getBool(key) ?? defValue;
+  }
+
+  // 设置布尔值
+  static Future<bool> putBool(String key, bool value) async {
+    if (_prefs == null) return false;
+    return await _prefs!.setBool(key, value);
+  }
+
+  // 获取字符串
+  static String? getString(String key, {String defValue = ""}) {
+    if (_prefs == null) return defValue;
+    return _prefs!.getString(key) ?? defValue;
+  }
+
+  // 设置字符串
+  static Future<bool> putString(String key, String value) async {
+    if (_prefs == null) return false;
+    return await _prefs!.setString(key, value);
+  }
+
+  // 获取整数
+  static int? getInt(String key, {int defValue = 0}) {
+    if (_prefs == null) return defValue;
+    return _prefs!.getInt(key) ?? defValue;
+  }
+
+  // 设置整数
+  static Future<bool> putInt(String key, int value) async {
+    if (_prefs == null) return false;
+    return await _prefs!.setInt(key, value);
+  }
+
+  // 获取双精度浮点数
+  static double? getDouble(String key, {double defValue = 0.0}) {
+    if (_prefs == null) return defValue;
+    return _prefs!.getDouble(key) ?? defValue;
+  }
+
+  // 设置双精度浮点数
+  static Future<bool> putDouble(String key, double value) async {
+    if (_prefs == null) return false;
+    return await _prefs!.setDouble(key, value);
+  }
+
+  // 获取字符串列表
+  static List<String>? getStringList(String key, {List<String>? defValue}) {
+    if (_prefs == null) return defValue;
+    return _prefs!.getStringList(key) ?? defValue;
+  }
+
+  // 设置字符串列表
+  static Future<bool> putStringList(String key, List<String> value) async {
+    if (_prefs == null) return false;
+    return await _prefs!.setStringList(key, value);
+  }
+
+  // 获取对象 (JSON)
+  static T? getObj<T>(String key, T Function(Map<String, dynamic> v) f, {T? defValue}) {
+    if (_prefs == null) return defValue;
+    String? jsonStr = _prefs!.getString(key);
+    if (jsonStr == null || jsonStr.isEmpty) return defValue;
+
+    try {
+      Map<String, dynamic> map = json.decode(jsonStr);
+      return f(map);
+    } catch (e) {
+      print('SharedPrefsUtil getObj error: $e');
+      return defValue;
+    }
+  }
+
+  // 设置对象 (JSON)
+  static Future<bool> putObject(String key, Object value) async {
+    if (_prefs == null) return false;
+    try {
+      String jsonStr = json.encode(value);
+      return await _prefs!.setString(key, jsonStr);
+    } catch (e) {
+      print('SharedPrefsUtil putObj error: $e');
+      return false;
+    }
+  }
+
+  // 移除键值对
+  static Future<bool> remove(String key) async {
+    if (_prefs == null) return false;
+    return await _prefs!.remove(key);
+  }
+
+  // 清除所有数据
+  static Future<bool> clear() async {
+    if (_prefs == null) return false;
+    return await _prefs!.clear();
+  }
+
+  // 检查是否包含某个键
+  static bool containsKey(String key) {
+    if (_prefs == null) return false;
+    return _prefs!.containsKey(key);
+  }
+}

+ 13 - 10
lib/module/user_service.dart

@@ -1,4 +1,7 @@
 
+import 'dart:io';
+
+import 'package:iquokka/module/shared_prefs_util.dart';
 import 'package:iquokka/utils/app_loading.dart';
 import 'package:get/get.dart';
 import 'package:get/route_manager.dart';
@@ -10,7 +13,7 @@ import 'package:iquokka/pages/main_page.dart';
 import 'package:iquokka/pages/my/login/page/login_page.dart';
 import 'package:iquokka/pages/my/main/model/user_model.dart';
 import 'package:iquokka/utils/toast_utils.dart';
-import 'package:sp_util/sp_util.dart';
+// import 'package:sp_util/sp_util.dart';
 import 'package:umeng_common_sdk/umeng_common_sdk.dart';
 import 'package:universal_platform/universal_platform.dart';
 
@@ -43,12 +46,12 @@ class UserService {
       if (ret.isSuccess() && ret.data != null) {
         ToastUtil.showMsg("登录成功");
         AppService().setPwdLock("");
-        SpUtil.putObject(spUserInfo, ret.data!);
+        SharedPrefsUtil.putObject(spUserInfo, ret.data!);
         _backPage();
         UserModel userModel = ret.data!;
         UmengCommonSdk.onProfileSignIn(userModel.quokkaId??"");
 
-        HomeWidgetService().updateLoginState();
+        // HomeWidgetService().updateLoginState();
       } else {
         ToastUtil.showMsg(ret.msg??"");
       }
@@ -68,13 +71,13 @@ class UserService {
       if (ret.isSuccess() && ret.data != null) {
         ToastUtil.showMsg("登录成功");
         AppService().setPwdLock("");
-        SpUtil.putObject(spUserInfo, ret.data!);
+        SharedPrefsUtil.putObject(spUserInfo, ret.data!);
         _backPage();
 
         UserModel userModel = ret.data!;
         UmengCommonSdk.onProfileSignIn(userModel.quokkaId??"");
 
-        HomeWidgetService().updateLoginState();
+        // HomeWidgetService().updateLoginState();
       } else {
         ToastUtil.showMsg(ret.msg??"");
       }
@@ -83,8 +86,8 @@ class UserService {
 
   void _backPage() {
     //Get.offAll(()=> MainPage(), binding: MainBinding());
-    bool isShowGuide = AppService().isShowGuide();
-    if (UniversalPlatform.isIOS || UniversalPlatform.isAndroid) {
+    if (Platform.isIOS || Platform.isAndroid || Platform.operatingSystem == "ohos") {
+      bool isShowGuide = AppService().isShowGuide();
       if (!isShowGuide) { //展示引导页
         Get.offAll(()=> GuidePage());
       }
@@ -98,7 +101,7 @@ class UserService {
   }
 
   getUserInfo() {
-    return SpUtil.getObj<UserModel?>(spUserInfo, (v) {
+    return SharedPrefsUtil.getObj<UserModel?>(spUserInfo, (v) {
       Map<String, dynamic> converted = {};
       for (var item in v.keys) {
         converted[item.toString()] = v[item];
@@ -114,7 +117,7 @@ class UserService {
   }
 
   logout() {
-    SpUtil.remove(spUserInfo);
+    SharedPrefsUtil.remove(spUserInfo);
     AppService().setPwdLock("");
     UmengCommonSdk.onProfileSignOff();
 
@@ -129,7 +132,7 @@ class UserService {
     UserModel userInfo = getUserInfo();
     userInfo.nickname = nickName;
     userInfo.avatar = avatarUrl;
-    SpUtil.putObject(spUserInfo, userInfo);
+    SharedPrefsUtil.putObject(spUserInfo, userInfo);
   }
 
   // 判断是否登录,没有登录加弹窗提示跳转登录

+ 12 - 0
lib/pages/guide_page.dart

@@ -3,10 +3,14 @@ import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:get/get.dart';
+import 'package:iquokka/module/shared_prefs_util.dart';
+import 'package:iquokka/module/user_service.dart';
 import 'package:iquokka/pages/main_binding.dart';
 import 'package:iquokka/pages/main_page.dart';
 import 'package:iquokka/utils/health_kit_utils.dart';
 import 'package:iquokka/utils/hex_color.dart';
+import 'package:iquokka/utils/tips_dialog.dart';
+import 'package:iquokka/utils/toast_utils.dart';
 
 import '../gen_a/A.dart';
 import '../module/app_service.dart';
@@ -289,6 +293,14 @@ class _GuideState extends State<GuidePage> {
                           onTap: () {
                             if (index < 3) {
                               _pageController.animateToPage(index+1, duration: Duration(milliseconds: 500), curve: Curves.ease);
+
+                              if (index == 0) {
+                                ToastUtil.showMsg(UserService().getToken());
+                                SharedPrefsUtil.putString("xiaobai", "heiheihei");
+                              }
+                              if (index == 2) {
+                                TipsDialog.showDialog(title: SharedPrefsUtil.getString("xiaobai"));
+                              }
                             }
                             else {
                               _toMainPage();

+ 3 - 1
macos/Flutter/GeneratedPluginRegistrant.swift

@@ -21,10 +21,11 @@ import photo_manager
 import rate_my_app
 import share_plus
 import shared_preferences_foundation
-import sqflite
+import sqflite_darwin
 import url_launcher_macos
 import video_player_avfoundation
 import wakelock_plus
+import webview_flutter_wkwebview
 
 func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
   AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
@@ -47,4 +48,5 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
   UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
   FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
   WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
+  WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
 }

File diff suppressed because it is too large
+ 200 - 200
pubspec.lock


+ 19 - 2
pubspec.yaml

@@ -96,7 +96,12 @@ dependencies:
   get: ^4.6.6
 
   #数据存储
-  shared_preferences: ^2.0.18
+#  shared_preferences: ^2.3.2
+
+  shared_preferences:
+    git:
+      url: "https://gitcode.com/openharmony-tpc/flutter_packages.git"
+      path: "packages/shared_preferences/shared_preferences"
 
   #弹窗,鸿蒙不支持
 #  adaptive_dialog: ^1.8.2
@@ -160,7 +165,7 @@ dependencies:
   #intl: ^0.19.0 #多语言
   #easy_localization: ^3.0.7 #多语言
 #  chart_sparkline: ^1.1.1  #图标
-  rate_my_app: ^2.2.0  #评分
+  rate_my_app: ^2.3.0  #评分
   in_app_review: ^2.0.10 #评分
   fl_chart: ^0.69.2 #图标
   #scrollable_positioned_list: ^0.3.8 #设置ListView 滚动到某个位置
@@ -193,6 +198,11 @@ dev_dependencies:
   flutter_test:
     sdk: flutter
 
+#  pigeon:
+#    git:
+#      url: "https://gitcode.com/openharmony-tpc/flutter_packages.git"
+#      path: "packages/pigeon"
+
   # The "flutter_lints" package below contains a set of recommended lints to
   # encourage good coding practices. The lint set provided by the package is
   # activated in the `analysis_options.yaml` file located at the root of your
@@ -251,3 +261,10 @@ flutter:
   # see https://flutter.dev/custom-fonts/#from-packages
 #flutter_intl:
 #  enabled: true
+
+#让所有依赖都指向同一个来源
+dependency_overrides:
+  shared_preferences:
+    git:
+      url: "https://gitcode.com/openharmony-tpc/flutter_packages.git"
+      path: "packages/shared_preferences/shared_preferences"

Some files were not shown because too many files changed in this diff