提交 311d6caf 编写于 作者: fxy060608's avatar fxy060608

wip(uts): compiler

上级 07e826dc
{"version":3,"sources":["uni_modules/test-component/utssdk/app-android/index.vue"],"sourcesContent":["\n\n\n\n\n\nimport Animator from 'android.animation.Animator'\nimport TextUtils from 'android.text.TextUtils'\nimport View from 'android.view.View'\nimport LottieAnimationView from 'com.airbnb.lottie.LottieAnimationView'\nimport LottieDrawable from 'com.airbnb.lottie.LottieDrawable'\n\n\nclass CustomAnimListener extends Animator.AnimatorListener {\n\n comp: UTSComponent<LottieAnimationView>\n constructor(com: UTSComponent<LottieAnimationView>) {\n super();\n this.comp = com\n }\n\n override onAnimationStart(animation: Animator | null) {\n }\n\n override onAnimationEnd(animation: Animator | null, isReverse: Boolean) {\n this.comp.emit(\"bindended\")\n }\n\n override onAnimationEnd(animation: Animator | null) {\n }\n\n override onAnimationCancel(animation: Animator | null) {\n }\n\n override onAnimationRepeat(animation: Animator | null) {\n }\n}\n\n//原生提供以下属性或方法的实现 \nexport default {\n name: \"animation-view\",\n /**\n * 当播放到末尾时触发 ended 事件(自然播放结束会触发回调,循环播放结束及手动停止动画不会触发)\n */\n emits: ['bindended'],\n props: {\n /**\n * 动画资源地址,目前只支持绝对路径\n */\n \"path\": {\n type: String,\n\t\t\tdefault:\"\"\n },\n /**\n * 动画是否循环播放\n */\n \"autoplay\": {\n type: Boolean,\n\t\t\tdefault:false\n },\n /**\n * 动画是否自动播放\n */\n \"loop\": {\n type: Boolean,\n\t\t\tdefault:false\n },\n /**\n * 是否隐藏动画\n */\n \"hidden\": {\n type: Boolean,\n\t\t\tdefault:false\n },\n /**\n * 动画操作,可取值 play、pause、stop\n */\n \"action\": {\n type: String,\n\t\t\tdefault:\"stop\"\n }\n\n },\n data() {\n return {\n\n }\n },\n watch: {\n \"path\": {\n handler(newPath: string, oldPath: string) {\n\n let lottieAnimationView = this.$el\n\n if (lottieAnimationView != null && !TextUtils.isEmpty(newPath)) {\n if (newPath.startsWith(\"http://\") || newPath.startsWith(\"https://\")) {\n lottieAnimationView.setAnimationFromUrl(newPath)\n } else {\n // 默认是asset了\n lottieAnimationView.setAnimation(newPath)\n }\n }\n if (this.autoplay) {\n lottieAnimationView.playAnimation()\n }\n },\n immediate: false //创建时是否通过此方法更新属性,默认值为false \n },\n \"loop\": {\n handler(newLoop: Boolean, oldLoop: Boolean) {\n\n if (newLoop) {\n this.$el.repeatCount = Int.MAX_VALUE\n } else {\n // 不循环则设置成1次\n this.$el.repeatCount = 0\n }\n\n if (this.autoplay) {\n this.$el.playAnimation()\n }\n },\n immediate: false //创建时是否通过此方法更新属性,默认值为false \n },\n\n \"autoplay\": {\n handler(newValue: boolean, oldValue: boolean) {\n\n if (newValue) {\n this.$el.playAnimation()\n }\n },\n immediate: false //创建时是否通过此方法更新属性,默认值为false \n },\n\n \"action\": {\n handler(newAction: string, oldAction: string) {\n\n if (newAction == \"play\" || newAction == \"pause\" || newAction == \"stop\") {\n\n\n if (this.action == \"play\") {\n this.$el.playAnimation()\n } else if (this.action == \"play\") {\n this.$el.pauseAnimation()\n } else if (this.action == \"stop\") {\n this.$el.cancelAnimation()\n this.$el.clearAnimation()\n }\n\n } else {\n // 非法入参,不管\n }\n },\n immediate: false //创建时是否通过此方法更新属性,默认值为false \n },\n\n \"hidden\": {\n handler(newValue: boolean, oldValue: boolean) {\n\n if (newValue) {\n this.$el.visibility = View.GONE\n } else {\n this.$el.visibility = View.VISIBLE\n }\n },\n immediate: false //创建时是否通过此方法更新属性,默认值为false \n },\n\n },\n methods: {\n setRepeatMode(repeat: string) {\n if (\"RESTART\" == repeat) {\n this.$el.repeatMode = LottieDrawable.RESTART\n } else if (\"REVERSE\" == repeat) {\n this.$el.repeatMode = LottieDrawable.RESTART\n }\n },\n privateMethod() {\t//如何定义不对外暴露的API? 暂不支持,需在export外写 \n }\n },\n created() {\t\t\t//创建组件,替换created \n\n },\n NVBeforeLoad() {\t\t//组件将要创建,对应前端beforeMount \n //可选实现,这里可以提前做一些操作 \n },\n NVLoad(): LottieAnimationView { //创建原生View,必须定义返回值类型(Android需要明确知道View类型,需特殊校验) \n //必须实现 \n let lottieAnimationView = new LottieAnimationView(getContext())\n return lottieAnimationView\n },\n NVLoaded() {\t\t\t//原生View已创建 \n //可选实现,这里可以做后续操作 \n this.$el.repeatMode = LottieDrawable.RESTART;\n this.$el.visibility = View.GONE\n this.$el.repeatCount = 0\n this.$el.addAnimatorListener(new CustomAnimListener(this))\n\n },\n NVLayouted() {\t//原生View布局完成 \n //可选实现,这里可以做布局后续操作 \n },\n NVBeforeUnload() {\t\t//原生View将释放 \n //可选实现,这里可以做释放View之前的操作 \n },\n NVUnloaded() {\t\t\t//原生View已释放 \n //可选实现,这里可以做释放View之后的操作 \n },\n unmounted() {\t//组件销毁 \n //可选实现 \n }\n}\n\n\n\n\n\n\n\n\n"],"names":[],"mappings":";;;;;;AAMA,OAAqB,0BAA4B,CAAA;AACjD,OAAsB,sBAAwB,CAAA;AAC9C,OAAiB,iBAAmB,CAAA;AACpC,OAAgC,qCAAuC,CAAA;AACvE,OAA2B,gCAAkC,CAAA;;;;;;AAG7D,WAAM,qBAA2B,SAAS,gBAAgB;IAEtD,SAAA,MAAM,aAAa,qBAAoB;IACvC,YAAY,KAAK,aAAa,oBAAoB,IAC9C,KAAK,GAD2C;QAEhD,IAAI,CAAC,IAAI,GAAG;IAChB;IAEA,aAAS,iBAAiB,WAAW,SAAe,EAAE,CACtD;IAEA,aAAS,eAAe,WAAW,SAAe,EAAE,WAAW,OAAO,EAAE;QACpE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACnB;IAEA,aAAS,eAAe,WAAW,SAAe,EAAE,CACpD;IAEA,aAAS,kBAAkB,WAAW,SAAe,EAAE,CACvD;IAEA,aAAS,kBAAkB,WAAW,SAAe,EAAE,CACvD;AACJ;iDAuJc;;2BANA,CAEV;gCACe,CAEf;2BACU,oBAAoB;QAE1B,IAAI,sBAAsB,AAAI,oBAAoB;QAClD,OAAO;IACX;4BACW;QAEP,IAAI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,WAAW,aAAa,QAAQ;gBAGpE,IAAI,IAAI,CAAC,MAAM,IAAI,QACf,IAAI,CAAC,KAAG,CAAC,aAAa;qBACnB,IAAI,IAAI,CAAC,MAAM,IAAI,QACtB,IAAI,CAAC,KAAG,CAAC,cAAc;qBACpB,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ;oBAC9B,IAAI,CAAC,KAAG,CAAC,eAAe;oBACxB,IAAI,CAAC,KAAG,CAAC,cAAc;gBAC3B;YAEJ;QAGJ;;sBAKqC,OAAO,gBAApC,UAAmB,SAAmB;YAE1C,IAAI,UACA,IAAI,CAAC,KAAG,CAAC,UAAU,GAAG,KAAK,IAAI;iBAE/B,IAAI,CAAC,KAAG,CAAC,UAAU,GAAG,KAAK,OAAO;QAE1C;;;;qCAnHM;;;;;yCAOA;;;;;qCAOA;;;;;uCAOA;;;;;uCAOA"}
\ No newline at end of file
{"version":3,"sources":["uni_modules/test-component/utssdk/app-android/index.vue"],"sourcesContent":["\n\n\n\n\n\nimport Animator from 'android.animation.Animator'\nimport TextUtils from 'android.text.TextUtils'\nimport View from 'android.view.View'\nimport LottieAnimationView from 'com.airbnb.lottie.LottieAnimationView'\nimport LottieDrawable from 'com.airbnb.lottie.LottieDrawable'\n\n\nclass CustomAnimListener extends Animator.AnimatorListener {\n\n comp: UTSComponent<LottieAnimationView>\n constructor(com: UTSComponent<LottieAnimationView>) {\n super();\n this.comp = com\n }\n\n override onAnimationStart(animation: Animator | null) {\n }\n\n override onAnimationEnd(animation: Animator | null, isReverse: Boolean) {\n this.comp.emit(\"bindended\")\n }\n\n override onAnimationEnd(animation: Animator | null) {\n }\n\n override onAnimationCancel(animation: Animator | null) {\n }\n\n override onAnimationRepeat(animation: Animator | null) {\n }\n}\n\n//原生提供以下属性或方法的实现 \nexport default {\n name: \"animation-view\",\n /**\n * 当播放到末尾时触发 ended 事件(自然播放结束会触发回调,循环播放结束及手动停止动画不会触发)\n */\n emits: ['bindended'],\n props: {\n /**\n * 动画资源地址,目前只支持绝对路径\n */\n \"path\": {\n type: String,\n\t\t\tdefault:\"\"\n },\n /**\n * 动画是否循环播放\n */\n \"autoplay\": {\n type: Boolean,\n\t\t\tdefault:false\n },\n /**\n * 动画是否自动播放\n */\n \"loop\": {\n type: Boolean,\n\t\t\tdefault:false\n },\n /**\n * 是否隐藏动画\n */\n \"hidden\": {\n type: Boolean,\n\t\t\tdefault:false\n },\n /**\n * 动画操作,可取值 play、pause、stop\n */\n \"action\": {\n type: String,\n\t\t\tdefault:\"stop\"\n }\n\n },\n data() {\n return {\n\n }\n },\n watch: {\n \"path\": {\n handler(newPath: string, oldPath: string) {\n\n let lottieAnimationView = this.$el\n\n if (lottieAnimationView != null && !TextUtils.isEmpty(newPath)) {\n if (newPath.startsWith(\"http://\") || newPath.startsWith(\"https://\")) {\n lottieAnimationView.setAnimationFromUrl(newPath)\n } else {\n // 默认是asset了\n lottieAnimationView.setAnimation(newPath)\n }\n }\n if (this.autoplay) {\n lottieAnimationView.playAnimation()\n }\n },\n immediate: false //创建时是否通过此方法更新属性,默认值为false \n },\n \"loop\": {\n handler(newLoop: Boolean, oldLoop: Boolean) {\n\n if (newLoop) {\n this.$el.repeatCount = Int.MAX_VALUE\n } else {\n // 不循环则设置成1次\n this.$el.repeatCount = 0\n }\n\n if (this.autoplay) {\n this.$el.playAnimation()\n }\n },\n immediate: false //创建时是否通过此方法更新属性,默认值为false \n },\n\n \"autoplay\": {\n handler(newValue: boolean, oldValue: boolean) {\n\n if (newValue) {\n this.$el.playAnimation()\n }\n },\n immediate: false //创建时是否通过此方法更新属性,默认值为false \n },\n\n \"action\": {\n handler(newAction: string, oldAction: string) {\n\n if (newAction == \"play\" || newAction == \"pause\" || newAction == \"stop\") {\n\n\n if (this.action == \"play\") {\n this.$el.playAnimation()\n } else if (this.action == \"play\") {\n this.$el.pauseAnimation()\n } else if (this.action == \"stop\") {\n this.$el.cancelAnimation()\n this.$el.clearAnimation()\n }\n\n } else {\n // 非法入参,不管\n }\n },\n immediate: false //创建时是否通过此方法更新属性,默认值为false \n },\n\n \"hidden\": {\n handler(newValue: boolean, oldValue: boolean) {\n\n if (newValue) {\n this.$el.visibility = View.GONE\n } else {\n this.$el.visibility = View.VISIBLE\n }\n },\n immediate: false //创建时是否通过此方法更新属性,默认值为false \n },\n\n },\n methods: {\n setRepeatMode(repeat: string) {\n if (\"RESTART\" == repeat) {\n this.$el.repeatMode = LottieDrawable.RESTART\n } else if (\"REVERSE\" == repeat) {\n this.$el.repeatMode = LottieDrawable.RESTART\n }\n },\n privateMethod() {\t//如何定义不对外暴露的API? 暂不支持,需在export外写 \n }\n },\n created() {\t\t\t//创建组件,替换created \n\n },\n NVBeforeLoad() {\t\t//组件将要创建,对应前端beforeMount \n //可选实现,这里可以提前做一些操作 \n },\n NVLoad(): LottieAnimationView { //创建原生View,必须定义返回值类型(Android需要明确知道View类型,需特殊校验) \n //必须实现 \n let lottieAnimationView = new LottieAnimationView(getContext())\n return lottieAnimationView\n },\n NVLoaded() {\t\t\t//原生View已创建 \n //可选实现,这里可以做后续操作 \n this.$el.repeatMode = LottieDrawable.RESTART;\n this.$el.visibility = View.GONE\n this.$el.repeatCount = 0\n this.$el.addAnimatorListener(new CustomAnimListener(this))\n\n },\n NVLayouted() {\t//原生View布局完成 \n //可选实现,这里可以做布局后续操作 \n },\n NVBeforeUnload() {\t\t//原生View将释放 \n //可选实现,这里可以做释放View之前的操作 \n },\n NVUnloaded() {\t\t\t//原生View已释放 \n //可选实现,这里可以做释放View之后的操作 \n },\n unmounted() {\t//组件销毁 \n //可选实现 \n }\n}\n\n\n\n\n\n\n\n\n"],"names":[],"mappings":";;;;;;AAMA,OAAqB,0BAA4B,CAAA;AACjD,OAAsB,sBAAwB,CAAA;AAC9C,OAAiB,iBAAmB,CAAA;AACpC,OAAgC,qCAAuC,CAAA;AACvE,OAA2B,gCAAkC,CAAA;;;;;;AAG7D,WAAM,qBAA2B,SAAS,gBAAgB;IAEtD,SAAA,MAAM,aAAa,qBAAoB;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,oBAAoB,mBAAmB,CAAC;qBAGxC,oBAAoB,YAAY,CAAC;;YAGzC,IAAI,IAAI,CAAC,QAAQ,EACb,oBAAoB,aAAa;QAEzC;;sBAImC,qBAA3B,SAAkB,QAAkB;YAExC,IAAI,SACA,IAAI,CAAC,KAAG,CAAC,WAAW,GAAG,IAAI,SAAS;iBAGpC,IAAI,CAAC,KAAG,CAAC,WAAW,GAAG,CAAC;YAG5B,IAAI,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAG,CAAC,aAAa;QAE9B;;sBAKqC,OAAO,kBAApC,UAAmB,SAAmB;YAE1C,IAAI,UACA,IAAI,CAAC,KAAG,CAAC,aAAa;QAE9B;;sBAKsC,MAAM,gBAApC,WAAmB,UAAmB;YAE1C,IAAI,aAAa,UAAU,aAAa,WAAW,aAAa,QAAQ;gBAGpE,IAAI,IAAI,CAAC,MAAM,IAAI,QACf,IAAI,CAAC,KAAG,CAAC,aAAa;qBACnB,IAAI,IAAI,CAAC,MAAM,IAAI,QACtB,IAAI,CAAC,KAAG,CAAC,cAAc;qBACpB,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ;oBAC9B,IAAI,CAAC,KAAG,CAAC,eAAe;oBACxB,IAAI,CAAC,KAAG,CAAC,cAAc;gBAC3B;YAEJ;QAGJ;;sBAKqC,OAAO,gBAApC,UAAmB,SAAmB;YAE1C,IAAI,UACA,IAAI,CAAC,KAAG,CAAC,UAAU,GAAG,KAAK,IAAI;iBAE/B,IAAI,CAAC,KAAG,CAAC,UAAU,GAAG,KAAK,OAAO;QAE1C;;;;qCAnHM;;;;;yCAOA;;;;;qCAOA;;;;;uCAOA;;;;;uCAOA"}
\ No newline at end of file
......@@ -50,10 +50,12 @@ open class AnimationViewComponent : UTSComponent<LottieAnimationView> {
private var loop: Boolean = false;
private var hidden: Boolean = false;
private var action: String = "stop";
@JSMethod(uiThread = true)
open fun setRepeatMode(repeat: String) {
if ("RESTART" == repeat) this.`$el`.repeatMode = LottieDrawable.RESTART;
else if ("REVERSE" == repeat) this.`$el`.repeatMode = LottieDrawable.RESTART;
}
@JSMethod(uiThread = true)
open fun privateMethod() {}
override fun `$init`() {
this.`$watch`<String>("path", fun(newPath, oldPath){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册