From cacc3958a42295ec3ef3c1dcd43597cb1d5634bd Mon Sep 17 00:00:00 2001 From: Fernando Ferrara Date: Tue, 4 Jul 2023 09:56:16 -0300 Subject: [PATCH] fix: replace deprecated properties and update example app (#11) * fix: update dependencies * fix: use platformDispatcher instead of deprecated window * fix: update example app --- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 2 +- example/ios/Podfile.lock | 27 ++++++------ example/ios/Runner.xcodeproj/project.pbxproj | 41 +++++++++++-------- .../contents.xcworkspacedata | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/ios/Runner/Info.plist | 4 ++ example/lib/main.dart | 18 ++++---- .../lib/ui/dark_light/dark_light_view.dart | 2 +- .../multiple_themes/multiple_themes_view.dart | 2 +- .../multiple_themes_viewmodel.dart | 2 +- example/pubspec.yaml | 2 +- lib/src/theme_manager.dart | 10 +++-- pubspec.yaml | 5 +-- 14 files changed, 67 insertions(+), 54 deletions(-) diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..4f8d4d2 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 11.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index 1e8c3c9..88359b2 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index f9d4efd..78a7fd8 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,28 +1,29 @@ PODS: - Flutter (1.0.0) - - flutter_statusbarcolor (0.0.1): + - flutter_statusbarcolor_ns (0.0.1): - Flutter - - shared_preferences (0.0.1): + - shared_preferences_foundation (0.0.1): - Flutter + - FlutterMacOS DEPENDENCIES: - Flutter (from `Flutter`) - - flutter_statusbarcolor (from `.symlinks/plugins/flutter_statusbarcolor/ios`) - - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) + - flutter_statusbarcolor_ns (from `.symlinks/plugins/flutter_statusbarcolor_ns/ios`) + - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) EXTERNAL SOURCES: Flutter: :path: Flutter - flutter_statusbarcolor: - :path: ".symlinks/plugins/flutter_statusbarcolor/ios" - shared_preferences: - :path: ".symlinks/plugins/shared_preferences/ios" + flutter_statusbarcolor_ns: + :path: ".symlinks/plugins/flutter_statusbarcolor_ns/ios" + shared_preferences_foundation: + :path: ".symlinks/plugins/shared_preferences_foundation/darwin" SPEC CHECKSUMS: - Flutter: 0e3d915762c693b495b44d77113d4970485de6ec - flutter_statusbarcolor: 8afb1071ed8c58be929f1e32b36c629771fd2259 - shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d + Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + flutter_statusbarcolor_ns: 68a360889d88d7915ae524e422aeab62e4063804 + shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 -PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c +PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 -COCOAPODS: 1.9.3 +COCOAPODS: 1.11.3 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 359e4f5..6d2d415 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -164,7 +164,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -208,10 +208,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -244,6 +246,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -261,17 +264,12 @@ buildActionMask = 2147483647; files = ( ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../Flutter/Flutter.framework", - "${BUILT_PRODUCTS_DIR}/flutter_statusbarcolor/flutter_statusbarcolor.framework", - "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework", + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_statusbarcolor.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework", + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -353,7 +351,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -375,7 +373,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -435,7 +436,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -484,7 +485,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -507,7 +508,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -534,7 +538,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..3db53b6 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/example/lib/main.dart b/example/lib/main.dart index 4006898..cdb83c5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -17,21 +17,21 @@ class MyApp extends StatelessWidget { darkTheme: ThemeData( brightness: Brightness.dark, colorScheme: ColorScheme.fromSwatch().copyWith( - secondary: Colors.yellow[700], // Your accent color background: Colors.blue[700], + brightness: Brightness.dark, + secondary: Colors.yellow[700], ), ), lightTheme: ThemeData( brightness: Brightness.light, - colorScheme: ColorScheme.fromSwatch() - .copyWith( - secondary: Colors.yellow[300], // Your accent color - ) - .copyWith(background: Colors.blue[300]), + colorScheme: ColorScheme.fromSwatch().copyWith( + background: Colors.blue[300], + brightness: Brightness.light, + secondary: Colors.yellow[300], + ), ), - statusBarColorBuilder: (theme) => theme.colorScheme.secondary, - navigationBarColorBuilder: (theme) => theme.colorScheme.secondary, - // themes: getThemes(), + statusBarColorBuilder: (theme) => theme?.colorScheme.secondary, + navigationBarColorBuilder: (theme) => theme?.colorScheme.secondary, builder: (context, regularTheme, darkTheme, themeMode) => MaterialApp( title: 'Flutter Demo', theme: regularTheme, diff --git a/example/lib/ui/dark_light/dark_light_view.dart b/example/lib/ui/dark_light/dark_light_view.dart index ffc435f..ff2a74d 100644 --- a/example/lib/ui/dark_light/dark_light_view.dart +++ b/example/lib/ui/dark_light/dark_light_view.dart @@ -5,7 +5,7 @@ import 'package:stacked_themes/stacked_themes.dart'; import 'dark_light_viewmodel.dart'; class DarkLightView extends StatelessWidget { - const DarkLightView({Key key}) : super(key: key); + const DarkLightView({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/ui/multiple_themes/multiple_themes_view.dart b/example/lib/ui/multiple_themes/multiple_themes_view.dart index e66eff2..096b777 100644 --- a/example/lib/ui/multiple_themes/multiple_themes_view.dart +++ b/example/lib/ui/multiple_themes/multiple_themes_view.dart @@ -4,7 +4,7 @@ import 'package:stacked/stacked.dart'; import 'multiple_themes_viewmodel.dart'; class MultipleThemesView extends StatelessWidget { - const MultipleThemesView({Key key}) : super(key: key); + const MultipleThemesView({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/ui/multiple_themes/multiple_themes_viewmodel.dart b/example/lib/ui/multiple_themes/multiple_themes_viewmodel.dart index f933bf5..b679b1a 100644 --- a/example/lib/ui/multiple_themes/multiple_themes_viewmodel.dart +++ b/example/lib/ui/multiple_themes/multiple_themes_viewmodel.dart @@ -6,7 +6,7 @@ class ThemeModel { final int index; final String title; - ThemeModel({this.index, this.title}); + ThemeModel({required this.index, required this.title}); } class MultipleThemesViewModel extends BaseViewModel { diff --git a/example/pubspec.yaml b/example/pubspec.yaml index dc8c684..1028c7e 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=2.19.0 <3.0.0" dependencies: flutter: diff --git a/lib/src/theme_manager.dart b/lib/src/theme_manager.dart index 79ee6d5..6409757 100644 --- a/lib/src/theme_manager.dart +++ b/lib/src/theme_manager.dart @@ -118,8 +118,9 @@ You can supply either a list of ThemeData objects to the themes property or a li } if (_selectedThemeMode == ThemeMode.system) { - final brightness = - ambiguate(SchedulerBinding.instance)!.window.platformBrightness; + final brightness = ambiguate(SchedulerBinding.instance)! + .platformDispatcher + .platformBrightness; selectedTheme = brightness == Brightness.dark ? darkTheme : lightTheme; } else { selectedTheme = @@ -223,8 +224,9 @@ You can supply either a list of ThemeData objects to the themes property or a li updateOverlayColors( _selectedThemeMode == ThemeMode.dark ? darkTheme : lightTheme); } else { - var currentBrightness = - ambiguate(SchedulerBinding.instance)!.window.platformBrightness; + var currentBrightness = ambiguate(SchedulerBinding.instance)! + .platformDispatcher + .platformBrightness; updateOverlayColors( currentBrightness == Brightness.dark ? darkTheme : lightTheme); } diff --git a/pubspec.yaml b/pubspec.yaml index b458aa1..ff259a9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,20 +6,19 @@ repository: https://github.com/Stacked-Org/themes.git issue_tracker: https://github.com/Stacked-Org/framework/issues environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=2.19.0 <3.0.0" dependencies: flutter: sdk: flutter - stacked_shared: ^1.3.2 + stacked_shared: provider: ^6.0.0 rxdart: ^0.27.1 shared_preferences: ^2.0.6 get_it: ^7.1.3 flutter_statusbarcolor_ns: ^0.5.0 - #universal_io universal_io: ^2.0.4 # dependency_overrides: