From e5ecb2c7cd4944b20a45782c5ae5279e76114d9d Mon Sep 17 00:00:00 2001 From: luisoliveirazup <59032818+luisoliveirazup@users.noreply.github.com> Date: Tue, 1 Jun 2021 09:38:19 -0300 Subject: [PATCH] refactor: remove widgetView inheritance from PageIndicator component (#1592) * remove widgetView inheritance from PageIndicator component * remove unused import * changed RegisterWidget annotation to BeagleJson --- .../zup/beagle/android/components/page/PageIndicator.kt | 7 +++---- .../data/serializer/adapter/ComponentJsonAdapterFactory.kt | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/android/beagle/src/main/java/br/com/zup/beagle/android/components/page/PageIndicator.kt b/android/beagle/src/main/java/br/com/zup/beagle/android/components/page/PageIndicator.kt index d67d3f5a7b..a4e2d7bdf8 100644 --- a/android/beagle/src/main/java/br/com/zup/beagle/android/components/page/PageIndicator.kt +++ b/android/beagle/src/main/java/br/com/zup/beagle/android/components/page/PageIndicator.kt @@ -23,8 +23,7 @@ import br.com.zup.beagle.android.utils.toAndroidColor import br.com.zup.beagle.android.view.ViewFactory import br.com.zup.beagle.android.view.custom.BeaglePageIndicatorView import br.com.zup.beagle.android.widget.RootView -import br.com.zup.beagle.android.widget.WidgetView -import br.com.zup.beagle.annotation.RegisterWidget +import br.com.zup.beagle.core.BeagleJson /** * The PageView component is a specialized container to hold pages (views) that will be displayed horizontally. @@ -34,13 +33,13 @@ import br.com.zup.beagle.annotation.RegisterWidget * @param numberOfPages Numbers of pages that will contain. * @param currentPage Integer number that identifies that selected */ -@RegisterWidget("pageIndicator") +@BeagleJson(name = "pageIndicator") class PageIndicator( val selectedColor: String, val unselectedColor: String, var numberOfPages: Int? = null, var currentPage: Bind? = null, -) : WidgetView(), PageIndicatorComponent { +) : PageIndicatorComponent { constructor( selectedColor: String, diff --git a/android/beagle/src/main/java/br/com/zup/beagle/android/data/serializer/adapter/ComponentJsonAdapterFactory.kt b/android/beagle/src/main/java/br/com/zup/beagle/android/data/serializer/adapter/ComponentJsonAdapterFactory.kt index 4f99d453ec..fe514107ee 100644 --- a/android/beagle/src/main/java/br/com/zup/beagle/android/data/serializer/adapter/ComponentJsonAdapterFactory.kt +++ b/android/beagle/src/main/java/br/com/zup/beagle/android/data/serializer/adapter/ComponentJsonAdapterFactory.kt @@ -20,6 +20,7 @@ import br.com.zup.beagle.android.components.Touchable import br.com.zup.beagle.android.components.form.FormInput import br.com.zup.beagle.android.components.form.FormSubmit import br.com.zup.beagle.android.components.form.InputWidget +import br.com.zup.beagle.android.components.page.PageIndicator import br.com.zup.beagle.android.components.page.PageIndicatorComponent import br.com.zup.beagle.android.components.page.PageView import br.com.zup.beagle.android.data.serializer.PolymorphicJsonAdapterFactory @@ -66,7 +67,8 @@ internal object ComponentJsonAdapterFactory { .withSubtype(Touchable::class.java, createNameSpaceToDefaultWidget("touchable")) .withSubtype(FormInput::class.java, createNameSpaceToDefaultWidget("formInput")) .withSubtype(FormSubmit::class.java, createNameSpaceToDefaultWidget("formSubmit")) - .withSubtype(PageView::class.java, createNameSpaceToDefaultWidget("pageView")) + .withSubtype(PageView::class.java, createNameSpaceToDefaultWidget("pageView")) + .withSubtype(PageIndicator::class.java, createNameSpaceToDefaultWidget("pageIndicator")) } private fun registerWidgets(