Skip to content

Commit aef7e01

Browse files
author
余玠
committed
尝试支持present非fUIModalPresentationFullScreen样式的VC,但会闪烁
1 parent ac1f354 commit aef7e01

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

example/ios/Runner/NativeViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ - (void)viewDidAppear:(BOOL)animated{
5252
// [self.flutterContainer.view layoutIfNeeded];
5353
}
5454

55+
//NOTES: embed情景下必须实现!!!
5556
- (void)didMoveToParentViewController:(UIViewController *)parent {
5657
[self.flutterContainer didMoveToParentViewController:parent];
5758
[super didMoveToParentViewController:parent];

ios/Classes/Boost/FLBFlutterApplicationInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
6666
onPageFinished:(void (^)(NSDictionary *))resultCallback
6767
completion:(void (^)(BOOL))completion;
6868

69+
- (void)attachToPreviousContainer;
6970

7071
- (void)didInitPageContainer:(NSString *)url
7172
params:(NSDictionary *)urlParams

ios/Classes/Boost/FLBFlutterProvider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
3131
@protocol FLBFlutterProvider <NSObject>
3232
@required
3333
- (FlutterEngine *)engine;
34-
- (void)atacheToViewController:(FlutterViewController *)vc;
34+
- (BOOL)atacheToViewController:(FlutterViewController *)vc;
3535
- (void)detach;
3636
- (void)prepareEngineIfNeeded;
3737
- (void)pause;

ios/Classes/Engine/FLBFlutterApplication.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
@interface FLBFlutterApplication()
3232
@property (nonatomic,strong) FLBFlutterContainerManager *manager;
3333
@property (nonatomic,strong) id<FLBFlutterProvider> viewProvider;
34+
@property (nonatomic, weak, readonly)FlutterViewController * previousViewController;
3435
@property (nonatomic,assign) BOOL isRunning;
3536
@property (nonatomic,strong) NSMutableDictionary *pageResultCallbacks;
3637
@property (nonatomic,strong) NSMutableDictionary *callbackCache;
@@ -157,6 +158,13 @@ - (FlutterViewController *)flutterViewController
157158
return self.flutterProvider.engine.viewController;
158159
}
159160

161+
- (void)attachToPreviousContainer{
162+
if([self.viewProvider atacheToViewController:self.previousViewController]){
163+
[self.previousViewController.view setNeedsLayout];
164+
[(FLBFlutterViewContainer*)self.previousViewController surfaceUpdated:YES];
165+
}
166+
}
167+
160168
- (void)close:(NSString *)uniqueId
161169
result:(NSDictionary *)resultData
162170
exts:(NSDictionary *)exts
@@ -190,7 +198,7 @@ - (void)open:(NSString *)url
190198
[newParams setObject:cid?cid:@"__default#0__" forKey:kPageCallBackId];
191199
urlParams = newParams;
192200
}
193-
201+
_previousViewController = [self flutterViewController];
194202
_callbackCache[cid] = resultCallback;
195203
if([urlParams[@"present"]respondsToSelector:@selector(boolValue)] && [urlParams[@"present"] boolValue] && [self.platform respondsToSelector:@selector(present:urlParams:exts:completion:)]){
196204
[self.platform present:url

ios/Classes/Engine/FLBFlutterEngine.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ - (void)willEnterForeground
9797
arguments:@{@"type":@"foreground"}];
9898
}
9999

100-
- (void)atacheToViewController:(FlutterViewController *)vc
100+
- (BOOL)atacheToViewController:(FlutterViewController *)vc
101101
{
102102
if(_engine.viewController != vc){
103-
// [(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
104103
_engine.viewController = vc;
104+
return YES;
105105
}
106+
return NO;
106107
}
107108

108109
- (void)detach

ios/Classes/container/FLBFlutterViewContainer.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,6 @@ - (void)viewDidDisappear:(BOOL)animated
287287
pageName:_name
288288
params:_params
289289
uniqueId:self.uniqueIDString];
290-
// 如果当前不可见vc和engine所持有的vc一致。在FlutterVC在混合栈中是最后一张页面,如tab中的页面
291-
// if (self == FLUTTER_VC)
292-
// {
293-
// [self surfaceUpdated:NO];
294-
// }
295290
[super bridge_viewDidDisappear:animated];
296291
}
297292

0 commit comments

Comments
 (0)