Commit 755c0093 authored by ColdPaleLight's avatar ColdPaleLight

f2f develop

parent 5740f8d9
...@@ -94,7 +94,11 @@ ...@@ -94,7 +94,11 @@
pageInfo[@"params"] = [FlutterBoostPlugin sharedInstance].fParams; pageInfo[@"params"] = [FlutterBoostPlugin sharedInstance].fParams;
pageInfo[@"uniqueId"] = [FlutterBoostPlugin sharedInstance].fPageId; pageInfo[@"uniqueId"] = [FlutterBoostPlugin sharedInstance].fPageId;
if(result) result(pageInfo); if(result) result(pageInfo);
}else{ } if([@"disablePopGesture" isEqualToString:call.method]) {
[FlutterBoostPlugin sharedInstance].application.flutterViewController.navigationController.interactivePopGestureRecognizer.enabled = NO;
} if([@"enablePopGesture" isEqualToString:call.method]){
[FlutterBoostPlugin sharedInstance].application.flutterViewController.navigationController.interactivePopGestureRecognizer.enabled = YES;
} else{
result(FlutterMethodNotImplemented); result(FlutterMethodNotImplemented);
} }
} }
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'container_manager.dart'; import 'container_manager.dart';
import '../flutter_boost.dart'; import '../flutter_boost.dart';
...@@ -201,6 +203,11 @@ class BoostContainerState extends NavigatorState { ...@@ -201,6 +203,11 @@ class BoostContainerState extends NavigatorState {
if (canPop()) { if (canPop()) {
super.pop<T>(result); super.pop<T>(result);
if (Platform.isIOS && multipleRouteMode && !canPop()) {
FlutterBoost.singleton.channel
.invokeMethod<dynamic>('enablePopGesture', null);
//开启native返回手势
}
} else { } else {
if (T is Map<String, dynamic>) { if (T is Map<String, dynamic>) {
FlutterBoost.singleton FlutterBoost.singleton
...@@ -229,6 +236,11 @@ class BoostContainerState extends NavigatorState { ...@@ -229,6 +236,11 @@ class BoostContainerState extends NavigatorState {
.postPushRoute(name, uniqueId, params, newRoute ?? route, future); .postPushRoute(name, uniqueId, params, newRoute ?? route, future);
} }
if (Platform.isIOS && multipleRouteMode && canPop()) {
FlutterBoost.singleton.channel
.invokeMethod<dynamic>('disablePopGesture', null);
}
return future; return future;
} }
......
...@@ -32,6 +32,17 @@ import 'boost_container.dart'; ...@@ -32,6 +32,17 @@ import 'boost_container.dart';
import '../flutter_boost.dart'; import '../flutter_boost.dart';
import '../support/logger.dart'; import '../support/logger.dart';
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 ContainerCoordinator { class ContainerCoordinator {
static ContainerCoordinator get singleton => _instance; static ContainerCoordinator get singleton => _instance;
...@@ -40,6 +51,7 @@ class ContainerCoordinator { ...@@ -40,6 +51,7 @@ class ContainerCoordinator {
final Map<String, PageBuilder> _pageBuilders = <String, PageBuilder>{}; final Map<String, PageBuilder> _pageBuilders = <String, PageBuilder>{};
PageBuilder _defaultPageBuilder; PageBuilder _defaultPageBuilder;
BoostRouteSettingsBuilder _routeSettingsBuilder;
ContainerCoordinator(BoostChannel channel) { ContainerCoordinator(BoostChannel channel) {
assert(_instance == null); assert(_instance == null);
...@@ -94,6 +106,22 @@ class ContainerCoordinator { ...@@ -94,6 +106,22 @@ class ContainerCoordinator {
return page; return page;
} }
BoostRouteSettings createRouteSettings(String url,
{Map<String, dynamic> urlParams, Map<String, dynamic> exts}) {
if (_routeSettingsBuilder != null) {
return _routeSettingsBuilder(url, urlParams:urlParams,exts:exts);
}
return BoostRouteSettings(
uniqueId: '${url}_${DateTime.now().millisecondsSinceEpoch}',
name: url,
params: urlParams);
}
void registerRouteSettingsBuilder(BoostRouteSettingsBuilder builder) {
_routeSettingsBuilder = builder;
}
//Register a default page builder. //Register a default page builder.
void registerDefaultPageBuilder(PageBuilder builder) { void registerDefaultPageBuilder(PageBuilder builder) {
_defaultPageBuilder = builder; _defaultPageBuilder = builder;
......
...@@ -28,6 +28,7 @@ import 'package:flutter/cupertino.dart'; ...@@ -28,6 +28,7 @@ import 'package:flutter/cupertino.dart';
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_coordinator.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';
...@@ -37,6 +38,7 @@ import 'observers_holders.dart'; ...@@ -37,6 +38,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'; export 'flutter_boost_api.dart';
export 'container/container_coordinator.dart' show BoostRouteSettings;
typedef Widget PageBuilder(String pageName, Map params, String uniqueId); typedef Widget PageBuilder(String pageName, Map params, String uniqueId);
...@@ -48,6 +50,9 @@ typedef void PostPushRoute(String url, String uniqueId, Map params, Route route, ...@@ -48,6 +50,9 @@ typedef void PostPushRoute(String url, String uniqueId, Map params, Route route,
typedef Route FlutterBoostRouteBuilder(Widget widget); typedef Route FlutterBoostRouteBuilder(Widget widget);
class FlutterBoost { class FlutterBoost {
static final FlutterBoost _instance = FlutterBoost(); static final FlutterBoost _instance = FlutterBoost();
final GlobalKey<ContainerManagerState> containerManagerKey = final GlobalKey<ContainerManagerState> containerManagerKey =
...@@ -124,6 +129,11 @@ class FlutterBoost { ...@@ -124,6 +129,11 @@ class FlutterBoost {
ContainerCoordinator.singleton.registerPageBuilders(builders); ContainerCoordinator.singleton.registerPageBuilders(builders);
} }
///Register a route settings builder
void registerRouteSettingsBuilder(BoostRouteSettingsBuilder builder) {
ContainerCoordinator.singleton.registerRouteSettingsBuilder(builder);
}
Future<Map<dynamic, dynamic>> open(String url, Future<Map<dynamic, dynamic>> open(String url,
{Map<String, dynamic> urlParams, {Map<String, dynamic> urlParams,
Map<String, dynamic> exts}) { Map<String, dynamic> exts}) {
...@@ -145,14 +155,15 @@ class FlutterBoost { ...@@ -145,14 +155,15 @@ class FlutterBoost {
Map<String, dynamic> exts, Map<String, dynamic> exts,
FlutterBoostRouteBuilder routeBuilder}) { FlutterBoostRouteBuilder routeBuilder}) {
// if(!ContainerCoordinator.singleton.isFlutterPageUrl(url)){
// return open(url, urlParams: urlParams, exts: exts);
// }
String uniqueId='${url}_${DateTime.now().millisecondsSinceEpoch}'; final BoostRouteSettings routeSettings = ContainerCoordinator.singleton.createRouteSettings(url,urlParams: urlParams,exts: exts);
final Widget page = ContainerCoordinator.singleton.createPage( final Widget page = ContainerCoordinator.singleton.createPage(
url, urlParams, uniqueId); routeSettings.name, routeSettings.params, routeSettings.uniqueId);
if (page == null ) {
return open(url, urlParams: urlParams, exts: exts);
}
final Route<Map<dynamic, dynamic>> route = routeBuilder != null final Route<Map<dynamic, dynamic>> route = routeBuilder != null
? routeBuilder(page) ? routeBuilder(page)
......
...@@ -7,13 +7,7 @@ import 'flutter_boost.dart'; ...@@ -7,13 +7,7 @@ import 'flutter_boost.dart';
typedef Route FlutterBoostRouteBuilder(Widget widget); 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, typedef BoostRouteSettings BoostRouteSettingsBuilder(String url,
{Map<String, dynamic> urlParams, Map<String, dynamic> exts}); {Map<String, dynamic> urlParams, Map<String, dynamic> exts});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment