diff --git a/.gitignore b/.gitignore index e9dc58d..9780fc1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,7 @@ .packages .pub/ +.build/ +.swiftpm/ build/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4109d..b91f238 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,19 @@ -## 1.0.3 +# Changelog -- Migrated to null-safety (#10) +## 1.1.0 +- **ADDED**: Support for Swift Package Manager -## 1.0.2 +## 1.0.3 +- **CHANGED**: Migrated to null-safety (#10) -- Added WidgetKit.removeItem(String key, String appGroup) +## 1.0.2 +- **ADDED**: WidgetKit.removeItem(String key, String appGroup) ## 1.0.1 - -- Fixed `error: cannot find 'WidgetCenter' in scope` +- **FIXED**: `error: cannot find 'WidgetCenter' in scope` ## 1.0.0 - -Initial Release 👑 - -- Added WidgetKit.reloadAllTimelines() -- Added WidgetKit.reloadTimelines(ofKind: String) -- Added WidgetKit.setItem(String key, dynamic value, String appGroup) -- Added WidgetKit.getItem(String key, String appGroup) +- **ADDED**: WidgetKit.reloadAllTimelines() +- **ADDED**: WidgetKit.reloadTimelines(ofKind: String) +- **ADDED**: WidgetKit.setItem(String key, dynamic value, String appGroup) +- **ADDED**: WidgetKit.getItem(String key, String appGroup) diff --git a/LICENSE b/LICENSE index 62fed7e..d610b47 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Thomas Leiter, Fasky OG +Copyright (c) 2020 Thomas Leiter, Fasky OG, Anton Ustinoff Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index f2872cf..ab8e063 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -20,7 +20,5 @@ ???? CFBundleVersion 1.0 - MinimumOSVersion - 9.0 diff --git a/example/ios/Flutter/ephemeral/flutter_lldb_helper.py b/example/ios/Flutter/ephemeral/flutter_lldb_helper.py new file mode 100644 index 0000000..a88caf9 --- /dev/null +++ b/example/ios/Flutter/ephemeral/flutter_lldb_helper.py @@ -0,0 +1,32 @@ +# +# Generated file, do not edit. +# + +import lldb + +def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict): + """Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages.""" + base = frame.register["x0"].GetValueAsAddress() + page_len = frame.register["x1"].GetValueAsUnsigned() + + # Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the + # first page to see if handled it correctly. This makes diagnosing + # misconfiguration (e.g. missing breakpoint) easier. + data = bytearray(page_len) + data[0:8] = b'IHELPED!' + + error = lldb.SBError() + frame.GetThread().GetProcess().WriteMemory(base, data, error) + if not error.Success(): + print(f'Failed to write into {base}[+{page_len}]', error) + return + +def __lldb_init_module(debugger: lldb.SBDebugger, _): + target = debugger.GetDummyTarget() + # Caveat: must use BreakpointCreateByRegEx here and not + # BreakpointCreateByName. For some reasons callback function does not + # get carried over from dummy target for the later. + bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$") + bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__)) + bp.SetAutoContinue(True) + print("-- LLDB integration loaded --") diff --git a/example/ios/Flutter/ephemeral/flutter_lldbinit b/example/ios/Flutter/ephemeral/flutter_lldbinit new file mode 100644 index 0000000..e3ba6fb --- /dev/null +++ b/example/ios/Flutter/ephemeral/flutter_lldbinit @@ -0,0 +1,5 @@ +# +# Generated file, do not edit. +# + +command script import --relative-to-command-file flutter_lldb_helper.py diff --git a/example/ios/Flutter/ephemeral/flutter_native_integration.env b/example/ios/Flutter/ephemeral/flutter_native_integration.env new file mode 100644 index 0000000..b140ec0 --- /dev/null +++ b/example/ios/Flutter/ephemeral/flutter_native_integration.env @@ -0,0 +1,13 @@ +FLUTTER_ROOT=/Users/ziqq/Development/flutter +FLUTTER_APPLICATION_PATH=/Users/ziqq/Development/git/ziqq/flutter_widgetkit/example +FLUTTER_FRAMEWORK_SWIFT_PACKAGE_PATH=/Users/ziqq/Development/git/ziqq/flutter_widgetkit/example/ios/Flutter/ephemeral/Packages/.packages/FlutterFramework +COCOAPODS_PARALLEL_CODE_SIGN=true +FLUTTER_TARGET=/Users/ziqq/Development/git/ziqq/flutter_widgetkit/example/lib/main.dart +FLUTTER_BUILD_DIR=build +FLUTTER_BUILD_NAME=1.0.0 +FLUTTER_BUILD_NUMBER=1.0.0 +DART_DEFINES=RkxVVFRFUl9WRVJTSU9OPTMuNDQuMA==,RkxVVFRFUl9DSEFOTkVMPXN0YWJsZQ==,RkxVVFRFUl9HSVRfVVJMPWh0dHBzOi8vZ2l0aHViLmNvbS9mbHV0dGVyL2ZsdXR0ZXIuZ2l0,RkxVVFRFUl9GUkFNRVdPUktfUkVWSVNJT049NTU5ZmZhM2Y3NQ==,RkxVVFRFUl9FTkdJTkVfUkVWSVNJT049NGM1MjVkYWM1ZQ==,RkxVVFRFUl9EQVJUX1ZFUlNJT049My4xMi4w +DART_OBFUSCATION=false +TRACK_WIDGET_CREATION=true +TREE_SHAKE_ICONS=false +PACKAGE_CONFIG=/Users/ziqq/Development/git/ziqq/flutter_widgetkit/example/.dart_tool/package_config.json diff --git a/example/ios/Podfile b/example/ios/Podfile index 1e8c3c9..e72e0b4 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, '13.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 a5515e3..207469a 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -14,9 +14,9 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_widgetkit/ios" SPEC CHECKSUMS: - Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c - flutter_widgetkit: a0e9b0d50ee9bec366dad36c639509daaafc397a + Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 + flutter_widgetkit: e24ff9dc82d7b1d05d1005a3463fb95be9ab1916 -PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c +PODFILE CHECKSUM: 0dbd5a87e0ace00c9610d2037ac22083a01f861d -COCOAPODS: 1.10.1 +COCOAPODS: 1.16.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index b5f9a7f..18d94c3 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -199,10 +199,10 @@ 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, + F94DE6A425496A4100852052 /* Embed App Extensions */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 1EBFC55EDDEEFFB5523F7B91 /* [CP] Embed Pods Frameworks */, - F94DE6A425496A4100852052 /* Embed App Extensions */, ); buildRules = ( ); @@ -238,7 +238,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1210; - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -311,10 +311,12 @@ }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -347,6 +349,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -452,7 +455,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -540,7 +543,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -589,7 +592,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..fc5ae03 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ @@ -45,11 +46,13 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" + enableGPUValidationMode = "1" allowLocationSimulation = "YES"> diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index 70693e4..c30b367 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -1,13 +1,16 @@ -import UIKit import Flutter +import UIKit -@UIApplicationMain -@objc class AppDelegate: FlutterAppDelegate { +@main +@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } + + func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { + GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + } } diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 32115f4..bc33d71 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -22,6 +24,29 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneConfigurationName + flutter + UISceneDelegateClassName + FlutterSceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile diff --git a/example/lib/FlutterWidgetData.dart b/example/lib/FlutterWidgetData.dart index 7b6cb80..e1ed340 100644 --- a/example/lib/FlutterWidgetData.dart +++ b/example/lib/FlutterWidgetData.dart @@ -1,13 +1,35 @@ +import 'package:flutter/foundation.dart'; + +@immutable class FlutterWidgetData { + const FlutterWidgetData(this.text); + final String text; - FlutterWidgetData(this.text); + factory FlutterWidgetData.fromJson(Map json) { + if (json.isEmpty) throw ArgumentError('JSON is empty'); + if (json case {'text': String text}) { + return FlutterWidgetData(text); + } else { + throw FormatException( + 'Invalid JSON format: ' + 'expected a map with a "text" key of type String', + ); + } + } + + Map toJson() => {'text': text}; + + @override + String toString() => 'FlutterWidgetData{text: $text}'; - FlutterWidgetData.fromJson(Map json) - : text = json['text']; + @override + bool operator ==(Object other) => + identical(this, other) || + other is FlutterWidgetData && + runtimeType == other.runtimeType && + text == other.text; - Map toJson() => - { - 'text': text, - }; -} \ No newline at end of file + @override + int get hashCode => text.hashCode; +} diff --git a/example/lib/main.dart b/example/lib/main.dart index a502ec3..26598c1 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,8 +1,10 @@ -import 'dart:convert'; +// ignore_for_file: unused_local_variable -import 'package:flutter/material.dart'; import 'dart:async'; +import 'dart:convert'; +import 'package:flutter/cupertino.dart' show CupertinoButton; +import 'package:flutter/material.dart'; import 'package:flutter_widgetkit/flutter_widgetkit.dart'; import 'package:flutter_widgetkit_example/FlutterWidgetData.dart'; @@ -30,13 +32,22 @@ class _MyAppState extends State { WidgetKit.reloadTimelines('test'); final data = FlutterWidgetData('Hello From Flutter'); - final resultString = await WidgetKit.getItem('testString', 'group.com.fasky'); + final resultString = await WidgetKit.getItem( + 'testString', + 'group.com.fasky', + ); final resultBool = await WidgetKit.getItem('testBool', 'group.com.fasky'); - final resultNumber = await WidgetKit.getItem('testNumber', 'group.com.fasky'); - final resultJsonString = await WidgetKit.getItem('testJson', 'group.com.fasky'); + final resultNumber = await WidgetKit.getItem( + 'testNumber', + 'group.com.fasky', + ); + final resultJsonString = await WidgetKit.getItem( + 'testJson', + 'group.com.fasky', + ); var resultData; - if(resultJsonString != null) { + if (resultJsonString != null) { resultData = FlutterWidgetData.fromJson(jsonDecode(resultJsonString)); } @@ -50,31 +61,36 @@ class _MyAppState extends State { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( - appBar: AppBar( - title: const Text('iOS Widget Showcase'), - ), + appBar: AppBar(title: const Text('iOS Widget Showcase')), body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'Enter a text 🙏🏻', - ), - Container( - margin: const EdgeInsets.only(left: 20, right: 20, bottom: 10), - child: TextField( - controller: textController - )), - RaisedButton(onPressed: () { - WidgetKit.setItem('widgetData', jsonEncode(FlutterWidgetData(textController.text)), 'group.com.fasky'); - WidgetKit.reloadAllTimelines(); - }, child: Text('Update Widget 🥳')), - RaisedButton(onPressed: () { - WidgetKit.removeItem('widgetData', 'group.com.fasky'); - WidgetKit.reloadAllTimelines(); - }, child: Text('Remove Widget Data ⚠️')) - ], - ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Enter a text 🙏🏻'), + Container( + margin: const EdgeInsets.only(left: 20, right: 20, bottom: 10), + child: TextField(controller: textController), + ), + CupertinoButton( + onPressed: () { + WidgetKit.setItem( + 'widgetData', + jsonEncode(FlutterWidgetData(textController.text)), + 'group.com.fasky', + ); + WidgetKit.reloadAllTimelines(); + }, + child: Text('Update Widget 🥳'), + ), + CupertinoButton( + onPressed: () { + WidgetKit.removeItem('widgetData', 'group.com.fasky'); + WidgetKit.reloadAllTimelines(); + }, + child: Text('Remove Widget Data ⚠️'), + ), + ], + ), ), ), ); diff --git a/example/pubspec.lock b/example/pubspec.lock index f9c655c..59430ce 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,58 +5,66 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 + url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.13.1" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "5bbf32bc9e518d41ec49718e2931cd4527292c9b0c6d2dffcf7fe6b9a8a8cf72" + url: "https://pub.dev" source: hosted version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.1" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: "8e36feea6de5ea69f2199f29cf42a450a855738c498b57c0b980e2d3cca9c362" + url: "https://pub.dev" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.2" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.19.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: "41e005c33bd814be4d3096aff55b1908d419fde52ca656c8c47719ec745873cd" + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.0.9" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.3" flutter: dependency: "direct main" description: flutter @@ -74,88 +82,131 @@ packages: relative: true source: path version: "1.0.3" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.12.19" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" + url: "https://pub.dev" + source: hosted + version: "0.13.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.18.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: f4b22294de9a549967d0033d4f30fcad4f0afc200f4bf58e82d815725feec70c + url: "https://pub.dev" source: hosted version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: dd11571b8a03f7cadcf91ec26a77e02bfbd6bbba2a512924d3116646b4198fc4 + url: "https://pub.dev" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a88162591b02c1f3a3db3af8ce1ea2b374bd75a7bb8d5e353bcfbdc79d719830 + url: "https://pub.dev" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" + url: "https://pub.dev" source: hosted - version: "0.2.19" - typed_data: + version: "0.7.11" + vector_math: dependency: transitive description: - name: typed_data - url: "https://pub.dartlang.org" + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" source: hosted - version: "1.3.0" - vector_math: + version: "2.2.0" + vm_service: dependency: transitive description: - name: vector_math - url: "https://pub.dartlang.org" + name: vm_service + sha256: "0016aef94fc66495ac78af5859181e3f3bf2026bd8eecc72b9565601e19ab360" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "15.2.0" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=1.20.0" + dart: ">=3.11.0 <4.0.0" + flutter: ">=3.41.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index f219094..5346e1a 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,12 +1,15 @@ name: flutter_widgetkit_example description: Demonstrates how to use the flutter_widgetkit plugin. +version: 1.0.0 + # The following line prevents the package from being accidentally published to # pub.dev using `pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev environment: - sdk: ">=2.7.0 <3.0.0" + sdk: '>=3.11.0 <4.0.0' + flutter: ">=3.41.0" dependencies: flutter: diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index ffa5dcf..88131c6 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -7,7 +7,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; - import 'package:flutter_widgetkit_example/main.dart'; void main() { @@ -18,8 +17,7 @@ void main() { // Verify that platform version is retrieved. expect( find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data.startsWith('Running on:'), + (w) => w is Text && (w.data?.startsWith('Running on:') ?? false), ), findsOneWidget, ); diff --git a/ios/Classes/FlutterWidgetkitPlugin.h b/ios/Classes/FlutterWidgetkitPlugin.h deleted file mode 100644 index ed4e8ee..0000000 --- a/ios/Classes/FlutterWidgetkitPlugin.h +++ /dev/null @@ -1,4 +0,0 @@ -#import - -@interface FlutterWidgetkitPlugin : NSObject -@end diff --git a/ios/Classes/FlutterWidgetkitPlugin.m b/ios/Classes/FlutterWidgetkitPlugin.m deleted file mode 100644 index 773dd8c..0000000 --- a/ios/Classes/FlutterWidgetkitPlugin.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "FlutterWidgetkitPlugin.h" -#if __has_include() -#import -#else -// Support project import fallback if the generated compatibility header -// is not copied when this plugin is created as a library. -// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 -#import "flutter_widgetkit-Swift.h" -#endif - -@implementation FlutterWidgetkitPlugin -+ (void)registerWithRegistrar:(NSObject*)registrar { - [SwiftFlutterWidgetkitPlugin registerWithRegistrar:registrar]; -} -@end diff --git a/ios/Classes/SwiftFlutterWidgetkitPlugin.swift b/ios/Classes/SwiftFlutterWidgetkitPlugin.swift deleted file mode 100644 index 7fba277..0000000 --- a/ios/Classes/SwiftFlutterWidgetkitPlugin.swift +++ /dev/null @@ -1,109 +0,0 @@ -import Flutter -import UIKit -import WidgetKit - -public class SwiftFlutterWidgetkitPlugin: NSObject, FlutterPlugin { - public static func register(with registrar: FlutterPluginRegistrar) { - let channel = FlutterMethodChannel(name: "flutter_widgetkit", binaryMessenger: registrar.messenger()) - let instance = SwiftFlutterWidgetkitPlugin() - registrar.addMethodCallDelegate(instance, channel: channel) - } - - public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { - if(call.method == "reloadAllTimelines") { - if #available(iOS 14.0, *) { - #if arch(arm64) || arch(i386) || arch(x86_64) - WidgetCenter.shared.reloadAllTimelines() - #endif - } - result(nil); - return; - } else if(call.method == "reloadTimelines") { - if #available(iOS 14.0, *) { - if let args = call.arguments as? [String: Any], - let ofKind = args["ofKind"] as? String { - #if arch(arm64) || arch(i386) || arch(x86_64) - WidgetCenter.shared.reloadTimelines(ofKind: ofKind) - #endif - } - } - - result(nil); - return; - } else if(call.method == "getItem") { - if let args = call.arguments as? [String: Any], - let appGroup = args["appGroup"] as? String, - let key = args["key"] as? String { - - var sharedDefaults: UserDefaults? = nil; - - if(appGroup != "") { - sharedDefaults = UserDefaults.init(suiteName: appGroup) - } - - if(sharedDefaults == nil) { - // TODO: Throw Exception - result(nil) - return - } - - let value = sharedDefaults?.value(forKey: key) - - result(value) - return - } - - result(nil); - return; - } else if(call.method == "setItem") { - if let args = call.arguments as? [String: Any], - let appGroup = args["appGroup"] as? String, - let key = args["key"] as? String, - let value = args["value"] as? Any { - - var sharedDefaults: UserDefaults? = nil; - - if(appGroup != "") { - sharedDefaults = UserDefaults.init(suiteName: appGroup) - } - - if(sharedDefaults == nil) { - result(nil) - return - } - - sharedDefaults?.setValue(value, forKey: key) - - result(value) - return - } - - result(nil); - return; - } else if(call.method == "removeItem") { - if let args = call.arguments as? [String: Any], - let appGroup = args["appGroup"] as? String, - let key = args["key"] as? String { - - var sharedDefaults: UserDefaults? = nil - - if(appGroup != "") { - sharedDefaults = UserDefaults.init(suiteName: appGroup) - } - - if(sharedDefaults == nil) { - result(nil) - return - } - - sharedDefaults?.removeObject(forKey: key) - - result(true) - return - } - } - - result(FlutterMethodNotImplemented); - } -} - diff --git a/ios/flutter_widgetkit.podspec b/ios/flutter_widgetkit.podspec index 6f6c60b..4318c4c 100644 --- a/ios/flutter_widgetkit.podspec +++ b/ios/flutter_widgetkit.podspec @@ -13,9 +13,9 @@ A new flutter plugin project. s.license = { :file => '../LICENSE' } s.author = { 'Your Company' => 'email@example.com' } s.source = { :path => '.' } - s.source_files = 'Classes/**/*' + s.source_files = 'flutter_widgetkit/Sources/flutter_widgetkit/**/*.swift' s.dependency 'Flutter' - s.platform = :ios, '8.0' + s.platform = :ios, '13.0' # Flutter.framework does not contain a i386 slice. s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } diff --git a/ios/flutter_widgetkit/Package.swift b/ios/flutter_widgetkit/Package.swift new file mode 100644 index 0000000..c86f9a4 --- /dev/null +++ b/ios/flutter_widgetkit/Package.swift @@ -0,0 +1,24 @@ +// swift-tools-version: 5.9 + +import PackageDescription + +let package = Package( + name: "flutter_widgetkit", + platforms: [ + .iOS("13.0") + ], + products: [ + .library(name: "flutter-widgetkit", targets: ["flutter_widgetkit"]) + ], + dependencies: [ + .package(name: "FlutterFramework", path: "../FlutterFramework") + ], + targets: [ + .target( + name: "flutter_widgetkit", + dependencies: [ + .product(name: "FlutterFramework", package: "FlutterFramework") + ] + ) + ] +) \ No newline at end of file diff --git a/ios/flutter_widgetkit/Sources/flutter_widgetkit/FlutterWidgetkitPlugin.swift b/ios/flutter_widgetkit/Sources/flutter_widgetkit/FlutterWidgetkitPlugin.swift new file mode 100644 index 0000000..05b2061 --- /dev/null +++ b/ios/flutter_widgetkit/Sources/flutter_widgetkit/FlutterWidgetkitPlugin.swift @@ -0,0 +1,108 @@ +import Flutter +import UIKit +import WidgetKit + +public class FlutterWidgetkitPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + let channel = FlutterMethodChannel(name: "flutter_widgetkit", binaryMessenger: registrar.messenger()) + let instance = FlutterWidgetkitPlugin() + registrar.addMethodCallDelegate(instance, channel: channel) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + if call.method == "reloadAllTimelines" { + if #available(iOS 14.0, *) { + #if arch(arm64) || arch(i386) || arch(x86_64) + WidgetCenter.shared.reloadAllTimelines() + #endif + } + result(nil) + return + } else if call.method == "reloadTimelines" { + if #available(iOS 14.0, *) { + if let args = call.arguments as? [String: Any], + let ofKind = args["ofKind"] as? String + { + #if arch(arm64) || arch(i386) || arch(x86_64) + WidgetCenter.shared.reloadTimelines(ofKind: ofKind) + #endif + } + } + + result(nil) + return + } else if call.method == "getItem" { + if let args = call.arguments as? [String: Any], + let appGroup = args["appGroup"] as? String, + let key = args["key"] as? String + { + var sharedDefaults: UserDefaults? = nil + + if appGroup != "" { + sharedDefaults = UserDefaults(suiteName: appGroup) + } + + if sharedDefaults == nil { + result(nil) + return + } + + let value = sharedDefaults?.value(forKey: key) + + result(value) + return + } + + result(nil) + return + } else if call.method == "setItem" { + if let args = call.arguments as? [String: Any], + let appGroup = args["appGroup"] as? String, + let key = args["key"] as? String, + let value = args["value"] + { + var sharedDefaults: UserDefaults? = nil + + if appGroup != "" { + sharedDefaults = UserDefaults(suiteName: appGroup) + } + + if sharedDefaults == nil { + result(nil) + return + } + + sharedDefaults?.setValue(value, forKey: key) + + result(value) + return + } + + result(nil) + return + } else if call.method == "removeItem" { + if let args = call.arguments as? [String: Any], + let appGroup = args["appGroup"] as? String, + let key = args["key"] as? String + { + var sharedDefaults: UserDefaults? = nil + + if appGroup != "" { + sharedDefaults = UserDefaults(suiteName: appGroup) + } + + if sharedDefaults == nil { + result(nil) + return + } + + sharedDefaults?.removeObject(forKey: key) + + result(true) + return + } + } + + result(FlutterMethodNotImplemented) + } +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 96b4a33..d8382aa 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,51 +5,58 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 + url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.13.1" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "5bbf32bc9e518d41ec49718e2931cd4527292c9b0c6d2dffcf7fe6b9a8a8cf72" + url: "https://pub.dev" source: hosted version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.4.1" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: "8e36feea6de5ea69f2199f29cf42a450a855738c498b57c0b980e2d3cca9c362" + url: "https://pub.dev" source: hosted version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.2" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.19.1" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.3" flutter: dependency: "direct main" description: flutter @@ -60,88 +67,131 @@ packages: description: flutter source: sdk version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.12.19" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" + url: "https://pub.dev" + source: hosted + version: "0.13.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.18.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" sky_engine: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: f4b22294de9a549967d0033d4f30fcad4f0afc200f4bf58e82d815725feec70c + url: "https://pub.dev" source: hosted version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.4" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: dd11571b8a03f7cadcf91ec26a77e02bfbd6bbba2a512924d3116646b4198fc4 + url: "https://pub.dev" source: hosted version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a88162591b02c1f3a3db3af8ce1ea2b374bd75a7bb8d5e353bcfbdc79d719830 + url: "https://pub.dev" source: hosted version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" + url: "https://pub.dev" source: hosted - version: "0.2.19" - typed_data: + version: "0.7.11" + vector_math: dependency: transitive description: - name: typed_data - url: "https://pub.dartlang.org" + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" source: hosted - version: "1.3.0" - vector_math: + version: "2.2.0" + vm_service: dependency: transitive description: - name: vector_math - url: "https://pub.dartlang.org" + name: vm_service + sha256: "0016aef94fc66495ac78af5859181e3f3bf2026bd8eecc72b9565601e19ab360" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "15.2.0" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=1.20.0" + dart: ">=3.11.0 <4.0.0" + flutter: ">=3.41.0" diff --git a/pubspec.yaml b/pubspec.yaml index 5f9a11a..a6fe395 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,8 +5,8 @@ homepage: https://github.com/fasky-software/flutter_widgetkit repository: https://github.com/fasky-software/flutter_widgetkit environment: - sdk: ">=2.12.0 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: '>=3.11.0 <4.0.0' + flutter: ">=3.41.0" dependencies: flutter: