-
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 #20846 from wordpress-mobile/issue/20621-tags-feed…
…-onboarding [Reader] Implement announcement card
- Loading branch information
Showing
14 changed files
with
419 additions
and
14 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
183 changes: 183 additions & 0 deletions
183
...ess/src/main/java/org/wordpress/android/ui/reader/views/compose/ReaderAnnouncementCard.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,183 @@ | ||
package org.wordpress.android.ui.reader.views.compose | ||
|
||
import android.content.res.Configuration | ||
import androidx.annotation.DrawableRes | ||
import androidx.annotation.StringRes | ||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.animation.expandIn | ||
import androidx.compose.animation.shrinkOut | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.defaultMinSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.ButtonDefaults | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.drawBehind | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import org.wordpress.android.R | ||
import org.wordpress.android.designsystem.footnote | ||
import org.wordpress.android.ui.compose.theme.AppColor | ||
import org.wordpress.android.ui.compose.theme.AppTheme | ||
import org.wordpress.android.ui.compose.unit.Margin | ||
|
||
@Composable | ||
fun ReaderAnnouncementCard( | ||
shouldShow: Boolean, | ||
items: List<ReaderAnnouncementCardItemData>, | ||
onAnnouncementCardDoneClick: () -> Unit, | ||
) { | ||
val primaryColor = if (isSystemInDarkTheme()) AppColor.White else AppColor.Black | ||
val secondaryColor = if (isSystemInDarkTheme()) AppColor.Black else AppColor.White | ||
AnimatedVisibility( | ||
visible = shouldShow, | ||
enter = expandIn(), | ||
exit = shrinkOut( | ||
shrinkTowards = Alignment.TopCenter, | ||
), | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(Margin.ExtraLarge.value), | ||
verticalArrangement = Arrangement.spacedBy(Margin.ExtraLarge.value), | ||
) { | ||
// Title | ||
Text( | ||
text = stringResource(R.string.reader_announcement_card_title), | ||
style = MaterialTheme.typography.labelLarge, | ||
color = primaryColor, | ||
) | ||
// Items | ||
Column( | ||
modifier = Modifier | ||
.fillMaxWidth(), | ||
verticalArrangement = Arrangement.spacedBy(Margin.ExtraLarge.value) | ||
) { | ||
items.forEach { | ||
ReaderAnnouncementCardItem(it) | ||
} | ||
} | ||
// Done button | ||
Button( | ||
modifier = Modifier | ||
.fillMaxWidth(), | ||
onClick = { onAnnouncementCardDoneClick() }, | ||
elevation = ButtonDefaults.elevation(0.dp), | ||
colors = ButtonDefaults.buttonColors( | ||
backgroundColor = primaryColor, | ||
), | ||
) { | ||
Text( | ||
text = stringResource(id = R.string.reader_btn_done), | ||
color = secondaryColor, | ||
style = MaterialTheme.typography.labelLarge, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun ReaderAnnouncementCardItem(data: ReaderAnnouncementCardItemData) { | ||
val primaryColor = if (isSystemInDarkTheme()) AppColor.White else AppColor.Black | ||
val secondaryColor = if (isSystemInDarkTheme()) AppColor.Black else AppColor.White | ||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.defaultMinSize(minWidth = 54.dp, minHeight = 54.dp), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
val iconBackgroundColor = primaryColor | ||
Icon( | ||
modifier = Modifier | ||
.padding( | ||
start = Margin.Large.value, | ||
end = Margin.Large.value | ||
) | ||
.drawBehind { | ||
drawCircle( | ||
color = iconBackgroundColor, | ||
radius = this.size.maxDimension, | ||
) | ||
}, | ||
painter = painterResource(data.iconRes), | ||
tint = secondaryColor, | ||
contentDescription = null | ||
) | ||
Column(verticalArrangement = Arrangement.Center) { | ||
Text( | ||
modifier = Modifier.padding( | ||
start = Margin.Large.value, | ||
), | ||
text = stringResource(data.titleRes), | ||
style = MaterialTheme.typography.labelLarge, | ||
color = primaryColor, | ||
) | ||
val secondaryElementColor = primaryColor.copy( | ||
alpha = 0.6F | ||
) | ||
Text( | ||
modifier = Modifier.padding( | ||
start = Margin.Large.value, | ||
), | ||
text = stringResource(data.descriptionRes), | ||
style = MaterialTheme.typography.footnote, | ||
color = secondaryElementColor, | ||
) | ||
} | ||
} | ||
} | ||
|
||
data class ReaderAnnouncementCardItemData( | ||
@DrawableRes val iconRes: Int, | ||
@StringRes val titleRes: Int, | ||
@StringRes val descriptionRes: Int, | ||
) | ||
|
||
|
||
@Preview | ||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) | ||
@Composable | ||
fun ReaderTagsFeedPostListItemPreview() { | ||
AppTheme { | ||
Box( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
) { | ||
ReaderAnnouncementCard( | ||
shouldShow = false, | ||
items = listOf( | ||
ReaderAnnouncementCardItemData( | ||
iconRes = R.drawable.ic_wifi_off_24px, | ||
titleRes = R.string.reader_tags_display_name, | ||
descriptionRes = R.string.reader_tags_feed_loading_error_description, | ||
), | ||
ReaderAnnouncementCardItemData( | ||
iconRes = R.drawable.ic_wifi_off_24px, | ||
titleRes = R.string.reader_tags_display_name, | ||
descriptionRes = R.string.reader_tags_feed_loading_error_description, | ||
), | ||
ReaderAnnouncementCardItemData( | ||
iconRes = R.drawable.ic_wifi_off_24px, | ||
titleRes = R.string.reader_tags_display_name, | ||
descriptionRes = R.string.reader_tags_feed_loading_error_description, | ||
), | ||
), | ||
onAnnouncementCardDoneClick = {}, | ||
) | ||
} | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
...ss/src/main/java/org/wordpress/android/util/config/ReaderAnnouncementCardFeatureConfig.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,15 @@ | ||
package org.wordpress.android.util.config | ||
|
||
import org.wordpress.android.BuildConfig | ||
import org.wordpress.android.annotation.Feature | ||
import javax.inject.Inject | ||
|
||
private const val READER_ANNOUNCEMENT_CARD_REMOTE_FIELD = "reader_announcement_card" | ||
@Feature(remoteField = READER_ANNOUNCEMENT_CARD_REMOTE_FIELD, defaultValue = false) | ||
class ReaderAnnouncementCardFeatureConfig @Inject constructor( | ||
appConfig: AppConfig | ||
) : FeatureConfig( | ||
appConfig, | ||
BuildConfig.READER_ANNOUNCEMENT_CARD, | ||
READER_ANNOUNCEMENT_CARD_REMOTE_FIELD, | ||
) |
File renamed without changes.
Oops, something went wrong.