Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
flutter_boost_1.22.4
Commits
854b8d32
Commit
854b8d32
authored
Jun 03, 2019
by
Jidong Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉截图,运行成功
parent
39cbcbc7
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
120 additions
and
1203 deletions
+120
-1203
example/ios/.symlinks/plugins/flutter_boost
example/ios/.symlinks/plugins/flutter_boost
+1
-1
example/ios/.symlinks/plugins/xservice_kit
example/ios/.symlinks/plugins/xservice_kit
+1
-1
example/ios/Podfile.lock
example/ios/Podfile.lock
+5
-5
example/ios/Runner/AppDelegate.m
example/ios/Runner/AppDelegate.m
+8
-5
ios/Classes/Adaptor/FLBFlutterEngine.h
ios/Classes/Adaptor/FLBFlutterEngine.h
+2
-2
ios/Classes/Adaptor/FLBFlutterEngine.m
ios/Classes/Adaptor/FLBFlutterEngine.m
+32
-20
ios/Classes/Adaptor/FLBFlutterEngineOld.m
ios/Classes/Adaptor/FLBFlutterEngineOld.m
+0
-108
ios/Classes/Adaptor/FLBFlutterProvider.h
ios/Classes/Adaptor/FLBFlutterProvider.h
+7
-5
ios/Classes/Adaptor/FLBFlutterProviderFactory.h
ios/Classes/Adaptor/FLBFlutterProviderFactory.h
+5
-3
ios/Classes/Adaptor/FLBFlutterProviderFactory.m
ios/Classes/Adaptor/FLBFlutterProviderFactory.m
+12
-9
ios/Classes/Adaptor/FLBFlutterViewControllerAdaptor.h
ios/Classes/Adaptor/FLBFlutterViewControllerAdaptor.h
+0
-39
ios/Classes/Adaptor/FLBFlutterViewControllerAdaptor.m
ios/Classes/Adaptor/FLBFlutterViewControllerAdaptor.m
+0
-105
ios/Classes/Adaptor/FLBViewProviderFactory.m
ios/Classes/Adaptor/FLBViewProviderFactory.m
+0
-51
ios/Classes/Boost/FLBFlutterApplication.h
ios/Classes/Boost/FLBFlutterApplication.h
+4
-2
ios/Classes/Boost/FLBFlutterApplication.m
ios/Classes/Boost/FLBFlutterApplication.m
+12
-26
ios/Classes/Boost/FlutterBoostPlugin.h
ios/Classes/Boost/FlutterBoostPlugin.h
+1
-1
ios/Classes/Boost/FlutterBoostPlugin.m
ios/Classes/Boost/FlutterBoostPlugin.m
+1
-6
ios/Classes/Container/FLBFlutterViewContainer.h
ios/Classes/Container/FLBFlutterViewContainer.h
+4
-1
ios/Classes/Container/FLBFlutterViewContainer.m
ios/Classes/Container/FLBFlutterViewContainer.m
+25
-174
ios/Classes/Support/Cache/FLBStackCache.h
ios/Classes/Support/Cache/FLBStackCache.h
+0
-72
ios/Classes/Support/Cache/FLBStackCache.m
ios/Classes/Support/Cache/FLBStackCache.m
+0
-210
ios/Classes/Support/Cache/FLBStackCacheObjectImg.h
ios/Classes/Support/Cache/FLBStackCacheObjectImg.h
+0
-37
ios/Classes/Support/Cache/FLBStackCacheObjectImg.m
ios/Classes/Support/Cache/FLBStackCacheObjectImg.m
+0
-116
ios/Classes/Support/Memory/FLBMemoryInspector.h
ios/Classes/Support/Memory/FLBMemoryInspector.h
+0
-47
ios/Classes/Support/Memory/FLBMemoryInspector.mm
ios/Classes/Support/Memory/FLBMemoryInspector.mm
+0
-157
No files found.
example/ios/.symlinks/plugins/flutter_boost
View file @
854b8d32
/Users/jidong/Documents/opensource/flutter_boost
/Users/jidong/Documents/projects/Flutter/flutter_boost
\ No newline at end of file
\ No newline at end of file
example/ios/.symlinks/plugins/xservice_kit
View file @
854b8d32
/Users/jidong/.pub-cache/hosted/pub.dartlang.org/xservice_kit-0.0.27
/Users/jidong/.pub-cache/hosted/pub.dartlang.org/xservice_kit-0.0.29
\ No newline at end of file
\ No newline at end of file
example/ios/Podfile.lock
View file @
854b8d32
...
@@ -8,20 +8,20 @@ PODS:
...
@@ -8,20 +8,20 @@ PODS:
DEPENDENCIES:
DEPENDENCIES:
- Flutter (from `.symlinks/flutter/ios`)
- Flutter (from `.symlinks/flutter/ios`)
- flutter_boost (from `/Users/jidong/Documents/
opensource
/flutter_boost/ios`)
- flutter_boost (from `/Users/jidong/Documents/
projects/Flutter
/flutter_boost/ios`)
- xservice_kit (from `/Users/jidong/.pub-cache/hosted/pub.dartlang.org/xservice_kit-0.0.2
7
/ios`)
- xservice_kit (from `/Users/jidong/.pub-cache/hosted/pub.dartlang.org/xservice_kit-0.0.2
9
/ios`)
EXTERNAL SOURCES:
EXTERNAL SOURCES:
Flutter:
Flutter:
:path: ".symlinks/flutter/ios"
:path: ".symlinks/flutter/ios"
flutter_boost:
flutter_boost:
:path: "/Users/jidong/Documents/
opensource
/flutter_boost/ios"
:path: "/Users/jidong/Documents/
projects/Flutter
/flutter_boost/ios"
xservice_kit:
xservice_kit:
:path: "/Users/jidong/.pub-cache/hosted/pub.dartlang.org/xservice_kit-0.0.2
7
/ios"
:path: "/Users/jidong/.pub-cache/hosted/pub.dartlang.org/xservice_kit-0.0.2
9
/ios"
SPEC CHECKSUMS:
SPEC CHECKSUMS:
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
flutter_boost:
24249d12d924d858cf445a84949484bc08bca000
flutter_boost:
6a083f2f1b67f9b08724d6c4b280a099d1b40797
xservice_kit: a86c64372b3e41e7d8e9b1a0b9139866680f525c
xservice_kit: a86c64372b3e41e7d8e9b1a0b9139866680f525c
PODFILE CHECKSUM: 2a757a7bdc03b37a2814666652fdff1cf694243f
PODFILE CHECKSUM: 2a757a7bdc03b37a2814666652fdff1cf694243f
...
...
example/ios/Runner/AppDelegate.m
View file @
854b8d32
...
@@ -19,6 +19,12 @@
...
@@ -19,6 +19,12 @@
-
(
BOOL
)
application
:(
UIApplication
*
)
application
didFinishLaunchingWithOptions
:(
NSDictionary
*
)
launchOptions
-
(
BOOL
)
application
:(
UIApplication
*
)
application
didFinishLaunchingWithOptions
:(
NSDictionary
*
)
launchOptions
{
{
DemoRouter
*
router
=
[
DemoRouter
sharedRouter
];
[
FlutterBoostPlugin
.
sharedInstance
startFlutterWithPlatform
:
router
onStart:
^
(
FlutterEngine
*
fvc
)
{
}];
self
.
window
=
[[
UIWindow
alloc
]
initWithFrame
:
[
UIScreen
mainScreen
].
bounds
];
self
.
window
=
[[
UIWindow
alloc
]
initWithFrame
:
[
UIScreen
mainScreen
].
bounds
];
...
@@ -37,16 +43,13 @@
...
@@ -37,16 +43,13 @@
UITabBarController
*
tabVC
=
[[
UITabBarController
alloc
]
init
];
UITabBarController
*
tabVC
=
[[
UITabBarController
alloc
]
init
];
UINavigationController
*
rvc
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
tabVC
];
UINavigationController
*
rvc
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
tabVC
];
DemoRouter
*
router
=
[
DemoRouter
sharedRouter
];
router
.
navigationController
=
rvc
;
router
.
navigationController
=
rvc
;
tabVC
.
viewControllers
=
@[
vc
,
fvc
];
tabVC
.
viewControllers
=
@[
vc
,
fvc
];
[
FlutterBoostPlugin
.
sharedInstance
startFlutterWithPlatform
:
router
onStart:
^
(
FlutterViewController
*
fvc
)
{
}];
self
.
window
.
rootViewController
=
rvc
;
self
.
window
.
rootViewController
=
rvc
;
...
...
ios/Classes/Adaptor/FLBFlutterEngine.h
View file @
854b8d32
...
@@ -23,13 +23,13 @@
...
@@ -23,13 +23,13 @@
*/
*/
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
#import "FLBFlutter
View
Provider.h"
#import "FLBFlutterProvider.h"
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
#if RELEASE_1_0
#if RELEASE_1_0
@interface
FLBFlutterEngine
:
NSObject
<
FLBFlutter
View
Provider
>
@interface
FLBFlutterEngine
:
NSObject
<
FLBFlutterProvider
>
@end
@end
#endif
#endif
...
...
ios/Classes/Adaptor/FLBFlutterEngine.m
View file @
854b8d32
...
@@ -24,13 +24,13 @@
...
@@ -24,13 +24,13 @@
#import "FLBFlutterEngine.h"
#import "FLBFlutterEngine.h"
#import <Flutter/Flutter.h>
#import <Flutter/Flutter.h>
#import "FLBFlutterViewCont
rollerAdapto
r.h"
#import "FLBFlutterViewCont
aine
r.h"
#if RELEASE_1_0
#if RELEASE_1_0
@interface
FLBFlutterEngine
()
@interface
FLBFlutterEngine
()
@property
(
nonatomic
,
strong
)
FLBFlutterViewControllerAdaptor
*
viewController
;
@property
(
nonatomic
,
strong
)
FlutterEngine
*
engine
;
@property
(
nonatomic
,
strong
)
FlutterEngine
*
engine
;
@property
(
nonatomic
,
strong
)
FLBFlutterViewContainer
*
dummy
;
@end
@end
@implementation
FLBFlutterEngine
@implementation
FLBFlutterEngine
...
@@ -43,15 +43,14 @@
...
@@ -43,15 +43,14 @@
if
(
self
=
[
super
init
])
{
if
(
self
=
[
super
init
])
{
_engine
=
[[
FlutterEngine
alloc
]
initWithName
:
@"io.flutter"
project
:
nil
];
_engine
=
[[
FlutterEngine
alloc
]
initWithName
:
@"io.flutter"
project
:
nil
];
[
_engine
runWithEntrypoint
:
nil
];
[
_engine
runWithEntrypoint
:
nil
];
_viewController
=
[[
FLBFlutterViewControllerAdaptor
alloc
]
initWithEngine
:
_engine
_dummy
=
[[
FLBFlutterViewContainer
alloc
]
initWithEngine
:
_engine
nibName:
nil
nibName:
nil
bundle:
nil
];
bundle:
nil
];
[
_viewController
view
];
Class
clazz
=
NSClassFromString
(
@"GeneratedPluginRegistrant"
);
Class
clazz
=
NSClassFromString
(
@"GeneratedPluginRegistrant"
);
if
(
clazz
)
{
if
(
clazz
)
{
if
([
clazz
respondsToSelector
:
NSSelectorFromString
(
@"registerWithRegistry:"
)])
{
if
([
clazz
respondsToSelector
:
NSSelectorFromString
(
@"registerWithRegistry:"
)])
{
[
clazz
performSelector
:
NSSelectorFromString
(
@"registerWithRegistry:"
)
[
clazz
performSelector
:
NSSelectorFromString
(
@"registerWithRegistry:"
)
withObject:
_
viewController
];
withObject:
_
engine
];
}
}
}
}
}
}
...
@@ -60,23 +59,14 @@
...
@@ -60,23 +59,14 @@
#pragma clang diagnostic pop
#pragma clang diagnostic pop
}
}
-
(
FlutterViewController
*
)
viewController
{
return
_viewController
;
}
-
(
void
)
pause
-
(
void
)
pause
{
{
//TODO: [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.paused"];
[[
_engine
lifecycleChannel
]
sendMessage
:
@"AppLifecycleState.pause"
];
[
self
.
viewController
boost_viewWillDisappear
:
NO
];
[
self
.
viewController
boost_viewDidDisappear
:
NO
];
}
}
-
(
void
)
resume
-
(
void
)
resume
{
{
//TODO: [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"];
[[
_engine
lifecycleChannel
]
sendMessage
:
@"AppLifecycleState.resume"
];
[
self
.
viewController
boost_viewWillAppear
:
NO
];
[
self
.
viewController
boost_viewDidAppear
:
NO
];
}
}
-
(
void
)
inactive
-
(
void
)
inactive
...
@@ -84,10 +74,32 @@
...
@@ -84,10 +74,32 @@
[[
_engine
lifecycleChannel
]
sendMessage
:
@"AppLifecycleState.inactive"
];
[[
_engine
lifecycleChannel
]
sendMessage
:
@"AppLifecycleState.inactive"
];
}
}
-
(
void
)
setAccessibilityEnable
:(
BOOL
)
enable
-
(
FlutterEngine
*
)
engine
{
return
_engine
;
}
-
(
void
)
atacheToViewController
:(
FlutterViewController
*
)
vc
{
if
(
_engine
.
viewController
!=
vc
){
_engine
.
viewController
=
vc
;
}
}
-
(
void
)
detach
{
if
(
_engine
.
viewController
!=
_dummy
){
_engine
.
viewController
=
_dummy
;
}
}
-
(
void
)
prepareEngineIfNeeded
{
{
self
.
viewController
.
accessibilityEnable
=
enable
;
[
self
detach
];
[
_dummy
surfaceUpdated
:
YES
];
}
}
@end
@end
#endif
#endif
ios/Classes/Adaptor/FLBFlutterEngineOld.m
deleted
100755 → 0
View file @
39cbcbc7
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "FLBFlutterEngineOld.h"
#import "FLBFlutterViewControllerAdaptor.h"
#import <objc/runtime.h>
@interface
FLBFlutterEngineOld
()
@property
(
nonatomic
,
strong
)
FLBFlutterViewControllerAdaptor
*
viewController
;
@end
@implementation
FLBFlutterEngineOld
-
(
instancetype
)
initWithPlatform
:(
id
<
FLBPlatform
>
)
platform
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
if
(
self
=
[
super
init
])
{
Class
class
=
[
FLBFlutterViewControllerAdaptor
class
];
SEL
originalSelector
=
@selector
(
onAccessibilityStatusChanged
:
);
SEL
swizzledSelector
=
@selector
(
fixed_onAccessibilityStatusChanged
:
);
Method
originalMethod
=
class_getInstanceMethod
(
class
,
originalSelector
);
Method
swizzledMethod
=
class_getInstanceMethod
(
class
,
swizzledSelector
);
method_exchangeImplementations
(
originalMethod
,
swizzledMethod
);
_viewController
=
[
FLBFlutterViewControllerAdaptor
new
];
if
([
platform
respondsToSelector
:
@selector
(
accessibilityEnable
)]){
_viewController
.
accessibilityEnable
=
[
platform
accessibilityEnable
];
}
else
{
_viewController
.
accessibilityEnable
=
YES
;
}
[
_viewController
view
];
Class
clazz
=
NSClassFromString
(
@"GeneratedPluginRegistrant"
);
if
(
clazz
)
{
if
([
clazz
respondsToSelector
:
NSSelectorFromString
(
@"registerWithRegistry:"
)])
{
[
clazz
performSelector
:
NSSelectorFromString
(
@"registerWithRegistry:"
)
withObject:
_viewController
];
}
}
}
return
self
;
#pragma clang diagnostic pop
}
-
(
FlutterViewController
*
)
viewController
{
return
_viewController
;
}
-
(
void
)
pause
{
[
self
.
viewController
boost_viewWillDisappear
:
NO
];
[
self
.
viewController
boost_viewDidDisappear
:
NO
];
}
-
(
void
)
resume
{
[
self
.
viewController
boost_viewWillAppear
:
NO
];
[
self
.
viewController
boost_viewDidAppear
:
NO
];
}
-
(
void
)
inactive
{
NSString
*
channel
=
@"flutter/lifecycle"
;
NSString
*
message
=
@"AppLifecycleState.inactive"
;
NSData
*
data
=
[[
FlutterStringCodec
sharedInstance
]
encode
:
message
];
[
self
.
viewController
sendOnChannel
:
channel
message
:
data
];
}
-
(
void
)
resumeFlutterOnly
{
NSString
*
channel
=
@"flutter/lifecycle"
;
NSString
*
message
=
@"AppLifecycleState.resumed"
;
NSData
*
data
=
[[
FlutterStringCodec
sharedInstance
]
encode
:
message
];
[
self
.
viewController
sendOnChannel
:
channel
message
:
data
];
}
-
(
void
)
setAccessibilityEnable
:(
BOOL
)
enable
{
self
.
viewController
.
accessibilityEnable
=
enable
;
}
@end
ios/Classes/Adaptor/FLBFlutter
View
Provider.h
→
ios/Classes/Adaptor/FLBFlutterProvider.h
View file @
854b8d32
...
@@ -25,21 +25,23 @@
...
@@ -25,21 +25,23 @@
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
@class
FlutterViewController
;
@class
FlutterViewController
;
@class
FlutterEngine
;
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
#define RELEASE_1_0
0
#define RELEASE_1_0
1
@protocol
FLBFlutter
View
Provider
<
NSObject
>
@protocol
FLBFlutterProvider
<
NSObject
>
@required
@required
-
(
void
)
setAccessibilityEnable
:(
BOOL
)
enabl
e
;
-
(
FlutterEngine
*
)
engin
e
;
-
(
BOOL
)
accessibilityEnable
;
-
(
void
)
atacheToViewController
:(
FlutterViewController
*
)
vc
;
-
(
FlutterViewController
*
)
viewController
;
-
(
void
)
detach
;
-
(
void
)
pause
;
-
(
void
)
pause
;
-
(
void
)
resume
;
-
(
void
)
resume
;
-
(
void
)
inactive
;
-
(
void
)
inactive
;
-
(
void
)
prepareEngineIfNeeded
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
ios/Classes/Adaptor/FLBFlutter
EngineOld
.h
→
ios/Classes/Adaptor/FLBFlutter
ProviderFactory
.h
View file @
854b8d32
...
@@ -23,14 +23,16 @@
...
@@ -23,14 +23,16 @@
*/
*/
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
#import "FLBFlutterViewProvider.h"
#import "FLBFlutterProvider.h"
#import "FLBPlatform.h"
#import "FLBPlatform.h"
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
@interface
FLBFlutter
EngineOld
:
NSObject
<
FLBFlutterViewProvider
>
@interface
FLBFlutter
ProviderFactory
:
NSObject
-
(
instancetype
)
initWithPlatform
:(
id
<
FLBPlatform
>
)
platform
;
-
(
id
<
FLBFlutterProvider
>
)
createViewProvider
;
-
(
id
<
FLBFlutterProvider
>
)
createViewProviderWithPlatform
:(
id
<
FLBPlatform
>
)
platform
;
@end
@end
...
...
ios/Classes/Adaptor/FLB
ViewProviderFactory.h
→
ios/Classes/Adaptor/FLB
FlutterProviderFactory.m
View file @
854b8d32
...
@@ -22,18 +22,21 @@
...
@@ -22,18 +22,21 @@
* THE SOFTWARE.
* THE SOFTWARE.
*/
*/
#import <Foundation/Foundation.h>
#import "FLBFlutterProviderFactory.h"
#import "FLBFlutterEngine.h"
#import "FLBFlutterViewProvider.h"
#import "FLBPlatform.h"
#import "FLBPlatform.h"
NS_ASSUME_NONNULL_BEGIN
@i
nterface
FLBViewProviderFactory
:
NSObject
@i
mplementation
FLBFlutterProviderFactory
-
(
id
<
FLBFlutterViewProvider
>
)
createViewProvider
;
-
(
id
<
FLBFlutterProvider
>
)
createViewProviderWithPlatform
:(
id
<
FLBPlatform
>
)
platform
-
(
id
<
FLBFlutterViewProvider
>
)
createViewProviderWithPlatform
:(
id
<
FLBPlatform
>
)
platform
;
{
return
[
FLBFlutterEngine
new
];
}
@end
-
(
id
<
FLBFlutterProvider
>
)
createViewProvider
{
return
[
FLBFlutterEngine
new
];
}
NS_ASSUME_NONNULL_END
@end
ios/Classes/Adaptor/FLBFlutterViewControllerAdaptor.h
deleted
100755 → 0
View file @
39cbcbc7
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Flutter/Flutter.h>
NS_ASSUME_NONNULL_BEGIN
@interface
FLBFlutterViewControllerAdaptor
:
FlutterViewController
-
(
void
)
boost_viewWillAppear
:(
BOOL
)
animated
;
-
(
void
)
boost_viewDidAppear
:(
BOOL
)
animated
;
-
(
void
)
boost_viewWillDisappear
:(
BOOL
)
animated
;
-
(
void
)
boost_viewDidDisappear
:(
BOOL
)
animated
;
@property
(
nonatomic
,
assign
)
BOOL
accessibilityEnable
;
@end
NS_ASSUME_NONNULL_END
ios/Classes/Adaptor/FLBFlutterViewControllerAdaptor.m
deleted
100755 → 0
View file @
39cbcbc7
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "FLBFlutterViewControllerAdaptor.h"
#import <objc/runtime.h>
@interface
FLBFlutterViewControllerAdaptor
()
@end
@implementation
FLBFlutterViewControllerAdaptor
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
self
.
view
.
backgroundColor
=
[
UIColor
whiteColor
];
// Do any additional setup after loading the view.
}
-
(
void
)
viewWillAppear
:(
BOOL
)
animated
{
//Left blank intentionally.
}
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
//Left blank intentionally.
}
-
(
void
)
viewWillDisappear
:(
BOOL
)
animated
{
[[
UIApplication
sharedApplication
]
sendAction
:
@selector
(
resignFirstResponder
)
to
:
nil
from
:
nil
forEvent
:
nil
];
//Avoid super call intentionally.
}
-
(
void
)
viewDidDisappear
:(
BOOL
)
animated
{
//Avoid super call intentionally.
[[[
UIApplication
sharedApplication
]
keyWindow
]
endEditing
:
YES
];
}
-
(
void
)
boost_viewWillAppear
:(
BOOL
)
animated
{
[
super
viewWillAppear
:
animated
];
}
-
(
void
)
boost_viewDidAppear
:(
BOOL
)
animated
{
[
super
viewDidAppear
:
animated
];
}
-
(
void
)
boost_viewWillDisappear
:(
BOOL
)
animated
{
[
super
viewWillDisappear
:
animated
];
}
-
(
void
)
boost_viewDidDisappear
:(
BOOL
)
animated
{
[
super
viewDidDisappear
:
animated
];
}
-
(
UIEdgeInsets
)
paddingEdgeInsets
{
UIEdgeInsets
edgeInsets
=
UIEdgeInsetsZero
;
if
(
@available
(
iOS
11
,
*
))
{
edgeInsets
=
UIEdgeInsetsMake
(
0
,
self
.
view
.
safeAreaInsets
.
left
,
self
.
view
.
safeAreaInsets
.
bottom
,
self
.
view
.
safeAreaInsets
.
right
);
}
else
{
edgeInsets
=
UIEdgeInsetsZero
;
}
return
edgeInsets
;
}
-
(
void
)
installSplashScreenViewIfNecessary
{
//Override this to avoid unnecessary splash Screen.
}
-
(
void
)
fixed_onAccessibilityStatusChanged
:(
NSNotification
*
)
notification
{
if
(
self
.
accessibilityEnable
){
[
self
fixed_onAccessibilityStatusChanged
:
notification
];
}
}
@end
ios/Classes/Adaptor/FLBViewProviderFactory.m
deleted
100755 → 0
View file @
39cbcbc7
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "FLBViewProviderFactory.h"
#import "FLBFlutterEngine.h"
#import "FLBFlutterEngineOld.h"
#import "FLBPlatform.h"
@implementation
FLBViewProviderFactory
-
(
id
<
FLBFlutterViewProvider
>
)
createViewProviderWithPlatform
:(
id
<
FLBPlatform
>
)
platform
{
#if RELEASE_1_0
return
[
FLBFlutterEngine
new
];
#else
return
[[
FLBFlutterEngineOld
alloc
]
initWithPlatform
:
platform
];
#endif
}
-
(
id
<
FLBFlutterViewProvider
>
)
createViewProvider
{
#if RELEASE_1_0
return
[
FLBFlutterEngine
new
];
#else
return
[
FLBFlutterEngineOld
new
];
#endif
}
@end
ios/Classes/Boost/FLBFlutterApplication.h
View file @
854b8d32
...
@@ -26,17 +26,19 @@
...
@@ -26,17 +26,19 @@
#import <Flutter/Flutter.h>
#import <Flutter/Flutter.h>
#import "FLBPlatform.h"
#import "FLBPlatform.h"
#import "FlutterBoost.h"
#import "FlutterBoost.h"
#import "FLBFlutterProvider.h"
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
@interface
FLBFlutterApplication
:
NSObject
@interface
FLBFlutterApplication
:
NSObject
@property
(
nonatomic
,
strong
)
id
<
FLBPlatform
>
platform
;
@property
(
nonatomic
,
strong
)
id
<
FLBPlatform
>
platform
;
-
(
id
<
FLBFlutterProvider
>
)
flutterProvider
;
#pragma mark - Getters
#pragma mark - Getters
-
(
void
)
setAccessibilityEnable
:(
BOOL
)
enable
;
+
(
FLBFlutterApplication
*
)
sharedApplication
;
+
(
FLBFlutterApplication
*
)
sharedApplication
;
-
(
void
)
startFlutterWithPlatform
:(
id
<
FLBPlatform
>
)
platform
-
(
void
)
startFlutterWithPlatform
:(
id
<
FLBPlatform
>
)
platform
onStart
:(
void
(
^
)(
Flutter
ViewController
*
))
callback
;
onStart
:(
void
(
^
)(
Flutter
Engine
*
_Nonnull
))
callback
;
-
(
FlutterViewController
*
)
flutterViewController
;
-
(
FlutterViewController
*
)
flutterViewController
;
#pragma mark - Container Management
#pragma mark - Container Management
...
...
ios/Classes/Boost/FLBFlutterApplication.m
View file @
854b8d32
...
@@ -25,15 +25,14 @@
...
@@ -25,15 +25,14 @@
#import "FLBFlutterApplication.h"
#import "FLBFlutterApplication.h"
#import "FlutterBoost.h"
#import "FlutterBoost.h"
#import "FLBFlutterViewContainerManager.h"
#import "FLBFlutterViewContainerManager.h"
#import "FLB
View
ProviderFactory.h"
#import "FLB
Flutter
ProviderFactory.h"
@interface
FLBFlutterApplication
()
@interface
FLBFlutterApplication
()
@property
(
nonatomic
,
strong
)
FLBFlutterViewContainerManager
*
manager
;
@property
(
nonatomic
,
strong
)
FLBFlutterViewContainerManager
*
manager
;
@property
(
nonatomic
,
strong
)
id
<
FLBFlutter
View
Provider
>
viewProvider
;
@property
(
nonatomic
,
strong
)
id
<
FLBFlutterProvider
>
viewProvider
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
pageBuilders
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
pageBuilders
;
@property
(
nonatomic
,
copy
)
FLBPageBuilder
defaultPageBuilder
;
@property
(
nonatomic
,
copy
)
FLBPageBuilder
defaultPageBuilder
;
@property
(
nonatomic
,
assign
)
BOOL
isRendering
;
@property
(
nonatomic
,
assign
)
BOOL
isRunning
;
@property
(
nonatomic
,
assign
)
BOOL
isRunning
;
@end
@end
...
@@ -55,17 +54,20 @@
...
@@ -55,17 +54,20 @@
return
_isRunning
;
return
_isRunning
;
}
}
-
(
id
)
flutterProvider
{
return
_viewProvider
;
}
-
(
void
)
startFlutterWithPlatform
:(
id
<
FLBPlatform
>
)
platform
-
(
void
)
startFlutterWithPlatform
:(
id
<
FLBPlatform
>
)
platform
onStart
:(
void
(
^
)(
Flutter
ViewController
*
_Nonnull
))
callback
onStart
:(
void
(
^
)(
Flutter
Engine
*
_Nonnull
))
callback
{
{
static
dispatch_once_t
onceToken
;
static
dispatch_once_t
onceToken
;
dispatch_once
(
&
onceToken
,
^
{
dispatch_once
(
&
onceToken
,
^
{
self
.
platform
=
platform
;
self
.
platform
=
platform
;
self
.
viewProvider
=
[[
FLBViewProviderFactory
new
]
createViewProviderWithPlatform
:
platform
];
self
.
viewProvider
=
[[
FLBFlutterProviderFactory
new
]
createViewProviderWithPlatform
:
platform
];
[
self
.
viewProvider
resume
];
self
.
isRendering
=
YES
;
self
.
isRunning
=
YES
;
self
.
isRunning
=
YES
;
if
(
callback
)
callback
(
self
.
viewProvider
.
viewController
);
if
(
callback
)
callback
(
self
.
viewProvider
.
engine
);
});
});
}
}
...
@@ -88,11 +90,6 @@
...
@@ -88,11 +90,6 @@
return
[
self
flutterViewController
].
view
;
return
[
self
flutterViewController
].
view
;
}
}
-
(
FlutterViewController
*
)
flutterViewController
{
return
self
.
viewProvider
.
viewController
;
}
-
(
BOOL
)
contains
:(
FLBFlutterViewContainer
*
)
vc
-
(
BOOL
)
contains
:(
FLBFlutterViewContainer
*
)
vc
{
{
...
@@ -117,22 +114,12 @@
...
@@ -117,22 +114,12 @@
-
(
void
)
pause
-
(
void
)
pause
{
{
if
(
!
_isRendering
)
return
;
[
self
.
viewProvider
pause
];
[
self
.
viewProvider
pause
];
_isRendering
=
NO
;
}
}
-
(
void
)
resume
-
(
void
)
resume
{
{
if
(
_isRendering
)
return
;
[
self
.
viewProvider
resume
];
[
self
.
viewProvider
resume
];
_isRendering
=
YES
;
}
}
-
(
void
)
inactive
-
(
void
)
inactive
...
@@ -140,10 +127,9 @@
...
@@ -140,10 +127,9 @@
[
self
.
viewProvider
inactive
];
[
self
.
viewProvider
inactive
];
}
}
-
(
void
)
setAccessibilityEnable
:(
BOOL
)
enable
-
(
FlutterViewController
*
)
flutterViewController
{
{
[
self
.
viewProvider
setAccessibilityEnable
:
enable
]
;
return
self
.
flutterProvider
.
engine
.
viewController
;
}
}
@end
@end
ios/Classes/Boost/FlutterBoostPlugin.h
View file @
854b8d32
...
@@ -35,7 +35,7 @@ typedef FLBFlutterViewContainer * (^FLBPageBuilder)(NSString *name,NSDictionary
...
@@ -35,7 +35,7 @@ typedef FLBFlutterViewContainer * (^FLBPageBuilder)(NSString *name,NSDictionary
+
(
instancetype
)
sharedInstance
;
+
(
instancetype
)
sharedInstance
;
-
(
void
)
startFlutterWithPlatform
:(
id
<
FLBPlatform
>
)
platform
onStart
:(
void
(
^
)(
Flutter
ViewController
*
))
callback
;
-
(
void
)
startFlutterWithPlatform
:(
id
<
FLBPlatform
>
)
platform
onStart
:(
void
(
^
)(
Flutter
Engine
*
))
callback
;
#pragma mark - Some properties.
#pragma mark - Some properties.
-
(
BOOL
)
isRunning
;
-
(
BOOL
)
isRunning
;
...
...
ios/Classes/Boost/FlutterBoostPlugin.m
View file @
854b8d32
...
@@ -70,7 +70,7 @@
...
@@ -70,7 +70,7 @@
-
(
void
)
startFlutterWithPlatform
:(
id
<
FLBPlatform
>
)
platform
-
(
void
)
startFlutterWithPlatform
:(
id
<
FLBPlatform
>
)
platform
onStart
:(
void
(
^
)(
Flutter
ViewController
*
))
callback
;
onStart
:(
void
(
^
)(
Flutter
Engine
*
))
callback
;
{
{
[
FLBFlutterApplication
.
sharedApplication
startFlutterWithPlatform
:
platform
[
FLBFlutterApplication
.
sharedApplication
startFlutterWithPlatform
:
platform
onStart:
callback
];
onStart:
callback
];
...
@@ -101,9 +101,4 @@
...
@@ -101,9 +101,4 @@
[
_resultMediator
removeHandlerForKey
:
vcid
];
[
_resultMediator
removeHandlerForKey
:
vcid
];
}
}
-
(
void
)
setAccessibilityEnable
:(
BOOL
)
enable
{
[[
FLBFlutterApplication
sharedApplication
]
setAccessibilityEnable
:
enable
];
}
@end
@end
ios/Classes/Container/FLBFlutterViewContainer.h
View file @
854b8d32
...
@@ -24,10 +24,11 @@
...
@@ -24,10 +24,11 @@
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#import "FLBViewControllerResultHandler.h"
#import "FLBViewControllerResultHandler.h"
#import <Flutter/Flutter.h>
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
@interface
FLBFlutterViewContainer
:
UI
ViewController
<
FLBViewControllerResultHandler
>
@interface
FLBFlutterViewContainer
:
Flutter
ViewController
<
FLBViewControllerResultHandler
>
@property
(
nonatomic
,
copy
,
readonly
)
NSString
*
name
;
@property
(
nonatomic
,
copy
,
readonly
)
NSString
*
name
;
@property
(
nonatomic
,
strong
,
readonly
)
NSDictionary
*
params
;
@property
(
nonatomic
,
strong
,
readonly
)
NSDictionary
*
params
;
...
@@ -41,6 +42,8 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -41,6 +42,8 @@ NS_ASSUME_NONNULL_BEGIN
-
(
void
)
flutterViewDidAppear
:(
NSDictionary
*
)
params
;
-
(
void
)
flutterViewDidAppear
:(
NSDictionary
*
)
params
;
-
(
void
)
surfaceUpdated
:(
BOOL
)
appeared
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
ios/Classes/Container/FLBFlutterViewContainer.m
View file @
854b8d32
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#import "FLBMemoryInspector.h"
#import "FLBMemoryInspector.h"
#import "Service_NavigationService.h"
#import "Service_NavigationService.h"
#import "FlutterBoostConfig.h"
#import "FlutterBoostConfig.h"
#import "FLBFlutterViewContainerManager.h"
#define FLUTTER_VIEW [FLBFlutterApplication sharedApplication].flutterViewController.view
#define FLUTTER_VIEW [FLBFlutterApplication sharedApplication].flutterViewController.view
#define FLUTTER_VC [FLBFlutterApplication sharedApplication].flutterViewController
#define FLUTTER_VC [FLBFlutterApplication sharedApplication].flutterViewController
...
@@ -37,9 +38,7 @@
...
@@ -37,9 +38,7 @@
@interface
FLBFlutterViewContainer
()
@interface
FLBFlutterViewContainer
()
@property
(
nonatomic
,
copy
,
readwrite
)
NSString
*
name
;
@property
(
nonatomic
,
copy
,
readwrite
)
NSString
*
name
;
@property
(
nonatomic
,
strong
,
readwrite
)
NSDictionary
*
params
;
@property
(
nonatomic
,
strong
,
readwrite
)
NSDictionary
*
params
;
@property
(
nonatomic
,
strong
)
UIImageView
*
screenShotView
;
@property
(
nonatomic
,
assign
)
long
long
identifier
;
@property
(
nonatomic
,
assign
)
long
long
identifier
;
@property
(
nonatomic
,
assign
)
BOOL
interactiveGestureActive
;
@end
@end
@implementation
FLBFlutterViewContainer
@implementation
FLBFlutterViewContainer
...
@@ -76,7 +75,6 @@ static NSUInteger kInstanceCounter = 0;
...
@@ -76,7 +75,6 @@ static NSUInteger kInstanceCounter = 0;
{
{
kInstanceCounter
--
;
kInstanceCounter
--
;
if
([
self
.
class
instanceCounter
]
==
0
){
if
([
self
.
class
instanceCounter
]
==
0
){
[[
FLBStackCache
sharedInstance
]
clear
];
[[
FLBFlutterApplication
sharedApplication
]
pause
];
[[
FLBFlutterApplication
sharedApplication
]
pause
];
}
}
}
}
...
@@ -102,7 +100,10 @@ static NSUInteger kInstanceCounter = 0;
...
@@ -102,7 +100,10 @@ static NSUInteger kInstanceCounter = 0;
-
(
instancetype
)
init
-
(
instancetype
)
init
{
{
if
(
self
=
[
super
init
]){
[
FLUTTER_APP
.
flutterProvider
prepareEngineIfNeeded
];
if
(
self
=
[
super
initWithEngine
:
FLUTTER_APP
.
flutterProvider
.
engine
nibName:
nil
bundle:
nil
]){
[
self
_setup
];
[
self
_setup
];
}
}
return
self
;
return
self
;
...
@@ -122,12 +123,7 @@ static NSUInteger kInstanceCounter = 0;
...
@@ -122,12 +123,7 @@ static NSUInteger kInstanceCounter = 0;
-
(
void
)
flutterViewDidShow
:(
NSNotification
*
)
notification
-
(
void
)
flutterViewDidShow
:(
NSNotification
*
)
notification
{
{
__weak
typeof
(
self
)
weakSelf
=
self
;
if
([
notification
.
object
isEqual
:
self
.
uniqueIDString
]){
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
weakSelf
showFlutterView
];
});
}
}
}
-
(
void
)
dealloc
-
(
void
)
dealloc
...
@@ -150,140 +146,28 @@ static NSUInteger kInstanceCounter = 0;
...
@@ -150,140 +146,28 @@ static NSUInteger kInstanceCounter = 0;
-
(
void
)
viewDidLoad
{
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
[
super
viewDidLoad
];
self
.
view
.
backgroundColor
=
UIColor
.
whiteColor
;
self
.
view
.
backgroundColor
=
UIColor
.
whiteColor
;
self
.
screenShotView
=
[[
UIImageView
alloc
]
initWithFrame
:
self
.
view
.
bounds
];
self
.
screenShotView
.
backgroundColor
=
[
UIColor
whiteColor
];
[
self
.
view
addSubview
:
self
.
screenShotView
];
}
}
#pragma mark - ScreenShots
#pragma mark - ScreenShots
-
(
UIImage
*
)
takeScreenShot
{
CGFloat
scale
=
1
;
switch
([
FLBMemoryInspector
.
sharedInstance
currentCondition
])
{
case
FLBMemoryConditionNormal
:
scale
=
2
;
break
;
case
FLBMemoryConditionLowMemory
:
scale
=
1
;
break
;
case
FLBMemoryConditionExtremelyLow
:
scale
=
0
.
75
;
break
;
case
FLBMemoryConditionAboutToDie
:
return
[
UIImage
new
];
break
;
case
FLBMemoryConditionUnknown
:
if
([[
FLBMemoryInspector
sharedInstance
]
smallMemoryDevice
]){
scale
=
1
;
}
else
{
scale
=
2
;
}
break
;
}
self
.
screenShotView
.
opaque
=
YES
;
CGRect
flutterBounds
=
self
.
view
.
bounds
;
CGSize
snapshotSize
=
CGSizeMake
(
flutterBounds
.
size
.
width
,
flutterBounds
.
size
.
height
);
UIGraphicsBeginImageContextWithOptions
(
snapshotSize
,
NO
,
scale
);
[
self
.
view
drawViewHierarchyInRect
:
flutterBounds
afterScreenUpdates:
NO
];
UIImage
*
snapImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
return
snapImage
;
}
-
(
void
)
saveScreenShot
{
UIImage
*
snapImage
=
[
self
takeScreenShot
];
if
(
snapImage
){
FLBStackCacheObjectImg
*
cImg
=
[[
FLBStackCacheObjectImg
alloc
]
initWithImage
:
snapImage
];
[[
FLBStackCache
sharedInstance
]
pushObject
:
cImg
key
:
self
.
uniqueIDString
];
}
}
-
(
void
)
clearCurrentScreenShotImage
{
self
.
screenShotView
.
image
=
nil
;
}
-
(
UIImage
*
)
getSavedScreenShot
{
FLBStackCacheObjectImg
*
cImg
=
[[
FLBStackCache
sharedInstance
]
objectForKey
:
self
.
uniqueIDString
];
return
[
cImg
image
];
}
-
(
BOOL
)
isFlutterViewAttatched
-
(
BOOL
)
isFlutterViewAttatched
{
{
return
FLUTTER_VIEW
.
superview
==
self
.
view
;
return
FLUTTER_VIEW
.
superview
==
self
.
view
;
}
}
-
(
void
)
attatchFlutter
View
-
(
void
)
attatchFlutter
Engine
{
{
if
([
self
isFlutterViewAttatched
])
return
;
[
FLUTTER_APP
.
flutterProvider
prepareEngineIfNeeded
];
[
FLUTTER_APP
.
flutterProvider
atacheToViewController
:
self
];
[
FLUTTER_VC
willMoveToParentViewController
:
nil
];
[
FLUTTER_VC
removeFromParentViewController
];
[
FLUTTER_VC
didMoveToParentViewController
:
nil
];
[
FLUTTER_VC
willMoveToParentViewController
:
self
];
FLUTTER_VIEW
.
frame
=
self
.
view
.
bounds
;
if
(
!
self
.
screenShotView
.
image
){
[
self
.
view
addSubview
:
FLUTTER_VIEW
];
}
else
{
[
self
.
view
insertSubview
:
FLUTTER_VIEW
belowSubview
:
self
.
screenShotView
];
}
[
self
addChildViewController
:
FLUTTER_VC
];
[
FLUTTER_VC
didMoveToParentViewController
:
self
];
}
}
-
(
BOOL
)
showSnapShotVew
-
(
void
)
detatchFlutterEngine
{
{
self
.
screenShotView
.
image
=
[
self
getSavedScreenShot
];
// [FLUTTER_APP.flutterProvider prepareEngineIfNeeded];
[
FLUTTER_APP
.
flutterProvider
detach
];
if
([
self
isFlutterViewAttatched
]){
NSUInteger
fIdx
=
[
self
.
view
.
subviews
indexOfObject
:
FLUTTER_VIEW
];
NSUInteger
sIdx
=
[
self
.
view
.
subviews
indexOfObject
:
self
.
screenShotView
];
if
(
fIdx
>
sIdx
){
[
self
.
view
insertSubview
:
FLUTTER_VIEW
atIndex:
0
];
}
}
else
{
}
return
self
.
screenShotView
.
image
!=
nil
;
}
}
-
(
void
)
showFlutterView
{
if
(
FLUTTER_VIEW
.
superview
!=
self
.
view
)
return
;
if
([
self
isFlutterViewAttatched
]
){
NSUInteger
fIdx
=
[
self
.
view
.
subviews
indexOfObject
:
FLUTTER_VIEW
];
NSUInteger
sIdx
=
[
self
.
view
.
subviews
indexOfObject
:
self
.
screenShotView
];
self
.
screenShotView
.
backgroundColor
=
UIColor
.
clearColor
;
if
(
sIdx
>
fIdx
){
[
self
.
view
insertSubview
:
self
.
screenShotView
belowSubview
:
FLUTTER_VIEW
];
[
self
flutterViewDidAppear
:@{
@"uid"
:
self
.
uniqueIDString
?:
@""
}];
}
}
[
self
clearCurrentScreenShotImage
];
//Invalidate obsolete screenshot.
[
FLBStackCache
.
sharedInstance
invalidate
:
self
.
uniqueIDString
];
}
#pragma mark - Life circle methods
#pragma mark - Life circle methods
...
@@ -295,19 +179,18 @@ static NSUInteger kInstanceCounter = 0;
...
@@ -295,19 +179,18 @@ static NSUInteger kInstanceCounter = 0;
-
(
void
)
viewWillAppear
:(
BOOL
)
animated
-
(
void
)
viewWillAppear
:(
BOOL
)
animated
{
{
if
(
self
.
navigationController
.
interactivePopGestureRecognizer
.
state
==
UIGestureRecognizerStateBegan
){
if
([
FLUTTER_APP
contains
:
self
]){
self
.
interactiveGestureActive
=
true
;
[
self
detatchFlutterEngine
];
}
else
{
[
self
attatchFlutterEngine
];
}
}
[[
FLBFlutterApplication
sharedApplication
]
resume
];
[[
FLBFlutterApplication
sharedApplication
]
resume
];
[
self
surfaceUpdated
:
YES
];
//For new page we should attach flutter view in view will appear
//For new page we should attach flutter view in view will appear
//for better performance.
//for better performance.
if
(
!
[[
FLBFlutterApplication
sharedApplication
]
contains
:
self
]){
[
self
attatchFlutterView
];
}
[
self
showSnapShotVew
];
[
Service_NavigationService
willShowPageContainer
:
^
(
NSNumber
*
result
)
{}
[
Service_NavigationService
willShowPageContainer
:
^
(
NSNumber
*
result
)
{}
pageName:
_name
pageName:
_name
params:
_params
params:
_params
...
@@ -324,49 +207,21 @@ static NSUInteger kInstanceCounter = 0;
...
@@ -324,49 +207,21 @@ static NSUInteger kInstanceCounter = 0;
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
{
[[
FLBFlutterApplication
sharedApplication
]
resume
];
[
FLUTTER_APP
addUniqueViewController
:
self
];
//Ensure flutter view is attached.
[
self
attatchFlutterView
];
//Ensure flutter view is attached.
[
self
attatchFlutterEngine
];
[
self
surfaceUpdated
:
YES
];
[
Service_NavigationService
didShowPageContainer
:
^
(
NSNumber
*
result
)
{}
[
Service_NavigationService
didShowPageContainer
:
^
(
NSNumber
*
result
)
{}
pageName:
_name
pageName:
_name
params:
_params
params:
_params
uniqueId:
self
.
uniqueIDString
];
uniqueId:
self
.
uniqueIDString
];
[[
FLBFlutterApplication
sharedApplication
]
addUniqueViewController
:
self
];
[
super
viewDidAppear
:
animated
];
[
super
viewDidAppear
:
animated
];
__weak
typeof
(
self
)
weakSelf
=
self
;
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
2
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
if
(
weakSelf
.
isViewLoaded
&&
weakSelf
.
view
.
window
)
{
// viewController is visible
[
weakSelf
showFlutterView
];
}
});
self
.
interactiveGestureActive
=
NO
;
}
}
-
(
void
)
viewWillDisappear
:(
BOOL
)
animated
-
(
void
)
viewWillDisappear
:(
BOOL
)
animated
{
{
//is top.
if
([
FLUTTER_APP
isTop
:
self
.
uniqueIDString
]
&&
self
.
navigationController
.
interactivePopGestureRecognizer
.
state
!=
UIGestureRecognizerStateBegan
&&
!
self
.
interactiveGestureActive
){
[
self
saveScreenShot
];
}
self
.
interactiveGestureActive
=
NO
;
self
.
screenShotView
.
image
=
[
self
getSavedScreenShot
];
if
(
self
.
screenShotView
.
image
){
[
self
.
view
bringSubviewToFront
:
self
.
screenShotView
];
}
[
Service_NavigationService
willDisappearPageContainer
:
^
(
NSNumber
*
result
)
{}
[
Service_NavigationService
willDisappearPageContainer
:
^
(
NSNumber
*
result
)
{}
pageName:
_name
pageName:
_name
params:
_params
params:
_params
...
@@ -377,16 +232,12 @@ static NSUInteger kInstanceCounter = 0;
...
@@ -377,16 +232,12 @@ static NSUInteger kInstanceCounter = 0;
-
(
void
)
viewDidDisappear
:(
BOOL
)
animated
-
(
void
)
viewDidDisappear
:(
BOOL
)
animated
{
{
[
self
detatchFlutterEngine
];
[
Service_NavigationService
didDisappearPageContainer
:
^
(
NSNumber
*
result
)
{}
[
Service_NavigationService
didDisappearPageContainer
:
^
(
NSNumber
*
result
)
{}
pageName:
_name
pageName:
_name
params:
_params
params:
_params
uniqueId:
self
.
uniqueIDString
];
uniqueId:
self
.
uniqueIDString
];
[
self
clearCurrentScreenShotImage
];
[
super
viewDidDisappear
:
animated
];
[
super
viewDidDisappear
:
animated
];
[
FLUTTER_APP
inactive
];
self
.
interactiveGestureActive
=
NO
;
}
}
#pragma mark - FLBViewControllerResultHandler
#pragma mark - FLBViewControllerResultHandler
...
...
ios/Classes/Support/Cache/FLBStackCache.h
deleted
100755 → 0
View file @
39cbcbc7
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
@class
FLBStackCache
;
@protocol
FLBStackCacheObject
<
NSObject
>
@required
@property
(
nonatomic
,
copy
)
NSString
*
key
;
-
(
BOOL
)
writeToFileWithKey
:(
NSString
*
)
key
queue
:(
dispatch_queue_t
)
queue
cache
:(
FLBStackCache
*
)
cache
completion
:(
void
(
^
)(
NSError
*
err
,
NSString
*
path
))
completion
;
+
(
BOOL
)
loadFromFileWithKey
:(
NSString
*
)
key
queue
:(
dispatch_queue_t
)
queue
cache
:(
FLBStackCache
*
)
cache
completion
:(
void
(
^
)(
NSError
*
err
,
id
<
FLBStackCacheObject
>
))
completion
;
-
(
BOOL
)
removeCachedFileWithKey
:(
NSString
*
)
key
queue
:(
dispatch_queue_t
)
queue
cache
:(
FLBStackCache
*
)
cache
completion
:(
void
(
^
)(
NSError
*
,
NSString
*
))
completion
;
@end
@interface
FLBStackCache
:
NSObject
+
(
instancetype
)
sharedInstance
;
/**
* Num of objects allowed in memory.
* Default value is set to 2.
*/
@property
(
nonatomic
,
assign
)
NSUInteger
inMemoryCount
;
#pragma mark - basic operations.
-
(
void
)
pushObject
:(
id
<
FLBStackCacheObject
>
)
obj
key
:(
NSString
*
)
key
;
-
(
id
<
FLBStackCacheObject
>
)
remove
:(
NSString
*
)
key
;
-
(
void
)
invalidate
:(
NSString
*
)
key
;
-
(
BOOL
)
empty
;
-
(
void
)
clear
;
-
(
id
<
FLBStackCacheObject
>
)
objectForKey
:(
NSString
*
)
key
;
#pragma mark - Disk thing.
-
(
NSString
*
)
cacheDir
;
@end
ios/Classes/Support/Cache/FLBStackCache.m
deleted
100755 → 0
View file @
39cbcbc7
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "FLBStackCache.h"
@interface
FLBStackCache
()
@property
(
nonatomic
,
strong
)
NSMutableArray
*
keyStack
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
typesMap
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
inMemoryObjectsMap
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
loadinMap
;
@property
(
nonatomic
,
strong
)
dispatch_queue_t
queueIO
;
@end
@implementation
FLBStackCache
+
(
instancetype
)
sharedInstance
{
static
id
sInstance
=
nil
;
static
dispatch_once_t
onceToken
;
dispatch_once
(
&
onceToken
,
^
{
sInstance
=
[
self
.
class
new
];
});
return
sInstance
;
}
-
(
BOOL
)
empty
{
return
_keyStack
.
count
<=
0
;
}
-
(
void
)
clear
{
[
self
.
keyStack
removeAllObjects
];
[
self
.
inMemoryObjectsMap
removeAllObjects
];
[
self
.
typesMap
removeAllObjects
];
NSError
*
err
=
nil
;
[[
NSFileManager
defaultManager
]
removeItemAtPath
:
self
.
cacheDir
error
:
&
err
];
if
(
err
)
{
NSLog
(
@"fail to remove cache dir %@"
,
err
);
}
}
-
(
instancetype
)
init
{
if
(
self
=
[
super
init
])
{
_keyStack
=
[
NSMutableArray
new
];
_inMemoryObjectsMap
=
[
NSMutableDictionary
new
];
_loadinMap
=
[
NSMutableDictionary
new
];
_typesMap
=
[
NSMutableDictionary
new
];
_queueIO
=
dispatch_queue_create
(
"Stack cache working queue"
,
NULL
);
}
_inMemoryCount
=
2
;
return
self
;
}
-
(
void
)
pushObject
:(
id
<
FLBStackCacheObject
>
)
obj
key
:(
NSString
*
)
key
{
if
(
!
obj
||
key
.
length
<=
0
)
{
return
;
}
if
(
!
[
_keyStack
containsObject
:
key
]){
[
_keyStack
addObject
:
key
];
}
else
{
//return;
}
obj
.
key
=
key
;
_typesMap
[
key
]
=
obj
.
class
;
_inMemoryObjectsMap
[
key
]
=
obj
;
for
(
NSUInteger
i
=
_keyStack
.
count
-
_inMemoryObjectsMap
.
count
;
i
<
_keyStack
.
count
&&
_inMemoryObjectsMap
.
count
>
_inMemoryCount
;
i
++
){
NSString
*
keyToSave
=
_keyStack
[
i
];
if
(
_inMemoryObjectsMap
[
keyToSave
]){
id
<
FLBStackCacheObject
>
ob
=
_inMemoryObjectsMap
[
keyToSave
];
[
_inMemoryObjectsMap
removeObjectForKey
:
keyToSave
];
[
ob
writeToFileWithKey
:
keyToSave
queue:
_queueIO
cache:
self
completion:
^
(
NSError
*
err
,
NSString
*
path
)
{
if
(
err
)
{
NSLog
(
@"Caching object to file failed!"
);
}
}];
}
}
}
-
(
id
<
FLBStackCacheObject
>
)
objectForKey
:(
NSString
*
)
key
{
return
_inMemoryObjectsMap
[
key
];
}
-
(
id
<
FLBStackCacheObject
>
)
remove
:(
NSString
*
)
key
{
if
([
self
empty
])
return
nil
;
if
(
!
[
_keyStack
containsObject
:
key
])
return
nil
;
id
ob
=
_inMemoryObjectsMap
[
key
];
[
_keyStack
removeObject
:
key
];
[
_inMemoryObjectsMap
removeObjectForKey
:
key
];
[
_typesMap
removeObjectForKey
:
key
];
[
self
preloadIfNeeded
];
return
ob
;
}
-
(
void
)
invalidate
:(
NSString
*
)
key
{
if
(
!
key
||
[
self
empty
])
return
;
if
(
!
[
_keyStack
containsObject
:
key
])
return
;
id
<
FLBStackCacheObject
>
ob
=
_inMemoryObjectsMap
[
key
];
[
ob
removeCachedFileWithKey
:
key
queue:
_queueIO
cache:
self
completion:
^
(
NSError
*
err
,
NSString
*
k
)
{
}];
[
_inMemoryObjectsMap
removeObjectForKey
:
key
];
[
self
preloadIfNeeded
];
}
-
(
void
)
preloadIfNeeded
{
for
(
NSString
*
key
in
self
.
keyStack
.
reverseObjectEnumerator
){
Class
typeClass
=
_typesMap
[
key
];
id
cache
=
_inMemoryObjectsMap
[
key
];
if
(
typeClass
&&
!
cache
&&
[
typeClass
conformsToProtocol
:
@protocol
(
FLBStackCacheObject
)]){
_loadinMap
[
key
]
=
@
(
YES
);
[
typeClass
loadFromFileWithKey
:
key
queue:
_queueIO
cache:
self
completion:
^
(
NSError
*
err
,
id
<
FLBStackCacheObject
>
ob
){
[
self
.
loadinMap
removeObjectForKey
:
key
];
if
(
ob
&&
!
err
)
{
if
(
self
.
typesMap
[
key
]){
self
.
inMemoryObjectsMap
[
key
]
=
ob
;
}
}
else
{
NSLog
(
@"preload object from file failed!"
);
}
}];
}
if
(
_inMemoryObjectsMap
.
count
+
_loadinMap
.
count
>=
_inMemoryCount
){
break
;
}
}
}
-
(
NSString
*
)
cacheDir
{
static
NSString
*
cachePath
=
nil
;
if
(
!
cachePath
)
{
NSArray
*
paths
=
NSSearchPathForDirectoriesInDomains
(
NSCachesDirectory
,
NSUserDomainMask
,
YES
);
NSString
*
cacheDirectory
=
[
paths
objectAtIndex
:
0
];
cachePath
=
[
cacheDirectory
stringByAppendingPathComponent
:
@"FlutterScreenshots"
];
}
BOOL
dir
=
NO
;
if
(
!
[[
NSFileManager
defaultManager
]
fileExistsAtPath
:
cachePath
isDirectory
:
&
dir
]){
NSError
*
eror
=
nil
;
[[
NSFileManager
defaultManager
]
createDirectoryAtPath
:
cachePath
withIntermediateDirectories:
YES
attributes:
nil
error:
&
eror
];
if
(
eror
)
{
NSLog
(
@"%@"
,
eror
);
}
}
return
cachePath
;
}
@end
ios/Classes/Support/Cache/FLBStackCacheObjectImg.h
deleted
100755 → 0
View file @
39cbcbc7
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#import "FLBStackCache.h"
@interface
FLBStackCacheObjectImg
:
NSObject
<
FLBStackCacheObject
>
@property
(
nonatomic
,
copy
)
NSString
*
key
;
-
(
instancetype
)
initWithImage
:(
UIImage
*
)
image
;
-
(
UIImage
*
)
image
;
@end
ios/Classes/Support/Cache/FLBStackCacheObjectImg.m
deleted
100755 → 0
View file @
39cbcbc7
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "FLBStackCacheObjectImg.h"
@interface
FLBStackCacheObjectImg
()
@property
(
nonatomic
,
strong
)
UIImage
*
image
;
@end
@implementation
FLBStackCacheObjectImg
-
(
instancetype
)
initWithImage
:(
UIImage
*
)
image
{
if
(
self
=
[
super
init
])
{
_image
=
image
;
}
return
self
;
}
+
(
BOOL
)
loadFromFileWithKey
:(
NSString
*
)
key
queue
:(
dispatch_queue_t
)
queue
cache
:(
FLBStackCache
*
)
cache
completion
:(
void
(
^
)(
NSError
*
,
id
<
FLBStackCacheObject
>
))
completion
{
dispatch_async
(
queue
,
^
{
UIImage
*
image
=
[[
UIImage
alloc
]
initWithContentsOfFile
:[
self
filePathByKey
:
key
dirPath
:
cache
.
cacheDir
]];
if
(
completion
)
{
if
(
image
)
{
FLBStackCacheObjectImg
*
ob
=
[[
FLBStackCacheObjectImg
alloc
]
initWithImage
:
image
];
ob
.
key
=
key
;
completion
(
nil
,
ob
);
}
else
{
completion
([
NSError
new
],
nil
);
}
}
});
return
YES
;
}
+
(
NSString
*
)
filePathByKey
:(
NSString
*
)
key
dirPath
:(
NSString
*
)
cacheDir
{
key
=
[
key
stringByReplacingOccurrencesOfString
:
@"/"
withString
:
@""
];
key
=
[
key
stringByReplacingOccurrencesOfString
:
@":"
withString
:
@""
];
NSString
*
path
=
[
cacheDir
stringByAppendingPathComponent
:
key
];
return
path
;
}
-
(
BOOL
)
writeToFileWithKey
:(
NSString
*
)
key
queue
:(
dispatch_queue_t
)
queue
cache
:(
FLBStackCache
*
)
cache
completion
:(
void
(
^
)(
NSError
*
,
NSString
*
))
completion
{
if
(
!
_image
){
return
NO
;
}
dispatch_async
(
queue
,
^
{
NSData
*
imgData
=
UIImagePNGRepresentation
(
self
.
image
);
NSString
*
filePath
=
[
FLBStackCacheObjectImg
filePathByKey
:
key
dirPath
:
cache
.
cacheDir
];
[
imgData
writeToFile
:
filePath
atomically
:
YES
];
if
(
completion
)
{
completion
(
nil
,
key
);
}
});
return
YES
;
}
-
(
BOOL
)
removeCachedFileWithKey
:(
NSString
*
)
key
queue
:(
dispatch_queue_t
)
queue
cache
:(
FLBStackCache
*
)
cache
completion
:(
void
(
^
)(
NSError
*
,
NSString
*
))
completion
{
if
(
!
key
){
return
NO
;
}
dispatch_async
(
queue
,
^
{
NSString
*
filePath
=
[
FLBStackCacheObjectImg
filePathByKey
:
key
dirPath
:
cache
.
cacheDir
];
NSError
*
err
=
nil
;
[
NSFileManager
.
defaultManager
removeItemAtPath
:
filePath
error
:
&
err
];
if
(
completion
)
{
completion
(
err
,
key
);
}
});
return
YES
;
}
@end
ios/Classes/Support/Memory/FLBMemoryInspector.h
deleted
100755 → 0
View file @
39cbcbc7
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#define kFLBMemoryInspectorChangedNotification @"__FlutterMemoryInspectorChangedNotification__"
#define kFLBMemoryInspectorKeyCondition @"condition"
typedef
NS_ENUM
(
NSUInteger
,
FLBMemoryCondition
)
{
FLBMemoryConditionUnknown
,
FLBMemoryConditionNormal
,
FLBMemoryConditionLowMemory
,
FLBMemoryConditionExtremelyLow
,
FLBMemoryConditionAboutToDie
};
@interface
FLBMemoryInspector
:
NSObject
+
(
instancetype
)
sharedInstance
;
-
(
FLBMemoryCondition
)
currentCondition
;
-
(
int64_t
)
currentFootPrint
;
-
(
int64_t
)
deviceMemory
;
-
(
BOOL
)
smallMemoryDevice
;
@end
ios/Classes/Support/Memory/FLBMemoryInspector.mm
deleted
100755 → 0
View file @
39cbcbc7
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#import "FLBMemoryInspector.h"
#include <mach/mach.h>
#include <stdlib.h>
#include <sys/sysctl.h>
#define MB(_v_) (_v_*1024*1024)
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
@interface
FLBMemoryInspector
()
@property
(
nonatomic
,
assign
)
FLBMemoryCondition
condition
;
@end
@implementation
FLBMemoryInspector
+
(
instancetype
)
sharedInstance
{
static
id
sInstance
=
nil
;
static
dispatch_once_t
onceToken
;
dispatch_once
(
&
onceToken
,
^
{
sInstance
=
[[
self
.
class
alloc
]
init
];
});
return
sInstance
;
}
static
bool
isHighterThanIos9
(){
bool
ret
=
SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO
(
@"9.0.0"
);
return
ret
;
}
static
int64_t
memoryFootprint
()
{
task_vm_info_data_t
vmInfo
;
mach_msg_type_number_t
count
=
TASK_VM_INFO_COUNT
;
kern_return_t
result
=
task_info
(
mach_task_self
(),
TASK_VM_INFO
,
(
task_info_t
)
&
vmInfo
,
&
count
);
if
(
result
!=
KERN_SUCCESS
)
return
-
1
;
return
vmInfo
.
phys_footprint
;
}
static
int64_t
_memoryWarningLimit
()
{
size_t
size
;
sysctlbyname
(
"hw.machine"
,
NULL
,
&
size
,
NULL
,
0
);
char
*
machine
=
(
char
*
)
malloc
(
size
);
sysctlbyname
(
"hw.machine"
,
machine
,
&
size
,
NULL
,
0
);
NSString
*
platform
=
[
NSString
stringWithUTF8String
:
machine
];
free
(
machine
);
if
([
platform
isEqualToString
:
@"iPhone5,1"
])
return
MB
(
600
);
if
([
platform
isEqualToString
:
@"iPhone5,2"
])
return
MB
(
600
);
if
([
platform
isEqualToString
:
@"iPhone5,3"
])
return
MB
(
600
);
if
([
platform
isEqualToString
:
@"iPhone5,4"
])
return
MB
(
600
);
if
([
platform
isEqualToString
:
@"iPhone6,1"
])
return
MB
(
600
);
if
([
platform
isEqualToString
:
@"iPhone6,2"
])
return
MB
(
600
);
if
([
platform
isEqualToString
:
@"iPhone7,1"
])
return
MB
(
600
);
if
([
platform
isEqualToString
:
@"iPhone7,2"
])
return
MB
(
600
);
if
([
platform
isEqualToString
:
@"iPhone8,1"
])
return
MB
(
1280
);
if
([
platform
isEqualToString
:
@"iPhone8,2"
])
return
MB
(
1280
);
if
([
platform
isEqualToString
:
@"iPhone8,4"
])
return
MB
(
1280
);
if
([
platform
isEqualToString
:
@"iPhone9,1"
])
return
MB
(
1280
);
if
([
platform
isEqualToString
:
@"iPhone9,2"
])
return
MB
(
1950
);
if
([
platform
isEqualToString
:
@"iPhone9,3"
])
return
MB
(
1280
);
if
([
platform
isEqualToString
:
@"iPhone9,4"
])
return
MB
(
1950
);
if
([
platform
isEqualToString
:
@"iPhone10,1"
])
return
MB
(
1280
);
if
([
platform
isEqualToString
:
@"iPhone10,2"
])
return
MB
(
1950
);
if
([
platform
isEqualToString
:
@"iPhone10,3"
])
return
MB
(
1950
);
if
([
platform
isEqualToString
:
@"iPhone10,4"
])
return
MB
(
1280
);
if
([
platform
isEqualToString
:
@"iPhone10,5"
])
return
MB
(
1950
);
if
([
platform
isEqualToString
:
@"iPhone10,6"
])
return
MB
(
1950
);
return
0
;
}
static
int64_t
getLimit
(){
const
static
size_t
l
=
_memoryWarningLimit
();
return
l
;
}
-
(
int64_t
)
deviceMemory
{
int64_t
size
=
[
NSProcessInfo
processInfo
].
physicalMemory
;
return
size
;
}
-
(
BOOL
)
smallMemoryDevice
{
if
([
self
deviceMemory
]
<=
MB
(
1024
)){
return
YES
;
}
else
{
return
NO
;
}
}
-
(
FLBMemoryCondition
)
currentCondition
{
FLBMemoryCondition
newCondition
=
FLBMemoryConditionUnknown
;
if
(
!
isHighterThanIos9
()
||
getLimit
()
<=
0
){
newCondition
=
FLBMemoryConditionUnknown
;
}
else
if
(
memoryFootprint
()
<
getLimit
()
*
0.40
){
newCondition
=
FLBMemoryConditionNormal
;
}
else
if
(
memoryFootprint
()
<
getLimit
()
*
0.60
){
newCondition
=
FLBMemoryConditionLowMemory
;
}
else
if
(
memoryFootprint
()
<
getLimit
()
*
0.80
){
newCondition
=
FLBMemoryConditionExtremelyLow
;
}
else
{
newCondition
=
FLBMemoryConditionAboutToDie
;
}
if
(
newCondition
!=
self
.
condition
)
{
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
kFLBMemoryInspectorChangedNotification
object:
@{
kFLBMemoryInspectorKeyCondition
:
@
(
newCondition
)}];
}
self
.
condition
=
newCondition
;
return
newCondition
;
}
-
(
int64_t
)
currentFootPrint
{
return
memoryFootprint
();
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment