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
0
Merge Requests
0
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
b3a5d505
Commit
b3a5d505
authored
Apr 01, 2020
by
余玠
Committed by
justin
Apr 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pick from master
parent
ea007356
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
245 additions
and
26 deletions
+245
-26
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
...src/main/java/com/idlefish/flutterboost/FlutterBoost.java
+0
-1
example/ios/Runner/NativeViewController.m
example/ios/Runner/NativeViewController.m
+11
-0
example/lib/main.dart
example/lib/main.dart
+2
-0
example/lib/simple_page_widgets.dart
example/lib/simple_page_widgets.dart
+181
-8
ios/Classes/Boost/FLBFlutterApplicationInterface.h
ios/Classes/Boost/FLBFlutterApplicationInterface.h
+1
-0
ios/Classes/Boost/FLBFlutterProvider.h
ios/Classes/Boost/FLBFlutterProvider.h
+1
-1
ios/Classes/Engine/FLBFlutterApplication.m
ios/Classes/Engine/FLBFlutterApplication.m
+10
-1
ios/Classes/Engine/FLBFlutterEngine.m
ios/Classes/Engine/FLBFlutterEngine.m
+4
-2
ios/Classes/container/FLBFlutterViewContainer.m
ios/Classes/container/FLBFlutterViewContainer.m
+30
-10
lib/container/container_coordinator.dart
lib/container/container_coordinator.dart
+3
-3
lib/container/container_manager.dart
lib/container/container_manager.dart
+2
-0
No files found.
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
View file @
b3a5d505
...
...
@@ -17,7 +17,6 @@ import io.flutter.embedding.engine.dart.DartExecutor;
import
io.flutter.embedding.engine.loader.FlutterLoader
;
import
io.flutter.view.FlutterMain
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
example/ios/Runner/NativeViewController.m
View file @
b3a5d505
...
...
@@ -51,6 +51,13 @@
// [self.flutterContainer.view setNeedsLayout];
// [self.flutterContainer.view layoutIfNeeded];
}
//NOTES: embed情景下必须实现!!!
-
(
void
)
didMoveToParentViewController
:(
UIViewController
*
)
parent
{
[
self
.
flutterContainer
didMoveToParentViewController
:
parent
];
[
super
didMoveToParentViewController
:
parent
];
}
/*
#pragma mark - Navigation
...
...
@@ -61,4 +68,8 @@
}
*/
-
(
void
)
dealloc
{
NSLog
(
@"dealloc native controller%p"
,
self
.
flutterContainer
);
}
@end
example/lib/main.dart
View file @
b3a5d505
...
...
@@ -19,7 +19,9 @@ class _MyAppState extends State<MyApp> {
FlutterBoost
.
singleton
.
registerPageBuilders
({
'embeded'
:
(
pageName
,
params
,
_
)=>
EmbededFirstRouteWidget
(),
'first'
:
(
pageName
,
params
,
_
)
=>
FirstRouteWidget
(),
'firstFirst'
:
(
pageName
,
params
,
_
)
=>
FirstFirstRouteWidget
(),
'second'
:
(
pageName
,
params
,
_
)
=>
SecondRouteWidget
(),
'secondStateful'
:
(
pageName
,
params
,
_
)
=>
SecondStatefulRouteWidget
(),
'tab'
:
(
pageName
,
params
,
_
)
=>
TabRouteWidget
(),
'platformView'
:
(
pageName
,
params
,
_
)
=>
PlatformRouteWidget
(),
'flutterFragment'
:
(
pageName
,
params
,
_
)
=>
FragmentRouteWidget
(
params
),
...
...
example/lib/simple_page_widgets.dart
100755 → 100644
View file @
b3a5d505
...
...
@@ -3,7 +3,45 @@ import 'package:flutter/material.dart';
import
'package:flutter_boost/flutter_boost.dart'
;
import
'package:flutter_boost_example/platform_view.dart'
;
class
FirstRouteWidget
extends
StatelessWidget
{
class
FirstRouteWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
_FirstRouteWidgetState
();
}
}
class
_FirstRouteWidgetState
extends
State
<
FirstRouteWidget
>{
_FirstRouteWidgetState
();
@override
void
initState
()
{
print
(
'initState'
);
super
.
initState
();
}
@override
void
didChangeDependencies
()
{
print
(
'didChangeDependencies'
);
super
.
didChangeDependencies
();
}
@override
void
didUpdateWidget
(
FirstRouteWidget
oldWidget
)
{
print
(
'didUpdateWidget'
);
super
.
didUpdateWidget
(
oldWidget
);
}
@override
void
deactivate
()
{
print
(
'deactivate'
);
super
.
deactivate
();
}
@override
void
dispose
()
{
print
(
'[XDEBUG] - FirstRouteWidget is disposing~'
);
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
...
...
@@ -22,13 +60,22 @@ class FirstRouteWidget extends StatelessWidget {
print
(
"open natve page!"
);
FlutterBoost
.
singleton
.
open
(
"native"
).
then
((
Map
<
dynamic
,
dynamic
>
value
)
{
print
(
"call me when page is finished. did recieve
second
route result
$value
"
);
"call me when page is finished. did recieve
native
route result
$value
"
);
});
},
),
RaisedButton
(
child:
Text
(
'Open second route'
),
child:
Text
(
'Open FF route'
),
onPressed:
()
{
print
(
"open FF page!"
);
FlutterBoost
.
singleton
.
open
(
"firstFirst"
).
then
((
Map
value
)
{
print
(
"call me when page is finished. did recieve FF route result
$value
"
);
});
},
),
RaisedButton
(
child:
Text
(
'Open second route1'
),
onPressed:
()
{
print
(
"open second page!"
);
FlutterBoost
.
singleton
.
open
(
"second"
).
then
((
Map
<
dynamic
,
dynamic
>
value
)
{
...
...
@@ -38,6 +85,16 @@ class FirstRouteWidget extends StatelessWidget {
},
),
RaisedButton
(
child:
Text
(
'Present second stateful route'
),
onPressed:
()
{
print
(
"Present second stateful page!"
);
FlutterBoost
.
singleton
.
open
(
"secondStateful"
,
urlParams:
<
dynamic
,
dynamic
>{
"present"
:
true
}).
then
((
Map
value
)
{
print
(
"call me when page is finished. did recieve second stateful route result
$value
"
);
});
},
),
RaisedButton
(
child:
Text
(
'Present second route'
),
onPressed:
()
{
...
...
@@ -54,14 +111,87 @@ class FirstRouteWidget extends StatelessWidget {
);
}
}
class
FirstFirstRouteWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
_FirstFirstRouteWidgetState
();
}
}
class
_FirstFirstRouteWidgetState
extends
State
<
FirstFirstRouteWidget
>{
_FirstFirstRouteWidgetState
();
@override
void
initState
()
{
print
(
'initState'
);
super
.
initState
();
}
@override
void
didChangeDependencies
()
{
print
(
'didChangeDependencies'
);
super
.
didChangeDependencies
();
}
class
EmbededFirstRouteWidget
extends
StatelessWidget
{
@override
void
didUpdateWidget
(
FirstFirstRouteWidget
oldWidget
)
{
print
(
'didUpdateWidget'
);
super
.
didUpdateWidget
(
oldWidget
);
}
@override
void
deactivate
()
{
print
(
'deactivate'
);
super
.
deactivate
();
}
@override
void
dispose
()
{
print
(
'[XDEBUG] - FirstFirstRouteWidget is disposing~'
);
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'First Route'
),
),
body:
Center
(
child:
RaisedButton
(
child:
Text
(
'Open first route'
),
onPressed:
()
{
print
(
"open first page again!"
);
FlutterBoost
.
singleton
.
open
(
"first"
).
then
((
Map
value
){
print
(
"did recieve first route result"
);
print
(
"did recieve first route result
$value
"
);
});
},
),
),
);
}
}
class
EmbededFirstRouteWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
// TODO: implement createState
return
_EmbededFirstRouteWidgetState
();
}
}
class
_EmbededFirstRouteWidgetState
extends
State
<
EmbededFirstRouteWidget
>
{
@override
Widget
build
(
BuildContext
context
)
{
print
(
'_EmbededFirstRouteWidgetState build called!'
);
return
Scaffold
(
body:
Center
(
child:
RaisedButton
(
child:
Text
(
'Open second route'
),
child:
Text
(
'Open second route
2
'
),
onPressed:
()
{
print
(
"open second page!"
);
FlutterBoost
.
singleton
.
open
(
"second"
).
then
((
Map
<
dynamic
,
dynamic
>
value
)
{
...
...
@@ -73,6 +203,48 @@ class EmbededFirstRouteWidget extends StatelessWidget {
),
);
}
@override
void
dispose
()
{
print
(
'[XDEBUG]:_EmbededFirstRouteWidgetState disposing~'
);
super
.
dispose
();
}
}
class
SecondStatefulRouteWidget
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
// TODO: implement createState
return
_SecondStatefulRouteWidgetState
();
}
}
class
_SecondStatefulRouteWidgetState
extends
State
<
SecondStatefulRouteWidget
>{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"SecondStateful Route"
),
),
body:
Center
(
child:
RaisedButton
(
onPressed:
()
{
// Navigate back to first route when tapped.
BoostContainerSettings
settings
=
BoostContainer
.
of
(
context
).
settings
;
FlutterBoost
.
singleton
.
close
(
settings
.
uniqueId
,
result:
<
dynamic
,
dynamic
>{
"result"
:
"data from second"
});
},
child:
Text
(
'Go back with result!'
),
),
),
);
}
@override
void
dispose
()
{
print
(
'[XDEBUG]:SecondStatefulRouteWidget disposing~'
);
super
.
dispose
();
}
}
class
SecondRouteWidget
extends
StatelessWidget
{
...
...
@@ -111,7 +283,7 @@ class TabRouteWidget extends StatelessWidget {
onPressed:
()
{
FlutterBoost
.
singleton
.
open
(
"second"
);
},
child:
Text
(
'Open second route'
),
child:
Text
(
'Open second route
3
'
),
),
),
);
...
...
@@ -432,6 +604,7 @@ class _PushWidgetState extends State<PushWidget> {
@override
void
dispose
()
{
// TODO: implement dispose
print
(
'[XDEBUG] - PushWidget is disposing~'
);
super
.
dispose
();
_backPressedListenerUnsub
?.
call
();
}
...
...
ios/Classes/Boost/FLBFlutterApplicationInterface.h
View file @
b3a5d505
...
...
@@ -66,6 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
onPageFinished
:(
void
(
^
)(
NSDictionary
*
))
resultCallback
completion
:(
void
(
^
)(
BOOL
))
completion
;
-
(
void
)
attachToPreviousContainer
;
-
(
void
)
didInitPageContainer
:(
NSString
*
)
url
params
:(
NSDictionary
*
)
urlParams
...
...
ios/Classes/Boost/FLBFlutterProvider.h
View file @
b3a5d505
...
...
@@ -31,7 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol
FLBFlutterProvider
<
NSObject
>
@required
-
(
FlutterEngine
*
)
engine
;
-
(
void
)
atacheToViewController
:(
FlutterViewController
*
)
vc
;
-
(
BOOL
)
atacheToViewController
:(
FlutterViewController
*
)
vc
;
-
(
void
)
detach
;
-
(
void
)
prepareEngineIfNeeded
;
-
(
void
)
pause
;
...
...
ios/Classes/Engine/FLBFlutterApplication.m
View file @
b3a5d505
...
...
@@ -26,10 +26,12 @@
#import "FlutterBoost.h"
#import "FLBFlutterContainerManager.h"
#import "FLBFlutterEngine.h"
#import "FLBFlutterViewContainer.h"
@interface
FLBFlutterApplication
()
@property
(
nonatomic
,
strong
)
FLBFlutterContainerManager
*
manager
;
@property
(
nonatomic
,
strong
)
id
<
FLBFlutterProvider
>
viewProvider
;
@property
(
nonatomic
,
weak
,
readonly
)
FlutterViewController
*
previousViewController
;
@property
(
nonatomic
,
assign
)
BOOL
isRunning
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
pageResultCallbacks
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
callbackCache
;
...
...
@@ -156,6 +158,13 @@
return
self
.
flutterProvider
.
engine
.
viewController
;
}
-
(
void
)
attachToPreviousContainer
{
if
([
self
.
viewProvider
atacheToViewController
:
self
.
previousViewController
]){
[
self
.
previousViewController
.
view
setNeedsLayout
];
[(
FLBFlutterViewContainer
*
)
self
.
previousViewController
surfaceUpdated
:
YES
];
}
}
-
(
void
)
close
:(
NSString
*
)
uniqueId
result
:(
NSDictionary
*
)
resultData
exts
:(
NSDictionary
*
)
exts
...
...
@@ -189,7 +198,7 @@
[
newParams
setObject
:
cid
?
cid
:
@"__default#0__"
forKey
:
kPageCallBackId
];
urlParams
=
newParams
;
}
_previousViewController
=
[
self
flutterViewController
];
_callbackCache
[
cid
]
=
resultCallback
;
if
([
urlParams
[
@"present"
]
respondsToSelector
:
@selector
(
boolValue
)]
&&
[
urlParams
[
@"present"
]
boolValue
]
&&
[
self
.
platform
respondsToSelector
:
@selector
(
present
:
urlParams
:
exts
:
completion
:
)]){
[
self
.
platform
present
:
url
...
...
ios/Classes/Engine/FLBFlutterEngine.m
View file @
b3a5d505
...
...
@@ -97,17 +97,19 @@
arguments:
@{
@"type"
:
@"foreground"
}];
}
-
(
void
)
atacheToViewController
:(
FlutterViewController
*
)
vc
-
(
BOOL
)
atacheToViewController
:(
FlutterViewController
*
)
vc
{
if
(
_engine
.
viewController
!=
vc
){
// [(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
_engine
.
viewController
=
vc
;
return
YES
;
}
return
NO
;
}
-
(
void
)
detach
{
if
(
_engine
.
viewController
!=
_dummy
){
[(
FLBFlutterViewContainer
*
)
_engine
.
viewController
surfaceUpdated
:
NO
];
_engine
.
viewController
=
_dummy
;
}
}
...
...
ios/Classes/container/FLBFlutterViewContainer.m
View file @
b3a5d505
...
...
@@ -118,10 +118,6 @@
if
(
!
_name
&&
name
){
_name
=
name
;
_params
=
params
;
[
BoostMessageChannel
didInitPageContainer
:
^
(
NSNumber
*
r
)
{}
pageName:
name
params:
params
uniqueId:
[
self
uniqueIDString
]];
}
}
...
...
@@ -160,9 +156,38 @@ static NSUInteger kInstanceCounter = 0;
[
self
.
class
instanceCounterIncrease
];
}
-
(
void
)
willMoveToParentViewController
:(
UIViewController
*
)
parent
{
if
(
parent
&&
_name
)
{
//当VC将要被移动到Parent中的时候,才出发flutter层面的page init
[
BoostMessageChannel
didInitPageContainer
:
^
(
NSNumber
*
r
)
{}
pageName:
_name
params:
_params
uniqueId:
[
self
uniqueIDString
]];
}
[
super
willMoveToParentViewController
:
parent
];
}
-
(
void
)
didMoveToParentViewController
:(
UIViewController
*
)
parent
{
if
(
!
parent
)
{
//当VC被移出parent时,就通知flutter层销毁page
[
self
notifyWillDealloc
];
}
[
super
didMoveToParentViewController
:
parent
];
}
-
(
void
)
dismissViewControllerAnimated
:(
BOOL
)
flag
completion
:(
void
(
^
)(
void
))
completion
{
[
super
dismissViewControllerAnimated
:
flag
completion
:
^
(){
if
(
completion
)
{
completion
();
}
//当VC被dismiss时,就通知flutter层销毁page
[
self
notifyWillDealloc
];
}];
}
-
(
void
)
dealloc
{
[
self
notifyWillDealloc
];
[
NSNotificationCenter
.
defaultCenter
removeObserver
:
self
];
}
...
...
@@ -262,11 +287,6 @@ static NSUInteger kInstanceCounter = 0;
pageName:
_name
params:
_params
uniqueId:
self
.
uniqueIDString
];
//如果当前不可见vc和engine所持有的vc一致。在FlutterVC在混合栈中是最后一张页面,如tab中的页面
if
(
self
==
FLUTTER_VC
)
{
[
self
surfaceUpdated
:
NO
];
}
[
super
bridge_viewDidDisappear
:
animated
];
}
...
...
lib/container/container_coordinator.dart
View file @
b3a5d505
...
...
@@ -102,7 +102,7 @@ class ContainerCoordinator {
Map
map
=
event
;
final
String
type
=
map
[
'type'
];
Logger
.
log
(
"onEvent
$type
"
);
Logger
.
log
(
'onEvent
$type
'
);
switch
(
type
)
{
//Handler back key pressed event.
...
...
@@ -242,7 +242,7 @@ class ContainerCoordinator {
ContainerLifeCycle
.
Appear
);
Logger
.
log
(
'native containner did show,
\n
manager dump:
\n
${FlutterBoost.containerManager?.dump()}
'
);
'native containner did show
-
$name
,
\n
manager dump:
\n
${FlutterBoost.containerManager?.dump()}
'
);
return
true
;
}
...
...
@@ -275,7 +275,7 @@ class ContainerCoordinator {
FlutterBoost
.
containerManager
?.
remove
(
pageId
);
Logger
.
log
(
'native containner dealloc,
\n
manager dump:
\n
${FlutterBoost.containerManager?.dump()}
'
);
'native containner dealloc
for
$name
,
\n
manager dump:
\n
${FlutterBoost.containerManager?.dump()}
'
);
return
true
;
}
...
...
lib/container/container_manager.dart
View file @
b3a5d505
...
...
@@ -183,9 +183,11 @@ class ContainerManagerState extends State<BoostContainerManager> {
if
(
SchedulerBinding
.
instance
.
schedulerPhase
==
SchedulerPhase
.
persistentCallbacks
)
{
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
duration
)
{
Logger
.
log
(
'_refreshOverlayEntries in addPostFrameCallback'
);
_refreshOverlayEntries
();
});
}
else
{
Logger
.
log
(
'_refreshOverlayEntries in setState'
);
_refreshOverlayEntries
();
}
...
...
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