From 823482a8bd6a8721279d4f310677bb14a27235a4 Mon Sep 17 00:00:00 2001 From: kidozh <11661760+kidozh@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:48:41 +0100 Subject: [PATCH] change version dependency --- ios/Runner/AppDelegate.swift | 2 +- lib/app/MainApp.dart | 324 +++++++++++++++++++---------------- pubspec.yaml | 6 +- 3 files changed, 176 insertions(+), 156 deletions(-) diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 33da405b..179c5575 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -1,7 +1,7 @@ import UIKit import Flutter -@UIApplicationMain +@main @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, diff --git a/lib/app/MainApp.dart b/lib/app/MainApp.dart index 7dac5c6f..460a410a 100644 --- a/lib/app/MainApp.dart +++ b/lib/app/MainApp.dart @@ -63,12 +63,13 @@ class MyApp extends StatelessWidget { await UserPreferencesUtils.getMaterial3PropertyPreference(); bool allowPush = await UserPreferencesUtils.getPushPreference(); String signature = await UserPreferencesUtils.getSignaturePreference(); - String? typography = await UserPreferencesUtils.getTypographyThemePreference(); + String? typography = + await UserPreferencesUtils.getTypographyThemePreference(); bool useThinFont = await UserPreferencesUtils.getUseThinFontPreference(); - bool useCompactParagraph = await UserPreferencesUtils.getUseCompactParagraphPreference(); - DynamicSchemeVariant dynamicSchemeVariant = await UserPreferencesUtils.getInterfaceDynamicSchemeVariantPreference(); - - + bool useCompactParagraph = + await UserPreferencesUtils.getUseCompactParagraphPreference(); + DynamicSchemeVariant dynamicSchemeVariant = + await UserPreferencesUtils.getInterfaceDynamicSchemeVariantPreference(); Provider.of(context, listen: false) .setTheme(colorName); @@ -86,14 +87,18 @@ class MyApp extends StatelessWidget { .allowPush = allowPush; Provider.of(context, listen: false) .signature = signature; - Provider.of(context, listen: false).setNotificationCount(NoticeCount()); + Provider.of(context, listen: false) + .setNotificationCount(NoticeCount()); - if(typography != null){ - Provider.of(context, listen: false).typographyTheme = typography; + if (typography != null) { + Provider.of(context, listen: false) + .typographyTheme = typography; } - Provider.of(context, listen: false).useThinFontWeight = useThinFont; - Provider.of(context, listen: false).useCompactParagraph = useCompactParagraph; + Provider.of(context, listen: false) + .useThinFontWeight = useThinFont; + Provider.of(context, listen: false) + .useCompactParagraph = useCompactParagraph; } TargetPlatform? getTargetPlatformByName(String name) { @@ -127,64 +132,73 @@ class MyApp extends StatelessWidget { ThemeMode? themeMode = null; Typography typography = Typography.material2021(); - String platformName = Provider.of(context, listen: false).platformName; + String platformName = + Provider.of(context, listen: false) + .platformName; TargetPlatform targetPlatform = TargetPlatform.android; - TypeSettingNotifierProvider typeSetting = Provider.of(context, listen:false); + TypeSettingNotifierProvider typeSetting = + Provider.of(context, listen: false); - switch(platformName){ - case "ios":{ - targetPlatform = TargetPlatform.iOS; - break; - } - case "android":{ - targetPlatform = TargetPlatform.android; - break; - } - case "":{ - targetPlatform = Theme.of(context).platform; - } + switch (platformName) { + case "ios": + { + targetPlatform = TargetPlatform.iOS; + break; + } + case "android": + { + targetPlatform = TargetPlatform.android; + break; + } + case "": + { + targetPlatform = Theme.of(context).platform; + } } - switch (typeSetting.typographyTheme){ - case "material2014":{ - typography = Typography.material2014(platform: targetPlatform); - break; - } - case "material2018":{ - typography = Typography.material2018(platform: targetPlatform); - break; - } - case "material2021":{ - typography = Typography.material2021(platform: targetPlatform); - break; - } - default:{ - typography = Theme.of(context).typography; - } + switch (typeSetting.typographyTheme) { + case "material2014": + { + typography = Typography.material2014(platform: targetPlatform); + break; + } + case "material2018": + { + typography = Typography.material2018(platform: targetPlatform); + break; + } + case "material2021": + { + typography = Typography.material2021(platform: targetPlatform); + break; + } + default: + { + typography = Theme.of(context).typography; + } } final materialThemeDataLight = ThemeData.from( - colorScheme: ColorScheme.fromSeed( - seedColor: themeColorEntity.themeColor, - dynamicSchemeVariant: themeColorEntity.dynamicSchemeVariant, - brightness: Brightness.light, - //surface: Colors.white, - ).harmonized(), - useMaterial3: themeColorEntity.useMaterial3, - textTheme: typography.black.useSystemChineseFont(Brightness.light), + colorScheme: ColorScheme.fromSeed( + seedColor: themeColorEntity.themeColor, + dynamicSchemeVariant: themeColorEntity.dynamicSchemeVariant, + brightness: Brightness.light, + //surface: Colors.white, + ).harmonized(), + useMaterial3: themeColorEntity.useMaterial3, + textTheme: typography.black.useSystemChineseFont(Brightness.light), ); final materialThemeDataDark = ThemeData.from( - colorScheme: ColorScheme.fromSeed( - seedColor: themeColorEntity.themeColor, - dynamicSchemeVariant: themeColorEntity.dynamicSchemeVariant, - brightness: Brightness.dark, - //surface: Colors.black54 - ).harmonized() - , - useMaterial3: themeColorEntity.useMaterial3, - textTheme: typography.white.useSystemChineseFont(Brightness.dark), + colorScheme: ColorScheme.fromSeed( + seedColor: themeColorEntity.themeColor, + dynamicSchemeVariant: themeColorEntity.dynamicSchemeVariant, + brightness: Brightness.dark, + //surface: Colors.black54 + ).harmonized(), + useMaterial3: themeColorEntity.useMaterial3, + textTheme: typography.white.useSystemChineseFont(Brightness.dark), ); const darkDefaultCupertinoTheme = CupertinoThemeData(brightness: Brightness.dark); @@ -213,7 +227,6 @@ class MyApp extends StatelessWidget { if (themeColorEntity.brightness == null) { themeMode = ThemeMode.system; - } else if (themeColorEntity.brightness == Brightness.light) { themeMode = ThemeMode.light; } else if (themeColorEntity.brightness == Brightness.dark) { @@ -227,34 +240,36 @@ class MyApp extends StatelessWidget { settings: PlatformSettingsData(), builder: (context) { return PlatformTheme( - themeMode: themeMode, - materialLightTheme: materialThemeDataLight, - materialDarkTheme: materialThemeDataDark, - cupertinoLightTheme: cupertinoLightTheme, - cupertinoDarkTheme: cupertinoDarkTheme, - onThemeModeChanged: (themeMode) { - themeMode = themeMode; - }, - - builder: (context) => UpgradeAlert( + themeMode: themeMode, + materialLightTheme: materialThemeDataLight, + materialDarkTheme: materialThemeDataDark, + cupertinoLightTheme: cupertinoLightTheme, + cupertinoDarkTheme: cupertinoDarkTheme, + onThemeModeChanged: (themeMode) { + themeMode = themeMode; + }, + builder: (context) => UpgradeAlert( child: PlatformApp( - //title: S.of(context).appName, - navigatorKey: navigatorKey, - debugShowCheckedModeBanner: false, - navigatorObservers: [ - FirebaseAnalyticsObserver(analytics: FirebaseAnalytics.instance), - ], - localizationsDelegates: [ - S.delegate, - GlobalCupertinoLocalizations.delegate, - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate - ], - supportedLocales: S.delegate.supportedLocales, - builder: EasyLoading.init(), - home: MainTwoPanePage(navigatorKey: this.navigatorKey,), - )), - ); + //title: S.of(context).appName, + navigatorKey: navigatorKey, + debugShowCheckedModeBanner: false, + navigatorObservers: [ + FirebaseAnalyticsObserver( + analytics: FirebaseAnalytics.instance), + ], + localizationsDelegates: [ + S.delegate, + GlobalCupertinoLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate + ], + supportedLocales: S.delegate.supportedLocales, + builder: EasyLoading.init(), + home: MainTwoPanePage( + navigatorKey: this.navigatorKey, + ), + )), + ); }, ); }, @@ -264,7 +279,11 @@ class MyApp extends StatelessWidget { class MyHomePage extends StatefulWidget { GlobalKey navigatorKey; - MyHomePage({Key? key, required this.title, this.onSelectTid, required this.navigatorKey}) + MyHomePage( + {Key? key, + required this.title, + this.onSelectTid, + required this.navigatorKey}) : super(key: key); final ValueChanged? onSelectTid; @@ -272,8 +291,8 @@ class MyHomePage extends StatefulWidget { final String title; @override - _MyHomePageState createState() => - _MyHomePageState(onSelectTid: this.onSelectTid, navigatorKey: this.navigatorKey); + _MyHomePageState createState() => _MyHomePageState( + onSelectTid: this.onSelectTid, navigatorKey: this.navigatorKey); } class _MyHomePageState extends State with WidgetsBindingObserver { @@ -288,7 +307,7 @@ class _MyHomePageState extends State with WidgetsBindingObserver { // List _allDiscuzs = []; - _MyHomePageState({this.onSelectTid,required this.navigatorKey}) { + _MyHomePageState({this.onSelectTid, required this.navigatorKey}) { _queryDiscuzList(); } @@ -296,7 +315,8 @@ class _MyHomePageState extends State with WidgetsBindingObserver { void didChangePlatformBrightness() { super.didChangePlatformBrightness(); // change now - final MediaQueryData data = MediaQueryData.fromView(WidgetsBinding.instance.platformDispatcher.views.single); + final MediaQueryData data = MediaQueryData.fromView( + WidgetsBinding.instance.platformDispatcher.views.single); Provider.of(context, listen: false) .setBrightness(data.platformBrightness); //Theme.of(context).brightness = window.platformBrightness; @@ -307,13 +327,11 @@ class _MyHomePageState extends State with WidgetsBindingObserver { super.didChangeDependencies(); // print("Update token to all applicable discuzes"); // PushServiceUtils.updateTokenToAllApplicableDiscuzes(context); - } StreamSubscription>? _onNotificationTap = null; - - Future checkIfNotificationIsTap()async { + Future checkIfNotificationIsTap() async { // Push.Push.instance.notificationTapWhichLaunchedAppFromTerminated.then((data){ // if (data == null) { // print("App was not launched by tapping a notification"); @@ -337,7 +355,6 @@ class _MyHomePageState extends State with WidgetsBindingObserver { // }); } - Future setupInteractedMessage() async { // Get any messages which caused the application to open from // a terminated state. @@ -369,15 +386,15 @@ class _MyHomePageState extends State with WidgetsBindingObserver { } } - Future reportDiscuzListToAnalytics() async{ + Future reportDiscuzListToAnalytics() async { // check with last submission bool shouldSendReport = await UserPreferencesUtils.shouldReportAnalytics(); - if(shouldSendReport){ + if (shouldSendReport) { log("Send Discuz report to Google analytics"); DiscuzDao _discuzDao = await AppDatabase.getDiscuzDao(); List discuzList = await _discuzDao.findAllDiscuzs(); - discuzList.forEach((discuz) async{ + discuzList.forEach((discuz) async { await FirebaseAnalytics.instance.logEvent( name: "discuz_maintain", parameters: { @@ -389,14 +406,12 @@ class _MyHomePageState extends State with WidgetsBindingObserver { }); await UserPreferencesUtils.putLastReportAnalyticsTime(); } - - } @override void dispose() { WidgetsBinding.instance.removeObserver(this); - if(_onNotificationTap != null){ + if (_onNotificationTap != null) { _onNotificationTap!.cancel(); } super.dispose(); @@ -456,7 +471,11 @@ class _MyHomePageState extends State with WidgetsBindingObserver { padding: EdgeInsets.fromLTRB(24.0, 12.0, 24.0, 16.0), child: PlatformElevatedButton( color: Theme.of(context).colorScheme.primaryContainer, - child: Text(S.of(context).addNewDiscuz, style: TextStyle(color: Theme.of(context).colorScheme.onPrimaryContainer),), + child: Text( + S.of(context).addNewDiscuz, + style: TextStyle( + color: Theme.of(context).colorScheme.onPrimaryContainer), + ), //color: Theme.of(context).colorScheme.onPrimaryContainer, onPressed: () { VibrationUtils.vibrateWithClickIfPossible(); @@ -473,7 +492,6 @@ class _MyHomePageState extends State with WidgetsBindingObserver { await showPlatformModalSheet( context: context, //BuildContext对象 builder: (BuildContext context) { - return SimpleDialog( title: Text(S.of(context).chooseDiscuz), children: widgetList); }); @@ -483,7 +501,8 @@ class _MyHomePageState extends State with WidgetsBindingObserver { builder: (BuildContext context) { return SimpleDialog( backgroundColor: Theme.of(context).colorScheme.surface, - title: Text(S.of(context).chooseDiscuz), children: widgetList); + title: Text(S.of(context).chooseDiscuz), + children: widgetList); }); } } @@ -529,16 +548,12 @@ class _MyHomePageState extends State with WidgetsBindingObserver { @override Widget build(BuildContext context) { // need to check whether discuz exists in dataset - User? user = Provider.of(context, listen: false).user; - if(user == null && _bottomNavigationbarIndex >= 2){ + User? user = + Provider.of(context, listen: false).user; + if (user == null && _bottomNavigationbarIndex >= 2) { _bottomNavigationbarIndex = 0; } - - - - - return PlatformScaffold( //iosContentPadding: true, appBar: PlatformAppBar( @@ -551,7 +566,11 @@ class _MyHomePageState extends State with WidgetsBindingObserver { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(value.discuz!.siteName, maxLines: 1, overflow: TextOverflow.ellipsis,), + Text( + value.discuz!.siteName, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), if (value.user == null) Text(S.of(context).incognitoTitle, style: TextStyle(fontSize: 12)), @@ -567,13 +586,12 @@ class _MyHomePageState extends State with WidgetsBindingObserver { ), trailingActions: [ DiscuzNotificationAppbarIconWidget(), - PlatformIconButton( padding: EdgeInsets.symmetric(vertical: 0, horizontal: 0), onPressed: _triggerSwitchDiscuzDialog, - icon: Icon( AppPlatformIcons(context).manageDiscuzSolid, + size: 24, color: Theme.of(context).textTheme.titleSmall?.color, semanticLabel: S.of(context).selectDiscuzIconTooltip, ), @@ -586,28 +604,30 @@ class _MyHomePageState extends State with WidgetsBindingObserver { return Container(); } else { return PlatformIconButton( + padding: EdgeInsets.symmetric(vertical: 0, horizontal: 0), + + onPressed: () async { + // open drawer + VibrationUtils.vibrateWithClickIfPossible(); + await Navigator.push( + context, + platformPageRoute( + context: context, + builder: (context) => DrawerPage())); + }, + icon: Icon(AppPlatformIcons(context).menuSolid, + semanticLabel: S.of(context).menuIconTooltip, + color: Theme.of(context).textTheme.titleSmall?.color, + size: 24, + ), - padding: EdgeInsets.symmetric(vertical: 0, horizontal: 0), - onPressed: () async { - // open drawer - VibrationUtils.vibrateWithClickIfPossible(); - await Navigator.push( - context, - platformPageRoute( - context: context, - builder: (context) => DrawerPage())); - }, - icon: Icon( - - AppPlatformIcons(context).menuSolid, - semanticLabel: S.of(context).menuIconTooltip, - color: Theme.of(context).textTheme.titleSmall?.color)); + ); } }, ), ), body: Consumer( - builder: (context, value, child){ + builder: (context, value, child) { List bodyWidgetList = [ DashboardScreen( onSelectTid: onSelectTid, @@ -630,19 +650,17 @@ class _MyHomePageState extends State with WidgetsBindingObserver { key: ValueKey(4), ) ]; - if(value.user == null){ + if (value.user == null) { print("Get btm index ${_bottomNavigationbarIndex}"); - if(_bottomNavigationbarIndex < 2){ + if (_bottomNavigationbarIndex < 2) { return bodyWidgetList[_bottomNavigationbarIndex]; - } - else{ + } else { setState(() { _bottomNavigationbarIndex = 0; }); return bodyWidgetList[_bottomNavigationbarIndex]; } - } - else{ + } else { return bodyWidgetList[_bottomNavigationbarIndex]; } }, @@ -652,8 +670,7 @@ class _MyHomePageState extends State with WidgetsBindingObserver { material: (context, _) => MaterialNavBarData( selectedItemColor: Theme.of(context).colorScheme.primary, unselectedItemColor: Theme.of(context).unselectedWidgetColor, - elevation: 0 - ), + elevation: 0), itemChanged: (index) { setState(() { VibrationUtils.vibrateWithClickIfPossible(); @@ -675,18 +692,18 @@ class _MyHomePageState extends State with WidgetsBindingObserver { icon: new Icon(AppPlatformIcons(context).discuzPortalOutlined), activeIcon: Icon(AppPlatformIcons(context).discuzPortalSolid), label: S.of(context).index), - if(user!= null) - BottomNavigationBarItem( - icon: new Icon( - AppPlatformIcons(context).discuzNotificationOutlined), - activeIcon: - Icon(AppPlatformIcons(context).discuzNotificationSolid), - label: S.of(context).notification), - if(user!= null) - BottomNavigationBarItem( - icon: new Icon(AppPlatformIcons(context).discuzMessageOutlined), - activeIcon: Icon(AppPlatformIcons(context).discuzMessageSolid), - label: S.of(context).chatMessage), + if (user != null) + BottomNavigationBarItem( + icon: new Icon( + AppPlatformIcons(context).discuzNotificationOutlined), + activeIcon: + Icon(AppPlatformIcons(context).discuzNotificationSolid), + label: S.of(context).notification), + if (user != null) + BottomNavigationBarItem( + icon: new Icon(AppPlatformIcons(context).discuzMessageOutlined), + activeIcon: Icon(AppPlatformIcons(context).discuzMessageSolid), + label: S.of(context).chatMessage), ], ), material: (_, __) => MaterialScaffoldData(), @@ -701,7 +718,6 @@ class MainTwoPanePage extends StatelessWidget { @override Widget build(BuildContext context) { - return LayoutBuilder(builder: (context, constraints) { return MainTwoPaneStatefulWidget( navigatorKey: this.navigatorKey, @@ -715,7 +731,8 @@ class MainTwoPaneStatefulWidget extends StatefulWidget { final TwoPaneType type; GlobalKey navigatorKey; - MainTwoPaneStatefulWidget({super.key, required this.type, required this.navigatorKey}); + MainTwoPaneStatefulWidget( + {super.key, required this.type, required this.navigatorKey}); @override State createState() { @@ -750,7 +767,10 @@ class MainTwoPaneState extends State if (widget.type == TwoPaneType.smallScreen) { panePriority = _currentTid.value == 0 ? TwoPanePriority.start : TwoPanePriority.end; - return MyHomePage(title: "", navigatorKey: this.navigatorKey,); + return MyHomePage( + title: "", + navigatorKey: this.navigatorKey, + ); } double paneProportion = 0.35; // directly give diff --git a/pubspec.yaml b/pubspec.yaml index a47f5919..50faa133 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -58,7 +58,7 @@ dependencies: intl: ^0.19.0 flutter_platform_widgets: ^7.0.0 flutter_launcher_icons: ^0.13.1 - extended_text_field: ^15.0.0 + extended_text_field: ^16.0.0 image_picker: ^1.0.4 flutter_image_compress: ^2.0.4 package_info_plus: ^8.0.0 @@ -68,7 +68,7 @@ dependencies: hive: any hive_flutter: any device_info_plus: ^10.1.0 - share_plus: ^9.0.0 + share_plus: ^10.0.0 firebase_messaging: ^15.0.3 font_awesome_flutter: ^10.1.0 firebase_analytics: ^11.2.0 @@ -85,7 +85,7 @@ dependencies: intl_utils: ^2.8.1 dual_screen: ^1.0.3 flutter_html_iframe: ^3.0.0-beta.2 - carousel_slider: ^4.2.1 + carousel_slider: ^5.0.0 flutter_html_audio: ^3.0.0-beta.2 flutter_html_svg: ^3.0.0-beta.2 flutter_html_table: ^3.0.0-beta.2