From b39c1740cd89e7be72950ced3db8e05ccdd5efda Mon Sep 17 00:00:00 2001 From: Matheus Ribeiro Lima <57918064+matheusribeirozup@users.noreply.github.com> Date: Tue, 1 Jun 2021 12:37:59 -0300 Subject: [PATCH] fix: ListView's manager id and GridView contract (#1593) Signed-off-by: Matheus Ribeiro --- .../zup/beagle/android/components/GridView.kt | 12 +++++---- .../zup/beagle/android/components/ListView.kt | 6 ++--- .../android/components/list/ListAdapter.kt | 10 +++++--- .../ListViewTemplate.kt => utils/Template.kt} | 13 ++++++---- .../TemplateJson.kt} | 6 ++--- .../beagle/android/components/GridViewTest.kt | 5 ++-- .../components/list/ListAdapterTest.kt | 17 +++++++------ .../sample/fragment/GridViewFragment.kt | 25 +++++++++++-------- .../sample/fragment/list/ListViewFragment.kt | 2 +- .../br/com/zup/beagle/widget/ui/GridView.kt | 9 ++++--- .../br/com/zup/beagle/widget/ui/ListView.kt | 4 +-- .../ui/{ListViewTemplate.kt => Template.kt} | 10 ++++---- 12 files changed, 68 insertions(+), 51 deletions(-) rename android/beagle/src/main/java/br/com/zup/beagle/android/components/{list/ListViewTemplate.kt => utils/Template.kt} (76%) rename android/beagle/src/main/java/br/com/zup/beagle/android/components/{list/ListViewTemplateJson.kt => utils/TemplateJson.kt} (92%) rename backend/widgets/src/main/kotlin/br/com/zup/beagle/widget/ui/{ListViewTemplate.kt => Template.kt} (87%) diff --git a/android/beagle/src/main/java/br/com/zup/beagle/android/components/GridView.kt b/android/beagle/src/main/java/br/com/zup/beagle/android/components/GridView.kt index fbbb0e4eac..10b328e7e8 100644 --- a/android/beagle/src/main/java/br/com/zup/beagle/android/components/GridView.kt +++ b/android/beagle/src/main/java/br/com/zup/beagle/android/components/GridView.kt @@ -18,20 +18,22 @@ package br.com.zup.beagle.android.components import android.view.View import br.com.zup.beagle.android.action.Action +import br.com.zup.beagle.android.components.utils.Template import br.com.zup.beagle.android.context.Bind import br.com.zup.beagle.android.context.ContextComponent import br.com.zup.beagle.android.context.ContextData 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.ServerDrivenComponent import br.com.zup.beagle.widget.core.ListDirection /** * @param context define the contextData that be set to component. * @param onInit allows to define a list of actions to be performed when the Widget is displayed. * @param dataSource it's an expression that points to a list of values used to populate the Widget. - * @param template represents each cell in the list through a ServerDrivenComponent. + * @param templates Multiple templates support. The template to use will be decided according to the property `case` + * of the template. The first template where `case` is `true` is the template chosen to render an item. If for every + * template `case` is `false`, then, the first template where `case` is omitted (default template) is used. * @param onScrollEnd list of actions performed when the list is scrolled to the end. * @param scrollEndThreshold sets the scrolled percentage of the list to trigger onScrollEnd. * @param isScrollIndicatorVisible this attribute enables or disables the scroll bar. @@ -45,7 +47,7 @@ data class GridView( override val context: ContextData? = null, val onInit: List? = null, val dataSource: Bind>? = null, - val template: ServerDrivenComponent? = null, + val templates: List