-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into issue/9959-blaze-no-campaign
# Conflicts: # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/MyStoreBlazeView.kt # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/MyStoreBlazeViewModel.kt # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/mystore/MyStoreFragment.kt
- Loading branch information
Showing
16 changed files
with
622 additions
and
222 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/BlazeUiModels.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,48 @@ | ||
package com.woocommerce.android.ui.blaze | ||
|
||
import androidx.annotation.ColorRes | ||
import androidx.annotation.StringRes | ||
import com.woocommerce.android.R | ||
|
||
data class BlazeProductUi( | ||
val name: String, | ||
val imgUrl: String | ||
) | ||
|
||
data class BlazeCampaignUi( | ||
val product: BlazeProductUi, | ||
val status: CampaignStatusUi, | ||
val stats: List<BlazeCampaignStat>, | ||
) | ||
|
||
data class BlazeCampaignStat( | ||
@StringRes val name: Int, | ||
val value: Int | ||
) | ||
|
||
enum class CampaignStatusUi( | ||
@StringRes val statusDisplayText: Int, | ||
@ColorRes val textColor: Int, | ||
@ColorRes val backgroundColor: Int, | ||
) { | ||
InModeration( | ||
statusDisplayText = R.string.blaze_campaign_status_in_moderation, | ||
textColor = R.color.blaze_campaign_status_in_moderation_text, | ||
backgroundColor = R.color.blaze_campaign_status_in_moderation_background | ||
), | ||
Active( | ||
statusDisplayText = R.string.blaze_campaign_status_active, | ||
textColor = R.color.blaze_campaign_status_active_text, | ||
backgroundColor = R.color.blaze_campaign_status_active_background | ||
), | ||
Completed( | ||
statusDisplayText = R.string.blaze_campaign_status_completed, | ||
textColor = R.color.blaze_campaign_status_rejected_text, | ||
backgroundColor = R.color.blaze_campaign_status_rejected_background | ||
), | ||
Rejected( | ||
statusDisplayText = R.string.blaze_campaign_status_rejected, | ||
textColor = R.color.blaze_campaign_status_completed_text, | ||
backgroundColor = R.color.blaze_campaign_status_completed_background | ||
), | ||
} |
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
99 changes: 99 additions & 0 deletions
99
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/blaze/campaigs/BlazeCampaignItem.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,99 @@ | ||
package com.woocommerce.android.ui.blaze.campaigs | ||
|
||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.res.dimensionResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.sp | ||
import com.woocommerce.android.R | ||
import com.woocommerce.android.ui.blaze.BlazeCampaignUi | ||
import com.woocommerce.android.ui.compose.component.ProductThumbnail | ||
import com.woocommerce.android.ui.compose.component.WCTag | ||
|
||
@Composable | ||
fun BlazeCampaignItem( | ||
campaign: BlazeCampaignUi, | ||
onCampaignClicked: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Box( | ||
modifier = modifier | ||
.border( | ||
width = dimensionResource(id = R.dimen.minor_10), | ||
color = colorResource(R.color.divider_color), | ||
shape = RoundedCornerShape(dimensionResource(id = R.dimen.minor_100)) | ||
) | ||
.clip(shape = RoundedCornerShape(dimensionResource(id = R.dimen.minor_100))) | ||
.clickable { onCampaignClicked() } | ||
.padding(dimensionResource(id = R.dimen.major_100)) | ||
) { | ||
Row(verticalAlignment = Alignment.Top) { | ||
ProductThumbnail(imageUrl = campaign.product.imgUrl) | ||
Column( | ||
modifier = Modifier | ||
.padding(start = dimensionResource(id = R.dimen.major_100)) | ||
.weight(1f), | ||
) { | ||
WCTag( | ||
text = stringResource(id = campaign.status.statusDisplayText).uppercase(), | ||
textColor = colorResource(id = campaign.status.textColor), | ||
backgroundColor = colorResource(id = campaign.status.backgroundColor), | ||
textStyle = MaterialTheme.typography.caption.copy( | ||
letterSpacing = 1.5.sp | ||
) | ||
) | ||
Text( | ||
modifier = Modifier | ||
.padding(top = dimensionResource(id = R.dimen.minor_50)), | ||
text = campaign.product.name, | ||
style = MaterialTheme.typography.subtitle1, | ||
fontWeight = FontWeight.Bold, | ||
) | ||
Row(modifier = Modifier.padding(top = dimensionResource(id = R.dimen.major_100))) { | ||
campaign.stats.forEach { | ||
CampaignStat( | ||
statName = stringResource(id = it.name), | ||
statValue = it.value | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun CampaignStat( | ||
statName: String, | ||
statValue: Int, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Column( | ||
modifier = modifier.padding(end = dimensionResource(id = R.dimen.major_100)) | ||
) { | ||
Text( | ||
text = statName, | ||
style = MaterialTheme.typography.body2, | ||
color = colorResource(id = R.color.color_on_surface_medium_selector), | ||
) | ||
Text( | ||
modifier = Modifier | ||
.padding(top = dimensionResource(id = R.dimen.minor_50)), | ||
text = statValue.toString(), | ||
style = MaterialTheme.typography.h6, | ||
) | ||
} | ||
} |
Oops, something went wrong.