Skip to content

Commit

Permalink
feat(MyKSuiteScheduled): Put the new bottomsheet in scheduled
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Feb 20, 2025
1 parent 9c225fb commit 5673b20
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ import com.infomaniak.mail.R
import com.infomaniak.mail.databinding.BottomSheetScheduleSendBinding
import com.infomaniak.mail.ui.alertDialogs.SelectDateAndTimeForScheduledDraftDialog.Companion.MIN_SCHEDULE_DELAY_MINUTES
import com.infomaniak.mail.ui.main.thread.actions.ActionItemView
import com.infomaniak.mail.ui.main.thread.actions.ActionItemView.TrailingContent
import com.infomaniak.mail.utils.MyKSuiteUiUtils.openMyKSuiteUpgradeBottomSheet
import com.infomaniak.mail.utils.date.DateFormatUtils.dayOfWeekDateWithoutYear
import dagger.hilt.android.AndroidEntryPoint
import java.util.Date
import javax.inject.Inject


@AndroidEntryPoint
class ScheduleSendBottomSheetDialog @Inject constructor() : BottomSheetDialogFragment() {

Expand Down Expand Up @@ -87,13 +88,12 @@ class ScheduleSendBottomSheetDialog @Inject constructor() : BottomSheetDialogFra
}
}

private fun setCustomScheduleClickListener() {
binding.customScheduleItem.setOnClickListener {
private fun setCustomScheduleClickListener() = with(binding.customScheduleItem) {
trailingContent = if (navigationArgs.isCurrentMailboxFree) TrailingContent.MyKSuiteChip else TrailingContent.Chevron

setOnClickListener {
if (navigationArgs.isCurrentMailboxFree) {
safeNavigate(
resId = R.id.upgradeProductBottomSheetDialog,
currentClassName = ScheduleSendBottomSheetDialog::class.java.name,
)
openMyKSuiteUpgradeBottomSheet(ScheduleSendBottomSheetDialog::class.java.name)
} else {
setBackNavigationResult(OPEN_DATE_AND_TIME_SCHEDULE_DIALOG, true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ class ActionItemView @JvmOverloads constructor(

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

private var isInIconMode: Boolean = false
var trailingContent = TrailingContent.None
set(value) {
field = value
setTrailingContentUi(value)
}

init {
attrs?.getAttributes(context, R.styleable.ActionItemView) {
Expand Down Expand Up @@ -76,14 +80,6 @@ class ActionItemView @JvmOverloads constructor(
}

if (getBoolean(R.styleable.ActionItemView_keepIconTint, false)) icon.imageTintList = null

isInIconMode = getBoolean(R.styleable.ActionItemView_showActionIcon, isInIconMode)
if (isInIconMode) {
description.isGone = true
actionIcon.isVisible = true
}

getString(R.styleable.ActionItemView_description)?.let { setDescription(it) }
}
}
}
Expand All @@ -102,17 +98,46 @@ class ActionItemView @JvmOverloads constructor(

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

fun setDescription(text: String) = with(binding) {
description.text = text
if (isInIconMode) return@with
actionIcon.isGone = true
description.isVisible = true
fun setDescription(text: String) {
trailingContent = if (text.isEmpty()) TrailingContent.None else TrailingContent.Description
binding.description.text = text
}

fun setDividerVisibility(isVisible: Boolean) {
binding.divider.isVisible = isVisible
}

private fun setTrailingContentUi(trailingContent: TrailingContent) = with(binding) {
trailingContentLayout.isVisible = true

when (trailingContent) {
TrailingContent.None -> trailingContentLayout.isGone = true
TrailingContent.Chevron -> {
actionIcon.isVisible = true

myKSuitePlusChip.isGone = true
description.isGone = true
}
TrailingContent.Description -> {
description.isVisible = true

myKSuitePlusChip.isGone = true
actionIcon.isGone = true
}
TrailingContent.MyKSuiteChip -> {
myKSuitePlusChip.isVisible = true

actionIcon.isGone = true
description.isGone = true
}
}
}

/** Keep the entries order, it's used by the attribute (or change also the attributes order in attrs.xml) */
enum class TrailingContent {
None, Chevron, Description, MyKSuiteChip
}

private fun TypedArray.getDimenOrNull(@StyleableRes index: Int): Int? {
return getDimensionPixelSize(index, NOT_SET).takeIf { it != NOT_SET }
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/bottom_sheet_schedule_send.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
android:layout_height="wrap_content"
app:icon="@drawable/ic_pen"
app:iconTint="?attr/colorPrimary"
app:showActionIcon="true"
app:title="@string/buttonCustomSchedule" />

</com.infomaniak.mail.views.BottomSheetScaffoldingView>
8 changes: 8 additions & 0 deletions app/src/main/res/layout/item_bottom_sheet_action.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
tools:text="@string/restoreEmailsTitle" />

<FrameLayout
android:id="@+id/trailingContentLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
Expand All @@ -83,6 +84,13 @@
android:contentDescription="@string/contentDescriptionActionIcon"
android:src="@drawable/ic_chevron_right"
android:visibility="gone" />

<com.infomaniak.core.myksuite.ui.views.MyKSuitePlusChipView
android:id="@+id/myKSuitePlusChip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible" />
</FrameLayout>
</LinearLayout>

Expand Down
21 changes: 7 additions & 14 deletions app/src/main/res/navigation/main_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -683,10 +683,13 @@
tools:layout="@layout/bottom_sheet_account" />

<dialog
android:id="@+id/upgradeProductBottomSheetDialog"
android:name="com.infomaniak.mail.ui.bottomSheetDialogs.UpgradeProductBottomSheetDialog"
android:label="UpgradeProductBottomSheetDialog"
tools:layout="@layout/bottom_sheet_upgrade_product" />
android:id="@+id/myKSuiteUpgradeBottomSheet"
android:name="com.infomaniak.core.myksuite.ui.views.MyKSuiteUpgradeBottomSheetDialog"
android:label="MyKSuiteUpgradeBottomSheet">
<argument
android:name="kSuiteApp"
app:argType="com.infomaniak.core.myksuite.ui.screens.KSuiteApp" />
</dialog>

<fragment
android:id="@+id/myKSuiteDashboardFragment"
Expand All @@ -702,14 +705,4 @@
android:name="dailySendLimit"
app:argType="string" />
</fragment>

<dialog
android:id="@+id/myKSuiteUpgradeBottomSheet"
android:name="com.infomaniak.core.myksuite.ui.views.MyKSuiteUpgradeBottomSheetDialog"
android:label="MyKSuiteUpgradeBottomSheet">
<argument
android:name="kSuiteApp"
app:argType="com.infomaniak.core.myksuite.ui.screens.KSuiteApp" />
</dialog>

</navigation>
12 changes: 7 additions & 5 deletions app/src/main/res/navigation/new_message_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@
</dialog>

<dialog
android:id="@+id/upgradeProductBottomSheetDialog"
android:name="com.infomaniak.mail.ui.bottomSheetDialogs.UpgradeProductBottomSheetDialog"
android:label="UpgradeProductBottomSheetDialog"
tools:layout="@layout/bottom_sheet_upgrade_product" />

android:id="@+id/myKSuiteUpgradeBottomSheet"
android:name="com.infomaniak.core.myksuite.ui.views.MyKSuiteUpgradeBottomSheetDialog"
android:label="MyKSuiteUpgradeBottomSheet">
<argument
android:name="kSuiteApp"
app:argType="com.infomaniak.core.myksuite.ui.screens.KSuiteApp" />
</dialog>
</navigation>
2 changes: 0 additions & 2 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@
<attr name="iconPaddingEnd" format="dimension" />
<attr name="title" />
<attr name="titleColor" format="color" />
<attr name="description" />
<attr name="showActionIcon" format="boolean" />
<attr name="visibleDivider" format="boolean" />
<attr name="dividerColor" format="color" />
<attr name="staffOnly" format="boolean" />
Expand Down

0 comments on commit 5673b20

Please sign in to comment.