Skip to content

Commit 5673b20

Browse files
committed
feat(MyKSuiteScheduled): Put the new bottomsheet in scheduled
1 parent 9c225fb commit 5673b20

File tree

7 files changed

+68
-43
lines changed

7 files changed

+68
-43
lines changed

app/src/main/java/com/infomaniak/mail/ui/bottomSheetDialogs/ScheduleSendBottomSheetDialog.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ import com.infomaniak.mail.R
3333
import com.infomaniak.mail.databinding.BottomSheetScheduleSendBinding
3434
import com.infomaniak.mail.ui.alertDialogs.SelectDateAndTimeForScheduledDraftDialog.Companion.MIN_SCHEDULE_DELAY_MINUTES
3535
import com.infomaniak.mail.ui.main.thread.actions.ActionItemView
36+
import com.infomaniak.mail.ui.main.thread.actions.ActionItemView.TrailingContent
37+
import com.infomaniak.mail.utils.MyKSuiteUiUtils.openMyKSuiteUpgradeBottomSheet
3638
import com.infomaniak.mail.utils.date.DateFormatUtils.dayOfWeekDateWithoutYear
3739
import dagger.hilt.android.AndroidEntryPoint
3840
import java.util.Date
3941
import javax.inject.Inject
4042

41-
4243
@AndroidEntryPoint
4344
class ScheduleSendBottomSheetDialog @Inject constructor() : BottomSheetDialogFragment() {
4445

@@ -87,13 +88,12 @@ class ScheduleSendBottomSheetDialog @Inject constructor() : BottomSheetDialogFra
8788
}
8889
}
8990

90-
private fun setCustomScheduleClickListener() {
91-
binding.customScheduleItem.setOnClickListener {
91+
private fun setCustomScheduleClickListener() = with(binding.customScheduleItem) {
92+
trailingContent = if (navigationArgs.isCurrentMailboxFree) TrailingContent.MyKSuiteChip else TrailingContent.Chevron
93+
94+
setOnClickListener {
9295
if (navigationArgs.isCurrentMailboxFree) {
93-
safeNavigate(
94-
resId = R.id.upgradeProductBottomSheetDialog,
95-
currentClassName = ScheduleSendBottomSheetDialog::class.java.name,
96-
)
96+
openMyKSuiteUpgradeBottomSheet(ScheduleSendBottomSheetDialog::class.java.name)
9797
} else {
9898
setBackNavigationResult(OPEN_DATE_AND_TIME_SCHEDULE_DIALOG, true)
9999
}

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

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ class ActionItemView @JvmOverloads constructor(
4444

4545
private val binding by lazy { ItemBottomSheetActionBinding.inflate(LayoutInflater.from(context), this, true) }
4646

47-
private var isInIconMode: Boolean = false
47+
var trailingContent = TrailingContent.None
48+
set(value) {
49+
field = value
50+
setTrailingContentUi(value)
51+
}
4852

4953
init {
5054
attrs?.getAttributes(context, R.styleable.ActionItemView) {
@@ -76,14 +80,6 @@ class ActionItemView @JvmOverloads constructor(
7680
}
7781

7882
if (getBoolean(R.styleable.ActionItemView_keepIconTint, false)) icon.imageTintList = null
79-
80-
isInIconMode = getBoolean(R.styleable.ActionItemView_showActionIcon, isInIconMode)
81-
if (isInIconMode) {
82-
description.isGone = true
83-
actionIcon.isVisible = true
84-
}
85-
86-
getString(R.styleable.ActionItemView_description)?.let { setDescription(it) }
8783
}
8884
}
8985
}
@@ -102,17 +98,46 @@ class ActionItemView @JvmOverloads constructor(
10298

10399
private fun setTitleColor(color: ColorStateList) = binding.title.setTextColor(color)
104100

105-
fun setDescription(text: String) = with(binding) {
106-
description.text = text
107-
if (isInIconMode) return@with
108-
actionIcon.isGone = true
109-
description.isVisible = true
101+
fun setDescription(text: String) {
102+
trailingContent = if (text.isEmpty()) TrailingContent.None else TrailingContent.Description
103+
binding.description.text = text
110104
}
111105

112106
fun setDividerVisibility(isVisible: Boolean) {
113107
binding.divider.isVisible = isVisible
114108
}
115109

110+
private fun setTrailingContentUi(trailingContent: TrailingContent) = with(binding) {
111+
trailingContentLayout.isVisible = true
112+
113+
when (trailingContent) {
114+
TrailingContent.None -> trailingContentLayout.isGone = true
115+
TrailingContent.Chevron -> {
116+
actionIcon.isVisible = true
117+
118+
myKSuitePlusChip.isGone = true
119+
description.isGone = true
120+
}
121+
TrailingContent.Description -> {
122+
description.isVisible = true
123+
124+
myKSuitePlusChip.isGone = true
125+
actionIcon.isGone = true
126+
}
127+
TrailingContent.MyKSuiteChip -> {
128+
myKSuitePlusChip.isVisible = true
129+
130+
actionIcon.isGone = true
131+
description.isGone = true
132+
}
133+
}
134+
}
135+
136+
/** Keep the entries order, it's used by the attribute (or change also the attributes order in attrs.xml) */
137+
enum class TrailingContent {
138+
None, Chevron, Description, MyKSuiteChip
139+
}
140+
116141
private fun TypedArray.getDimenOrNull(@StyleableRes index: Int): Int? {
117142
return getDimensionPixelSize(index, NOT_SET).takeIf { it != NOT_SET }
118143
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
android:layout_height="wrap_content"
5555
app:icon="@drawable/ic_pen"
5656
app:iconTint="?attr/colorPrimary"
57-
app:showActionIcon="true"
5857
app:title="@string/buttonCustomSchedule" />
5958

6059
</com.infomaniak.mail.views.BottomSheetScaffoldingView>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
tools:text="@string/restoreEmailsTitle" />
6262

6363
<FrameLayout
64+
android:id="@+id/trailingContentLayout"
6465
android:layout_width="wrap_content"
6566
android:layout_height="wrap_content"
6667
android:layout_gravity="center_vertical"
@@ -83,6 +84,13 @@
8384
android:contentDescription="@string/contentDescriptionActionIcon"
8485
android:src="@drawable/ic_chevron_right"
8586
android:visibility="gone" />
87+
88+
<com.infomaniak.core.myksuite.ui.views.MyKSuitePlusChipView
89+
android:id="@+id/myKSuitePlusChip"
90+
android:layout_width="wrap_content"
91+
android:layout_height="wrap_content"
92+
android:visibility="gone"
93+
tools:visibility="visible" />
8694
</FrameLayout>
8795
</LinearLayout>
8896

app/src/main/res/navigation/main_navigation.xml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,13 @@
683683
tools:layout="@layout/bottom_sheet_account" />
684684

685685
<dialog
686-
android:id="@+id/upgradeProductBottomSheetDialog"
687-
android:name="com.infomaniak.mail.ui.bottomSheetDialogs.UpgradeProductBottomSheetDialog"
688-
android:label="UpgradeProductBottomSheetDialog"
689-
tools:layout="@layout/bottom_sheet_upgrade_product" />
686+
android:id="@+id/myKSuiteUpgradeBottomSheet"
687+
android:name="com.infomaniak.core.myksuite.ui.views.MyKSuiteUpgradeBottomSheetDialog"
688+
android:label="MyKSuiteUpgradeBottomSheet">
689+
<argument
690+
android:name="kSuiteApp"
691+
app:argType="com.infomaniak.core.myksuite.ui.screens.KSuiteApp" />
692+
</dialog>
690693

691694
<fragment
692695
android:id="@+id/myKSuiteDashboardFragment"
@@ -702,14 +705,4 @@
702705
android:name="dailySendLimit"
703706
app:argType="string" />
704707
</fragment>
705-
706-
<dialog
707-
android:id="@+id/myKSuiteUpgradeBottomSheet"
708-
android:name="com.infomaniak.core.myksuite.ui.views.MyKSuiteUpgradeBottomSheetDialog"
709-
android:label="MyKSuiteUpgradeBottomSheet">
710-
<argument
711-
android:name="kSuiteApp"
712-
app:argType="com.infomaniak.core.myksuite.ui.screens.KSuiteApp" />
713-
</dialog>
714-
715708
</navigation>

app/src/main/res/navigation/new_message_navigation.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@
9696
</dialog>
9797

9898
<dialog
99-
android:id="@+id/upgradeProductBottomSheetDialog"
100-
android:name="com.infomaniak.mail.ui.bottomSheetDialogs.UpgradeProductBottomSheetDialog"
101-
android:label="UpgradeProductBottomSheetDialog"
102-
tools:layout="@layout/bottom_sheet_upgrade_product" />
103-
99+
android:id="@+id/myKSuiteUpgradeBottomSheet"
100+
android:name="com.infomaniak.core.myksuite.ui.views.MyKSuiteUpgradeBottomSheetDialog"
101+
android:label="MyKSuiteUpgradeBottomSheet">
102+
<argument
103+
android:name="kSuiteApp"
104+
app:argType="com.infomaniak.core.myksuite.ui.screens.KSuiteApp" />
105+
</dialog>
104106
</navigation>

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
<attr name="iconPaddingEnd" format="dimension" />
6666
<attr name="title" />
6767
<attr name="titleColor" format="color" />
68-
<attr name="description" />
69-
<attr name="showActionIcon" format="boolean" />
7068
<attr name="visibleDivider" format="boolean" />
7169
<attr name="dividerColor" format="color" />
7270
<attr name="staffOnly" format="boolean" />

0 commit comments

Comments
 (0)