Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
minSdkVersion parent.minSdkVersion
targetSdkVersion parent.targetSdkVersion
versionCode 10000
versionName "1.13.2"
versionName "1.13.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ package exchange.dydx.trading.feature.profile

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -93,18 +90,10 @@ object DydxProfileView : DydxComponent {
DydxProfileBalancesView.Content(Modifier.padding(horizontal = ThemeShapes.HorizontalPadding))
}
item(key = "fees") {
Row(
Modifier
.fillMaxWidth()
.padding(
horizontal = ThemeShapes.HorizontalPadding,
),
horizontalArrangement = Arrangement.SpaceBetween,
) {
DydxProfileFeesView.Content(modifier = Modifier.weight(1f))
Spacer(modifier = Modifier.width(16.dp))
DydxProfileRewardsView.Content(modifier = Modifier.weight(1f))
}
DydxProfileFeesView.Content(Modifier.padding(horizontal = ThemeShapes.HorizontalPadding))
}
item(key = "rewards") {
DydxProfileRewardsView.Content(Modifier.padding(horizontal = ThemeShapes.HorizontalPadding))
}
item(key = "history") {
DydxProfileHistoryView.Content(Modifier.padding(horizontal = ThemeShapes.HorizontalPadding))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
package exchange.dydx.trading.feature.profile.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Icon
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.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import exchange.dydx.abacus.protocols.LocalizerProtocol
import exchange.dydx.platformui.components.dividers.PlatformDivider
import exchange.dydx.platformui.components.icons.PlatformImage
import exchange.dydx.platformui.designSystem.theme.ThemeColor
import exchange.dydx.platformui.designSystem.theme.ThemeFont
import exchange.dydx.platformui.designSystem.theme.ThemeShapes
Expand All @@ -46,19 +48,21 @@ fun Preview_DydxProfileRewardsView() {
object DydxProfileRewardsView : DydxComponent {
data class ViewState(
val localizer: LocalizerProtocol,
val summary: DydxRewardsSummaryState?,
val nativeTokenLogoUrl: String? = null,
val title: String,
val activeBadgeText: String,
val bodyText: String,
val countdownLabel: String,
val countdownText: String,
val onTapAction: (() -> Unit)? = null,
) {
companion object {
val preview = ViewState(
localizer = MockLocalizer(),
summary = DydxRewardsSummaryState(
titleText = "Rewards",
rewards7DaysText = "0.01",
range7DaysText = "Jan 1 to Jan 7",
rewardsAllTimeText = "1.0",
),
title = "Liquidation Rebates",
activeBadgeText = "Active",
bodyText = "With the Liquidation Rebate Program, eligible traders liquidated on non-BTC perpetual pairs have the opportunity to earn DYDX rebates on a portion of their losses. Reminder to claim previous loss rebates and check eligibility here.",
countdownLabel = "Month May Countdown",
countdownText = "0d 9h 51m 46s",
)
}
}
Expand All @@ -68,181 +72,91 @@ object DydxProfileRewardsView : DydxComponent {
val viewModel: DydxProfileRewardsViewModel = hiltViewModel()

val state = viewModel.state.collectAsStateWithLifecycle(initialValue = null).value
Content(modifier, state, false)
Content(modifier, state)
}

@Composable
fun Content(modifier: Modifier, state: ViewState?, detailed: Boolean = false) {
fun Content(modifier: Modifier, state: ViewState?, @Suppress("UNUSED_PARAMETER") detailed: Boolean = false) {
if (state == null) {
return
}

Column(
modifier = modifier
.clickable { state.onTapAction?.invoke() }
.background(
color = ThemeColor.SemanticColor.layer_3.color,
shape = RoundedCornerShape(14.dp),
),
.fillMaxWidth()
.clip(RoundedCornerShape(14.dp))
.background(color = ThemeColor.SemanticColor.layer_3.color)
.clickable(enabled = state.onTapAction != null) { state.onTapAction?.invoke() },
) {
CreateHeader(
modifier = Modifier.padding(horizontal = ThemeShapes.HorizontalPadding),
state = state,
detailed = detailed,
)

PlatformDivider()

if (detailed) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly,
) {
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
CreateLastWeekContent(
modifier = Modifier
.padding(horizontal = ThemeShapes.HorizontalPadding)
.padding(vertical = 16.dp),
state = state,
detailed = detailed,
)
}
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
CreateAllTimeContent(
modifier = Modifier
.padding(horizontal = ThemeShapes.HorizontalPadding)
.padding(vertical = 16.dp),
state = state,
)
}
}
} else {
CreateLastWeekContent(
modifier = Modifier
.padding(horizontal = ThemeShapes.HorizontalPadding)
.padding(vertical = 16.dp),
state = state,
detailed = detailed,
Row(
modifier = Modifier
.padding(horizontal = ThemeShapes.HorizontalPadding)
.padding(vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = state.title,
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(foreground = ThemeColor.SemanticColor.text_secondary),
modifier = Modifier.weight(1f),
)
CreateAllTimeContent(

Text(
text = state.activeBadgeText,
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.mini)
.themeColor(foreground = ThemeColor.SemanticColor.color_green),
modifier = Modifier
.padding(horizontal = ThemeShapes.HorizontalPadding)
.padding(vertical = 16.dp),
state = state,
.border(
width = 1.dp,
color = ThemeColor.SemanticColor.color_green.color,
shape = RoundedCornerShape(4.dp),
)
.padding(horizontal = 6.dp, vertical = 4.dp),
)
}
}
}

@Composable
private fun CreateHeader(modifier: Modifier, state: ViewState, detailed: Boolean = false) {
Row(
modifier = modifier.padding(vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
) {
Text(
text = state.summary?.titleText ?: "",
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small),
modifier = Modifier.weight(1f),
)

if (!detailed) {
Column(modifier = Modifier.align(Alignment.CenterVertically)) {
Icon(
painter = painterResource(id = R.drawable.chevron_right),
contentDescription = "",
modifier = Modifier.size(16.dp),
tint = ThemeColor.SemanticColor.text_secondary.color,
)
}
}
}
}

@Composable
private fun CreateLastWeekContent(modifier: Modifier, state: ViewState, detailed: Boolean) {
Row(
modifier = modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly,
) {
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier
.padding(horizontal = ThemeShapes.HorizontalPadding)
.padding(bottom = 16.dp),
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
Text(
text = state.localizer.localize("APP.GENERAL.TIME_STRINGS.THIS_WEEK"),
text = state.bodyText,
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small),
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(foreground = ThemeColor.SemanticColor.text_tertiary),
)

Row(
modifier = Modifier
.clip(RoundedCornerShape(20.dp))
.background(ThemeColor.SemanticColor.layer_4.color)
.padding(horizontal = 12.dp, vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
Text(
text = state.summary?.rewards7DaysText ?: "-",
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.medium)
.themeColor(ThemeColor.SemanticColor.text_primary),
Icon(
painter = painterResource(id = R.drawable.icon_clock),
contentDescription = null,
modifier = Modifier.size(14.dp),
tint = ThemeColor.SemanticColor.color_purple.color,
)
if (state.nativeTokenLogoUrl != null && state.summary?.rewards7DaysText != null) {
PlatformImage(
icon = state.nativeTokenLogoUrl,
modifier = Modifier.size(24.dp),
)
}
}

if (detailed) {
Spacer(modifier = Modifier.width(8.dp))
Text(
text = state.summary?.range7DaysText ?: "",
text = state.countdownLabel,
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small),
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(foreground = ThemeColor.SemanticColor.color_purple),
)
}
}
}
}

@Composable
private fun CreateAllTimeContent(modifier: Modifier, state: ViewState) {
Row(
modifier = modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly,
) {
Column(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Text(
text = state.localizer.localize("APP.GENERAL.TIME_STRINGS.ALL_TIME"),
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small),
)
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
Spacer(modifier = Modifier.width(6.dp))
Text(
text = state.summary?.rewardsAllTimeText ?: "-",
text = state.countdownText,
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.medium)
.themeColor(ThemeColor.SemanticColor.text_primary),
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(foreground = ThemeColor.SemanticColor.text_primary),
)
if (state.nativeTokenLogoUrl != null && state.summary?.rewardsAllTimeText != null) {
PlatformImage(
icon = state.nativeTokenLogoUrl,
modifier = Modifier.size(24.dp),
)
}
}
}
}
Expand Down
Loading
Loading