Skip to content

Commit

Permalink
Removed Default cursor position settings
Browse files Browse the repository at this point in the history
  • Loading branch information
AmadeyKuspakov committed Sep 12, 2023
1 parent 459860b commit 9c4d85e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package jp.co.soramitsu.common.domain

import java.math.BigDecimal
import jp.co.soramitsu.ui_core.component.input.number.DefaultCursorPosition

data class AssetAmountInputState(
val token: Token,
Expand All @@ -43,6 +42,5 @@ data class AssetAmountInputState(
val enabled: Boolean,
val readOnly: Boolean = false,
val error: Boolean = false,
val errorHint: String = "",
val defaultCursorPosition: DefaultCursorPosition = DefaultCursorPosition.END
val errorHint: String = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fun AssetAmountInput(
textStyle = MaterialTheme.customTypography.displayS.copy(textAlign = TextAlign.End),
enabled = state?.let { it.enabled && !it.readOnly } ?: false,
precision = state?.token?.precision ?: OptionsProvider.defaultScale,
defaultCursorPosition = state?.defaultCursorPosition ?: DefaultCursorPosition.END,
defaultCursorPosition = DefaultCursorPosition.START,
initial = state?.initialAmount,
onValueChanged = onAmountChange,
focusRequester = focusRequester,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ import jp.co.soramitsu.feature_assets_api.presentation.AssetsRouter
import jp.co.soramitsu.feature_assets_impl.presentation.states.SendState
import jp.co.soramitsu.feature_wallet_api.launcher.WalletRouter
import jp.co.soramitsu.sora.substrate.runtime.SubstrateOptionsProvider
import jp.co.soramitsu.ui_core.component.input.number.DefaultCursorPosition
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.catch
Expand Down Expand Up @@ -167,8 +166,7 @@ class TransferAmountViewModel @AssistedInject constructor(
amountFiat = "",
enabled = false,
error = false,
errorHint = "",
defaultCursorPosition = DefaultCursorPosition.END
errorHint = ""
)
)
} else {
Expand All @@ -179,8 +177,7 @@ class TransferAmountViewModel @AssistedInject constructor(
amountFiat = asset.token.printFiat(
_sendState.value.input?.initialAmount.orZero(),
numbersFormatter
),
defaultCursorPosition = DefaultCursorPosition.END
)
)
)
}
Expand Down Expand Up @@ -232,8 +229,7 @@ class TransferAmountViewModel @AssistedInject constructor(
_sendState.value = _sendState.value.copy(
input = _sendState.value.input?.copy(
readOnly = false,
initialAmount = _sendState.value.input?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
initialAmount = _sendState.value.input?.initialAmount?.nullZero()
),
)
}
Expand Down Expand Up @@ -396,8 +392,7 @@ class TransferAmountViewModel @AssistedInject constructor(
fun onReviewClick() {
_sendState.value = _sendState.value.copy(
input = _sendState.value.input?.copy(
initialAmount = _sendState.value.input?.initialAmount.orZero(),
defaultCursorPosition = DefaultCursorPosition.START
initialAmount = _sendState.value.input?.initialAmount.orZero()
)
)
}
Expand All @@ -409,8 +404,7 @@ class TransferAmountViewModel @AssistedInject constructor(
amountFiat = _sendState.value.input?.token?.printFiat(
value,
numbersFormatter
).orEmpty(),
defaultCursorPosition = DefaultCursorPosition.END
).orEmpty()
)
)
enteredFlow.value = value
Expand All @@ -433,8 +427,7 @@ class TransferAmountViewModel @AssistedInject constructor(
amountFiat = _sendState.value.input?.token?.printFiat(
amount,
numbersFormatter
).orEmpty(),
defaultCursorPosition = DefaultCursorPosition.START
).orEmpty()
)
)
enteredFlow.value = amount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ import jp.co.soramitsu.feature_wallet_api.domain.interfaces.WalletInteractor
import jp.co.soramitsu.feature_wallet_api.launcher.WalletRouter
import jp.co.soramitsu.sora.substrate.runtime.SubstrateOptionsProvider
import jp.co.soramitsu.sora.substrate.runtime.isSynthetic
import jp.co.soramitsu.ui_core.component.input.number.DefaultCursorPosition
import jp.co.soramitsu.ui_core.component.toolbar.Action
import jp.co.soramitsu.ui_core.component.toolbar.BasicToolbarState
import jp.co.soramitsu.ui_core.component.toolbar.SoramitsuToolbarState
Expand Down Expand Up @@ -509,12 +508,10 @@ class LiquidityAddViewModel @AssistedInject constructor(
val list = assets.filter { it.token.id in bases && it.token.id != addToken2 }
_addState.value = _addState.value.copy(
assetState1 = _addState.value.assetState1?.copy(
initialAmount = _addState.value.assetState1?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
initialAmount = _addState.value.assetState1?.initialAmount?.nullZero()
),
assetState2 = _addState.value.assetState2?.copy(
initialAmount = _addState.value.assetState2?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
initialAmount = _addState.value.assetState2?.initialAmount?.nullZero()
),
)
_searchTokenFilter.value = _searchTokenFilter.value.copy(
Expand Down Expand Up @@ -552,12 +549,10 @@ class LiquidityAddViewModel @AssistedInject constructor(
}
_addState.value = _addState.value.copy(
assetState1 = _addState.value.assetState1?.copy(
initialAmount = _addState.value.assetState1?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
initialAmount = _addState.value.assetState1?.initialAmount?.nullZero()
),
assetState2 = _addState.value.assetState2?.copy(
initialAmount = _addState.value.assetState2?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
initialAmount = _addState.value.assetState2?.initialAmount?.nullZero()
),
)
_searchTokenFilter.value = _searchTokenFilter.value.copy(
Expand All @@ -575,11 +570,7 @@ class LiquidityAddViewModel @AssistedInject constructor(
assetState1 = state.copy(
token = a.token,
balance = getAssetBalanceText(a),
amountFiat = a.token.printFiat(state.initialAmount.orZero(), numbersFormatter),
defaultCursorPosition = DefaultCursorPosition.END
),
assetState2 = _addState.value.assetState2?.copy(
defaultCursorPosition = DefaultCursorPosition.END
amountFiat = a.token.printFiat(state.initialAmount.orZero(), numbersFormatter)
),
)
hasXorReminderWarningBeenChecked = false
Expand All @@ -592,14 +583,10 @@ class LiquidityAddViewModel @AssistedInject constructor(
val a = assets.first { t -> t.token.id == id }
val state = _addState.value.assetState2
_addState.value = _addState.value.copy(
assetState1 = _addState.value.assetState1?.copy(
defaultCursorPosition = DefaultCursorPosition.END
),
assetState2 = state?.copy(
token = a.token,
balance = getAssetBalanceText(a),
amountFiat = a.token.printFiat(state.initialAmount.orZero(), numbersFormatter),
defaultCursorPosition = DefaultCursorPosition.END
amountFiat = a.token.printFiat(state.initialAmount.orZero(), numbersFormatter)
)
?: buildInitialAssetState(a),
)
Expand All @@ -624,24 +611,16 @@ class LiquidityAddViewModel @AssistedInject constructor(
_addState.value = _addState.value.copy(
assetState1 = _addState.value.assetState1?.copy(
balance = getAssetBalanceText(asset),
token = asset.token,
defaultCursorPosition = DefaultCursorPosition.END
),
assetState2 = _addState.value.assetState2?.copy(
defaultCursorPosition = DefaultCursorPosition.END
token = asset.token
)
)
}
assets.find { it.token.id == addToken2 }?.let { asset ->
balance2 = asset.balance.transferable
_addState.value = _addState.value.copy(
assetState1 = _addState.value.assetState1?.copy(
defaultCursorPosition = DefaultCursorPosition.END
),
assetState2 = _addState.value.assetState2?.copy(
balance = getAssetBalanceText(asset),
token = asset.token,
defaultCursorPosition = DefaultCursorPosition.END
)
)
}
Expand Down Expand Up @@ -737,11 +716,9 @@ class LiquidityAddViewModel @AssistedInject constructor(
_addState.value = _addState.value.copy(
assetState1 = _addState.value.assetState1?.copy(
initialAmount = _addState.value.assetState1?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
assetState2 = _addState.value.assetState2?.copy(
initialAmount = _addState.value.assetState2?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
)
}
Expand All @@ -759,27 +736,19 @@ class LiquidityAddViewModel @AssistedInject constructor(
value,
numbersFormatter
).orEmpty(),
defaultCursorPosition = DefaultCursorPosition.END
),
assetState2 = _addState.value.assetState2?.copy(
defaultCursorPosition = DefaultCursorPosition.END
)
)
amount1Flow.value = value
}

fun onAmount2Change(value: BigDecimal) {
_addState.value = _addState.value.copy(
assetState1 = _addState.value.assetState1?.copy(
defaultCursorPosition = DefaultCursorPosition.END
),
assetState2 = _addState.value.assetState2?.copy(
initialAmount = value,
amountFiat = _addState.value.assetState2?.token?.printFiat(
value,
numbersFormatter
).orEmpty(),
defaultCursorPosition = DefaultCursorPosition.END
)
)
amount2Flow.value = value
Expand Down Expand Up @@ -814,10 +783,6 @@ class LiquidityAddViewModel @AssistedInject constructor(
assetState1 = _addState.value.assetState1?.copy(
amountFiat = tokenFrom.printFiat(amount, numbersFormatter),
initialAmount = amount,
defaultCursorPosition = DefaultCursorPosition.START
),
assetState2 = _addState.value.assetState2?.copy(
defaultCursorPosition = DefaultCursorPosition.START
)
)
amount1Flow.value = amount
Expand All @@ -829,13 +794,9 @@ class LiquidityAddViewModel @AssistedInject constructor(
tokenTo.precision
)
_addState.value = _addState.value.copy(
assetState1 = _addState.value.assetState1?.copy(
defaultCursorPosition = DefaultCursorPosition.START
),
assetState2 = _addState.value.assetState2?.copy(
amountFiat = tokenTo.printFiat(amount, numbersFormatter),
initialAmount = amount,
defaultCursorPosition = DefaultCursorPosition.START
)
)
amount2Flow.value = amount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ import jp.co.soramitsu.feature_polkaswap_impl.presentation.states.SwapMainState
import jp.co.soramitsu.feature_polkaswap_impl.presentation.states.defaultSwapDetailsState
import jp.co.soramitsu.feature_wallet_api.domain.interfaces.WalletInteractor
import jp.co.soramitsu.sora.substrate.runtime.SubstrateOptionsProvider
import jp.co.soramitsu.ui_core.component.input.number.DefaultCursorPosition
import jp.co.soramitsu.ui_core.component.toolbar.BasicToolbarState
import jp.co.soramitsu.ui_core.component.toolbar.SoramitsuToolbarState
import jp.co.soramitsu.ui_core.component.toolbar.SoramitsuToolbarType
Expand Down Expand Up @@ -400,11 +399,9 @@ class SwapViewModel @AssistedInject constructor(
_swapMainState.value = _swapMainState.value.copy(
tokenFromState = _swapMainState.value.tokenFromState?.copy(
initialAmount = _swapMainState.value.tokenFromState?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
tokenToState = _swapMainState.value.tokenToState?.copy(
initialAmount = _swapMainState.value.tokenToState?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
)
}
Expand All @@ -414,11 +411,9 @@ class SwapViewModel @AssistedInject constructor(
selectMarketState = _swapMainState.value.market to availableMarkets,
tokenFromState = _swapMainState.value.tokenFromState?.copy(
initialAmount = _swapMainState.value.tokenFromState?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
tokenToState = _swapMainState.value.tokenToState?.copy(
initialAmount = _swapMainState.value.tokenToState?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
)
}
Expand All @@ -434,11 +429,9 @@ class SwapViewModel @AssistedInject constructor(
_swapMainState.value = _swapMainState.value.copy(
tokenFromState = _swapMainState.value.tokenFromState?.copy(
initialAmount = _swapMainState.value.tokenFromState?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
tokenToState = _swapMainState.value.tokenToState?.copy(
initialAmount = _swapMainState.value.tokenToState?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
)
}
Expand All @@ -455,11 +448,9 @@ class SwapViewModel @AssistedInject constructor(
_swapMainState.value = _swapMainState.value.copy(
tokenFromState = _swapMainState.value.tokenFromState?.copy(
initialAmount = _swapMainState.value.tokenFromState?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
tokenToState = _swapMainState.value.tokenToState?.copy(
initialAmount = _swapMainState.value.tokenToState?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
)
}
Expand Down Expand Up @@ -510,11 +501,9 @@ class SwapViewModel @AssistedInject constructor(
_swapMainState.value = _swapMainState.value.copy(
tokenFromState = _swapMainState.value.tokenToState?.copy(
initialAmount = _swapMainState.value.tokenToState?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
tokenToState = _swapMainState.value.tokenFromState?.copy(
initialAmount = _swapMainState.value.tokenFromState?.initialAmount?.nullZero(),
defaultCursorPosition = DefaultCursorPosition.END
),
)
setSwapButtonLoading(true)
Expand Down Expand Up @@ -827,16 +816,12 @@ class SwapViewModel @AssistedInject constructor(

fun onFromAmountChange(value: BigDecimal) {
_swapMainState.value = _swapMainState.value.copy(
tokenToState = _swapMainState.value.tokenToState?.copy(
defaultCursorPosition = DefaultCursorPosition.START
),
tokenFromState = _swapMainState.value.tokenFromState?.copy(
initialAmount = value,
amountFiat = _swapMainState.value.tokenFromState?.token?.printFiat(
value,
numbersFormatter
).orEmpty(),
defaultCursorPosition = DefaultCursorPosition.START
)
)
fromAmountOnEach()
Expand Down Expand Up @@ -987,13 +972,9 @@ class SwapViewModel @AssistedInject constructor(
amount = subtractFee(amount, transferable, networkFee)
}
_swapMainState.value = _swapMainState.value.copy(
tokenToState = _swapMainState.value.tokenToState?.copy(
defaultCursorPosition = DefaultCursorPosition.START
),
tokenFromState = _swapMainState.value.tokenFromState?.copy(
amountFiat = fromAsset.token.printFiat(amount, numbersFormatter),
initialAmount = amount,
defaultCursorPosition = DefaultCursorPosition.START
)
)
desired = WithDesired.INPUT
Expand Down

0 comments on commit 9c4d85e

Please sign in to comment.