Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Add "Donate" button in More menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Jun 11, 2022
1 parent f6cb3b3 commit d6aeea5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
34 changes: 32 additions & 2 deletions app/src/main/java/com/ivy/wallet/ui/home/HomeMoreMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
import com.google.accompanist.insets.navigationBarsPadding
import com.google.accompanist.insets.statusBarsPadding
import com.ivy.design.l0_system.SunsetNight
import com.ivy.design.l0_system.Theme
import com.ivy.design.l0_system.UI
import com.ivy.design.l0_system.style
import com.ivy.frp.view.navigation.navigation
import com.ivy.wallet.Constants
import com.ivy.wallet.R
import com.ivy.wallet.ui.*
import com.ivy.wallet.ui.donate.DonateScreen
import com.ivy.wallet.ui.theme.Blue
import com.ivy.wallet.ui.theme.Gradient
import com.ivy.wallet.ui.theme.Gray
import com.ivy.wallet.ui.theme.components.BufferBattery
import com.ivy.wallet.ui.theme.components.CircleButtonFilled
import com.ivy.wallet.ui.theme.components.IvyButton
import com.ivy.wallet.ui.theme.components.IvyIcon
import com.ivy.wallet.ui.theme.modal.AddModalBackHandling
import com.ivy.wallet.ui.theme.wallet.AmountCurrencyB1
Expand Down Expand Up @@ -156,12 +160,17 @@ fun BoxWithConstraintsScope.MoreMenu(
}
}

if (percentExpanded > 0.01f) {
DonateButton(
percentExpanded = percentExpanded
)
}

CircleButtonFilled(
modifier = Modifier
.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)


layout(placeable.width, placeable.height) {
placeable.place(
x = xBase.roundToInt() - buttonSizePx.roundToInt(),
Expand All @@ -179,7 +188,6 @@ fun BoxWithConstraintsScope.MoreMenu(
) {
setExpanded(!expanded)
}

}

@Composable
Expand Down Expand Up @@ -553,6 +561,28 @@ private fun Preview_Expanded() {
}
}

@Composable
private fun BoxWithConstraintsScope.DonateButton(
percentExpanded: Float
) {
val nav = navigation()
IvyButton(
modifier = Modifier
.align(Alignment.BottomCenter)
.navigationBarsPadding()
.padding(bottom = 40.dp)
.zIndex(510f)
.alpha(percentExpanded),
text = "Donate",
iconStart = R.drawable.ic_donate_crown,
iconEdgePadding = 16.dp,
iconTextPadding = 12.dp,
backgroundGradient = Gradient.from(SunsetNight)
) {
nav.navigateTo(DonateScreen)
}
}

@Preview
@Composable
private fun Preview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ private fun BoxWithConstraintsScope.UI(
icon = R.drawable.ic_donate_crown,
text = "Donate",
iconPadding = 8.dp,
backgroundGradient = Gradient(SunsetNight.startColor, SunsetNight.endColor)
backgroundGradient = Gradient.from(SunsetNight)
) {
nav.navigateTo(DonateScreen)
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/ivy/wallet/ui/theme/IvyColors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ data class Gradient(
val endColor: Color
) {
companion object {
fun from(gradient: com.ivy.design.l0_system.Gradient) =
Gradient(gradient.startColor, gradient.endColor)

fun from(startColor: Int, endColor: Int?) = Gradient(
startColor = startColor.toComposeColor(),
endColor = (endColor ?: startColor).toComposeColor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fun IvyButton(
hasGlow: Boolean = true,
padding: Dp = 12.dp,
iconEdgePadding: Dp = 12.dp,
iconTextPadding: Dp = 4.dp,
onClick: () -> Unit
) {
Row(
Expand Down Expand Up @@ -77,13 +78,15 @@ fun IvyButton(
icon = iconStart,
tint = iconTint,
iconEdgePadding = iconEdgePadding,
iconTextPadding = iconTextPadding
)
}
iconEnd != null && !wrapContentMode -> {
IconEnd(
icon = iconEnd,
tint = Color.Transparent,
iconEdgePadding = iconEdgePadding,
iconTextPadding = iconTextPadding
)
}
else -> {
Expand Down Expand Up @@ -113,13 +116,15 @@ fun IvyButton(
icon = iconStart,
tint = Color.Transparent,
iconEdgePadding = iconEdgePadding,
iconTextPadding = iconTextPadding
)
}
iconEnd != null -> {
IconEnd(
icon = iconEnd,
tint = iconTint,
iconEdgePadding = iconEdgePadding,
iconTextPadding = iconTextPadding
)
}
else -> {
Expand All @@ -132,6 +137,7 @@ fun IvyButton(
@Composable
private fun IconStart(
iconEdgePadding: Dp,
iconTextPadding: Dp,
icon: Int,
tint: Color,
) {
Expand All @@ -144,16 +150,17 @@ private fun IconStart(
tint = tint,
)

Spacer(modifier = Modifier.width(4.dp))
Spacer(modifier = Modifier.width(iconTextPadding))
}

@Composable
private fun IconEnd(
iconEdgePadding: Dp,
iconTextPadding: Dp,
icon: Int,
tint: Color,
) {
Spacer(modifier = Modifier.width(4.dp))
Spacer(modifier = Modifier.width(iconTextPadding))

Icon(
modifier = Modifier,
Expand Down

0 comments on commit d6aeea5

Please sign in to comment.