-
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 #19721 from wordpress-mobile/feature/sotw-card-wor…
…dpress [SotW 2023] Add State of the Word post-event card to WordPress
- Loading branch information
Showing
23 changed files
with
595 additions
and
5 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
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
101 changes: 101 additions & 0 deletions
101
...Press/src/main/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCard.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,101 @@ | ||
package org.wordpress.android.ui.mysite.cards.sotw2023 | ||
|
||
import android.content.res.Configuration | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.semantics.semantics | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import org.wordpress.android.R | ||
import org.wordpress.android.ui.compose.components.card.UnelevatedCard | ||
import org.wordpress.android.ui.compose.styles.DashboardCardTypography | ||
import org.wordpress.android.ui.compose.theme.AppTheme | ||
import org.wordpress.android.ui.compose.unit.Margin | ||
import org.wordpress.android.ui.compose.utils.uiStringText | ||
import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.WpSotw2023NudgeCardModel | ||
import org.wordpress.android.ui.mysite.cards.compose.MySiteCardToolbar | ||
import org.wordpress.android.ui.mysite.cards.compose.MySiteCardToolbarContextMenuItem | ||
import org.wordpress.android.ui.utils.ListItemInteraction | ||
import org.wordpress.android.ui.utils.UiString.UiStringRes | ||
|
||
@Composable | ||
fun WpSotw2023NudgeCard( | ||
model: WpSotw2023NudgeCardModel, | ||
modifier: Modifier = Modifier, | ||
) { | ||
UnelevatedCard( | ||
modifier = modifier.semantics(mergeDescendants = true) {}, | ||
) { | ||
Column( | ||
modifier = Modifier.padding(bottom = Margin.Medium.value) | ||
) { | ||
CardToolbar(model) | ||
|
||
Spacer(Modifier.height(Margin.Medium.value)) | ||
|
||
Text( | ||
text = uiStringText(model.text), | ||
style = DashboardCardTypography.detailText, | ||
modifier = Modifier.padding(horizontal = Margin.ExtraLarge.value), | ||
) | ||
|
||
Spacer(Modifier.height(Margin.Small.value)) | ||
|
||
TextButton( | ||
onClick = { model.onCtaClick.click() }, | ||
modifier = Modifier.padding(horizontal = Margin.Small.value) | ||
) { | ||
Text( | ||
text = uiStringText(model.ctaText), | ||
style = DashboardCardTypography.footerCTA, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun CardToolbar( | ||
model: WpSotw2023NudgeCardModel | ||
) { | ||
MySiteCardToolbar( | ||
contextMenuItems = listOf( | ||
MySiteCardToolbarContextMenuItem.Option( | ||
text = stringResource(R.string.my_site_dashboard_card_more_menu_hide_card), | ||
onClick = { model.onHideMenuItemClick.click() }, | ||
) | ||
), | ||
) { | ||
Text( | ||
text = uiStringText(uiString = model.title), | ||
style = DashboardCardTypography.smallTitle, | ||
textAlign = TextAlign.Start, | ||
fontWeight = FontWeight.Medium, | ||
) | ||
} | ||
} | ||
|
||
@Preview(name = "Light Mode") | ||
@Preview(name = "Dark Mode", uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
@Composable | ||
fun WpSotw2023NudgeCardPreview() { | ||
AppTheme { | ||
WpSotw2023NudgeCard( | ||
model = WpSotw2023NudgeCardModel( | ||
title = UiStringRes(R.string.wp_sotw_2023_dashboard_nudge_title), | ||
text = UiStringRes(R.string.wp_sotw_2023_dashboard_nudge_text), | ||
ctaText = UiStringRes(R.string.wp_sotw_2023_dashboard_nudge_cta), | ||
onHideMenuItemClick = ListItemInteraction.create {}, | ||
onCtaClick = ListItemInteraction.create {}, | ||
) | ||
) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...ava/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardAnalyticsTracker.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,30 @@ | ||
package org.wordpress.android.ui.mysite.cards.sotw2023 | ||
|
||
import org.wordpress.android.analytics.AnalyticsTracker | ||
import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper | ||
import javax.inject.Inject | ||
|
||
class WpSotw2023NudgeCardAnalyticsTracker @Inject constructor( | ||
private val analyticsTracker: AnalyticsTrackerWrapper, | ||
) { | ||
private var cardShownTracked: Boolean = false | ||
|
||
fun resetShown() { | ||
cardShownTracked = false | ||
} | ||
|
||
fun trackShown() { | ||
if (!cardShownTracked) { | ||
cardShownTracked = true | ||
analyticsTracker.track(AnalyticsTracker.Stat.SOTW_2023_NUDGE_POST_EVENT_CARD_SHOWN) | ||
} | ||
} | ||
|
||
fun trackCtaTapped() { | ||
analyticsTracker.track(AnalyticsTracker.Stat.SOTW_2023_NUDGE_POST_EVENT_CARD_CTA_TAPPED) | ||
} | ||
|
||
fun trackHideTapped() { | ||
analyticsTracker.track(AnalyticsTracker.Stat.SOTW_2023_NUDGE_POST_EVENT_CARD_HIDE_TAPPED) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...main/java/org/wordpress/android/ui/mysite/cards/sotw2023/WpSotw2023NudgeCardViewHolder.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,27 @@ | ||
package org.wordpress.android.ui.mysite.cards.sotw2023 | ||
|
||
import android.view.ViewGroup | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.ViewCompositionStrategy | ||
import org.wordpress.android.databinding.WpSotw20223NudgeCardBinding | ||
import org.wordpress.android.ui.compose.theme.AppTheme | ||
import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.WpSotw2023NudgeCardModel | ||
import org.wordpress.android.ui.mysite.MySiteCardAndItemViewHolder | ||
import org.wordpress.android.util.extensions.viewBinding | ||
|
||
class WpSotw2023NudgeCardViewHolder(parent: ViewGroup) : | ||
MySiteCardAndItemViewHolder<WpSotw20223NudgeCardBinding>(parent.viewBinding(WpSotw20223NudgeCardBinding::inflate)) { | ||
fun bind(cardModel: WpSotw2023NudgeCardModel) = with(binding.wpSotw2023NudgeCard) { | ||
// Dispose of the Composition when the view's LifecycleOwner is destroyed | ||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnDetachedFromWindowOrReleasedFromPool) | ||
setContent { | ||
AppTheme { | ||
WpSotw2023NudgeCard( | ||
model = cardModel, | ||
modifier = Modifier.fillMaxWidth(), | ||
) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.