From 25aae118ca87658fa323ec660d5ab1bf94e2ce7e Mon Sep 17 00:00:00 2001 From: Marcelo Milhomem Date: Sun, 19 Dec 2021 11:25:23 +1100 Subject: [PATCH 1/4] Removes unused PlayStore URL This url was not used anymore as this is not required by Android apps as they know to self introspect and the framework provides the upgrade url for us. --- example/lib/dio.dart | 1 - example/lib/main.dart | 2 -- lib/src/native_updater.dart | 5 ----- 3 files changed, 8 deletions(-) diff --git a/example/lib/dio.dart b/example/lib/dio.dart index 183303d..09cf009 100644 --- a/example/lib/dio.dart +++ b/example/lib/dio.dart @@ -32,7 +32,6 @@ class _HomeState extends State { context, forceUpdate: true, appStoreUrl: '', - playStoreUrl: '', iOSDescription: '', iOSUpdateButtonLabel: 'Upgrade', iOSCloseButtonLabel: 'Exit', diff --git a/example/lib/main.dart b/example/lib/main.dart index 3f622f6..67ac8b4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -43,7 +43,6 @@ class _HomeState extends State { context, forceUpdate: true, appStoreUrl: '', - playStoreUrl: '', iOSDescription: '', iOSUpdateButtonLabel: 'Upgrade', iOSCloseButtonLabel: 'Exit', @@ -53,7 +52,6 @@ class _HomeState extends State { context, forceUpdate: false, appStoreUrl: '', - playStoreUrl: '', iOSDescription: '', iOSUpdateButtonLabel: 'Upgrade', iOSIgnoreButtonLabel: 'Next Time', diff --git a/lib/src/native_updater.dart b/lib/src/native_updater.dart index 5de7ab0..a9b3c43 100644 --- a/lib/src/native_updater.dart +++ b/lib/src/native_updater.dart @@ -14,7 +14,6 @@ class NativeUpdater { late bool _forceUpdate; late String _appName; String? _appStoreUrl; - String? _playStoreUrl; String? _iOSDescription; String? _iOSUpdateButtonLabel; String? _iOSCloseButtonLabel; @@ -31,7 +30,6 @@ class NativeUpdater { BuildContext context, { required bool forceUpdate, String? appStoreUrl, - String? playStoreUrl, String? iOSDescription, String? iOSUpdateButtonLabel, String? iOSCloseButtonLabel, @@ -46,7 +44,6 @@ class NativeUpdater { _nativeUpdaterInstance._forceUpdate = forceUpdate; _nativeUpdaterInstance._appName = info.appName; _nativeUpdaterInstance._appStoreUrl = appStoreUrl; - _nativeUpdaterInstance._playStoreUrl = playStoreUrl; _nativeUpdaterInstance._iOSDescription = iOSDescription; _nativeUpdaterInstance._iOSUpdateButtonLabel = iOSUpdateButtonLabel; _nativeUpdaterInstance._iOSCloseButtonLabel = iOSCloseButtonLabel; @@ -94,8 +91,6 @@ class NativeUpdater { } void _showMaterialAlertDialog() async { - developer.log('Playstore URL: ${_playStoreUrl ?? ''}'); - /// In App Update Related try { AppUpdateInfo _updateInfo = await InAppUpdate.checkForUpdate(); From 80f99ec075ff22cac90bfdb6419f2652367f35f5 Mon Sep 17 00:00:00 2001 From: Marcelo Milhomem Date: Sun, 19 Dec 2021 11:28:34 +1100 Subject: [PATCH 2/4] Improve example to include Dio and dependencies It was a bit odd to copy the example and make it run as it had dependencies that were not imported on its structure. --- example/ios/Podfile | 76 ++-------- example/ios/Podfile.lock | 28 +--- example/ios/Runner.xcodeproj/project.pbxproj | 7 - .../contents.xcworkspacedata | 2 +- example/lib/dio.dart | 6 +- example/pubspec.lock | 142 +++++++++--------- example/pubspec.yaml | 3 +- 7 files changed, 97 insertions(+), 167 deletions(-) diff --git a/example/ios/Podfile b/example/ios/Podfile index 6697f0a..1e8c3c9 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -10,78 +10,32 @@ project 'Runner', { 'Release' => :release, } -def parse_KV_file(file, separator='=') - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return []; +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" end - generated_key_values = {} - skip_line_start_symbols = ["#", "/"] - File.foreach(file_abs_path) do |line| - next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } - plugin = line.split(pattern=separator) - if plugin.length == 2 - podname = plugin[0].strip() - path = plugin[1].strip() - podpath = File.expand_path("#{path}", file_abs_path) - generated_key_values[podname] = podpath - else - puts "Invalid plugin specification: #{line}" - end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches end - generated_key_values + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" end +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + target 'Runner' do use_frameworks! use_modular_headers! - # Flutter Pod - - copied_flutter_dir = File.join(__dir__, 'Flutter') - copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework') - copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec') - unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path) - # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet. - # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration. - # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist. - - generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig') - unless File.exist?(generated_xcode_build_settings_path) - raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first" - end - generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path) - cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR']; - - unless File.exist?(copied_framework_path) - FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) - end - unless File.exist?(copied_podspec_path) - FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir) - end - end - - # Keep pod path relative so it can be checked into Podfile.lock. - pod 'Flutter', :path => 'Flutter' - - # Plugin Pods - - # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock - # referring to absolute paths on developers' machines. - system('rm -rf .symlinks') - system('mkdir -p .symlinks/plugins') - plugin_pods = parse_KV_file('../.flutter-plugins') - plugin_pods.each do |name, path| - symlink = File.join('.symlinks', 'plugins', name) - File.symlink(path, symlink) - pod name, :path => File.join(symlink, 'ios') - end + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) end post_install do |installer| installer.pods_project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['ENABLE_BITCODE'] = 'NO' - end + flutter_additional_ios_build_settings(target) end end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 18abab7..f262df4 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,46 +1,28 @@ PODS: - Flutter (1.0.0) - - in_app_update (0.0.1): - - Flutter - package_info (0.0.1): - Flutter - url_launcher (0.0.1): - Flutter - - url_launcher_macos (0.0.1): - - Flutter - - url_launcher_web (0.0.1): - - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - - in_app_update (from `.symlinks/plugins/in_app_update/ios`) - package_info (from `.symlinks/plugins/package_info/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`) - - url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`) - - url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`) EXTERNAL SOURCES: Flutter: :path: Flutter - in_app_update: - :path: ".symlinks/plugins/in_app_update/ios" package_info: :path: ".symlinks/plugins/package_info/ios" url_launcher: :path: ".symlinks/plugins/url_launcher/ios" - url_launcher_macos: - :path: ".symlinks/plugins/url_launcher_macos/ios" - url_launcher_web: - :path: ".symlinks/plugins/url_launcher_web/ios" SPEC CHECKSUMS: - Flutter: 0e3d915762c693b495b44d77113d4970485de6ec - in_app_update: 16e877e205f4360264cb536e3a6481f0d90299e1 - package_info: 48b108e75b8802c2d5e126f208ef540561c98aef - url_launcher: a1c0cc845906122c4784c542523d8cacbded5626 - url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313 - url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c + Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c + package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 + url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef -PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a +PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c -COCOAPODS: 1.9.1 +COCOAPODS: 1.9.3 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index e12cbd8..173b9a9 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -227,15 +227,11 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../Flutter/Flutter.framework", - "${BUILT_PRODUCTS_DIR}/in_app_update/in_app_update.framework", "${BUILT_PRODUCTS_DIR}/package_info/package_info.framework", "${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/in_app_update.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework", ); @@ -316,7 +312,6 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -393,7 +388,6 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -449,7 +443,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; 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/lib/dio.dart b/example/lib/dio.dart index 09cf009..3dbe947 100644 --- a/example/lib/dio.dart +++ b/example/lib/dio.dart @@ -27,7 +27,7 @@ class _HomeState extends State { /// response of HTTP request. /// Let's say the statusCode 412 requires you to force update Future.delayed(Duration.zero, () { - if (statusCode == HttpStatus.unauthorized;) { + if (statusCode == HttpStatus.unauthorized) { NativeUpdater.displayUpdateAlert( context, forceUpdate: true, @@ -47,7 +47,7 @@ class _HomeState extends State { title: Text('Your App'), ), body: Center( - child: FlatButton( + child: TextButton( onPressed: requestAPI, child: Text('Request API') ), @@ -55,7 +55,7 @@ class _HomeState extends State { ); } - requestAPI() { + requestAPI() async { var dio = Dio(BaseOptions( baseUrl: 'http://httpbin.org/', )); diff --git a/example/pubspec.lock b/example/pubspec.lock index 743b9f3..ca220b7 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,69 +1,69 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: + async: dependency: transitive description: - name: archive + name: async url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" - args: + version: "2.7.0" + boolean_selector: dependency: transitive description: - name: args + name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.5.2" - async: + version: "2.1.0" + characters: dependency: transitive description: - name: async + name: characters url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" - boolean_selector: + version: "1.1.0" + charcode: dependency: transitive description: - name: boolean_selector + name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" - charcode: + version: "1.3.1" + clock: dependency: transitive description: - name: charcode + name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" - convert: - dependency: transitive + version: "1.15.0" + cupertino_icons: + dependency: "direct main" description: - name: convert + name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: - dependency: transitive + version: "1.0.3" + dio: + dependency: "direct main" description: - name: crypto + name: dio url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" - cupertino_icons: - dependency: "direct main" + version: "4.0.0" + fake_async: + dependency: transitive description: - name: cupertino_icons + name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -79,76 +79,69 @@ packages: description: flutter source: sdk version: "0.0.0" - image: + http_parser: dependency: transitive description: - name: image + name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "4.0.0" in_app_update: dependency: transitive description: name: in_app_update url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "2.0.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.4.0" native_updater: dependency: "direct main" description: path: ".." relative: true source: path - version: "0.0.3" + version: "0.1.0" package_info: dependency: transitive description: name: package_info url: "https://pub.dartlang.org" source: hosted - version: "0.4.0+16" + version: "2.0.2" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" + version: "1.8.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" + version: "2.0.0" sky_engine: dependency: transitive description: flutter @@ -160,91 +153,98 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.4.1" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" url_launcher: dependency: transitive description: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "5.4.2" + version: "6.0.6" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+4" + version: "2.0.0" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.6" + version: "2.0.3" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.1+1" - vector_math: + version: "2.0.1" + url_launcher_windows: dependency: transitive description: - name: vector_math + name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" - xml: + version: "2.0.0" + vector_math: dependency: transitive description: - name: xml + name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "2.1.0" sdks: - dart: ">=2.4.0 <3.0.0" - flutter: ">=1.12.8 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 76e49c4..4c554ee 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,7 +9,8 @@ environment: dependencies: flutter: sdk: flutter - cupertino_icons: ^0.1.3 + cupertino_icons: ^1.0.3 + dio: ^4.0.0 native_updater: path: ../ From e876f2bd980bae07d1f9afe1db5a9a69e6aee8e1 Mon Sep 17 00:00:00 2001 From: Marcelo Milhomem Date: Sun, 19 Dec 2021 11:31:49 +1100 Subject: [PATCH 3/4] Improves ability to translate/customise messages As the community needs more flexibility for customising the language this package provides by default. New fields are not added to cover the hard coded messages which will also allow for translations if the user decides to do that too. It could have a better way to delegate the language but it's ok to have it as parameters for now. --- example/lib/main.dart | 3 +++ lib/src/error_material_alert.dart | 8 ++++++-- lib/src/native_updater.dart | 24 ++++++++++++++++++++---- lib/src/update_material_alert.dart | 7 +++++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 67ac8b4..2b44ad5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -46,6 +46,9 @@ class _HomeState extends State { iOSDescription: '', iOSUpdateButtonLabel: 'Upgrade', iOSCloseButtonLabel: 'Exit', + errorText: "Error", + errorCloseButtonLabel: "Close", + errorSubtitle: "This version of the app isn't legit" ); } else if (serverLatestVersion > localVersion) { NativeUpdater.displayUpdateAlert( diff --git a/lib/src/error_material_alert.dart b/lib/src/error_material_alert.dart index 6e75267..ff4cdb7 100644 --- a/lib/src/error_material_alert.dart +++ b/lib/src/error_material_alert.dart @@ -3,10 +3,14 @@ import 'package:flutter/material.dart'; class ErrorMaterialAlert extends StatelessWidget { final String appName; final String description; + final String? errorCloseButtonLabel; + final String? errorSubtitle; ErrorMaterialAlert({ required this.appName, required this.description, + this.errorCloseButtonLabel, + this.errorSubtitle, }); @override @@ -16,7 +20,7 @@ class ErrorMaterialAlert extends StatelessWidget { ); Widget closeButton = TextButton( - child: Text('CLOSE', style: TextStyle(color: Colors.white)), + child: Text(errorCloseButtonLabel ?? 'CLOSE', style: TextStyle(color: Colors.white)), onPressed: () => Navigator.pop(context), style: flatButtonStyle, ); @@ -28,7 +32,7 @@ class ErrorMaterialAlert extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Can\'t perform update.', + errorSubtitle ?? 'Can\'t perform update.', style: TextStyle(color: Colors.grey), ), SizedBox(height: 24.0), diff --git a/lib/src/native_updater.dart b/lib/src/native_updater.dart index a9b3c43..b7be4bd 100644 --- a/lib/src/native_updater.dart +++ b/lib/src/native_updater.dart @@ -19,6 +19,11 @@ class NativeUpdater { String? _iOSCloseButtonLabel; String? _iOSIgnoreButtonLabel; String? _iOSAlertTitle; + String? _requireUpdateText; + String? _recommendUpdateText; + String? _errorText; + String? _errorCloseButtonLabel; + String? _errorSubtitle; /// Singleton related static final NativeUpdater _nativeUpdaterInstance = NativeUpdater._internal(); @@ -35,6 +40,11 @@ class NativeUpdater { String? iOSCloseButtonLabel, String? iOSIgnoreButtonLabel, String? iOSAlertTitle, + String? requireUpdateText, + String? recommendUpdateText, + String? errorText, + String? errorCloseButtonLabel, + String? errorSubtitle, }) async { /// Get current installed version of app final PackageInfo info = await PackageInfo.fromPlatform(); @@ -49,7 +59,11 @@ class NativeUpdater { _nativeUpdaterInstance._iOSCloseButtonLabel = iOSCloseButtonLabel; _nativeUpdaterInstance._iOSIgnoreButtonLabel = iOSIgnoreButtonLabel; _nativeUpdaterInstance._iOSAlertTitle = iOSAlertTitle; - + _nativeUpdaterInstance._requireUpdateText = requireUpdateText ?? 'requires that you update to the latest version. You cannot use this app until it is updated.'; + _nativeUpdaterInstance._recommendUpdateText = recommendUpdateText ?? 'recommends that you update to the latest version. You can keep using this app while downloading the update.'; + _nativeUpdaterInstance._errorText = errorText; + _nativeUpdaterInstance._errorCloseButtonLabel = errorCloseButtonLabel; + _nativeUpdaterInstance._errorSubtitle = errorSubtitle; /// Show the alert based on current platform if (Platform.isIOS) { _nativeUpdaterInstance._showCupertinoAlertDialog(); @@ -64,10 +78,10 @@ class NativeUpdater { if (_forceUpdate) { selectedDefaultDescription = - '$_appName requires that you update to the latest version. You cannot use this app until it is updated.'; + '$_appName $_requireUpdateText'; } else { selectedDefaultDescription = - '$_appName recommends that you update to the latest version. You can keep using this app while downloading the update.'; + '$_appName $_recommendUpdateText'; } Widget alert = UpdateCupertinoAlert( @@ -113,7 +127,9 @@ class NativeUpdater { return ErrorMaterialAlert( appName: _appName, description: - 'This version of $_appName was not installed from Google Play Store.', + _errorText ?? 'This version of $_appName was not installed from Google Play Store.', + errorCloseButtonLabel:_errorCloseButtonLabel, + errorSubtitle: _errorSubtitle, ); }, ); diff --git a/lib/src/update_material_alert.dart b/lib/src/update_material_alert.dart index 4adef26..6182dbf 100644 --- a/lib/src/update_material_alert.dart +++ b/lib/src/update_material_alert.dart @@ -12,6 +12,7 @@ class UpdateMaterialAlert extends StatelessWidget { final String updateButtonLabel; final String closeButtonLabel; final String ignoreButtonLabel; + final String newVersionLabel; UpdateMaterialAlert({ required this.forceUpdate, @@ -22,6 +23,7 @@ class UpdateMaterialAlert extends StatelessWidget { required this.updateButtonLabel, required this.closeButtonLabel, required this.ignoreButtonLabel, + this.newVersionLabel = 'New version available' }); @override @@ -42,7 +44,8 @@ class UpdateMaterialAlert extends StatelessWidget { ); Widget updateButton = TextButton( - child: Text(updateButtonLabel.toUpperCase(), style: TextStyle(color: Colors.white)), + child: Text(updateButtonLabel.toUpperCase(), + style: TextStyle(color: Colors.white)), style: flatButtonStyle, onPressed: () => launch(playStoreUrl), ); @@ -55,7 +58,7 @@ class UpdateMaterialAlert extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'New version available', + newVersionLabel, style: TextStyle(color: Colors.grey), ), SizedBox(height: 24.0), From 78485e9359796a3bd0d97cd86c2398bb3007ec5f Mon Sep 17 00:00:00 2001 From: Marcelo Milhomem Date: Sun, 19 Dec 2021 11:35:01 +1100 Subject: [PATCH 4/4] Publishing version 0.1.1 Introducing more flexbibility to text messages and keeping Flutter dependencies up-to-date. This is to publish the needed requested by the community. Closes #22 Closes #18 --- CHANGELOG.md | 6 ++++++ pubspec.lock | 24 ++++++++++++------------ pubspec.yaml | 6 +++--- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b4aba2..125e93f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [0.1.1] - 19/12/2021 + +- Keeping dependencies up-to-date +- More flexibility on hard-coded text messages +- Improving example code + ## [0.1.0] - 16/05/2021 This is a major change as we are forcing an upgrade on the SDK. diff --git a/pubspec.lock b/pubspec.lock index c0fb8cb..1d6f95d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -99,7 +99,7 @@ packages: name: package_info url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" path: dependency: transitive description: @@ -113,7 +113,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" sky_engine: dependency: transitive description: flutter @@ -125,7 +125,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -160,7 +160,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: @@ -174,42 +174,42 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.3" + version: "6.0.10" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.4" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.5" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" vector_math: dependency: transitive description: @@ -219,4 +219,4 @@ packages: version: "2.1.0" sdks: dart: ">=2.12.0 <3.0.0" - flutter: ">=1.22.0" + flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index b27c398..d7e0853 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: native_updater description: Flutter package for prompting users to update with a native dialog whether using the app store version or any version at the user's discretion. author: Ofload -version: 0.1.0 +version: 0.1.1 homepage: https://github.com/ofload/native_updater environment: @@ -12,9 +12,9 @@ dependencies: flutter: sdk: flutter # package_info will help us to find current installed version of application. - package_info: ^2.0.0 + package_info: ^2.0.2 # url_launcher will help us to trigger app store / play store url from our app. - url_launcher: ^6.0.3 + url_launcher: ^6.0.10 # Enables In App Updates on Android using the official Android APIs. in_app_update: ^2.0.0