Skip to content

Commit

Permalink
Merge pull request #6 from alibaba/master
Browse files Browse the repository at this point in the history
merge code
  • Loading branch information
nightfallsad committed Apr 22, 2020
2 parents 832193c + 126c10c commit dc9f223
Show file tree
Hide file tree
Showing 79 changed files with 3,254 additions and 784 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
os:
- linux
sudo: false
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libstdc++6
# - fonts-droid
before_script:
- git clone https://github.com/flutter/flutter.git -b v1.12.13-hotfixes --depth 1
- ./flutter/bin/flutter doctor
script:
- ./flutter/bin/flutter test --coverage --coverage-path=lcov.info
after_success:
- bash <(curl -s https://codecov.io/bash)
cache:
directories:
- $HOME/.pub-cache

55 changes: 37 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
## 0.0.1
## 1.12.13
Supported Flutter sdk 1.12.13

* TODO: Describe initial release.
## 0.1.5
The main changes are as following:
1. The new version do the page jump (URL route) based on the inherited FlutterViewController or Activity. The jump procedure will create new instance of FlutterView, while the old version just reuse the underlying FlutterView
2. Avoiding keeping and reusing the FlutterView, there is no screenshot and complex attach&detach logical any more. As a result, memory is saved and black or white-screen issue occured in old version all are solved.
3. This version also solved the app life cycle observation issue, we recommend you to use ContainerLifeCycle observer to listen the app enter background or foreground notification instead of WidgetBinding.
4. We did some code refactoring, the main logic became more straightforward.
## 1.9.1+2

Rename the version number and start supporting androidx by default, Based on the flutter 1.9.1 - hotfixs。
fixed bugs

## 0.1.66

Fixed bugs

## 0.1.64

Fixed bugs

## 0.1.63

android:
Fixed bugs

iOS:
no change

## 0.1.61

android:
Fixed bugs

iOS:
no change

## 0.1.60

Expand All @@ -30,21 +51,19 @@ ios:
1.based on the v1.9.1+hotfixes branch of flutter
2.bugfixed

## 0.1.61

android:
Fixed bugs

iOS:
no change
## 0.1.5
The main changes are as following:
1. The new version do the page jump (URL route) based on the inherited FlutterViewController or Activity. The jump procedure will create new instance of FlutterView, while the old version just reuse the underlying FlutterView
2. Avoiding keeping and reusing the FlutterView, there is no screenshot and complex attach&detach logical any more. As a result, memory is saved and black or white-screen issue occured in old version all are solved.
3. This version also solved the app life cycle observation issue, we recommend you to use ContainerLifeCycle observer to listen the app enter background or foreground notification instead of WidgetBinding.
4. We did some code refactoring, the main logic became more straightforward.

## 0.1.63
## 0.0.1

android:
Fixed bugs
* TODO: Describe initial release.

iOS:
no change

### API changes
From the point of API changes, we did some refactoring as following:
Expand Down
67 changes: 60 additions & 7 deletions Frequently Asked Question.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 在FlutterBoost下如何管理Flutter页面的生命周期?原生的Flutter的AppLifecycleState事件会不一致,比如ViewAppear会导致app状态suspending或者paused。混合栈怎么处理?
### 1. 在FlutterBoost下如何管理Flutter页面的生命周期?原生的Flutter的AppLifecycleState事件会不一致,比如ViewAppear会导致app状态suspending或者paused。混合栈怎么处理?
回答:在混合栈下,页面事件基于以下自定义的事件:
```dart
enum ContainerLifeCycle {
Expand All @@ -12,35 +12,88 @@ enum ContainerLifeCycle {
}
```
对于页面事件重复,请参考下面的FAQ。
### 如何判断flutter的widget或者container是当前可见的?
### 2. 如何判断flutter的widget或者container是当前可见的?
回答:有个api可以判断当前页面是否可见:
```dart
bool isTopContainer = FlutterBoost.BoostContainer.of(context).onstage
```
传入你widget的context,就能判断你的widget是否是可见的
基于这个API,可以判断你的widget是否可见,从而避免接收一些重复的生命周期消息。参考这个issue:https://github.com/alibaba/flutter_boost/issues/498

### 您好,我想请教一下flutter_boost有关的问题:ABC三个都是flutter页面,从 A页面 -> B页面 -> C页面,当打开C页面时希望自动关掉B页面,当从C页面返回时直接返回A页面,可有什么方法?
### 3. 您好,我想请教一下flutter_boost有关的问题:ABC三个都是flutter页面,从 A页面 -> B页面 -> C页面,当打开C页面时希望自动关掉B页面,当从C页面返回时直接返回A页面,可有什么方法?
回答:你只需要操作Native层的UINavigationController里的vc数组就可以了。就如同平时你操作普通的UIViewController一样。因为FlutterBoost对Native层的FlutterViewController和Dart层的flutter page的生命周期管理是一致的,当FlutterViewController被销毁,其在dart层管理的flutter page也会自动被销毁。

### 在ios中voice over打开,demo在点击交互会crash
### 3.1如果我进了若干个flutter页或native页面,想实现点一个按钮直接返回到首页。如何做?
回答:同第3条,flutter页面由混合容器管理。上层实现不需要过多考虑。通过操作Native层的UINavigationController里的vc数组就可以了。清除部分或全部这个数组,就能实现你返回到什么页。底层flutter页面的资源会自动按需释放

### 4. 在ios中voice over打开,demo在点击交互会crash;
回答:无障碍模式下目前Flutter Engine有bug,已经提交issue和PR给flutter啦。请参考这个issue:https://github.com/alibaba/flutter_boost/issues/488及其分析。提交给flutter的PR见这里:https://github.com/flutter/engine/pull/14155

### 似乎官方已经提供了混合栈的功能,参考这里:https://flutter.dev/docs/development/add-to-app; FlutterBoost是否有存在的必要?
### 5. 在ios模拟器下运行最新的flutter boost会闪退
回答:如上面第4条所说的,最新的flutter engine在voice over下有bug,会导致crash。因为模拟器下flutter默认会将voice over模式打开,所以其实就是辅助模式,这回触发上面的bug:“在ios中voice over打开,demo在点击交互会crash”。
可参考Engine的代码注释:
```c++
#if TARGET_OS_SIMULATOR
// There doesn't appear to be any way to determine whether the accessibility
// inspector is enabled on the simulator. We conservatively always turn on the
// accessibility bridge in the simulator, but never assistive technology.
platformView->SetSemanticsEnabled(true);
platformView->SetAccessibilityFeatures(flags);
```
### 6. 似乎官方已经提供了混合栈的功能,参考这里:https://flutter.dev/docs/development/add-to-app; FlutterBoost是否有存在的必要?
回答:官方的解决方案仅仅是在native侧对FlutterViewController和Flutterengine进行解耦,如此可以一个FlutterEngine切换不同的FlutterViewController或者Activity进行渲染。但其并未解决Native和Flutter页面混合的问题,无法保证两侧的页面生命周期一致。即使是Flutter官方针对这个问题也是建议使用FlutterBoost。
其差别主要有:
|*|FlutterBoost1.5 |Flutter官方方案 |其他框架|
|*|FlutterBoost2.0 |Flutter官方方案 |其他框架|
|----|----|----|----|
|是否支持混合页面之间随意跳转 |Y |N |Y|
|一致的页面生命周期管理(多Flutter页面) |Y |N |?|
|是否支持页面间数据传递(回传等) |Y |N |N|
|是否支持测滑手势 |Y |Y |Y|
|是否支持跨页的hero动画 |N |Y |N|
|是否支持跨页的hero动画 |Y |Y |N|
|内存等资源占用是否可控 |Y |Y |Y|
|是否提供一致的页面route方案 |Y |Y |N|
|iOS和Android能力及接口是否一致 |Y |N |N|
|框架是否稳定,支持Flutter1.9 |Y |N |?|
|是否已经支持到View级别混合 |N |N |N|
同时FlutterBoost也提供了一次性创建混合工程的命令:flutterboot。代码参考:https://github.com/alibaba-flutter/flutter-boot
### 7. 如果我需要通过FlutterViewController再弹出一个新的但frame比较小的FlutterViewController,应该怎么实现?
回答:如果不加处理会遇到window大小变化的问题,但可以解决。具体可以参考这个issue:https://github.com/alibaba/flutter_boost/issues/435
### 8. Flutter ViewController如何设置横屏
VC设置横屏依赖于NavigationController或者rootVC。可以通过一下方式来设置:
1. dart层的SystemChrome.setPreferredOrientations函数并非直接设置转向,而是设置页面优先使用的转向(preferred)
2. app的转向控制除了info.plist的设置外,主要受UIWindow.rootViewController控制。大概过程是这样的:硬件检测到转向,就会调用UIWindow的转向函数,然后调用其rootViewController的shouldAutorotate判断是否需要自动转,然后取supportedInterfaceOrientations和info.plist中设置的交集来判断可否转
3. 对于UIViewController中的转向,也只在rootviewcontroller中才有效
举例如下,实现步骤可以这样:
1. 重写NavigationController:
```objc
-(BOOL)shouldAutorotate
{
// id currentViewController = self.topViewController;
//
//
// if ([currentViewController isKindOfClass:[FlutterViewController class]])
// return [currentViewController shouldAutorotate];
return YES;
}
-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
id currentViewController = self.topViewController;
if ([currentViewController isKindOfClass:[FlutterViewController class]]){
NSLog(@"[XDEBUG]----fvc supported:%ld\n",[currentViewController supportedInterfaceOrientations]);
return [currentViewController supportedInterfaceOrientations];
}
return UIInterfaceOrientationMaskAll;
}
```
2. 改dart层:因为SystemChrome.setPreferredOrientations的设置是全局的,但混合栈是多页面,所以在main函数中设置,后面在新建一个FlutterViewController时会被冲掉。为了解决这个问题,需要在每个dart页面的build处都加上这语句来设置每个页面能支持哪些转向类型

### 9. FlutterBoost for flutter1.12出现和surface相关的crash。可以参考这个issue:https://github.com/flutter/flutter/issues/52455
可能flutter engine的bug引起
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.com/alibaba/flutter_boost.svg?branch=master)](https://travis-ci.com/alibaba/flutter_boost) [![pub package](https://img.shields.io/pub/v/flutter_boost.svg)](https://pub.dartlang.org/packages/flutter_boost) [![codecov](https://codecov.io/gh/alibaba/flutter_boost/branch/master/graph/badge.svg)](https://codecov.io/gh/alibaba/flutter_boost)

<p align="center">
<img src="flutter_boost.png">
<b></b><br>
Expand All @@ -7,7 +9,7 @@

# Release Note

Please checkout the release note for the latest 0.1.63 to see changes [0.1.63 release note](https://github.com/alibaba/flutter_boost/releases)
Please checkout the release note for the latest 0.1.64 to see changes [0.1.64 release note](https://github.com/alibaba/flutter_boost/releases)

# FlutterBoost
A next-generation Flutter-Native hybrid solution. FlutterBoost is a Flutter plugin which enables hybrid integration of Flutter for your existing native apps with minimum efforts.The philosophy of FlutterBoost is to use Flutter as easy as using a WebView. Managing Native pages and Flutter pages at the same time is non-trivial in an existing App. FlutterBoost takes care of page resolution for you. The only thing you need to care about is the name of the page(usually could be an URL). 
Expand All @@ -20,24 +22,26 @@ You need to add Flutter to your project before moving on.The version of the flut

# boost version description

1. 0.1.50 is based on the flutter v1.5.4-hotfixes branch, android if other flutter versions or branches will compile incorrectly

2. 0.1.51--0.1.54 is a bugfix for 0.1.50


3. 0.1.60 is based on the flutter v1.9.1-hotfixes branch. Android does not support andriodx if other flutter branches will compile incorrectly

4. 0.1.61--0.1.62 is a bugfix for 0.1.60
| Flutter Boost Version | Support Flutter SDK Version | Description | Support AndroidX? |
| --------------------- | --------------------------- | ------------------------------------------------------------ | ------------------ |
| 0.1.50 | 1.5.4-hotfixes | android if other flutter versions or branches will compile incorrectly. | No |
| 0.1.51-0.1.59 | 1.5.4-hotfixes | bugfix for 0.1.50. | No |
| 0.1.60 | 1.9.1-hotfixes | Android does not support andriodx if other flutter branches will compile incorrectly. | No |
| 0.1.61-0.1.69 | 1.9.1-hotfixes | bugfix for 0.1.60. | No |
| 0.1.63 | 1.9.1-hotfixes | If other branches will compile incorrectly. Synchronize with the 0.1.60 code, and bugfix also merge to this branch. | No |
| 1.9.1+2 | 1.9.1-hotfixes | Rename the version number and start supporting androidx by default | Yes |
| 1.12.13 | 1.12.13-hotfixes | supporting androidx | Yes |


5. Statement of support for androidx

Current androidx branch is v0.1.61-androidx-hotfixes

Is based on flutter v1.9.1-hotfixes branch, if other branches will compile incorrectly

Synchronize with the 0.1.63 code, and bugfix also merge to this branch.

| Flutter Boost branch | Support Flutter SDK Version | Description | Support AndroidX? |
| --------------------- | --------------------------- | ------------------------------------------------------------ | ------------------ |
| v1.9.1-hotfixes | 1.9.1-hotfixes | for androidx | Yes |
| task/task_v1.9.1_support_hotfixes| 1.9.1-hotfixes | for support | NO |
| v1.12.13-hotfixes | 1.12.13-hotfixes | for androidx | Yes |
| task/task_v1.12.13_support_hotfixes| 1.12.13-hotfixes | for support | NO |


# Getting Started
Expand All @@ -47,19 +51,19 @@ You need to add Flutter to your project before moving on.The version of the flut

Open you pubspec.yaml and add the following line to dependencies:

support branch
androidx branch
```json
flutter_boost:
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: '0.1.63'
ref: ' 1.12.13'
```
androidx branch
support branch
```json
flutter_boost:
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: 'v0.1.61-androidx-hotfixes'
ref: 'task/task_v1.12.13_support_hotfixes'
```


Expand Down
43 changes: 21 additions & 22 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Release Note

请查看最新版本0.1.63的release note 确认变更,[0.1.63 release note](https://github.com/alibaba/flutter_boost/releases)
请查看最新版本0.1.64的release note 确认变更,[0.1.64 release note](https://github.com/alibaba/flutter_boost/releases)

# FlutterBoost

Expand All @@ -20,27 +20,28 @@
请阅读这篇文章:
<a href="Frequently Asked Question.md">FAQ</a>


# boost 版本说明

1. 0.1.50 是基于flutter v1.5.4-hotfixes 分支,android 如果其他flutter版本或者分支 会编译错误

2. 0.1.51--0.1.54 是对0.1.50的bugfix


3. 0.1.60 是基于flutter v1.9.1-hotfixes 分支,android如果其他flutter分支会编译错误,该版本不支持andriodx

4. 0.1.61-- 0.1.63 是对0.1.60 的bugfix
| Flutter Boost 版本 | 支持的 Flutter SDK 版本 | Description | 是否支持 AndroidX? |
| ----------------------- | ----------------------- | ------------------------------------------------------------ | ------------------- |
| 0.1.50 | 1.5.4-hotfixes | android 如果其他 flutter 版本或者分支会编译错误。 | No |
| 0.1.51-0.1.59 | 1.5.4-hotfixes | 0.1.50 的 bugfix。 | No |
| 0.1.60 | 1.9.1-hotfixes | android 如果其他 flutter 分支会编译错误。 | No |
| 0.1.63 | 1.9.1-hotfixes | 和 0.1.60 代码同步, bugfix 也会合入该分支,如果其他分支会编译错误。 | No |
| 0.1.61-0.1.69 | 1.9.1-hotfixes | 0.1.60 的 bugfix。 | No |
| 1.9.1+2 | 1.9.1-hotfixes | 版本号重新命名,开始默认支持androidx | Yes |
| 1.12.13 | 1.12.13 -hotfixes | 支持androidx | Yes |


5. 关于androidx 的支持声明

目前androidx 分支为 v0.1.61-androidx-hotfixes

是基于flutter v1.9.1-hotfixes 分支,如果其他分支会编译错误

和0.1.60代码同步, bugfix 也会合入该分支。

| Flutter Boost 分支 | 支持的 Flutter SDK 版本 | Description | Support AndroidX? |
| --------------------- | --------------------------- | ------------------------------------------------------------ | ------------------ |
| v1.9.1-hotfixes | 1.9.1-hotfixes | for androidx | Yes |
| task/task_v1.9.1_support_hotfixes| 1.9.1-hotfixes | for support | NO |
| v1.12.13-hotfixes | 1.12.13-hotfixes | for androidx | Yes |
| task/task_v1.12.13_support_hotfixes| 1.12.13-hotfixes | for support | NO |



Expand All @@ -50,22 +51,20 @@

打开pubspec.yaml并将以下行添加到依赖项:

support分支
androidx branch
```json

flutter_boost:
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: '0.1.63'

ref: '1.12.13'
```

androidx分支
support branch
```json
flutter_boost:
git:
url: 'https://github.com/alibaba/flutter_boost.git'
ref: 'v0.1.61-androidx-hotfixes'
ref: 'task/task_v1.12.13_support_hotfixes'

```


Expand Down

0 comments on commit dc9f223

Please sign in to comment.