-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18240 from wordpress-mobile/Dashboard-Domain-Card-UI
Dashboard domain card UI
- Loading branch information
Showing
14 changed files
with
286 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
.../src/main/java/org/wordpress/android/ui/mysite/cards/domain/DashboardDomainCardBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.wordpress.android.ui.mysite.cards.domain | ||
|
||
import org.wordpress.android.R | ||
import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DashboardCards.DashboardCard.DashboardDomainCard | ||
import org.wordpress.android.ui.mysite.MySiteCardAndItemBuilderParams.DashboardCardDomainBuilderParams | ||
import org.wordpress.android.ui.utils.ListItemInteraction | ||
import org.wordpress.android.ui.utils.UiString | ||
import javax.inject.Inject | ||
|
||
class DashboardDomainCardBuilder @Inject constructor() { | ||
fun build(params: DashboardCardDomainBuilderParams):DashboardDomainCard? { | ||
return if (params.isEligible) { | ||
DashboardDomainCard( | ||
title = UiString.UiStringRes(R.string.dashboard_card_domain_title), | ||
subtitle = UiString.UiStringRes(R.string.dashboard_card_domain_sub_title), | ||
onClick = ListItemInteraction.create(params.onClick), | ||
onHideMenuItemClick = ListItemInteraction.create(params.onHideMenuItemClick), | ||
onMoreMenuClick = ListItemInteraction.create(params.onMoreMenuClick) | ||
) | ||
} else { | ||
null | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...c/main/java/org/wordpress/android/ui/mysite/cards/domain/DashboardDomainCardViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.wordpress.android.ui.mysite.cards.domain | ||
|
||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.appcompat.widget.PopupMenu | ||
import org.wordpress.android.R | ||
import org.wordpress.android.databinding.DashboardCardDomainBinding | ||
import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DashboardCards.DashboardCard.DashboardDomainCard | ||
import org.wordpress.android.ui.mysite.cards.dashboard.CardViewHolder | ||
import org.wordpress.android.ui.utils.ListItemInteraction | ||
import org.wordpress.android.ui.utils.UiHelpers | ||
import org.wordpress.android.util.extensions.viewBinding | ||
|
||
class DashboardDomainCardViewHolder( | ||
parent: ViewGroup, | ||
private val uiHelpers: UiHelpers | ||
) : CardViewHolder<DashboardCardDomainBinding>( | ||
parent.viewBinding(DashboardCardDomainBinding::inflate) | ||
) { | ||
fun bind(card: DashboardDomainCard) = with(binding) { | ||
uiHelpers.setTextOrHide(dashboardCardDomainTitle, card.title) | ||
dashboardCardDomainCta.setOnClickListener { card.onClick.click() } | ||
dashboardDomainCardMore.setOnClickListener { | ||
showMoreMenu( | ||
card.onHideMenuItemClick, | ||
card.onMoreMenuClick, | ||
dashboardDomainCardMore, | ||
) | ||
} | ||
} | ||
|
||
private fun showMoreMenu( | ||
onHideMenuItemClick: ListItemInteraction, | ||
onMoreMenuClick: ListItemInteraction, | ||
anchor: View | ||
) { | ||
onMoreMenuClick.click() | ||
val popupMenu = PopupMenu(itemView.context, anchor) | ||
popupMenu.setOnMenuItemClickListener { | ||
when (it.itemId) { | ||
R.id.dashboard_card_domain_menu_item_hide_this -> { | ||
onHideMenuItemClick.click() | ||
return@setOnMenuItemClickListener true | ||
} | ||
else -> return@setOnMenuItemClickListener true | ||
} | ||
} | ||
popupMenu.inflate(R.menu.dashboard_card_domain_menu) | ||
popupMenu.show() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/dashboard_card_domain_cta" | ||
style="@style/WordPress.CardView.Unelevated" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:foreground="?attr/selectableItemBackground"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/margin_extra_large"> | ||
|
||
<ImageView | ||
android:id="@+id/dashboard_domain_card_more" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:background="?attr/selectableItemBackgroundBorderless" | ||
android:contentDescription="@string/content_description_more" | ||
android:src="@drawable/ic_more_vert_white_24dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:tint="?attr/wpColorOnSurfaceMedium" /> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/dashboard_card_domain_title" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:text="@string/dashboard_card_domain_title" | ||
android:textAlignment="viewStart" | ||
android:textAppearance="@style/dashboard_card_title" | ||
app:layout_constraintEnd_toStartOf="@+id/dashboard_domain_card_more" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<ImageView | ||
android:id="@+id/dashboard_card_domain_icon" | ||
android:importantForAccessibility="no" | ||
android:src="@drawable/ic_domains_white_24dp" | ||
android:background="@color/jetpack_green" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintTop_toBottomOf="@+id/dashboard_card_domain_title" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/dashboard_card_domain_sub_title" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:padding="@dimen/margin_medium" | ||
android:text="@string/dashboard_card_domain_sub_title" | ||
android:textAppearance="@style/dashboard_card_sub_title" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/dashboard_card_domain_icon" | ||
app:layout_constraintTop_toBottomOf="@+id/dashboard_card_domain_title" | ||
app:layout_constraintEnd_toEndOf="parent"/> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</com.google.android.material.card.MaterialCardView> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item | ||
android:id="@+id/dashboard_card_domain_menu_item_hide_this" | ||
android:title="@string/dashboard_card_domain_menu_hide_this" | ||
android:icon="@drawable/ic_not_visible_white_24dp"/> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<style name="dashboard_card_title"> | ||
<item name="android:textSize">17sp</item> | ||
<item name="android:letterSpacing">-0.03</item> | ||
<item name="android:textColor">?attr/wpColorOnSurfaceHigh</item> | ||
<item name="android:lineSpacingExtra">2sp</item> | ||
</style> | ||
|
||
<style name="dashboard_card_sub_title"> | ||
<item name="android:textSize">15sp</item> | ||
<item name="android:letterSpacing">-0.02</item> | ||
<item name="android:textColor">?attr/wpColorOnSurfaceMedium</item> | ||
<item name="android:lineSpacingExtra">3sp</item> | ||
</style> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.