Skip to content

Commit d2e66fc

Browse files
committed
Fix ui of account bottom sheet
1 parent 8d236a1 commit d2e66fc

File tree

7 files changed

+58
-63
lines changed

7 files changed

+58
-63
lines changed

app/src/main/java/com/infomaniak/mail/ui/main/thread/actions/ActionItemView.kt

+14-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ package com.infomaniak.mail.ui.main.thread.actions
1919

2020
import android.content.Context
2121
import android.content.res.ColorStateList
22+
import android.content.res.TypedArray
2223
import android.util.AttributeSet
2324
import android.view.LayoutInflater
2425
import android.widget.FrameLayout
2526
import androidx.annotation.ColorInt
2627
import androidx.annotation.DrawableRes
2728
import androidx.annotation.StringRes
29+
import androidx.annotation.StyleableRes
2830
import androidx.appcompat.content.res.AppCompatResources
2931
import androidx.core.view.isGone
3032
import androidx.core.view.isVisible
@@ -47,12 +49,16 @@ class ActionItemView @JvmOverloads constructor(
4749
with(binding) {
4850
button.apply {
4951
icon = getDrawable(R.styleable.ActionItemView_icon)
52+
getColorStateList(R.styleable.ActionItemView_iconColor)?.let(::setIconTint)
5053
text = getString(R.styleable.ActionItemView_text)
54+
getColorStateList(R.styleable.ActionItemView_textColor)?.let(::setTextColor)
5155

52-
getDimensionPixelSize(R.styleable.ActionItemView_padding, NOT_SET).takeIf { it != NOT_SET }?.let { padding ->
53-
iconPadding = padding
54-
setPaddingRelative(start = padding, end = padding)
55-
}
56+
val iconHorizontalPadding = getDimenOrNull(R.styleable.ActionItemView_iconPaddingHorizontal)
57+
val iconPaddingStart = iconHorizontalPadding ?: getDimenOrNull(R.styleable.ActionItemView_iconPaddingStart)
58+
val iconPaddingEnd = iconHorizontalPadding ?: getDimenOrNull(R.styleable.ActionItemView_iconPaddingEnd)
59+
60+
iconPaddingEnd?.let { iconPadding = it }
61+
setPaddingRelative(start = iconPaddingStart)
5662
}
5763

5864
divider.apply {
@@ -92,6 +98,10 @@ class ActionItemView @JvmOverloads constructor(
9298
binding.divider.isVisible = isVisible
9399
}
94100

101+
private fun TypedArray.getDimenOrNull(@StyleableRes index: Int): Int? {
102+
return getDimensionPixelSize(index, NOT_SET).takeIf { it != NOT_SET }
103+
}
104+
95105
companion object {
96106
private const val NOT_SET = -1
97107
}

app/src/main/java/com/infomaniak/mail/views/BottomSheetScaffoldingView.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import com.infomaniak.lib.core.utils.getAttributes
3131
import com.infomaniak.lib.core.utils.setMarginsRelative
3232
import com.infomaniak.mail.R
3333
import com.infomaniak.mail.databinding.ViewBottomSheetScaffoldingBinding
34-
import com.infomaniak.mail.ui.main.menuDrawer.SimpleSettingView
3534
import com.infomaniak.lib.core.R as RCore
3635

3736
class BottomSheetScaffoldingView @JvmOverloads constructor(
@@ -45,7 +44,7 @@ class BottomSheetScaffoldingView @JvmOverloads constructor(
4544
/**
4645
* We can receive 2 types of children:
4746
* - Children that come from the binding
48-
* - Children of [SimpleSettingView] that are defined in the xml
47+
* - Children of [BottomSheetScaffoldingView] that are defined in the xml
4948
*
5049
* We need to only add the second type of children to the `binding.cardView` to be able to display them
5150
*/

app/src/main/res/drawable/ic_logout.xml

+18-21
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,22 @@
2020
android:height="24dp"
2121
android:viewportWidth="24"
2222
android:viewportHeight="24">
23-
<path
24-
android:pathData="M12,12L23,12"
25-
android:strokeLineJoin="round"
26-
android:strokeWidth="1.5"
27-
android:fillColor="#00000000"
28-
android:strokeColor="#F44336"
29-
android:strokeLineCap="round"/>
30-
<path
31-
android:pathData="M19.5,15.754L23.25,12.004L19.5,8.254"
32-
android:strokeLineJoin="round"
33-
android:strokeWidth="1.5"
34-
android:fillColor="#00000000"
35-
android:strokeColor="#F44336"
36-
android:strokeLineCap="round"/>
37-
<path
38-
android:pathData="M17.287,16.286V20.571C17.303,20.933 17.176,21.286 16.933,21.554C16.689,21.822 16.35,21.982 15.988,22H4.3C3.938,21.982 3.599,21.821 3.356,21.553C3.112,21.286 2.985,20.933 3.001,20.571V3.429C2.985,3.067 3.112,2.714 3.355,2.446C3.599,2.178 3.938,2.018 4.3,2H15.988C16.35,2.018 16.689,2.178 16.933,2.446C17.176,2.714 17.303,3.067 17.287,3.429V7.714"
39-
android:strokeLineJoin="round"
40-
android:strokeWidth="1.42857"
41-
android:fillColor="#00000000"
42-
android:strokeColor="#F44336"
43-
android:strokeLineCap="round"/>
23+
<path
24+
android:pathData="M12,12L23,12"
25+
android:strokeWidth="1.5"
26+
android:strokeColor="#000000"
27+
android:strokeLineCap="round"
28+
android:strokeLineJoin="round" />
29+
<path
30+
android:pathData="M19.5,15.754L23.25,12.004L19.5,8.254"
31+
android:strokeWidth="1.5"
32+
android:strokeColor="#000000"
33+
android:strokeLineCap="round"
34+
android:strokeLineJoin="round" />
35+
<path
36+
android:pathData="M17.287,16.286V20.571C17.303,20.933 17.176,21.286 16.933,21.554C16.689,21.822 16.35,21.982 15.988,22H4.3C3.938,21.982 3.599,21.821 3.356,21.553C3.112,21.286 2.985,20.933 3.001,20.571V3.429C2.985,3.067 3.112,2.714 3.355,2.446C3.599,2.178 3.938,2.018 4.3,2H15.988C16.35,2.018 16.689,2.178 16.933,2.446C17.176,2.714 17.303,3.067 17.287,3.429V7.714"
37+
android:strokeWidth="1.42857"
38+
android:strokeColor="#000000"
39+
android:strokeLineCap="round"
40+
android:strokeLineJoin="round" />
4441
</vector>

app/src/main/res/layout/bottom_sheet_account.xml

+16-29
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,9 @@
2121
android:layout_width="match_parent"
2222
android:layout_height="match_parent"
2323
app:centerHorizontally="true"
24+
app:title="@string/titleMyAccount"
2425
tools:context=".ui.bottomSheetDialogs.AccountBottomSheetDialog">
2526

26-
<TextView
27-
android:id="@+id/title"
28-
style="@style/H2"
29-
android:layout_width="match_parent"
30-
android:layout_height="wrap_content"
31-
android:layout_margin="@dimen/marginStandardMedium"
32-
android:gravity="center"
33-
android:text="@string/titleMyAccount" />
34-
3527
<androidx.core.widget.NestedScrollView
3628
android:layout_width="match_parent"
3729
android:layout_height="match_parent">
@@ -52,37 +44,32 @@
5244
tools:itemCount="4"
5345
tools:listitem="@layout/item_switch_user_account" />
5446

55-
<com.google.android.material.divider.MaterialDivider android:layout_marginBottom="@dimen/marginStandard" style="@style/ItemDivider" />
47+
<com.google.android.material.divider.MaterialDivider
48+
style="@style/ItemDivider"
49+
android:layout_marginVertical="@dimen/marginStandardSmall" />
5650

57-
<com.google.android.material.button.MaterialButton
51+
<com.infomaniak.mail.ui.main.thread.actions.ActionItemView
5852
android:id="@+id/addAccount"
59-
style="@style/TextButtonSecondary"
6053
android:layout_width="match_parent"
6154
android:layout_height="wrap_content"
62-
android:fontFamily="@font/suisseintl_regular"
63-
android:gravity="start|center_vertical"
64-
android:layout_marginHorizontal="@dimen/marginStandardSmall"
65-
android:text="@string/buttonAddAccount"
66-
android:textColor="@color/black"
6755
app:icon="@drawable/ic_add_thin"
68-
app:iconPadding="@dimen/marginStandardMedium" />
56+
app:iconPaddingEnd="@dimen/marginStandardMedium"
57+
app:iconPaddingStart="@dimen/marginStandard"
58+
app:text="@string/buttonAddAccount"
59+
app:visibleDivider="false" />
6960

70-
<com.google.android.material.button.MaterialButton
61+
<com.infomaniak.mail.ui.main.thread.actions.ActionItemView
7162
android:id="@+id/logout"
72-
style="@style/TextButtonSecondary"
7363
android:layout_width="match_parent"
7464
android:layout_height="wrap_content"
75-
android:fontFamily="@font/suisseintl_regular"
76-
android:gravity="start|center_vertical"
77-
android:layout_marginHorizontal="@dimen/marginStandardSmall"
78-
android:text="@string/buttonAccountDisconnect"
79-
android:textColor="@color/red_light"
8065
app:icon="@drawable/ic_logout"
81-
app:iconPadding="@dimen/marginStandardMedium"
82-
app:iconTint="@color/red_light" />
66+
app:iconColor="@color/redDestructiveAction"
67+
app:iconPaddingEnd="@dimen/marginStandardMedium"
68+
app:iconPaddingStart="@dimen/marginStandard"
69+
app:text="@string/buttonAccountDisconnect"
70+
app:textColor="@color/redDestructiveAction"
71+
app:visibleDivider="false" />
8372

8473
</LinearLayout>
85-
8674
</androidx.core.widget.NestedScrollView>
87-
8875
</com.infomaniak.mail.views.BottomSheetScaffoldingView>

app/src/main/res/layout/item_switch_user_account.xml

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,15 @@
2727
android:id="@+id/accountCardview"
2828
android:layout_width="match_parent"
2929
android:layout_height="wrap_content"
30-
android:layout_marginHorizontal="@dimen/marginStandardSmall"
31-
android:layout_marginVertical="@dimen/marginStandardVerySmall"
3230
app:cardBackgroundColor="@color/backgroundColorSecondary"
33-
app:cardCornerRadius="10dp"
31+
app:cardCornerRadius="0dp"
3432
app:rippleColor="?attr/colorControlHighlight"
3533
app:strokeWidth="0dp">
3634

3735
<androidx.constraintlayout.widget.ConstraintLayout
3836
android:layout_width="match_parent"
3937
android:layout_height="wrap_content"
40-
android:paddingHorizontal="@dimen/marginStandardSmall"
38+
android:paddingHorizontal="@dimen/marginStandardMedium"
4139
android:paddingVertical="@dimen/marginStandardSmall">
4240

4341
<com.infomaniak.mail.views.AvatarView

app/src/main/res/layout/view_contact_chip_context_menu.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
android:layout_height="wrap_content"
4545
app:dividerColor="@color/popupDividerColor"
4646
app:icon="@drawable/ic_contact_action_copy"
47-
app:padding="@dimen/marginStandardMedium"
47+
app:iconPaddingHorizontal="@dimen/marginStandardMedium"
4848
app:text="Copier l'adresse mail" />
4949

5050
<com.infomaniak.mail.ui.main.thread.actions.ActionItemView
@@ -53,7 +53,7 @@
5353
android:layout_height="wrap_content"
5454
app:dividerColor="@color/popupDividerColor"
5555
app:icon="@drawable/ic_bin"
56-
app:padding="@dimen/marginStandardMedium"
56+
app:iconPaddingHorizontal="@dimen/marginStandardMedium"
5757
app:text="Supprimer" />
5858

5959
</LinearLayout>

app/src/main/res/values/attrs.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@
5757

5858
<declare-styleable name="ActionItemView">
5959
<attr name="icon" />
60-
<attr name="padding" />
60+
<attr name="iconColor" />
61+
<attr name="iconPaddingHorizontal" format="dimension" />
62+
<attr name="iconPaddingStart" format="dimension" />
63+
<attr name="iconPaddingEnd" format="dimension" />
6164
<attr name="text" />
65+
<attr name="textColor" format="color" />
6266
<attr name="visibleDivider" format="boolean" />
6367
<attr name="dividerColor" format="color" />
6468
<attr name="staffOnly" format="boolean" />

0 commit comments

Comments
 (0)