{"id":17969554,"url":"https://github.com/hackware1993/weiv","last_synced_at":"2025-04-09T15:06:21.517Z","repository":{"id":38890150,"uuid":"493227143","full_name":"hackware1993/weiV","owner":"hackware1993","description":"weiV (pronounced the same as wave), a new declarative UI development framework based on the Android View system. The core source files are only 35 KB. weiV（发音同 wave），一个基于 Android View 系统的全新声明式 UI 开发框架。核心源文件只有 35 KB。","archived":false,"fork":false,"pushed_at":"2024-12-07T07:49:00.000Z","size":734,"stargazers_count":79,"open_issues_count":5,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-09T15:06:15.199Z","etag":null,"topics":["android","declarative-ui","dynamic","hotfix"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hackware1993.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-17T11:46:25.000Z","updated_at":"2025-02-07T11:31:25.000Z","dependencies_parsed_at":"2025-01-15T17:35:26.588Z","dependency_job_id":"fc934ff2-2fd5-4870-99d7-95f2c5d432ec","html_url":"https://github.com/hackware1993/weiV","commit_stats":{"total_commits":78,"total_committers":1,"mean_commits":78.0,"dds":0.0,"last_synced_commit":"17867a038c0002e5f80ab40b4ebc6c7e8e440572"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackware1993%2FweiV","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackware1993%2FweiV/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackware1993%2FweiV/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackware1993%2FweiV/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackware1993","download_url":"https://codeload.github.com/hackware1993/weiV/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248055284,"owners_count":21040157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","declarative-ui","dynamic","hotfix"],"created_at":"2024-10-29T15:00:27.141Z","updated_at":"2025-04-09T15:06:21.494Z","avatar_url":"https://github.com/hackware1993.png","language":"Kotlin","funding_links":["https://www.paypal.com/paypalme/hackware1993"],"categories":[],"sub_categories":[],"readme":"# weiV\n\n[简体中文](https://github.com/hackware1993/weiV/blob/master/README_CN.md)\n\n**I have developed the world's fastest general purpose sorting algorithm, which is on average 3 times faster than Quicksort and up to 20 times faster**, [ChenSort](https://github.com/hackware1993/ChenSort)\n\n![wave.webp](https://github.com/hackware1993/weiV/blob/master/wave.webp?raw=true)\n\nweiV (pronounced the same as wave), a new declarative UI development framework based on the Android\nView system. The core source files are only 35 KB.\n\n[Download weiV Counter apk](https://github.com/hackware1993/weiV/blob/master/weiV_Counter.apk)\nBuilding the counter release obfuscated package took only 4 seconds and was 41 KB in size.\n![weiV_Counter_effect.webp](https://github.com/hackware1993/weiV/blob/master/weiV_Counter_effect.webp?raw=true)\n\n```kotlin\nif (\"weiV\" == \"View\".reversed()) {\n    Log.d(\n        \"weiV\",\n        \"It means Inversion of Control, you should always manipulate the UI 's description Widget directly instead of the View.\"\n    )\n}\n```\n\nIt has the following advantages:\n\n1. Declarative UI writing doubles the efficiency of native development\n2. Meets or exceeds the performance of the View system\n    1. I ported my Flutter ConstraintLayout to Android, relying on its advanced layout algorithm,\n       without introducing Intrinsic Measurement, so that the child elements in the View tree will\n       only be laid out once in any case, making arbitrary nesting does not cause performance\n       issues. Even if each level in the View tree is a mix of wrap_content and match_parent\n    2. xml will be discarded\n3. All your existing View system experience will be retained\n4. All existing UI components will be reused\n5. It is written in Kotlin but supports Java friendly\n6. At present, the initial support for real-time effective dynamization has begun. You can issue JS,\n   use JS to write page logic, and generate JSON describing the Widget tree and pass it to the\n   native, and the native uses a non-reflection method to convert it into a real Widget tree and\n   render. I might consider implementing a declarative API in JS later\n\nWhy is weiV based on the View system, but it is possible to surpass the View system in performance?\n\n1. Abandoned xml, the first frame always renders faster\n2. Enhanced ConstraintLayout solves performance problems caused by nesting, and for complex layouts,\n   non-first frame rendering may also be faster\n3. Enhanced ConstraintLayout makes the layout level more flat, and for general layout, non-first\n   frame rendering may also be faster\n4. In other cases the performance is quite close\n\n[Experience the Flutter version of the Enhanced ConstraintLayout online example](https://constraintlayout.flutterfirst.cn)\n\n**No one wants to overturn their past experience with the View system, Compose's design is too\nbad.**\n\n# Progress\n\nAt present, the definition of DSL has been completed, and it can be parsed into a Widget tree. The\nDSL style is as follows:\n\nKotlin style:\n\n```kotlin\nclass WeiVCounterKotlinActivity : WeiVActivity() {\n    private var count = 0\n    private val maxCount = 10\n    private val minCount = 0\n\n    override fun build(buildCount: Int) = WeiV {\n        Flex {\n            it.orientation = FlexDirection.VERTICAL\n\n            Button(text = \"Add count\", enable = count \u003c maxCount, onClick = {\n                setState {\n                    count++\n                }\n            })\n\n            Button(text = \"Sub count\", enable = count \u003e minCount, onClick = {\n                setState {\n                    count--\n                }\n            })\n\n            Text(text = \"count = $count\")\n        }\n    }\n}\n```\n\nJava style:\n\n```java\npublic class WeiVCounterJavaActivity extends BaseWeiVJavaActivity {\n    private int count = 0;\n    private int maxCount = 10;\n    private int minCount = 0;\n\n    @Override\n    public WeiV build(int buildCount) {\n        return WeiV(() -\u003e {\n            Flex((it) -\u003e {\n                it.wOrientation(FlexDirection.VERTICAL);\n\n                Button().wText(\"Add count\").wEnable(count \u003c maxCount).wOnClick(v -\u003e {\n                    setState(() -\u003e {\n                        count++;\n                    });\n                });\n\n                Button().wText(\"Sub count\").wEnable(count \u003e minCount).wOnClick(v -\u003e {\n                    setState(() -\u003e {\n                        count--;\n                    });\n                });\n\n                Text().wText(\"count = \" + count);\n            });\n        });\n    }\n}\n```\n\n![effect.gif](https://github.com/hackware1993/weiV/blob/master/effect.gif?raw=true)\n\n# The following functions have been implemented and are still under rapid iteration\n\n1. Scalable\n    1. Easily adapt third-party UI components to implement declarative APIs\n    2. The internal implementation can be replaced. For example, Text is rendered with TextView by\n       default. You can replace it with AppCompatTextView\n2. Provides JsContext based on WebView, which can be easily dynamic with WeiVParser, and will\n   continue to be enhanced later\n3. Friendly, full support for Java\n4. Provides XmlViewWidget that allows you to inline all existing views and implement a declarative\n   API without writing extensions\n5. Provides StatefulWidget to achieve separate management of subtree state, with it you no longer\n   need Fragment\n6. Provides WeiVView, WeiVJavaView to embed weiV anywhere\n7. ConstWidget is provided to achieve the same effect as Flutter const Widget\n\nKotlin:\n\n```kotlin\nclass WeiVCounterKotlinActivity : WeiVActivity() {\n    override fun build(buildCount: Int) = WeiV {\n        // Subtree wrapped with Const will not be updated, Lambda will only execute once\n        Const(buildCount = buildCount) {\n            Text(text = \"Widgets wrapped by Const will not be updated, count = $count\")\n        }\n    }\n}\n```\n\nJava:\n\n```java\nclass WeiVCounterJavaActivity extends WeiVJavaActivity {\n    public WeiV build(int buildCount) {\n        // Subtree wrapped with Const will not be updated, Lambda will only execute once\n        Const(buildCount, () -\u003e {\n            Text().wText(\"Widgets wrapped by Const will not be updated, count = \" + count);\n        });\n    }\n}\n```\n\n8. Provides a Hook for global Widget creation and update, which can easily achieve skinning and\n   night mode\n9. Provides a UI modular solution\n10. The core logic of the declarative architecture has been improved, the complexity of the Diff\n    algorithm is O(2n) or O(4n), and the code is extremely optimized\n\nNear-term plans:\n\n1. Porting Flutter ConstraintLayout to achieve the above performance goals and bring unprecedented\n   development efficiency and experience, ConstraintLayout provided by Compose Haven't gotten rid of\n   imperative thinking, it's really inefficient to use\n2. Rewrite common core controls such as RecyclerView and ViewPager2 to implement declarative API\n3. Wrap all system built-in common components to implement declarative API, some may be rewritten\n4. Support animation in an extremely simple way, property animation is no longer suitable under the\n   declarative system\n5. Develop layout preview, this may be a little troublesome\n6. Porting Flutter PVState to provide a more lightweight and easy-to-use state management solution\n   under a declarative UI\n7. Built-in lightweight QuickJS engine, use pure JS (abandon HTML, CSS) to develop cross-platform\n   apps, get rid of the dependence on WebView and achieve high-performance synchronous calls between\n   native and JS\n8. **Implements stateful hot reloading for Android. By developing an Android Studio plugin, when you\n   change the code, the plugin generates the JSON of the widget tree according to the latest code\n   and sends it to the App through ADB. The App restores the JSON to the real widget tree and\n   re-renders the UI. The state of the entire process application is preserved. This will further\n   improve the efficiency of Android development**\n\nIt is expected that all the code will be written, and the amount of code will be around 30,000\nlines.\n\nThe ultimate goal: the only declarative UI development framework under Java, a better declarative UI\ndevelopment framework under Kotlin than Compose.\n\nSome might say that Compose supports cross-platform, I think cross-platform you should prefer\nFlutter over Compose.\n\nFlutter should be prioritized at all times for developing UI parts. Even if there is no cross-end\nrequirement, when performance is not a problem, the efficiency it brings to you is doubled. Maybe\n80% of UI will be built with Flutter in the future. If you gave up Flutter because of nesting hell,\nnow is the time to pick it up again, because my Flutter ConstraintLayout has eliminated nesting\nhell.\n\nweiV is extensible. It will have all the commonly used widgets built in, which are wrappers for the\nsystem View. But for third-party libraries, you need to write extensions, which are extremely simple\nto write. For example, the extension for Button is as follows:\n\n```kotlin\nclass weiVButton(\n    key: Key? = null,\n    var text: String = \"\",\n    var textSize: Float = TextConst.defaultTextSize,\n    var textColor: Int = TextConst.defaultTextColor,\n    var onClick: View.OnClickListener? = null,\n    var enable: Boolean = true\n) :\n    LeafRenderWidget\u003cButton\u003e(key), IWeiVExtension {\n\n    override fun createView(context: Context): Button = Button(context)\n\n    override fun doParameter(view: Button, first: Boolean): Button {\n        if (view.text != text) {\n            view.text = text\n        }\n        if (view.currentTextColor != textColor) {\n            view.setTextColor(textColor)\n        }\n        if (view.textSize != textSize) {\n            view.textSize = textSize\n        }\n        view.setOnClickListener(onClick)\n        if (view.isEnabled != enable) {\n            view.isEnabled = enable\n        }\n        return view\n    }\n\n    @JavaOnly\n    fun wKey(key: Key? = null): weiVButton {\n        this.key = key\n        return this\n    }\n\n    @JavaOnly\n    fun wText(text: String = \"\"): weiVButton {\n        this.text = text\n        return this\n    }\n\n    @JavaOnly\n    fun wTextSize(textSize: Float = TextConst.defaultTextSize): weiVButton {\n        this.textSize = textSize\n        return this\n    }\n\n    @JavaOnly\n    fun wTextColor(textColor: Int = TextConst.defaultTextColor): weiVButton {\n        this.textColor = textColor\n        return this\n    }\n\n    @JavaOnly\n    fun wOnClick(onClick: View.OnClickListener?): weiVButton {\n        this.onClick = onClick\n        return this\n    }\n\n    @JavaOnly\n    fun wEnable(enable: Boolean = true): weiVButton {\n        this.enable = enable\n        return this\n    }\n\n    override fun toString(): String {\n        return \"weiVButton(text = $text, enable = $enable)\"\n    }\n}\n\n@KotlinOnly\nfun WeiV.Button(\n    key: Key? = null,\n    text: String = \"\",\n    textSize: Float = TextConst.defaultTextSize,\n    textColor: Int = TextConst.defaultTextColor,\n    onClick: View.OnClickListener? = null,\n    enable: Boolean = true\n) {\n    addLeafRenderWidget(\n        weiVButton(\n            key = key,\n            text = text,\n            textSize = textSize,\n            textColor = textColor,\n            onClick = onClick,\n            enable = enable\n        )\n    )\n}\n```\n\nweiV is based on the View system, so it can be embedded anywhere in the View tree. You can embed\nFlutter and Compose in weiV, or embed weiV in Compose and Flutter. It is recommended to embed weiV\non top of Compose to improve Compose performance. 😀\n\nSubscribe to my WeChat official account to get the latest news of weiV. Follow-up will also share\nsome high-quality, unique, and thoughtful Flutter and Android technical articles.\n\n![official_account.webp](https://github.com/hackware1993/weiV/blob/master/official_account.webp?raw=true)\n\n# Support me\n\nIf it helps you a lot, consider sponsoring me a cup of milk tea, or giving a star. Your support is\nthe driving force for me to continue to maintain.\n\n[Paypal](https://www.paypal.com/paypalme/hackware1993)\n\n![sponsorship.webp](https://github.com/hackware1993/weiV/blob/master/sponsorship.webp?raw=true)\n\nThanks to the following netizens for their sponsorship, let's make weiV better and better together.\n\n1. 庸人自扰 2022.06.06\n2. 杨永安 2022.07.02\n\n# Contact\n\nhackware1993@gmail.com\n\n# License\n\n```\nMIT License\n\nCopyright (c) 2022 hackware1993\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and\nassociated documentation files (the \"Software\"), to deal in the Software without restriction,\nincluding without limitation the rights to use, copy, modify, merge, publish, distribute,\nsublicense, and/or sell copies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial\nportions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT\nNOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES\nOR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackware1993%2Fweiv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackware1993%2Fweiv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackware1993%2Fweiv/lists"}