From 9fbac0fde7eb04a99b9210658cab7e8a5e65b81c Mon Sep 17 00:00:00 2001 From: Fernando Quilez Esquitino Date: Wed, 8 Nov 2023 18:07:34 +0100 Subject: [PATCH 01/13] implement callout image xml version --- .../components/CalloutsCatalogFragment.kt | 7 ++++ .../res/layout/screen_callouts_catalog.xml | 8 ++++ .../telefonica/mistica/callout/CalloutView.kt | 18 +++++++++ library/src/main/res/layout/callout_view.xml | 40 +++++++++++++------ 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/CalloutsCatalogFragment.kt b/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/CalloutsCatalogFragment.kt index a02ee88e9..810a35167 100644 --- a/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/CalloutsCatalogFragment.kt +++ b/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/CalloutsCatalogFragment.kt @@ -57,6 +57,13 @@ class CalloutsCatalogFragment : Fragment() { } else { setIcon(null) } + + if (view.findViewById(R.id.show_image_input).isChecked()) { + setImage(R.drawable.ic_callout) + } else { + setImage(null) + } + setDismissable(view.findViewById(R.id.dismiss_input).isChecked()) val inverse = view.findViewById(R.id.inverse_input).isChecked() setInverse(inverse) diff --git a/catalog/src/main/res/layout/screen_callouts_catalog.xml b/catalog/src/main/res/layout/screen_callouts_catalog.xml index 91568b9a3..6988b60fc 100644 --- a/catalog/src/main/res/layout/screen_callouts_catalog.xml +++ b/catalog/src/main/res/layout/screen_callouts_catalog.xml @@ -37,6 +37,14 @@ app:inputCheckText="Show icon" /> + + - + android:layout_marginStart="16dp"> + + + + + + @@ -109,7 +125,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent" - app:constraint_referenced_ids="callout_icon" + app:constraint_referenced_ids="callout_image_layout" app:barrierDirection="end" /> From 7c800a56777c47a6ce60f65055a26989d38ee942 Mon Sep 17 00:00:00 2001 From: Fernando Quilez Esquitino Date: Wed, 8 Nov 2023 18:33:13 +0100 Subject: [PATCH 02/13] implement callout image compose version --- .../catalog/ui/compose/components/Callouts.kt | 10 ++++++ .../mistica/compose/callout/Callout.kt | 33 ++++++++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/catalog/src/main/java/com/telefonica/mistica/catalog/ui/compose/components/Callouts.kt b/catalog/src/main/java/com/telefonica/mistica/catalog/ui/compose/components/Callouts.kt index eb7865cac..9b91a3543 100644 --- a/catalog/src/main/java/com/telefonica/mistica/catalog/ui/compose/components/Callouts.kt +++ b/catalog/src/main/java/com/telefonica/mistica/catalog/ui/compose/components/Callouts.kt @@ -56,6 +56,15 @@ fun Callouts() { Text("Show icon") } + var showImage by remember { mutableStateOf(false) } + Row( + modifier = Modifier.padding(horizontal = 16.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Checkbox(checked = showImage, onCheckedChange = { showImage = !showImage }) + Text("Show image") + } + var dismissable by remember { mutableStateOf(false) } Row( modifier = Modifier.padding(horizontal = 16.dp), @@ -133,6 +142,7 @@ fun Callouts() { description = description.takeIf { it.isNotBlank() }, buttonConfig = buttonConfig, iconRes = if (showIcon) R.drawable.ic_callout else null, + imageRes = if (showImage) R.drawable.ic_callout else null, dismissable = dismissable, inverse = inverse, onDismiss = { isShown = false }, diff --git a/library/src/main/java/com/telefonica/mistica/compose/callout/Callout.kt b/library/src/main/java/com/telefonica/mistica/compose/callout/Callout.kt index 161369a61..1066388d3 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/callout/Callout.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/callout/Callout.kt @@ -8,7 +8,9 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Text import androidx.compose.runtime.Composable @@ -31,6 +33,7 @@ fun Callout( description: String?, buttonConfig: CalloutButtonConfig, @DrawableRes iconRes: Int? = null, + @DrawableRes imageRes: Int? = null, dismissable: Boolean, onDismiss: (() -> Unit)? = null, inverse: Boolean, @@ -57,11 +60,27 @@ fun Callout( verticalAlignment = Alignment.Top, ) { iconRes?.let { + if (imageRes == null) { + Image( + modifier = Modifier + .padding(end = 16.dp) + .width(24.dp) + .height(24.dp), + painter = painterResource(id = iconRes), + contentDescription = null, + colorFilter = ColorFilter.tint(MisticaTheme.colors.neutralHigh) + ) + } + } + + imageRes?.let { Image( - modifier = Modifier.padding(end = 16.dp), - painter = painterResource(id = iconRes), - contentDescription = null, - colorFilter = ColorFilter.tint(MisticaTheme.colors.neutralHigh) + modifier = Modifier + .padding(end = 16.dp) + .width(40.dp) + .height(40.dp), + painter = painterResource(id = imageRes), + contentDescription = null ) } @@ -91,9 +110,11 @@ fun Callout( when (buttonConfig) { CalloutButtonConfig.NONE -> { /* No buttons are shown */ } + CalloutButtonConfig.PRIMARY -> { PrimaryButton(text = primaryButtonText, onClick = onPrimaryButtonClick) } + CalloutButtonConfig.PRIMARY_AND_LINK -> { PrimaryButton( text = primaryButtonText, @@ -102,9 +123,11 @@ fun Callout( ) LinkButton(text = linkText, onClick = onLinkClicked) } + CalloutButtonConfig.SECONDARY -> { SecondaryButton(text = secondaryButtonText, onClick = onSecondaryButtonClick) } + CalloutButtonConfig.PRIMARY_AND_SECONDARY -> { PrimaryButton( text = primaryButtonText, @@ -113,6 +136,7 @@ fun Callout( ) SecondaryButton(text = secondaryButtonText, onClick = onSecondaryButtonClick) } + CalloutButtonConfig.SECONDARY_AND_LINK -> { SecondaryButton( text = secondaryButtonText, @@ -121,6 +145,7 @@ fun Callout( ) LinkButton(text = linkText, onClick = onLinkClicked) } + CalloutButtonConfig.LINK -> { LinkButton(text = linkText, onClick = onLinkClicked) } From 5cf99edff419e53d0afd4e53b0387b7ca6a7fc0e Mon Sep 17 00:00:00 2001 From: Fernando Quilez Esquitino Date: Fri, 10 Nov 2023 13:36:39 +0100 Subject: [PATCH 03/13] implement callout circular image xml version --- .../components/CalloutsCatalogFragment.kt | 42 +++++++++--- .../res/layout/screen_callouts_catalog.xml | 18 ++--- .../telefonica/mistica/callout/CalloutView.kt | 68 +++++++++++++++++-- library/src/main/res/layout/callout_view.xml | 14 ++++ 4 files changed, 112 insertions(+), 30 deletions(-) diff --git a/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/CalloutsCatalogFragment.kt b/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/CalloutsCatalogFragment.kt index 810a35167..02f11729b 100644 --- a/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/CalloutsCatalogFragment.kt +++ b/catalog/src/main/java/com/telefonica/mistica/catalog/ui/classic/components/CalloutsCatalogFragment.kt @@ -40,6 +40,16 @@ class CalloutsCatalogFragment : Fragment() { ) setText(CalloutButtonsConfig.PRIMARY.name) } + with(view.findViewById(R.id.image_config_dropdown).dropDown) { + setAdapter( + DropDownInput.Adapter( + view.context, + R.layout.dropdown_menu_popup_item, + CalloutImageConfig.values().map { it.name }, + ) + ) + setText(CalloutImageConfig.ICON.name) + } view.findViewById