Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import one.mixin.android.extension.clickVibrate
import one.mixin.android.extension.generateQRCode
import one.mixin.android.extension.tickVibrate
import one.mixin.android.session.Session
import one.mixin.android.ui.home.web3.components.ActionButton
import one.mixin.android.widget.components.ActionButton
import one.mixin.android.util.getChainName
import one.mixin.android.vo.safe.TokenItem
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import one.mixin.android.extension.screenHeight
import one.mixin.android.ui.common.BottomSheetViewModel
import one.mixin.android.ui.common.MixinComposeBottomSheetDialogFragment
import one.mixin.android.ui.common.compose.MaterialInputField
import one.mixin.android.ui.home.web3.components.ActionButton
import one.mixin.android.widget.components.ActionButton
import one.mixin.android.ui.url.UrlInterpreterActivity
import one.mixin.android.util.ErrorHandler.Companion.errorHandler
import one.mixin.android.util.SystemUIManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import one.mixin.android.extension.screenHeight
import one.mixin.android.ui.common.BottomSheetViewModel
import one.mixin.android.ui.common.MixinComposeBottomSheetDialogFragment
import one.mixin.android.ui.common.UserBottomSheetDialogFragment
import one.mixin.android.ui.home.web3.components.ActionBottom
import one.mixin.android.widget.components.ActionBottom
import one.mixin.android.ui.landing.components.HighlightedTextWithClick
import one.mixin.android.ui.tip.wc.compose.ItemContent
import one.mixin.android.ui.wallet.ItemUserContent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import one.mixin.android.extension.roundTopOrBottom
import one.mixin.android.extension.screenHeight
import one.mixin.android.ui.common.MixinComposeBottomSheetDialogFragment
import one.mixin.android.ui.home.bot.INTERNAL_REFERRAL_ID
import one.mixin.android.ui.home.web3.components.ActionButton
import one.mixin.android.widget.components.ActionButton
import one.mixin.android.ui.landing.components.HighlightedTextWithClick
import one.mixin.android.ui.landing.components.NumberedText
import one.mixin.android.ui.setting.member.MixinMemberUpgradeBottomSheetDialogFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import one.mixin.android.extension.toast
import one.mixin.android.tip.wc.internal.Chain
import one.mixin.android.tip.wc.internal.TipGas
import one.mixin.android.tip.wc.internal.WCEthereumTransaction
import one.mixin.android.ui.home.web3.components.ActionBottom
import one.mixin.android.widget.components.ActionBottom
import one.mixin.android.ui.home.web3.components.MessagePreview
import one.mixin.android.ui.home.web3.components.ParsedTxPreview
import one.mixin.android.ui.home.web3.components.TokenTransactionPreview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import one.mixin.android.widget.components.MixinButton
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Icon
Expand Down Expand Up @@ -69,6 +69,7 @@ import one.mixin.android.util.GsonHelper
import one.mixin.android.vo.priceUSD
import one.mixin.android.vo.safe.Token
import one.mixin.android.web3.js.SolanaTxSource
import one.mixin.android.widget.components.ActionBottom
import java.math.BigDecimal

private val gradientColors = listOf(Cyan, Color(0xFF0066FF), Color(0xFF800080))
Expand Down Expand Up @@ -704,75 +705,6 @@ private fun WarningPreview() {
}
}

@Composable
fun ActionButton(
text: String,
onClick: () -> Unit,
backgroundColor: Color,
contentColor: Color,
modifier: Modifier = Modifier,
enabled: Boolean = true,
disabledBackgroundColor: Color = backgroundColor.copy(alpha = 0.4f),
disabledContentColor: Color = contentColor.copy(alpha = 0.6f),
) {
Button(
onClick = onClick,
enabled = enabled,
colors = ButtonDefaults.outlinedButtonColors(
backgroundColor = if (enabled) backgroundColor else disabledBackgroundColor,
contentColor = if (enabled) contentColor else disabledContentColor,
),
shape = RoundedCornerShape(30.dp),
contentPadding = PaddingValues(horizontal = 35.dp, vertical = 10.dp),
elevation = ButtonDefaults.elevation(
pressedElevation = 0.dp,
defaultElevation = 0.dp,
hoveredElevation = 0.dp,
focusedElevation = 0.dp,
),
modifier = modifier
) {
Text(
text = text,
color = if (enabled) contentColor else disabledContentColor,
fontSize = 16.sp,
fontWeight = FontWeight.W400
)
}
}

@Composable
fun ActionBottom(
modifier: Modifier,
cancelTitle: String,
confirmTitle: String,
cancelAction: () -> Unit,
confirmAction: () -> Unit,
) {
Row(
modifier =
modifier
.background(MixinAppTheme.colors.background)
.padding(8.dp)
.fillMaxWidth(),
horizontalArrangement = Arrangement.Center,
) {
ActionButton(
text = cancelTitle,
onClick = cancelAction,
backgroundColor = MixinAppTheme.colors.backgroundWindow,
contentColor = MixinAppTheme.colors.textPrimary
)
Box(modifier = Modifier.width(36.dp))
ActionButton(
text = confirmTitle,
onClick = confirmAction,
backgroundColor = MixinAppTheme.colors.accent,
contentColor = Color.White
)
}
}

@Preview
@Composable
fun TransferBottomPreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Button
import one.mixin.android.widget.components.MixinButton
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Divider
Expand Down Expand Up @@ -127,27 +127,16 @@ fun StakePage(
LocalSoftwareKeyboardController.current
val focusManager = LocalFocusManager.current
if (amountText.isNotEmpty()) {
Button(
MixinButton(
modifier = Modifier.fillMaxWidth(),
enabled = !isLoading,
onClick = {
keyboardController?.hide()
focusManager.clearFocus()
onStake.invoke()
},
colors =
ButtonDefaults.outlinedButtonColors(
backgroundColor = if (checkBalance != true) MixinAppTheme.colors.backgroundGray else MixinAppTheme.colors.accent,
),
shape = RoundedCornerShape(32.dp),
contentPadding = PaddingValues(vertical = 16.dp),
elevation =
ButtonDefaults.elevation(
pressedElevation = 0.dp,
defaultElevation = 0.dp,
hoveredElevation = 0.dp,
focusedElevation = 0.dp,
),
backgroundColor = if (checkBalance != true) MixinAppTheme.colors.backgroundGray else MixinAppTheme.colors.accent,
contentColor = if (checkBalance != true) MixinAppTheme.colors.textAssist else Color.White,
) {
if (isLoading) {
CircularProgressIndicator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import one.mixin.android.widget.components.MixinButton
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Divider
Expand Down Expand Up @@ -79,24 +79,11 @@ fun UnstakePage(
StakeInfo(validator, stakeAccount, stakeActivation)
Spacer(modifier = Modifier.weight(1f))
if (!stakeState.isDeactivatingState()) {
Button(
MixinButton(
modifier = Modifier.fillMaxWidth(),
onClick = {
onClick.invoke()
},
colors =
ButtonDefaults.outlinedButtonColors(
backgroundColor = MixinAppTheme.colors.accent,
),
shape = RoundedCornerShape(32.dp),
contentPadding = PaddingValues(vertical = 16.dp),
elevation =
ButtonDefaults.elevation(
pressedElevation = 0.dp,
defaultElevation = 0.dp,
hoveredElevation = 0.dp,
focusedElevation = 0.dp,
),
) {
if (isLoading) {
CircularProgressIndicator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import one.mixin.android.widget.components.MixinButton
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Icon
Expand Down Expand Up @@ -405,7 +405,9 @@ fun LimitOrderContent(
val isPriceValid = limitPriceText.toBigDecimalOrNull()?.let { it > BigDecimal.ZERO } == true
val isOutputValid = outputText.toBigDecimalOrNull()?.let { it > BigDecimal.ZERO } == true
val isEnabled = isInputValid && isPriceValid && isOutputValid && checkBalance == true && toToken != null
Button(
val buttonBackgroundColor = if (isEnabled) MixinAppTheme.colors.accent else MixinAppTheme.colors.backgroundGrayLight
val buttonContentColor = if (isEnabled) Color.White else MixinAppTheme.colors.textAssist
MixinButton(
modifier = Modifier
.fillMaxWidth()
.height(48.dp),
Expand Down Expand Up @@ -457,16 +459,8 @@ fun LimitOrderContent(
}
},
enabled = isEnabled,
colors = ButtonDefaults.outlinedButtonColors(
backgroundColor = if (isEnabled) MixinAppTheme.colors.accent else MixinAppTheme.colors.backgroundGrayLight,
),
shape = RoundedCornerShape(32.dp),
elevation = ButtonDefaults.elevation(
pressedElevation = 0.dp,
defaultElevation = 0.dp,
hoveredElevation = 0.dp,
focusedElevation = 0.dp,
),
backgroundColor = buttonBackgroundColor,
contentColor = buttonContentColor,
) {
Box(
modifier = Modifier
Expand All @@ -479,13 +473,13 @@ fun LimitOrderContent(
modifier = Modifier
.width(18.dp)
.height(18.dp),
color = if (isEnabled) Color.White else MixinAppTheme.colors.textAssist,
color = buttonContentColor,
strokeWidth = 2.dp,
)
} else {
Text(
text = if (checkBalance == false) "${fromToken?.symbol} ${stringResource(R.string.insufficient_balance)}" else stringResource(R.string.Review_Order),
color = if (isEnabled) Color.White else MixinAppTheme.colors.textAssist,
color = buttonContentColor,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import one.mixin.android.widget.components.MixinButton
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Icon
Expand Down Expand Up @@ -369,7 +369,17 @@ fun ReviewButton(
val checkBalance = checkBalance(inputText, fromBalance)

val hasError = quoteError != null
Button(
val buttonBackgroundColor = if (quoteResult != null && !hasError && checkBalance == true) {
MixinAppTheme.colors.accent
} else {
MixinAppTheme.colors.backgroundGrayLight
}
val buttonContentColor = if (checkBalance != true || hasError) {
MixinAppTheme.colors.textAssist
} else {
Color.White
}
MixinButton(
modifier = Modifier
.padding(horizontal = 20.dp)
.fillMaxWidth()
Expand All @@ -387,29 +397,13 @@ fun ReviewButton(
}
},
enabled = quoteResult != null && !hasError && !isLoading && checkBalance == true,
colors = ButtonDefaults.outlinedButtonColors(
backgroundColor = if (quoteResult != null && !hasError && checkBalance == true) {
MixinAppTheme.colors.accent
} else {
MixinAppTheme.colors.backgroundGrayLight
},
),
shape = RoundedCornerShape(32.dp),
elevation = ButtonDefaults.elevation(
pressedElevation = 0.dp,
defaultElevation = 0.dp,
hoveredElevation = 0.dp,
focusedElevation = 0.dp,
),
backgroundColor = buttonBackgroundColor,
contentColor = buttonContentColor,
) {
if (isLoading) {
CircularProgressIndicator(
modifier = Modifier.size(18.dp),
color = if (quoteResult != null && !hasError && checkBalance == true) {
Color.White
} else {
MixinAppTheme.colors.textAssist
},
color = buttonContentColor,
)
} else {
Text(
Expand All @@ -418,11 +412,7 @@ fun ReviewButton(
} else {
stringResource(R.string.Review_Order)
},
color = if (checkBalance != true || hasError) {
MixinAppTheme.colors.textAssist
} else {
Color.White
},
color = buttonContentColor,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import one.mixin.android.widget.components.MixinButton
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Icon
import androidx.compose.material.Text
Expand Down Expand Up @@ -103,23 +103,9 @@ fun SwapTokenPage(
}
}
Spacer(modifier = Modifier.height(20.dp))
Button(
MixinButton(
modifier = Modifier.fillMaxWidth(),
onClick =
confirmAction,
colors =
ButtonDefaults.outlinedButtonColors(
backgroundColor = MixinAppTheme.colors.accent,
),
shape = RoundedCornerShape(32.dp),
contentPadding = PaddingValues(vertical = 16.dp),
elevation =
ButtonDefaults.elevation(
pressedElevation = 0.dp,
defaultElevation = 0.dp,
hoveredElevation = 0.dp,
focusedElevation = 0.dp,
),
onClick = confirmAction,
) {
Text(
text = stringResource(id = R.string.view_on_explorer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import one.mixin.android.extension.withArgs
import one.mixin.android.ui.common.BottomSheetViewModel
import one.mixin.android.ui.common.MixinComposeBottomSheetDialogFragment
import one.mixin.android.ui.common.VerifyBottomSheetDialogFragment
import one.mixin.android.ui.home.web3.components.ActionBottom
import one.mixin.android.widget.components.ActionBottom
import one.mixin.android.ui.tip.wc.compose.ItemWalletContent
import one.mixin.android.ui.wallet.ItemUserContent
import one.mixin.android.ui.wallet.components.WalletLabel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import one.mixin.android.ui.common.PinInputBottomSheetDialogFragment
import one.mixin.android.ui.common.UtxoConsolidationBottomSheetDialogFragment
import one.mixin.android.ui.common.biometric.BiometricInfo
import one.mixin.android.ui.common.biometric.buildTransferBiometricItem
import one.mixin.android.ui.home.web3.components.ActionBottom
import one.mixin.android.widget.components.ActionBottom
import one.mixin.android.ui.tip.wc.compose.ItemWalletContent
import one.mixin.android.ui.wallet.ItemUserContent
import one.mixin.android.ui.wallet.components.WalletLabel
Expand Down
Loading
Loading