Commit 755c0093 authored by ColdPaleLight's avatar ColdPaleLight

f2f develop

parent 5740f8d9
......@@ -94,7 +94,11 @@
pageInfo[@"params"] = [FlutterBoostPlugin sharedInstance].fParams;
pageInfo[@"uniqueId"] = [FlutterBoostPlugin sharedInstance].fPageId;
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);
}
}
......
......@@ -21,6 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import 'dart:io';
import 'package:flutter/material.dart';
import 'container_manager.dart';
import '../flutter_boost.dart';
......@@ -201,6 +203,11 @@ class BoostContainerState extends NavigatorState {
if (canPop()) {
super.pop<T>(result);
if (Platform.isIOS && multipleRouteMode && !canPop()) {
FlutterBoost.singleton.channel
.invokeMethod<dynamic>('enablePopGesture', null);
//开启native返回手势
}
} else {
if (T is Map<String, dynamic>) {
FlutterBoost.singleton
......@@ -229,6 +236,11 @@ class BoostContainerState extends NavigatorState {
.postPushRoute(name, uniqueId, params, newRoute ?? route, future);
}
if (Platform.isIOS && multipleRouteMode && canPop()) {
FlutterBoost.singleton.channel
.invokeMethod<dynamic>('disablePopGesture', null);
}
return future;
}
......
......@@ -32,6 +32,17 @@ import 'boost_container.dart';
import '../flutter_boost.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 {
static ContainerCoordinator get singleton => _instance;
......@@ -40,6 +51,7 @@ class ContainerCoordinator {
final Map<String, PageBuilder> _pageBuilders = <String, PageBuilder>{};
PageBuilder _defaultPageBuilder;
BoostRouteSettingsBuilder _routeSettingsBuilder;
ContainerCoordinator(BoostChannel channel) {
assert(_instance == null);
......@@ -94,6 +106,22 @@ class ContainerCoordinator {
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.
void registerDefaultPageBuilder(PageBuilder builder) {
_defaultPageBuilder = builder;
......
......@@ -28,6 +28,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'container/boost_container.dart';
import 'container/container_coordinator.dart';
import 'container/container_coordinator.dart';
import 'container/container_manager.dart';
import 'channel/boost_channel.dart';
......@@ -37,6 +38,7 @@ import 'observers_holders.dart';
export 'container/boost_container.dart';
export 'container/container_manager.dart';
export 'flutter_boost_api.dart';
export 'container/container_coordinator.dart' show BoostRouteSettings;
typedef Widget PageBuilder(String pageName, Map params, String uniqueId);
......@@ -48,6 +50,9 @@ typedef void PostPushRoute(String url, String uniqueId, Map params, Route route,
typedef Route FlutterBoostRouteBuilder(Widget widget);
class FlutterBoost {
static final FlutterBoost _instance = FlutterBoost();
final GlobalKey<ContainerManagerState> containerManagerKey =
......@@ -124,6 +129,11 @@ class FlutterBoost {
ContainerCoordinator.singleton.registerPageBuilders(builders);
}
///Register a route settings builder
void registerRouteSettingsBuilder(BoostRouteSettingsBuilder builder) {
ContainerCoordinator.singleton.registerRouteSettingsBuilder(builder);
}
Future<Map<dynamic, dynamic>> open(String url,
{Map<String, dynamic> urlParams,
Map<String, dynamic> exts}) {
......@@ -145,14 +155,15 @@ class FlutterBoost {
Map<String, dynamic> exts,
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(
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
? routeBuilder(page)
......
......@@ -7,13 +7,7 @@ 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});
......
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