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
6db19519
Commit
6db19519
authored
Sep 05, 2020
by
ColdPaleLight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flutter page to flutter page without native container
parent
253f2d67
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
182 additions
and
9 deletions
+182
-9
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/PageRouter.java
...a/com/taobao/idlefish/flutterboostexample/PageRouter.java
+2
-0
example/lib/flutter_to_flutter_sample.dart
example/lib/flutter_to_flutter_sample.dart
+72
-0
example/lib/main.dart
example/lib/main.dart
+10
-0
example/lib/simple_page_widgets.dart
example/lib/simple_page_widgets.dart
+10
-0
lib/container/container_coordinator.dart
lib/container/container_coordinator.dart
+18
-8
lib/flutter_boost.dart
lib/flutter_boost.dart
+8
-1
lib/flutter_boost_api.dart
lib/flutter_boost_api.dart
+62
-0
No files found.
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/PageRouter.java
View file @
6db19519
...
@@ -16,6 +16,8 @@ public class PageRouter {
...
@@ -16,6 +16,8 @@ public class PageRouter {
put
(
"first"
,
"first"
);
put
(
"first"
,
"first"
);
put
(
"second"
,
"second"
);
put
(
"second"
,
"second"
);
put
(
"tab"
,
"tab"
);
put
(
"tab"
,
"tab"
);
put
(
"f2f_first"
,
"f2f_first"
);
put
(
"f2f_second"
,
"f2f_second"
);
put
(
"sample://flutterPage"
,
"flutterPage"
);
put
(
"sample://flutterPage"
,
"flutterPage"
);
}};
}};
...
...
example/lib/flutter_to_flutter_sample.dart
0 → 100644
View file @
6db19519
import
'package:flutter/material.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
class
F2FFirstPage
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
F2FFirstPageState
();
}
}
class
F2FFirstPageState
extends
State
<
F2FFirstPage
>{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'First Route'
),
),
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
RaisedButton
(
child:
Text
(
'Open second with native container'
),
onPressed:
()
{
FlutterBoost
.
singleton
.
open
(
"f2f_second"
);
},
),
RaisedButton
(
child:
Text
(
'Open second without native container'
),
onPressed:
()
{
FlutterBoostAPI
.
singleton
.
open
(
"f2f_second"
,
noNeedNativeContainer:
true
);
},
),
],
),
),
);
}
}
class
F2FSecondPage
extends
StatefulWidget
{
@override
State
<
StatefulWidget
>
createState
()
{
return
new
F2FSecondPageState
();
}
}
class
F2FSecondPageState
extends
State
<
F2FSecondPage
>{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
'Second Route'
),
),
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Text
(
'Hello'
)
],
),
),
);
}
}
\ No newline at end of file
example/lib/main.dart
View file @
6db19519
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
import
'simple_page_widgets.dart'
;
import
'simple_page_widgets.dart'
;
import
'flutter_to_flutter_sample.dart'
;
void
main
(
)
{
void
main
(
)
{
runApp
(
MyApp
());
runApp
(
MyApp
());
...
@@ -31,8 +32,17 @@ class _MyAppState extends State<MyApp> {
...
@@ -31,8 +32,17 @@ class _MyAppState extends State<MyApp> {
return
FlutterRouteWidget
(
params:
params
);
return
FlutterRouteWidget
(
params:
params
);
},
},
'f2f_first'
:
(
pageName
,
params
,
_
)
=>
F2FFirstPage
(),
'f2f_second'
:
(
pageName
,
params
,
_
)
=>
F2FSecondPage
(),
});
});
FlutterBoost
.
singleton
.
addBoostNavigatorObserver
(
TestBoostNavigatorObserver
());
FlutterBoost
.
singleton
.
addBoostNavigatorObserver
(
TestBoostNavigatorObserver
());
FlutterBoostAPI
.
singleton
.
routeSettingsBuilder
=
(
String
url
,
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
})
=>
BoostRouteSettings
(
uniqueId:
'
${url}
_
${DateTime.now().millisecondsSinceEpoch}
'
,
name:
url
,
params:
urlParams
,
);
}
}
@override
@override
...
...
example/lib/simple_page_widgets.dart
View file @
6db19519
...
@@ -105,6 +105,16 @@ class _FirstRouteWidgetState extends State<FirstRouteWidget>{
...
@@ -105,6 +105,16 @@ class _FirstRouteWidgetState extends State<FirstRouteWidget>{
});
});
},
},
),
),
RaisedButton
(
child:
Text
(
'Flutter to Flutter with Animation'
),
onPressed:
()
{
FlutterBoost
.
singleton
.
open
(
"f2f_first"
).
then
((
Map
<
dynamic
,
dynamic
>
value
)
{
print
(
"call me when page is finished. did recieve second route result
$value
"
);
});
}
)
],
],
),
),
),
),
...
...
lib/container/container_coordinator.dart
View file @
6db19519
...
@@ -40,6 +40,7 @@ class ContainerCoordinator {
...
@@ -40,6 +40,7 @@ class ContainerCoordinator {
final
Map
<
String
,
PageBuilder
>
_pageBuilders
=
<
String
,
PageBuilder
>{};
final
Map
<
String
,
PageBuilder
>
_pageBuilders
=
<
String
,
PageBuilder
>{};
PageBuilder
_defaultPageBuilder
;
PageBuilder
_defaultPageBuilder
;
ContainerCoordinator
(
BoostChannel
channel
)
{
ContainerCoordinator
(
BoostChannel
channel
)
{
assert
(
_instance
==
null
);
assert
(
_instance
==
null
);
...
@@ -60,6 +61,21 @@ class ContainerCoordinator {
...
@@ -60,6 +61,21 @@ class ContainerCoordinator {
name:
name
,
name:
name
,
params:
params
,
params:
params
,
builder:
(
BuildContext
ctx
)
{
builder:
(
BuildContext
ctx
)
{
page
=
createPage
(
name
,
params
,
pageId
);
assert
(
page
!=
null
);
Logger
.
log
(
'build widget:
$page
for page:
$name
(
$pageId
)'
);
return
page
;
});
return
routeSettings
;
}
Widget
createPage
(
String
name
,
Map
params
,
String
pageId
)
{
Widget
page
;
//Try to build a page using keyed builder.
//Try to build a page using keyed builder.
if
(
_pageBuilders
[
name
]
!=
null
)
{
if
(
_pageBuilders
[
name
]
!=
null
)
{
page
=
_pageBuilders
[
name
](
name
,
params
,
pageId
);
page
=
_pageBuilders
[
name
](
name
,
params
,
pageId
);
...
@@ -70,13 +86,7 @@ class ContainerCoordinator {
...
@@ -70,13 +86,7 @@ class ContainerCoordinator {
page
=
_defaultPageBuilder
(
name
,
params
,
pageId
);
page
=
_defaultPageBuilder
(
name
,
params
,
pageId
);
}
}
assert
(
page
!=
null
);
Logger
.
log
(
'build widget:
$page
for page:
$name
(
$pageId
)'
);
return
page
;
return
page
;
});
return
routeSettings
;
}
}
//Register a default page builder.
//Register a default page builder.
...
...
lib/flutter_boost.dart
View file @
6db19519
...
@@ -26,6 +26,7 @@ import 'dart:io';
...
@@ -26,6 +26,7 @@ import 'dart:io';
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'container/boost_container.dart'
;
import
'container/boost_container.dart'
;
import
'container/container_coordinator.dart'
;
import
'container/container_manager.dart'
;
import
'container/container_manager.dart'
;
import
'channel/boost_channel.dart'
;
import
'channel/boost_channel.dart'
;
...
@@ -34,6 +35,7 @@ import 'observers_holders.dart';
...
@@ -34,6 +35,7 @@ import 'observers_holders.dart';
export
'container/boost_container.dart'
;
export
'container/boost_container.dart'
;
export
'container/container_manager.dart'
;
export
'container/container_manager.dart'
;
export
'flutter_boost_api.dart'
;
typedef
Widget
PageBuilder
(
String
pageName
,
Map
params
,
String
uniqueId
);
typedef
Widget
PageBuilder
(
String
pageName
,
Map
params
,
String
uniqueId
);
...
@@ -121,11 +123,16 @@ class FlutterBoost {
...
@@ -121,11 +123,16 @@ class FlutterBoost {
}
}
Future
<
Map
<
dynamic
,
dynamic
>>
open
(
String
url
,
Future
<
Map
<
dynamic
,
dynamic
>>
open
(
String
url
,
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
})
{
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
})
{
Map
<
String
,
dynamic
>
properties
=
new
Map
<
String
,
dynamic
>();
Map
<
String
,
dynamic
>
properties
=
new
Map
<
String
,
dynamic
>();
properties
[
"url"
]
=
url
;
properties
[
"url"
]
=
url
;
properties
[
"urlParams"
]
=
urlParams
;
properties
[
"urlParams"
]
=
urlParams
;
properties
[
"exts"
]
=
exts
;
properties
[
"exts"
]
=
exts
;
//TODO 判断是不是需要跳Flutter,有没有前置拦截逻辑,如果都没有,就找到Navigator去把页面推进去
return
channel
.
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
'openPage'
,
properties
);
return
channel
.
invokeMethod
<
Map
<
dynamic
,
dynamic
>>(
'openPage'
,
properties
);
}
}
...
...
lib/flutter_boost_api.dart
0 → 100644
View file @
6db19519
import
'package:flutter/widgets.dart'
;
import
'container/container_coordinator.dart'
;
import
'flutter_boost.dart'
;
import
'flutter_boost.dart'
;
import
'flutter_boost.dart'
;
typedef
Route
FlutterBoostRouteBuilder
(
Widget
widget
);
class
BoostRouteSettings
{
final
String
uniqueId
;
final
String
name
;
final
Map
params
;
const
BoostRouteSettings
({
this
.
uniqueId
,
this
.
name
,
this
.
params
});
}
typedef
BoostRouteSettings
BoostRouteSettingsBuilder
(
String
url
,
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
});
class
FlutterBoostAPI
{
static
final
FlutterBoostAPI
_instance
=
FlutterBoostAPI
();
static
FlutterBoostAPI
get
singleton
=>
_instance
;
BoostRouteSettingsBuilder
routeSettingsBuilder
;
Future
<
Map
<
dynamic
,
dynamic
>>
open
(
String
url
,
{
Map
<
String
,
dynamic
>
urlParams
,
Map
<
String
,
dynamic
>
exts
,
bool
noNeedNativeContainer
,
FlutterBoostRouteBuilder
routeBuilder
})
{
if
(
noNeedNativeContainer
)
{
final
BoostRouteSettings
routeSettings
=
routeSettingsBuilder
(
url
,
urlParams:
urlParams
,
exts:
exts
);
final
Widget
page
=
ContainerCoordinator
.
singleton
.
createPage
(
routeSettings
.
name
,
routeSettings
.
params
,
routeSettings
.
uniqueId
);
final
Route
<
Map
<
dynamic
,
dynamic
>>
route
=
routeBuilder
!=
null
?
routeBuilder
(
page
)
:
PageRouteBuilder
<
Map
<
dynamic
,
dynamic
>>(
pageBuilder:
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
secondaryAnimation
,
)
=>
page
);
if
(
route
!=
null
)
{
return
FlutterBoost
.
containerManager
?.
onstageContainer
?.
push
(
route
);
}
return
Future
<
Map
<
dynamic
,
dynamic
>>.
value
(<
dynamic
,
dynamic
>{});
}
return
FlutterBoost
.
singleton
.
open
(
url
,
urlParams:
urlParams
,
exts:
exts
);
}
bool
close
<
T
extends
Object
>([
T
result
])
{
return
FlutterBoost
.
containerManager
?.
onstageContainer
?.
pop
(
result
);
}
}
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