Skip to content

Commit

Permalink
Merge pull request #277 from natura-cosmeticos/update/dialog_outlined…
Browse files Browse the repository at this point in the history
…_buttons

[DSY-2597] - Allows add outlined button at StandardDialog / Fixes warnings
  • Loading branch information
gsleonel authored Jan 19, 2022
2 parents 34986e2 + 413013c commit 5cfd768
Show file tree
Hide file tree
Showing 88 changed files with 542 additions and 293 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.natura.android.R
import com.natura.android.exceptions.MissingThemeException
import com.natura.android.resources.getColorTokenFromTheme

open class BaseAppBarTop(context: Context, attrs: AttributeSet) : AppBarLayout(context, attrs) {
class BaseAppBarTop(context: Context, attrs: AttributeSet) : AppBarLayout(context, attrs) {

private var typedArray: TypedArray

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class StandardAppBarTop(context: Context, attrs: AttributeSet) : AppBarLayout(co
return contentText
}

fun getContentImage(): Int? {
fun getContentImage(): Int {
return contentMedia
}

Expand Down
20 changes: 4 additions & 16 deletions designsystem/src/main/kotlin/com/natura/android/avatar/Avatar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.natura.android.avatar
import android.content.Context
import android.graphics.Typeface
import android.util.AttributeSet
import android.util.TypedValue
import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
Expand Down Expand Up @@ -75,9 +74,6 @@ class Avatar : AbstractComposeView {
var type: Int = RESOURCE_NOT_DEFINED
var icon: Int = RESOURCE_NOT_DEFINED
var image: Int = RESOURCE_NOT_DEFINED
set(value) {
field = value
}
var label: String = LABEL_FALLBACK_DEFAULT
var url: String = ""
var accessibilityDescription: String = ""
Expand Down Expand Up @@ -310,13 +306,13 @@ class Avatar : AbstractComposeView {
.obtainStyledAttributes(attrs, R.styleable.AvatarStyle, styleFromTheme, 0)
.apply {
backgroundColorResourceAttribute =
this.getResourceIdOrThrow(com.natura.android.R.styleable.AvatarStyle_colorBackground)
this.getResourceIdOrThrow(R.styleable.AvatarStyle_colorBackground)
fontFamilyResourceAttribute =
this.getStringOrThrow(com.natura.android.R.styleable.AvatarStyle_android_fontFamily)
this.getStringOrThrow(R.styleable.AvatarStyle_android_fontFamily)
textColorResourceAttribute =
this.getResourceIdOrThrow(com.natura.android.R.styleable.AvatarStyle_android_textColor)
this.getResourceIdOrThrow(R.styleable.AvatarStyle_android_textColor)
paddingResourceAttribute =
this.getResourceIdOrThrow(com.natura.android.R.styleable.AvatarStyle_android_padding)
this.getResourceIdOrThrow(R.styleable.AvatarStyle_android_padding)
sizeResourceAttribute =
this.getResourceIdOrThrow(R.styleable.AvatarStyle_avt_view_size)
iconSizeResourceAttribute =
Expand Down Expand Up @@ -348,14 +344,6 @@ class Avatar : AbstractComposeView {
}
}

@Composable
private fun getFontFromTheme(resource: Int): Typeface {
val typedValue = TypedValue()
context.theme.resolveAttribute(resource, typedValue, true)

return Typeface.create(typedValue.string.toString(), Typeface.NORMAL)
}

companion object {
const val STANDARD_SIZE = 0
const val SEMI_SIZE = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class Badge @JvmOverloads constructor(
* Change the number showed by badge
* When 0, badge is not visible, when bigger than 99, badge
* show 99+
* @param [number] to be showed by badge
* */
set(value) {
field = value
Expand All @@ -83,7 +82,6 @@ class Badge @JvmOverloads constructor(
get() = attrVisibility
/**
* Set badge visibility.
* @param [isVisible] as true to set badge as visible, false to not
* */
set(value) {
attrVisibility = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CheckBox : AppCompatCheckBox {
}

var state = UNCHECKED
get() = field
set(value) {
field = value
refreshDrawableState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ class DialogStandard private constructor(
val dialogStyle = when (styleButtons) {
DEFAULT -> { R.attr.dialogStandardTheme }
CONTAINED -> { R.attr.dialogWithContainedButtons }
else -> { R.attr.dialogWithTextButtons }
TEXT -> { R.attr.dialogWithTextButtons }
else -> { R.attr.dialogWithOutlinedButtons }
}

context.theme.resolveAttribute(dialogStyle, dialogThemeResource, true)
Expand All @@ -275,5 +276,6 @@ class DialogStandard private constructor(
const val DEFAULT = 0
const val CONTAINED = 1
const val TEXT = 2
const val OUTLINED = 3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ class IconButton @JvmOverloads constructor(
return colorAttribute
}

fun getSize(): Int? {
fun getSize(): Int {
return sizeAttribute
}

fun getStyle(): Int? {
fun getStyle(): Int {
return styleAttribute
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ExpandableNavigationView @JvmOverloads constructor(
defStyleAttr: Int = 0
) : NavigationView(context, attrs, defStyleAttr) {

private val navigationMenu: ExpandableListView by lazy { findViewById<ExpandableListView>(R.id.navigation_menu) }
private val navigationMenu: ExpandableListView by lazy { findViewById(R.id.navigation_menu) }
private var navigationAdapter: ExpandableNavigationAdapter? = null
private var navigationItems: List<NavigationItem>? = null
private var oldGroupPosition = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class ProgressIndicator @JvmOverloads constructor(
configureAppearance()
}

fun getSize(): Int? = sizeAttribute
fun getSize(): Int = sizeAttribute

fun getLayer(): Boolean? = layerAttribute
fun getLayer(): Boolean = layerAttribute

private fun getProgressIndicatorAttributes() {
sizeAttribute = progressIndicatorAttributesArray.getInt(R.styleable.ProgressIndicator_pgid_size, Size.MEDIUM.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Shortcut @JvmOverloads constructor(
private var iconAttribute: String? = null
private var shortcutAttributesArray: TypedArray

val labelContainer by lazy { findViewById<TextView>(R.id.shortCutLabel) }
val labelContainer: TextView by lazy { findViewById(R.id.shortCutLabel) }
private val backgroundContainer by lazy { findViewById<LinearLayout>(R.id.shortcutBackground) }
private val iconContainer by lazy { findViewById<ImageView>(R.id.shortCutIcon) }
private val notifyContainer by lazy { findViewById<Badge>(R.id.notifyContainer) }
Expand Down Expand Up @@ -68,7 +68,6 @@ class Shortcut @JvmOverloads constructor(
* Change the number showed by notification at shortcut
* When 0, notification is not visible, when bigger than 99, notification
* shows 99+
* @param [number] to be showed by notification
* */
set(value) {
field = value
Expand Down
4 changes: 2 additions & 2 deletions designsystem/src/main/kotlin/com/natura/android/tag/Tag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Tag @JvmOverloads constructor(
}

private fun configureTagBySize() {
var params = binding.tgBackground.layoutParams
val params = binding.tgBackground.layoutParams
params.height = resources.getDimension(sizeResourceAttribute).toInt()
binding.tgBackground.layoutParams = params
}
Expand All @@ -94,7 +94,7 @@ class Tag @JvmOverloads constructor(
resources.getDrawable(R.drawable.tag_background, null) as GradientDrawable
val backgroundWrap = DrawableCompat.wrap(background).mutate()

val cornerRadius: Float = 50F
val cornerRadius = 50F
when (positionAttribute) {
Position.CENTER.value -> background.cornerRadius = cornerRadius
Position.RIGHT.value ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ open class TextField @JvmOverloads constructor(
}

var required: Boolean = false
set(value) {
field = value
}

var size: Int = MEDIUMX
set(value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/dialogCustomContent"
android:orientation="vertical"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions designsystem/src/main/res/values-v23/theme_aesop_dark.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<item name="dialogAlertTheme">@style/Theme.DS.Dialog.Alert</item>
<item name="dialogWithContainedButtons">@style/Theme.DS.Dialog.ContainedButtons</item>
<item name="dialogWithTextButtons">@style/Theme.DS.Dialog.TextButtons</item>
<item name="dialogWithOutlinedButtons">@style/Theme.DS.Dialog.OutlinedButtons</item>
<item name="dialogTitleAppearance">@style/Theme.DS.Dialog.Title</item>
<item name="dialogBodyAppearance">@style/Theme.DS.Dialog.Body</item>

Expand Down
1 change: 1 addition & 0 deletions designsystem/src/main/res/values-v23/theme_aesop_light.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<item name="dialogAlertTheme">@style/Theme.DS.Dialog.Alert</item>
<item name="dialogWithContainedButtons">@style/Theme.DS.Dialog.ContainedButtons</item>
<item name="dialogWithTextButtons">@style/Theme.DS.Dialog.TextButtons</item>
<item name="dialogWithOutlinedButtons">@style/Theme.DS.Dialog.OutlinedButtons</item>
<item name="dialogTitleAppearance">@style/Theme.DS.Dialog.Title</item>
<item name="dialogBodyAppearance">@style/Theme.DS.Dialog.Body</item>

Expand Down
1 change: 1 addition & 0 deletions designsystem/src/main/res/values-v23/theme_avon_dark.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<item name="dialogAlertTheme">@style/Theme.DS.Dialog.Alert</item>
<item name="dialogWithContainedButtons">@style/Theme.DS.Dialog.ContainedButtons</item>
<item name="dialogWithTextButtons">@style/Theme.DS.Dialog.TextButtons</item>
<item name="dialogWithOutlinedButtons">@style/Theme.DS.Dialog.OutlinedButtons</item>
<item name="dialogTitleAppearance">@style/Theme.DS.Dialog.Title</item>
<item name="dialogBodyAppearance">@style/Theme.DS.Dialog.Body</item>

Expand Down
1 change: 1 addition & 0 deletions designsystem/src/main/res/values-v23/theme_avon_light.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<item name="dialogAlertTheme">@style/Theme.DS.Dialog.Alert</item>
<item name="dialogWithContainedButtons">@style/Theme.DS.Dialog.ContainedButtons</item>
<item name="dialogWithTextButtons">@style/Theme.DS.Dialog.TextButtons</item>
<item name="dialogWithOutlinedButtons">@style/Theme.DS.Dialog.OutlinedButtons</item>
<item name="dialogTitleAppearance">@style/Theme.DS.Dialog.Title</item>
<item name="dialogBodyAppearance">@style/Theme.DS.Dialog.Body</item>

Expand Down
1 change: 1 addition & 0 deletions designsystem/src/main/res/values-v23/theme_natura_dark.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<item name="dialogAlertTheme">@style/Theme.DS.Dialog.Alert</item>
<item name="dialogWithContainedButtons">@style/Theme.DS.Dialog.ContainedButtons</item>
<item name="dialogWithTextButtons">@style/Theme.DS.Dialog.TextButtons</item>
<item name="dialogWithOutlinedButtons">@style/Theme.DS.Dialog.OutlinedButtons</item>
<item name="dialogTitleAppearance">@style/Theme.DS.Dialog.Title</item>
<item name="dialogBodyAppearance">@style/Theme.DS.Dialog.Body</item>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<item name="dialogAlertTheme">@style/Theme.DS.Dialog.Alert</item>
<item name="dialogWithContainedButtons">@style/Theme.DS.Dialog.ContainedButtons</item>
<item name="dialogWithTextButtons">@style/Theme.DS.Dialog.TextButtons</item>
<item name="dialogWithOutlinedButtons">@style/Theme.DS.Dialog.OutlinedButtons</item>
<item name="dialogTitleAppearance">@style/Theme.DS.Dialog.Title</item>
<item name="dialogBodyAppearance">@style/Theme.DS.Dialog.Body</item>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<item name="dialogAlertTheme">@style/Theme.DS.Dialog.Alert</item>
<item name="dialogWithContainedButtons">@style/Theme.DS.Dialog.ContainedButtons</item>
<item name="dialogWithTextButtons">@style/Theme.DS.Dialog.TextButtons</item>
<item name="dialogWithOutlinedButtons">@style/Theme.DS.Dialog.OutlinedButtons</item>
<item name="dialogTitleAppearance">@style/Theme.DS.Dialog.Title</item>
<item name="dialogBodyAppearance">@style/Theme.DS.Dialog.Body</item>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<item name="dialogAlertTheme">@style/Theme.DS.Dialog.Alert</item>
<item name="dialogWithContainedButtons">@style/Theme.DS.Dialog.ContainedButtons</item>
<item name="dialogWithTextButtons">@style/Theme.DS.Dialog.TextButtons</item>
<item name="dialogWithOutlinedButtons">@style/Theme.DS.Dialog.OutlinedButtons</item>
<item name="dialogTitleAppearance">@style/Theme.DS.Dialog.Title</item>
<item name="dialogBodyAppearance">@style/Theme.DS.Dialog.Body</item>

Expand Down
1 change: 1 addition & 0 deletions designsystem/src/main/res/values/ds_base_attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<attr name="dialogAlertTheme" format="reference"/>
<attr name="dialogWithContainedButtons" format="reference"/>
<attr name="dialogWithTextButtons" format="reference"/>
<attr name="dialogWithOutlinedButtons" format="reference"/>
<attr name="dialogTitleAppearance" format="reference"/>
<attr name="dialogBodyAppearance" format="reference"/>

Expand Down
1 change: 1 addition & 0 deletions designsystem/src/main/res/values/ds_base_themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
<item name="dialogAlertTheme">@style/Theme.DS.Dialog.Alert</item>
<item name="dialogWithContainedButtons">@style/Theme.DS.Dialog.ContainedButtons</item>
<item name="dialogWithTextButtons">@style/Theme.DS.Dialog.TextButtons</item>
<item name="dialogWithOutlinedButtons">@style/Theme.DS.Dialog.OutlinedButtons</item>

<item name="shortcutContained">@style/Widget.DS.Shortcut.Contained</item>
<item name="shortcutOutlined">@style/Widget.DS.Shortcut.Outlined</item>
Expand Down
65 changes: 30 additions & 35 deletions designsystem/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,51 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- DIALOG STYLES -->
<style name="Theme.DS.Dialog.Standard" parent="@style/ThemeOverlay.MaterialComponents.Dialog.Alert">
<item name="buttonBarPositiveButtonStyle">@style/Theme.DS.Dialog.Standard.MainButton.V23
</item>
<item name="buttonBarNegativeButtonStyle">
@style/Theme.DS.Dialog.Standard.SecondaryButton.V23
</item>

<style name="Theme.DS.Dialog" parent="@style/ThemeOverlay.MaterialComponents.Dialog.Alert">
<item name="buttonBarStyle">@style/Theme.DS.Dialog.ButtonBarStyle</item>
<item name="android:windowBackground">@drawable/dialog_standard_background</item>
</style>

<style name="Theme.DS.Dialog.Alert" parent="@style/ThemeOverlay.MaterialComponents.Dialog.Alert">
<item name="buttonBarPositiveButtonStyle">
@style/Theme.DS.Dialog.Standard.SecondaryButton.V23
</item>
<item name="buttonBarNegativeButtonStyle">
@style/Theme.DS.Dialog.Standard.SecondaryButton.V23
</item>
<item name="buttonBarStyle">@style/Theme.DS.Dialog.ButtonBarStyle</item>
<item name="android:windowBackground">@drawable/dialog_standard_background</item>
<style name="Theme.DS.Dialog.Standard" parent="Theme.DS.Dialog">
<item name="buttonBarPositiveButtonStyle">@style/Theme.DS.Dialog.Standard.ContainedButton.V23</item>
<item name="buttonBarNegativeButtonStyle">@style/Theme.DS.Dialog.Standard.TextButton.V23</item>
</style>

<style name="Theme.DS.Dialog.ContainedButtons" parent="@style/ThemeOverlay.MaterialComponents.Dialog.Alert">
<item name="buttonBarPositiveButtonStyle">@style/Theme.DS.Dialog.Standard.MainButton.V23
</item>
<item name="buttonBarNegativeButtonStyle">@style/Theme.DS.Dialog.Standard.MainButton.V23
</item>
<item name="buttonBarStyle">@style/Theme.DS.Dialog.ButtonBarStyle</item>
<item name="android:windowBackground">@drawable/dialog_standard_background</item>
<item name="android:layout_marginBottom">?spacingTiny</item>
<item name="android:layout_marginTop">?spacingTiny</item>
<style name="Theme.DS.Dialog.Alert" parent="Theme.DS.Dialog">
<item name="buttonBarPositiveButtonStyle">@style/Theme.DS.Dialog.Standard.TextButton.V23</item>
<item name="buttonBarNegativeButtonStyle">@style/Theme.DS.Dialog.Standard.TextButton.V23</item>
</style>

<style name="Theme.DS.Dialog.TextButtons" parent="@style/ThemeOverlay.MaterialComponents.Dialog.Alert">
<item name="buttonBarPositiveButtonStyle">
@style/Theme.DS.Dialog.Standard.SecondaryButton.V23
</item>
<item name="buttonBarNegativeButtonStyle">
@style/Theme.DS.Dialog.Standard.SecondaryButton.V23
</item>
<item name="buttonBarStyle">@style/Theme.DS.Dialog.ButtonBarStyle</item>
<item name="android:windowBackground">@drawable/dialog_standard_background</item>
<style name="Theme.DS.Dialog.ContainedButtons" parent="Theme.DS.Dialog">
<item name="buttonBarPositiveButtonStyle">@style/Theme.DS.Dialog.Standard.ContainedButton.V23</item>
<item name="buttonBarNegativeButtonStyle">@style/Theme.DS.Dialog.Standard.ContainedButton.V23</item>
</style>

<style name="Theme.DS.Dialog.TextButtons" parent="Theme.DS.Dialog">
<item name="buttonBarPositiveButtonStyle">@style/Theme.DS.Dialog.Standard.TextButton.V23</item>
<item name="buttonBarNegativeButtonStyle">@style/Theme.DS.Dialog.Standard.TextButton.V23</item>
<item name="android:layout_marginBottom">?spacingTiny</item>
<item name="android:layout_marginTop">?spacingTiny</item>
</style>

<style name="Theme.DS.Dialog.OutlinedButtons" parent="Theme.DS.Dialog">
<item name="buttonBarPositiveButtonStyle">@style/Theme.DS.Dialog.Standard.OutlinedButton.V23</item>
<item name="buttonBarNegativeButtonStyle">@style/Theme.DS.Dialog.Standard.OutlinedButton.V23</item>
</style>

<style name="Theme.DS.Dialog.Title" parent="">
<item name="fontFamily">?dialogTitlePrimaryFontWeight</item>
<item name="android:textSize">?dialogTitleFontSize</item>
Expand All @@ -68,7 +56,7 @@
<item name="android:minHeight">?sizeLargeX</item>
</style>

<style name="Theme.DS.Dialog.Standard.MainButton.V23" parent="@style/Widget.MaterialComponents.Button">
<style name="Theme.DS.Dialog.Standard.ContainedButton.V23" parent="@style/Widget.MaterialComponents.Button">
<item name="android:layout_marginStart">?spacingSmall</item>
<item name="android:layout_marginEnd">?spacingMicro</item>
<item name="android:layout_gravity">center_vertical|right</item>
Expand All @@ -79,7 +67,14 @@
<item name="android:layout_marginTop">?spacingTiny</item>
</style>

<style name="Theme.DS.Dialog.Standard.SecondaryButton.V23" parent="@style/Widget.DS.Button.TextButton.V23">
<style name="Theme.DS.Dialog.Standard.TextButton.V23" parent="@style/Widget.DS.Button.TextButton.V23">
<item name="android:layout_marginStart">?spacingMicro</item>
<item name="android:layout_gravity">center_vertical|right</item>
<item name="android:layout_marginBottom">?spacingTiny</item>
<item name="android:layout_marginTop">?spacingTiny</item>
</style>

<style name="Theme.DS.Dialog.Standard.OutlinedButton.V23" parent="@style/Widget.DS.Button.Outlined.V23">
<item name="android:layout_marginStart">?spacingMicro</item>
<item name="android:layout_gravity">center_vertical|right</item>
<item name="android:layout_marginBottom">?spacingTiny</item>
Expand Down
Loading

0 comments on commit 5cfd768

Please sign in to comment.