File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,41 @@ Android based on the View system. It has the following advantages:
2002003 . All your existing View system experience will be retained
2012014 . All existing UI components will be reused
2022025 . It is written in Kotlin but supports Java friendly
203+ 6 . At present, the initial support for real-time effective dynamization has begun. You can issue JS,
204+ use JS to write page logic, and generate JSON describing the Widget tree and pass it to the
205+ native, and the native uses a non-reflection method to convert it into a real Widget tree and
206+ render. I might consider implementing a declarative API in JS later
207+ 7 . In the future, the same stateful hot reload as Flutter will be implemented
208+
209+ The sample code is as follows:
210+
211+ ``` kotlin
212+ class WeiVCounterKotlinActivity : WeiVActivity () {
213+ private var count = 0
214+ private val maxCount = 10
215+ private val minCount = 0
216+
217+ override fun build () = WeiV {
218+ Flex {
219+ it.orientation = FlexDirection .VERTICAL
220+
221+ Button (text = " Add count" , enable = count < maxCount, onClick = {
222+ setState {
223+ count++
224+ }
225+ })
226+
227+ Button (text = " Sub count" , enable = count > minCount, onClick = {
228+ setState {
229+ count--
230+ }
231+ })
232+
233+ Text (text = " count = $count " )
234+ }
235+ }
236+ }
237+ ```
203238
204239** No one wants to overturn their past experience with the View system, Compose's design is too
205240bad.**
Original file line number Diff line number Diff line change @@ -169,6 +169,39 @@ build 耗时有时甚至超过渲染耗时。
1691693 . 你所有的现有 View 系统的经验都将得到保留
1701704 . 所有的现有 UI 组件都将得以复用
1711715 . 它使用 Kotlin 编写,但友好的支持 Java
172+ 6 . 目前已经开始初步支持实时生效的动态化。你可以下发 JS,使用 JS 来写页面逻辑,并生成描述 Widget 树的 JSON 传递给原生,原生使用非反射的方式将其转为真正的 Widget
173+ 树并渲染。后面可能会考虑在 JS 中实现声明式 API
174+ 7 . 后续会实现跟 Flutter 一样的带状态的热重载
175+
176+ 示例代码如下:
177+
178+ ``` kotlin
179+ class WeiVCounterKotlinActivity : WeiVActivity () {
180+ private var count = 0
181+ private val maxCount = 10
182+ private val minCount = 0
183+
184+ override fun build () = WeiV {
185+ Flex {
186+ it.orientation = FlexDirection .VERTICAL
187+
188+ Button (text = " Add count" , enable = count < maxCount, onClick = {
189+ setState {
190+ count++
191+ }
192+ })
193+
194+ Button (text = " Sub count" , enable = count > minCount, onClick = {
195+ setState {
196+ count--
197+ }
198+ })
199+
200+ Text (text = " count = $count " )
201+ }
202+ }
203+ }
204+ ```
172205
173206** 没有人愿意推翻自己过去在 View 系统的经验,Compose 的设计太过糟糕。**
174207
You can’t perform that action at this time.
0 commit comments