-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from sanyuankexie/develop2
m
- Loading branch information
Showing
2 changed files
with
32 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,37 @@ | ||
<img src="https://i.loli.net/2020/02/20/MnxSy9cOAaJQrpX.jpg" width="100%" align=”middle“/> | ||
|
||
<img src="https://s2.ax1x.com/2019/11/18/Msc64f.png" width="100%" align=”middle“/> | ||
# Flexml        | ||
|
||
# Gbox        | ||
### 0 注意 | ||
**Gbox**已经被重命名为**Flexml**!目前最新版本为**0.3.0**。 | ||
|
||
### 1 适用的业务范围 | ||
|
||
在线上,对于某些适用于要求强展示、轻交互、高可配场景,RN和WebView显得不够灵活,性能表现也不够好。 | ||
|
||
使用RN时要占据整个Activity,而且Native和Js的通信损耗不可避,WebView的情况则更加糟糕,还要lock主线程来加载webkit。这在二级、三级页面还好,在首页是绝对不能用这种掉性能的方案的。 | ||
|
||
并且对于首页feed流卡片、一级页面的活动区块来说,这些页面的逻辑本身就不强,而且往往也只是需要局部动态化,所以综合来看RN和WebView都不是最优选,我们需要**第三条路**。 | ||
### 2 优势/特性 | ||
Gbox是对**业务**以及**性能**友好的,它为了解决上述应用场景中所存在的问题而出现,在性能上更接近于原生的基础上也能够编写简单的逻辑,Gbox具有以下优势/特性: | ||
* **耗时操作异步化**。将原本View体系中的measure、layout搬到异步线程中去,解放主线程,这也是Gbox之所以高效的原因之一 | ||
* **干掉布局层级**。直接使用轻量级的Drawable进行渲染,与WebView相比有更大的性能优势 | ||
* **异步图片加载**。使用轻量级Glide作为图片加载引擎,所有图片均可以从网络加载,并且不会触发额外的布局更新 | ||
* **敏捷开发,随时上线,前后端分离**。后端下发布局+数据的json,可集成在数据接口下发,本地自主解析渲染布局 | ||
* **单容器View接入,基本无入侵性**。可用于替换现有的任意一个静态展示型的View,并支持曝光埋点、点击埋点、点击时间处理等事件 | ||
* **提供完整的开发工具链,布局开发可实时预览**。提供布局**实时预览**APP(overview)和mock工具,可通过扫码连接电脑进行实时预览调试 | ||
* **基于广泛使用的flexbox布局模型,包含丰富的可配置样式**。例如边框颜色,圆角,图片,文本等 | ||
* **强大的布局内绑定表达式,编写布局内逻辑**。绑定表达式支持数学运算,for语句,三元表达式,简单的java方法调用,使用表达式时需使用`${}`包围 | ||
* **屏幕适配**。布局使用的单位为是设备独立的pt,以设备屏幕宽度为基准,将屏幕分成360份,1pt=设备屏幕宽度/360 | ||
* **使用kotlin实现**。代码实现非常简洁,很适合阅读学习 | ||
* **对旧逻辑友好**。支持原生View嵌入Gbox | ||
### 4 快速开始 | ||
[✨ 掘金文章:Gbox完全使用指南](https://juejin.im/post/5dbaceb5f265da4cf677b8c5) | ||
### 5 从Jitpack获取 | ||
Gbox使用jitpack进行构建,在你的根项目的build.gradle中添加 | ||
``` | ||
allprojects { | ||
repositories { | ||
... | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
``` | ||
然后在模块中依赖 | ||
``` | ||
dependencies { | ||
implementation 'com.github.LukeXeon.flexbox:core:latest.release' | ||
} | ||
``` | ||
|
||
### 5 我们开源 | ||
Gbox使用kotlin开发,在Apache 2.0开源协议下发布,是一个完全基于开源软件实现的开源软件。由[@LukeXeon](https://github.com/LukeXeon)维护。 | ||
使用RN时要占据整个Activity,而且Native和Js的通信损耗不可避,WebView的情况则更加糟糕,还要lock主线程来加载webkit。这在二级、三级页面还好,在首页使用上述两种方案效率显然不行。 | ||
|
||
但是对于首页feed流卡片、一级页面的活动区块来说,这些页面的逻辑本身就不强,而且往往也只是需要局部动态化,所以综合来看RN和WebView都不是最优选,所以我们需要**第三条路**。 | ||
|
||
### 2简介 | ||
Flexml就是为了解决以上的问题而诞生的,它基于facebook的litho和google推荐的glide。 | ||
|
||
不使用传统View的框架使用Drawable直接将图像绘制在单个View之上,所以你在开发者模式中打开View层级只会看到一个View。 | ||
 | ||
|
||
Flexml不使用非硬件加速的API,你看到的所有图像都是由**硬件加速**的API支持的,特别是在圆角处理上,不开玩笑几乎无敌,不是**clipPath**,我们有抗锯齿,不是**clipOutline**,我们支持**4个角**设置**不同**的弧度,最终是使用**BitmapShader**实现了该特性。 | ||
|
||
同时Flexml会在**异步线程**提前把布局测量好,等需要显示的时候布局早已完成测量,跳过**measure**环节直接就可以绘制,弯道超车完美解决**16ms**限制导致的卡顿问题。 | ||
|
||
Flexml使用最流行的Glide作为图片加载框架,所以拥有良好的资源回收能力,当你将View滑出屏幕的时候图片就会被自动回收,图多顶多内存高点,但是不会OOM。 | ||
|
||
下面的截图,也是由Flexml绘制是直接从**playground app**中截取的,你可以在[release](https://github.com/sanyuankexie/Flexml/releases)界面找到**apk**下载安装尝试,或者直接索取该布局的源码[introduction/template.flexml](https://github.com/sanyuankexie/Flexml/blob/master/playground/src/main/assets/layout/introduction/template.flexml)。 | ||
 | ||
|
||
连你上面看到的logo都是自己画的,对应的源码在这[logo/template.flexml](https://github.com/sanyuankexie/Flexml/blob/master/playground/src/main/assets/layout/logo/template.flexml)。 | ||
|
||
### 4 提供Intellij插件 | ||
同时提供Intellij(Android Studio)插件,配合playground app可以实时在真机上调试布局,插件您可以在[release](https://github.com/sanyuankexie/Flexml/releases)界面找到。 | ||
### 5 开源 | ||
Gbox使用kotlin开发,在Apache 2.0开源协议下发布,是一个完全基于开源软件实现的开源软件。由[@LukeXeon](https://github.com/LukeXeon)维护(我不会跑路)。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
## intellij 插件 | ||
请用IDEA打开(否则跑不了不要怪我😂) | ||
请用IDEA打开(否则跑不了不要怪我😂) | ||
插件您可以在[release](https://github.com/sanyuankexie/Flexml/releases)界面找到。 |