Commit b42773fd authored by yangwu.jia's avatar yangwu.jia

Merge branch 'v1.9.1-hotfixes'

# Conflicts:
#	android/build.gradle
#	android/src/main/java/com/idlefish/flutterboost/Platform.java
#	example/android/app/build.gradle
#	ios/Classes/Boost/FlutterBoostPlugin.h
#	ios/Classes/Engine/FLBFlutterEngine.m
#	lib/flutter_boost.dart
parents 328160d1 c3cabb73
...@@ -8,7 +8,7 @@ buildscript { ...@@ -8,7 +8,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.android.tools.build:gradle:3.2.0'
} }
} }
...@@ -23,11 +23,11 @@ apply plugin: 'com.android.library' ...@@ -23,11 +23,11 @@ apply plugin: 'com.android.library'
android { android {
compileSdkVersion 28 compileSdkVersion 28
buildToolsVersion '27.0.3' buildToolsVersion '28.0.3'
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 28 targetSdkVersion 28
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
lintOptions { lintOptions {
disable 'InvalidPackage' disable 'InvalidPackage'
...@@ -35,11 +35,12 @@ android { ...@@ -35,11 +35,12 @@ android {
} }
dependencies { dependencies {
compileOnly 'com.android.support:appcompat-v7:28.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
compileOnly 'com.android.support:design:28.0.0' implementation 'com.google.android.material:material:1.0.0'
compileOnly 'com.android.support:support-v4:28.0.0' implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'android.arch.lifecycle:common-java8:1.1.1' implementation 'androidx.annotation:annotation:1.0.0'
compileOnly 'com.alibaba:fastjson:1.2.41' implementation 'androidx.lifecycle:lifecycle-common-java8:2.1.0'
implementation 'com.alibaba:fastjson:1.2.41'
} }
......
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
\ No newline at end of file
...@@ -2,7 +2,7 @@ package com.idlefish.flutterboost; ...@@ -2,7 +2,7 @@ package com.idlefish.flutterboost;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import io.flutter.Log; import io.flutter.Log;
import io.flutter.embedding.engine.plugins.FlutterPlugin; import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware; import io.flutter.embedding.engine.plugins.activity.ActivityAware;
......
...@@ -5,7 +5,7 @@ import android.app.Activity; ...@@ -5,7 +5,7 @@ import android.app.Activity;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import com.idlefish.flutterboost.interfaces.*; import com.idlefish.flutterboost.interfaces.*;
import io.flutter.embedding.android.FlutterView; import io.flutter.embedding.android.FlutterView;
import io.flutter.embedding.engine.FlutterEngine; import io.flutter.embedding.engine.FlutterEngine;
......
package com.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.support.annotation.Nullable; import android.os.Handler;
import androidx.annotation.Nullable;
import com.idlefish.flutterboost.interfaces.IContainerRecord; import com.idlefish.flutterboost.interfaces.IContainerRecord;
......
...@@ -19,6 +19,7 @@ public abstract class Platform { ...@@ -19,6 +19,7 @@ public abstract class Platform {
public abstract int whenEngineStart(); public abstract int whenEngineStart();
public abstract int whenEngineDestroy();
public abstract FlutterView.RenderMode renderMode(); public abstract FlutterView.RenderMode renderMode();
...@@ -41,6 +42,14 @@ public abstract class Platform { ...@@ -41,6 +42,14 @@ public abstract class Platform {
if(pluginsRegister!=null){ if(pluginsRegister!=null){
pluginsRegister.registerPlugins(mRegistry); pluginsRegister.registerPlugins(mRegistry);
}else{
try {
Class clz = Class.forName("io.flutter.plugins.GeneratedPluginRegistrant");
Method method = clz.getDeclaredMethod("registerWith", PluginRegistry.class);
method.invoke(null, mRegistry);
} catch (Throwable t) {
Log.i("flutterboost.platform",t.toString());
}
} }
if (lifecycleListener!= null) { if (lifecycleListener!= null) {
......
package com.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.view.KeyCharacterMap; import android.view.KeyCharacterMap;
import android.view.KeyEvent; import android.view.KeyEvent;
......
...@@ -2,8 +2,8 @@ package com.idlefish.flutterboost; ...@@ -2,8 +2,8 @@ package com.idlefish.flutterboost;
import android.content.Context; import android.content.Context;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.Surface; import android.view.Surface;
import android.view.TextureView; import android.view.TextureView;
......
...@@ -8,11 +8,11 @@ import android.content.res.Configuration; ...@@ -8,11 +8,11 @@ import android.content.res.Configuration;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Build; import android.os.Build;
import android.os.LocaleList; import android.os.LocaleList;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.support.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import android.support.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import android.support.v4.view.ViewCompat; import androidx.core.view.ViewCompat;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.KeyEvent; import android.view.KeyEvent;
......
package com.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.text.Editable; import android.text.Editable;
import android.text.InputType; import android.text.InputType;
import android.text.Selection; import android.text.Selection;
...@@ -191,8 +191,13 @@ public class XTextInputPlugin { ...@@ -191,8 +191,13 @@ public class XTextInputPlugin {
if (isInputConnectionLocked) { if (isInputConnectionLocked) {
return lastInputConnection; return lastInputConnection;
} }
lastInputConnection = platformViewsController.getPlatformViewById(inputTarget.id).onCreateInputConnection(outAttrs); View platformView = platformViewsController.getPlatformViewById(inputTarget.id);
if (platformView != null) {
lastInputConnection = platformView.onCreateInputConnection(outAttrs);
return lastInputConnection; return lastInputConnection;
} else {
return null;
}
} }
outAttrs.inputType = inputTypeFromTextInputType( outAttrs.inputType = inputTypeFromTextInputType(
......
...@@ -2,9 +2,9 @@ package com.idlefish.flutterboost.containers; ...@@ -2,9 +2,9 @@ package com.idlefish.flutterboost.containers;
import android.app.Activity; import android.app.Activity;
import android.arch.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleOwner;
import android.arch.lifecycle.LifecycleRegistry; import androidx.lifecycle.LifecycleRegistry;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
...@@ -15,8 +15,8 @@ import android.graphics.drawable.ColorDrawable; ...@@ -15,8 +15,8 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.view.*; import android.view.*;
import android.widget.*; import android.widget.*;
import com.idlefish.flutterboost.FlutterBoost; import com.idlefish.flutterboost.FlutterBoost;
......
...@@ -2,14 +2,14 @@ package com.idlefish.flutterboost.containers; ...@@ -2,14 +2,14 @@ package com.idlefish.flutterboost.containers;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.arch.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
......
package com.idlefish.flutterboost.containers; package com.idlefish.flutterboost.containers;
import android.app.Activity; import android.app.Activity;
import android.arch.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.support.v4.app.Fragment; import androidx.fragment.app.Fragment;
import android.support.v4.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
......
...@@ -6,8 +6,8 @@ import android.os.Bundle; ...@@ -6,8 +6,8 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.annotation.NonNull; import androidx.annotation.NonNull;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.widget.FrameLayout; import android.widget.FrameLayout;
......
...@@ -38,7 +38,7 @@ android { ...@@ -38,7 +38,7 @@ android {
targetSdkVersion 28 targetSdkVersion 28
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
...@@ -56,11 +56,8 @@ flutter { ...@@ -56,11 +56,8 @@ flutter {
dependencies { dependencies {
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.alibaba:fastjson:1.2.41'
} }
...@@ -6,9 +6,9 @@ import android.graphics.Color; ...@@ -6,9 +6,9 @@ import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.support.v7.app.ActionBar; import androidx.appcompat.app.ActionBar;
import android.support.v7.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
......
package com.taobao.idlefish.flutterboostexample; package com.taobao.idlefish.flutterboostexample;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.support.v7.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
......
package com.taobao.idlefish.flutterboostexample; package com.taobao.idlefish.flutterboostexample;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import android.support.v7.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
......
...@@ -5,7 +5,7 @@ buildscript { ...@@ -5,7 +5,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.android.tools.build:gradle:3.2.0'
} }
} }
......
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
\ No newline at end of file
...@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME ...@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
...@@ -30,6 +30,7 @@ class _MyAppState extends State<MyApp> { ...@@ -30,6 +30,7 @@ class _MyAppState extends State<MyApp> {
return FlutterRouteWidget(params:params); return FlutterRouteWidget(params:params);
}, },
}); });
FlutterBoost.singleton.addBoostNavigatorObserver(TestBoostNavigatorObserver());
} }
@override @override
...@@ -44,3 +45,22 @@ class _MyAppState extends State<MyApp> { ...@@ -44,3 +45,22 @@ class _MyAppState extends State<MyApp> {
String pageName, String uniqueId, Map params, Route route, Future _) { String pageName, String uniqueId, Map params, Route route, Future _) {
} }
} }
class TestBoostNavigatorObserver extends NavigatorObserver{
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
print("flutterboost#didPush");
}
void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {
print("flutterboost#didPop");
}
void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) {
print("flutterboost#didRemove");
}
void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) {
print("flutterboost#didReplace");
}
}
...@@ -155,14 +155,11 @@ class BoostContainerState extends NavigatorState { ...@@ -155,14 +155,11 @@ class BoostContainerState extends NavigatorState {
@override @override
void didUpdateWidget(Navigator oldWidget) { void didUpdateWidget(Navigator oldWidget) {
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
findContainerNavigatorObserver(oldWidget)?.removeBoostNavigatorObserver(
FlutterBoost.containerManager.navigatorObserver);
} }
@override @override
void dispose() { void dispose() {
findContainerNavigatorObserver(widget)?.removeBoostNavigatorObserver(
FlutterBoost.containerManager.navigatorObserver);
routerHistory.clear(); routerHistory.clear();
super.dispose(); super.dispose();
} }
...@@ -261,63 +258,52 @@ class ContainerElement extends StatefulElement { ...@@ -261,63 +258,52 @@ class ContainerElement extends StatefulElement {
} }
class ContainerNavigatorObserver extends NavigatorObserver { class ContainerNavigatorObserver extends NavigatorObserver {
BoostNavigatorObserver observer;
final Set<BoostNavigatorObserver> _boostObservers = static final Set<NavigatorObserver> boostObservers =
Set<BoostNavigatorObserver>(); Set<NavigatorObserver>();
ContainerNavigatorObserver(); ContainerNavigatorObserver();
factory ContainerNavigatorObserver.bindContainerManager() => factory ContainerNavigatorObserver.bindContainerManager() =>
ContainerNavigatorObserver() ContainerNavigatorObserver();
..addBoostNavigatorObserver(
FlutterBoost.containerManager.navigatorObserver);
VoidCallback addBoostNavigatorObserver(BoostNavigatorObserver observer) { VoidCallback addBoostNavigatorObserver(NavigatorObserver observer) {
_boostObservers.add(observer); boostObservers.add(observer);
return () => _boostObservers.remove(observer); return () => boostObservers.remove(observer);
} }
void removeBoostNavigatorObserver(BoostNavigatorObserver observer) { void removeBoostNavigatorObserver(NavigatorObserver observer) {
_boostObservers.remove(observer); boostObservers.remove(observer);
} }
@override @override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
for (BoostNavigatorObserver observer in _boostObservers) { for (NavigatorObserver observer in boostObservers) {
observer.didPush(route, previousRoute); observer.didPush(route, previousRoute);
} }
} }
@override @override
void didPop(Route<dynamic> route, Route<dynamic> previousRoute) { void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {
for (BoostNavigatorObserver observer in _boostObservers) { for (NavigatorObserver observer in boostObservers) {
observer.didPop(route, previousRoute); observer.didPop(route, previousRoute);
} }
} }
@override @override
void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) { void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) {
for (BoostNavigatorObserver observer in _boostObservers) { for (NavigatorObserver observer in boostObservers) {
observer.didRemove(route, previousRoute); observer.didRemove(route, previousRoute);
} }
} }
@override @override
void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) { void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) {
for (BoostNavigatorObserver observer in _boostObservers) { for (NavigatorObserver observer in boostObservers) {
observer.didReplace(newRoute: newRoute, oldRoute: oldRoute); observer.didReplace(newRoute: newRoute, oldRoute: oldRoute);
} }
} }
} }
class BoostNavigatorObserver {
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {}
void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {}
void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) {}
void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) {}
}
...@@ -62,8 +62,6 @@ class BoostContainerManager extends StatefulWidget { ...@@ -62,8 +62,6 @@ class BoostContainerManager extends StatefulWidget {
class ContainerManagerState extends State<BoostContainerManager> { class ContainerManagerState extends State<BoostContainerManager> {
final GlobalKey<OverlayState> _overlayKey = GlobalKey<OverlayState>(); final GlobalKey<OverlayState> _overlayKey = GlobalKey<OverlayState>();
final List<BoostContainer> _offstage = <BoostContainer>[]; final List<BoostContainer> _offstage = <BoostContainer>[];
final ManagerNavigatorObserver _navigatorObserver =
ManagerNavigatorObserver();
List<_ContainerOverlayEntry> _leastEntries; List<_ContainerOverlayEntry> _leastEntries;
...@@ -78,7 +76,6 @@ class ContainerManagerState extends State<BoostContainerManager> { ...@@ -78,7 +76,6 @@ class ContainerManagerState extends State<BoostContainerManager> {
bool get foreground => _foreground; bool get foreground => _foreground;
ManagerNavigatorObserver get navigatorObserver => _navigatorObserver;
//Number of containers. //Number of containers.
int get containerCounts => _offstage.length; int get containerCounts => _offstage.length;
...@@ -349,51 +346,3 @@ class _ContainerOverlayEntry extends OverlayEntry { ...@@ -349,51 +346,3 @@ class _ContainerOverlayEntry extends OverlayEntry {
} }
} }
class ManagerNavigatorObserver extends BoostNavigatorObserver {
BoostNavigatorObserver observer;
final Set<BoostNavigatorObserver> _boostObservers =
Set<BoostNavigatorObserver>();
VoidCallback addBoostNavigatorObserver(BoostNavigatorObserver observer) {
_boostObservers.add(observer);
return () => _boostObservers.remove(observer);
}
void removeBoostNavigatorObserver(BoostNavigatorObserver observer) {
_boostObservers.remove(observer);
}
@override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
Logger.log('ManagerNavigatorObserver didPush');
for (BoostNavigatorObserver observer in _boostObservers) {
observer.didPush(route, previousRoute);
}
}
@override
void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {
Logger.log('ManagerNavigatorObserver didPop');
for (BoostNavigatorObserver observer in _boostObservers) {
observer.didPop(route, previousRoute);
}
}
@override
void didRemove(Route<dynamic> route, Route<dynamic> previousRoute) {
Logger.log('ManagerNavigatorObserver didRemove');
for (BoostNavigatorObserver observer in _boostObservers) {
observer.didRemove(route, previousRoute);
}
}
@override
void didReplace({Route<dynamic> newRoute, Route<dynamic> oldRoute}) {
Logger.log('ManagerNavigatorObserver didReplace');
for (BoostNavigatorObserver observer in _boostObservers) {
observer.didReplace(newRoute: newRoute, oldRoute: oldRoute);
}
}
}
...@@ -44,6 +44,7 @@ typedef void PostPushRoute( ...@@ -44,6 +44,7 @@ typedef void PostPushRoute(
String url, String uniqueId, Map params, Route route, Future result); String url, String uniqueId, Map params, Route route, Future result);
class FlutterBoost { class FlutterBoost {
static final FlutterBoost _instance = FlutterBoost(); static final FlutterBoost _instance = FlutterBoost();
final GlobalKey<ContainerManagerState> containerManagerKey = final GlobalKey<ContainerManagerState> containerManagerKey =
GlobalKey<ContainerManagerState>(); GlobalKey<ContainerManagerState>();
...@@ -55,14 +56,23 @@ class FlutterBoost { ...@@ -55,14 +56,23 @@ class FlutterBoost {
static ContainerManagerState get containerManager => static ContainerManagerState get containerManager =>
_instance.containerManagerKey.currentState; _instance.containerManagerKey.currentState;
static void onPageStart() { static TransitionBuilder init(
WidgetsBinding.instance.addPostFrameCallback((_) { {TransitionBuilder builder,
singleton.channel.invokeMethod<Map>('pageOnStart').then((Map pageInfo) { PrePushRoute prePush,
PostPushRoute postPush}) {
if(Platform.isAndroid){
WidgetsBinding.instance.addPostFrameCallback((_){
singleton.channel.invokeMethod<Map>('pageOnStart').then((Map pageInfo){
if (pageInfo == null || pageInfo.isEmpty) return; if (pageInfo == null || pageInfo.isEmpty) return;
if (pageInfo.containsKey("name") && if (pageInfo.containsKey("name") &&
pageInfo.containsKey("params") && pageInfo.containsKey("params") &&
pageInfo.containsKey("uniqueId")) { pageInfo.containsKey("uniqueId")) {
ContainerCoordinator.singleton.nativeContainerDidShow( ContainerCoordinator.singleton.nativeContainerDidShow(
pageInfo["name"], pageInfo["params"], pageInfo["uniqueId"]); pageInfo["name"], pageInfo["params"], pageInfo["uniqueId"]);
} }
...@@ -70,22 +80,6 @@ class FlutterBoost { ...@@ -70,22 +80,6 @@ class FlutterBoost {
}); });
} }
static TransitionBuilder init(
{TransitionBuilder builder,
PrePushRoute prePush,
PostPushRoute postPush}) {
if (Platform.isAndroid) {
onPageStart();
}
assert(() {
() async {
if (Platform.isIOS) {
onPageStart();
}
}();
return true;
}());
return (BuildContext context, Widget child) { return (BuildContext context, Widget child) {
assert(child is Navigator, 'child must be Navigator, what is wrong?'); assert(child is Navigator, 'child must be Navigator, what is wrong?');
...@@ -108,7 +102,7 @@ class FlutterBoost { ...@@ -108,7 +102,7 @@ class FlutterBoost {
BoostChannel get channel => _boostChannel; BoostChannel get channel => _boostChannel;
FlutterBoost() { FlutterBoost(){
ContainerCoordinator(_boostChannel); ContainerCoordinator(_boostChannel);
} }
...@@ -122,29 +116,30 @@ class FlutterBoost { ...@@ -122,29 +116,30 @@ class FlutterBoost {
ContainerCoordinator.singleton.registerPageBuilders(builders); ContainerCoordinator.singleton.registerPageBuilders(builders);
} }
Future<Map<dynamic, dynamic>> open(String url, Future<Map<dynamic,dynamic>> open(String url,{Map<dynamic,dynamic> urlParams,Map<dynamic,dynamic> exts}){
{Map<dynamic, dynamic> urlParams, Map<dynamic, dynamic> exts}) {
Map<dynamic, dynamic> properties = new Map<dynamic, dynamic>(); Map<dynamic, dynamic> properties = new Map<dynamic, dynamic>();
properties["url"] = url; properties["url"] = url;
properties["urlParams"] = urlParams; properties["urlParams"] = urlParams;
properties["exts"] = exts; properties["exts"] = exts;
return channel.invokeMethod<Map<dynamic, dynamic>>('openPage', properties); return channel.invokeMethod<Map<dynamic,dynamic>>(
'openPage', properties);
} }
Future<bool> close(String id, Future<bool> close(String id,{Map<dynamic,dynamic> result,Map<dynamic,dynamic> exts}){
{Map<dynamic, dynamic> result, Map<dynamic, dynamic> exts}) {
assert(id != null); assert(id != null);
BoostContainerSettings settings = containerManager?.onstageSettings; BoostContainerSettings settings = containerManager?.onstageSettings;
Map<dynamic, dynamic> properties = new Map<dynamic, dynamic>(); Map<dynamic, dynamic> properties = new Map<dynamic, dynamic>();
if (exts == null) { if(exts == null){
exts = Map<dynamic, dynamic>(); exts = Map<dynamic,dynamic>();
} }
exts["params"] = settings.params; exts["params"] = settings.params;
if (!exts.containsKey("animated")) { if(!exts.containsKey("animated")){
exts["animated"] = true; exts["animated"] = true;
} }
...@@ -160,30 +155,28 @@ class FlutterBoost { ...@@ -160,30 +155,28 @@ class FlutterBoost {
return channel.invokeMethod<bool>('closePage', properties); return channel.invokeMethod<bool>('closePage', properties);
} }
Future<bool> closeCurrent( Future<bool> closeCurrent({Map<String,dynamic> result,Map<String,dynamic> exts}) {
{Map<String, dynamic> result, Map<String, dynamic> exts}) {
BoostContainerSettings settings = containerManager?.onstageSettings; BoostContainerSettings settings = containerManager?.onstageSettings;
if (exts == null) { if(exts == null){
exts = Map<String, dynamic>(); exts = Map<String,dynamic>();
} }
exts["params"] = settings.params; exts["params"] = settings.params;
if (!exts.containsKey("animated")) { if(!exts.containsKey("animated")){
exts["animated"] = true; exts["animated"] = true;
} }
return close(settings.uniqueId, result: result, exts: exts); return close(settings.uniqueId,result: result,exts: exts);
} }
Future<bool> closeByContext(BuildContext context, Future<bool> closeByContext(BuildContext context,{Map<String,dynamic> result,Map<String,dynamic> exts}) {
{Map<String, dynamic> result, Map<String, dynamic> exts}) {
BoostContainerSettings settings = containerManager?.onstageSettings; BoostContainerSettings settings = containerManager?.onstageSettings;
if (exts == null) { if(exts == null){
exts = Map<String, dynamic>(); exts = Map<String,dynamic>();
} }
exts["params"] = settings.params; exts["params"] = settings.params;
if (!exts.containsKey("animated")) { if(!exts.containsKey("animated")){
exts["animated"] = true; exts["animated"] = true;
} }
return close(settings.uniqueId, result: result, exts: exts); return close(settings.uniqueId,result: result,exts: exts);
} }
///register for Container changed callbacks ///register for Container changed callbacks
...@@ -196,6 +189,8 @@ class FlutterBoost { ...@@ -196,6 +189,8 @@ class FlutterBoost {
_observersHolder.addObserver<BoostContainerLifeCycleObserver>(observer); _observersHolder.addObserver<BoostContainerLifeCycleObserver>(observer);
///register callbacks for Navigators push & pop ///register callbacks for Navigators push & pop
VoidCallback addBoostNavigatorObserver(BoostNavigatorObserver observer) => void addBoostNavigatorObserver(NavigatorObserver observer) =>
_observersHolder.addObserver<BoostNavigatorObserver>(observer); ContainerNavigatorObserver.boostObservers.add(observer);
} }
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