From d47cbbe44c5684c657e7c78e2cf11517aa36aaee Mon Sep 17 00:00:00 2001 From: wanghualei Date: Mon, 10 Apr 2023 16:22:48 +0800 Subject: [PATCH] =?UTF-8?q?update=20flutter=20=E5=AE=89=E5=8D=93=E5=92=8Ci?= =?UTF-8?q?os=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/ios/Podfile.lock | 16 +++--- example/ios/Runner.xcodeproj/project.pbxproj | 6 +++ example/ios/Runner/AppDelegate.swift | 6 +++ .../ios/Runner/FlutterMethodChannelHandler.h | 16 ++++++ .../ios/Runner/FlutterMethodChannelHandler.m | 53 +++++++++++++++++++ example/ios/Runner/LoadingView.m | 7 ++- example/ios/Runner/Runner-Bridging-Header.h | 1 + 7 files changed, 93 insertions(+), 12 deletions(-) create mode 100644 example/ios/Runner/FlutterMethodChannelHandler.h create mode 100644 example/ios/Runner/FlutterMethodChannelHandler.m diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 9197f2f..03fe68c 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,11 +1,11 @@ PODS: - - FinApplet (2.40.1) - - FinAppletExt (2.40.1): - - FinApplet (= 2.40.1) + - FinApplet (2.40.3) + - FinAppletExt (2.40.3): + - FinApplet (= 2.40.3) - Flutter (1.0.0) - mop (0.1.1): - - FinApplet (= 2.40.1) - - FinAppletExt (= 2.40.1) + - FinApplet (= 2.40.3) + - FinAppletExt (= 2.40.3) - Flutter DEPENDENCIES: @@ -24,10 +24,10 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/mop/ios" SPEC CHECKSUMS: - FinApplet: 053df5db21b766a8705a6fb809731ec19f75578e - FinAppletExt: 45c9fece1524d9eafa25e6bcd0fe492060492e3a + FinApplet: a76ded99df163388bb4de129df20c0ff44abe37c + FinAppletExt: 5c53d5c3554ce1be014871214a5c7a06f0bf9177 Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a - mop: 8dffe3317decd528a199f7a8695d74174fded976 + mop: 4881eb2c1d365d9cf148b5dc7f8eca2b7018121d PODFILE CHECKSUM: 2317ba7584871ae8cd67fd0244fbd5e96fd06167 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index c122f435..bdbee1c 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; A8C6E1F329E2FFEC00E3B446 /* LoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C6E1F229E2FFEC00E3B446 /* LoadingView.m */; }; + A8C6E1F629E3E71400E3B446 /* FlutterMethodChannelHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = A8C6E1F529E3E71400E3B446 /* FlutterMethodChannelHandler.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -49,6 +50,8 @@ 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A8C6E1F129E2FFEC00E3B446 /* LoadingView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoadingView.h; sourceTree = ""; }; A8C6E1F229E2FFEC00E3B446 /* LoadingView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoadingView.m; sourceTree = ""; }; + A8C6E1F429E3E71400E3B446 /* FlutterMethodChannelHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FlutterMethodChannelHandler.h; sourceTree = ""; }; + A8C6E1F529E3E71400E3B446 /* FlutterMethodChannelHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlutterMethodChannelHandler.m; sourceTree = ""; }; B691CF78BE1464D3451E07AF /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -125,6 +128,8 @@ 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, A8C6E1F129E2FFEC00E3B446 /* LoadingView.h */, A8C6E1F229E2FFEC00E3B446 /* LoadingView.m */, + A8C6E1F429E3E71400E3B446 /* FlutterMethodChannelHandler.h */, + A8C6E1F529E3E71400E3B446 /* FlutterMethodChannelHandler.m */, ); path = Runner; sourceTree = ""; @@ -278,6 +283,7 @@ files = ( 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, A8C6E1F329E2FFEC00E3B446 /* LoadingView.m in Sources */, + A8C6E1F629E3E71400E3B446 /* FlutterMethodChannelHandler.m in Sources */, 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index 70693e4..8c4081e 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -3,10 +3,16 @@ import Flutter @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { + + var channelHander : FlutterMethodChannelHandler? + override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { + + let controller : FlutterViewController = window?.rootViewController as! FlutterViewController + channelHander = FlutterMethodChannelHandler(messenger: controller) GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/example/ios/Runner/FlutterMethodChannelHandler.h b/example/ios/Runner/FlutterMethodChannelHandler.h new file mode 100644 index 0000000..3673c7d --- /dev/null +++ b/example/ios/Runner/FlutterMethodChannelHandler.h @@ -0,0 +1,16 @@ +// +// FlutterMethodChannelHandler.h +// Runner +// +// Created by Haley on 2023/4/10. +// + +#import +#import + +@interface FlutterMethodChannelHandler : NSObject + +- (instancetype)initWithMessenger:(NSObject *)messenger; + +@end + diff --git a/example/ios/Runner/FlutterMethodChannelHandler.m b/example/ios/Runner/FlutterMethodChannelHandler.m new file mode 100644 index 0000000..a1effd5 --- /dev/null +++ b/example/ios/Runner/FlutterMethodChannelHandler.m @@ -0,0 +1,53 @@ +// +// FlutterMethodChannelHandler.m +// Runner +// +// Created by Haley on 2023/4/10. +// + +#import "FlutterMethodChannelHandler.h" + +#import + +@interface FlutterMethodChannelHandler () + +@property (nonatomic,strong) FlutterMethodChannel *channel; + +@end + +@implementation FlutterMethodChannelHandler + +- (instancetype)initWithMessenger:(NSObject*)messenger +{ + self = [super init]; + if (self) { + [self setupChannelWithMessenger:messenger]; + } + + return self; +} + +- (void)setupChannelWithMessenger:(NSObject*)messenger +{ + _channel = [FlutterMethodChannel methodChannelWithName:@"com.message.flutter_to_app" binaryMessenger:messenger]; + + [_channel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult _Nonnull result) { + NSLog(@"收到Flutter消息:%@", call.method); + if ([call.method isEqualToString:@"showCustomMoreView"]) { + NSString *appId = call.arguments[@"appId"]; + // 弹出自定义的更多视图 + UIViewController *viewController = [[UIApplication sharedApplication] fat_topViewController]; + + UIAlertController *alertViewController = [UIAlertController alertControllerWithTitle:@"更多视图" message:appId preferredStyle:UIAlertControllerStyleActionSheet]; + [alertViewController addAction:[UIAlertAction actionWithTitle:@"转发" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + + }]]; + [alertViewController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + + }]]; + [viewController presentViewController:alertViewController animated:YES completion:nil]; + } + }]; +} + +@end diff --git a/example/ios/Runner/LoadingView.m b/example/ios/Runner/LoadingView.m index 4d98f07..859e546 100644 --- a/example/ios/Runner/LoadingView.m +++ b/example/ios/Runner/LoadingView.m @@ -11,9 +11,9 @@ - (instancetype)initWithFrame:(CGRect)frame { if ([super initWithFrame:frame]) { - self.loadingView.padding = 20; - self.loadingView.dotView.backgroundColor = [UIColor blackColor]; - self.loadingView.animation.duration = 5; + self.loadingView.padding = 5; + self.loadingView.dotView.backgroundColor = [UIColor redColor]; + self.loadingView.animation.duration = 2; self.titleLabel.textColor = [UIColor redColor]; } return self; @@ -22,7 +22,6 @@ { [super layoutSubviews]; - // 如果要改logo,必须在这里修改。 // 修改小程序logo应该是从管理后台上传新的小程序图标,因为更多面板、关于页面也会展示小程序logo,只改这里只是loding页面生效 self.bottomImageView.hidden = YES; } diff --git a/example/ios/Runner/Runner-Bridging-Header.h b/example/ios/Runner/Runner-Bridging-Header.h index 308a2a5..de72694 100644 --- a/example/ios/Runner/Runner-Bridging-Header.h +++ b/example/ios/Runner/Runner-Bridging-Header.h @@ -1 +1,2 @@ #import "GeneratedPluginRegistrant.h" +#import "FlutterMethodChannelHandler.h"