Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sn-2891 token search feature #189

Merged
merged 1 commit into from
Sep 5, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,11 @@ class Navigator :
navController?.popBackStack()
}

override fun openQrCodeFlow(shouldNavigateToScannerDirectly: Boolean, isLaunchedFromSoraCard: Boolean) {
override fun openQrCodeFlow(shouldNavigateToScannerDirectly: Boolean) {
navController?.navigate(
R.id.qrCodeFlow,
QRCodeFlowFragment.createBundle(
shouldNavigateToScanner = shouldNavigateToScannerDirectly,
isLaunchedFromSoraCard = isLaunchedFromSoraCard
)
)
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ buildscript {
composeMaterial : '1.4.3',
composeCompiler : '1.4.6',
composeConstraintLayout: '1.1.0-alpha05',
uiCore : '0.1.0',
soraCard : '0.1.35',
uiCore : '0.1.2',
soraCard : '0.1.38',
lazySodium : '5.0.2',
jna : '5.8.0',
accompanist : '0.30.1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ abstract class SoraBaseFragment<T : BaseViewModel> : Fragment() {
onNavClick = { debounceClickHandler.debounceClick(::onNavClicked) },
onActionClick = viewModel::onAction,
onMenuItemClick = viewModel::onMenuItem,
onSearch = viewModel::onToolbarSearch,
)
}
) { padding ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ fun Toolbar(
onNavClick: (() -> Unit)? = null,
onActionClick: (() -> Unit)? = null,
onMenuItemClick: ((Action) -> Unit)? = null,
onSearch: ((String) -> Unit)? = null,
) {
if (toolbarState != null && toolbarState.basic.visibility) {
val elevation = remember(scrollState) {
Expand All @@ -111,6 +112,7 @@ fun Toolbar(
onNavigate = onNavClick,
onAction = onActionClick,
onMenuItemClicked = onMenuItemClick,
onSearch = onSearch,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,22 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import jp.co.soramitsu.common.R
import jp.co.soramitsu.common.presentation.compose.uikit.tokens.Image
import jp.co.soramitsu.common.presentation.compose.uikit.tokens.ScreenStatus
import jp.co.soramitsu.common.presentation.compose.uikit.tokens.Text
import jp.co.soramitsu.common.presentation.compose.uikit.tokens.retrievePainter
import jp.co.soramitsu.common.presentation.compose.uikit.tokens.retrieveString
import jp.co.soramitsu.ui_core.component.card.ContentCard
import jp.co.soramitsu.ui_core.resources.Dimens
import jp.co.soramitsu.ui_core.theme.customColors

data class LoadableContentCardState(
val screenStatus: ScreenStatus
) {
val isLoading: Boolean = screenStatus === ScreenStatus.LOADING

val isErrorCaught: Boolean = screenStatus === ScreenStatus.ERROR

val errorImage: Image = Image.ResImage(
id = R.drawable.ic_error_80
)

val errorText: Text = Text.StringRes(
id = R.string.common_error_general_title
)
}

@Composable
fun LoadableContentCard(
modifier: Modifier,
innerPadding: PaddingValues,
cornerRadius: Dp,
state: LoadableContentCardState,
state: ScreenStatus,
onTryAgainClick: () -> Unit,
contentWhenLoaded: @Composable () -> Unit,
) {
Expand All @@ -91,8 +73,8 @@ fun LoadableContentCard(
innerPadding = innerPadding,
cornerRadius = cornerRadius
) {
when {
state.isLoading -> {
when (state) {
ScreenStatus.LOADING -> {
Box {
CircularProgressIndicator(
modifier = Modifier
Expand All @@ -101,13 +83,13 @@ fun LoadableContentCard(
)
}
}
state.isErrorCaught -> {
ScreenStatus.ERROR -> {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Image(
painter = state.errorImage.retrievePainter(),
painter = painterResource(id = R.drawable.ic_error_80),
contentDescription = null
)
Divider(
Expand All @@ -118,7 +100,7 @@ fun LoadableContentCard(
modifier = Modifier.clickable {
onTryAgainClick.invoke()
},
text = state.errorText.retrieveString(),
text = stringResource(id = R.string.common_error_general_title),
)
}
}
Expand All @@ -139,9 +121,7 @@ private fun PreviewLoadableContentCard_LOADING() {
innerPadding = PaddingValues(
all = Dimens.x3
),
state = LoadableContentCardState(
screenStatus = ScreenStatus.LOADING
),
state = ScreenStatus.LOADING,
cornerRadius = Dimens.x4,
contentWhenLoaded = {
Box(modifier = Modifier.fillMaxSize()) {
Expand All @@ -166,9 +146,7 @@ private fun PreviewLoadableContentCard_READY_TO_RENDER() {
all = Dimens.x3
),
cornerRadius = Dimens.x4,
state = LoadableContentCardState(
screenStatus = ScreenStatus.READY_TO_RENDER
),
state = ScreenStatus.READY_TO_RENDER,
contentWhenLoaded = {
Box(modifier = Modifier.fillMaxSize()) {
Text(
Expand All @@ -191,9 +169,7 @@ private fun PreviewLoadableContentCard_ERROR() {
innerPadding = PaddingValues(
all = Dimens.x3
),
state = LoadableContentCardState(
screenStatus = ScreenStatus.ERROR
),
state = ScreenStatus.ERROR,
cornerRadius = Dimens.x4,
contentWhenLoaded = {
Box(modifier = Modifier.fillMaxSize()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ open class BaseViewModel : ViewModel() {

open fun onMenuItem(action: Action) = Unit

open fun onToolbarSearch(value: String) = Unit

open fun onAction() = Unit

suspend fun tryCatchFinally(finally: () -> Unit, block: suspend () -> Unit) {
Expand Down
6 changes: 0 additions & 6 deletions common/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<string name="common_activity">نشاط</string>
<string name="common_and">و</string>
<string name="common_app_version">إصدار التطبيق</string>
<string name="common_apy">APY</string>
<string name="common_arab">العربية</string>
<string name="common_azerbaijani">Azerbaijani</string>
<string name="common_back">رجوع</string>
Expand Down Expand Up @@ -345,8 +344,6 @@
<string name="polkaswap_insufficient_liqudity">سيولة غير كافية</string>
<string name="polkaswap_liquidity_fee">رسوم حوض السيولة</string>
<string name="polkaswap_liquidity_fee_info">يذهب جزء من كل صفقة إلى موفري السيولة كحوافز للبروتوكول.</string>
<string name="polkaswap_liquidity_synthetic_fee">Synthetic fee</string>
<string name="polkaswap_liquidity_synthetic_fee_desc">The synthetic fee is composed of a synthetic asset fee and a dynamic fee to prevent front-running. The synthetic asset fee is determined upon the asset registration and can be changed at any time through governance. The dynamic fee is based on the percentage change in the oracle price.</string>
<string name="polkaswap_liquidity_total_fee">Swap fee</string>
<string name="polkaswap_liquidity_total_fee_desc">Your swap involves both a Synthetic fee and an LP fee.\nThe Synthetic fee is accounted when the swap goes through the XST liquidity source for synthetic assets, and the LP fee when the swap goes through liquidity pools.</string>
<string name="polkaswap_market">سوق</string>
Expand All @@ -369,9 +366,6 @@
<string name="polkaswap_smart">ذكي</string>
<string name="polkaswap_swap_title">تبديل</string>
<string name="polkaswap_swapped">تمت المبادلة</string>
<string name="polkaswap_tbc">TBC</string>
<string name="polkaswap_xyk">XYK</string>
<string name="pool_apy_title">APY المكافأة الاستراتيجية</string>
<string name="pool_button_remove">إزالة</string>
<string name="pool_details">تفاصيل المسبح</string>
<string name="pool_liquidity_placeholder">سيولتك ستظهر هنا</string>
Expand Down
6 changes: 0 additions & 6 deletions common/src/main/res/values-az/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<string name="common_activity">Fəaliyyət</string>
<string name="common_and">və</string>
<string name="common_app_version">Proqram versiyası</string>
<string name="common_apy">APY</string>
<string name="common_arab">Ərəb dili</string>
<string name="common_azerbaijani">Azerbaijani</string>
<string name="common_back">Geri</string>
Expand Down Expand Up @@ -341,8 +340,6 @@
<string name="polkaswap_insufficient_liqudity">Qeyri-kifayət qədər likvidlik</string>
<string name="polkaswap_liquidity_fee">LP haqqı</string>
<string name="polkaswap_liquidity_fee_info">Hər bir ticarətin bir hissəsi protokol təşviqi olaraq likvidlik təminatçılarına keçir.</string>
<string name="polkaswap_liquidity_synthetic_fee">Sintetik token haqqı</string>
<string name="polkaswap_liquidity_synthetic_fee_desc">Sintetik ödəniş sintetik aktiv haqqı və qabaqcadan qaçmağın qarşısını almaq üçün dinamik ödənişdən ibarətdir. Sintetik aktivin haqqı aktivin qeydiyyatı zamanı müəyyən edilir və istənilən vaxt idarəetmə vasitəsilə dəyişdirilə bilər. Dinamik ödəniş oracle qiymətindəki faiz dəyişikliyinə əsaslanır.</string>
<string name="polkaswap_liquidity_total_fee">Ümumi ödəniş</string>
<string name="polkaswap_liquidity_total_fee_desc">Ümumi ödəniş ödənişdən ibarətdir</string>
<string name="polkaswap_market">Bazar</string>
Expand All @@ -365,9 +362,6 @@
<string name="polkaswap_smart">Ağıllı</string>
<string name="polkaswap_swap_title">Mübadilə edin</string>
<string name="polkaswap_swapped">Dəyişdirildi</string>
<string name="polkaswap_tbc">TBC</string>
<string name="polkaswap_xyk">XYK</string>
<string name="pool_apy_title">Strateji bonus apy</string>
<string name="pool_button_remove">Sil</string>
<string name="pool_details">Pool details</string>
<string name="pool_liquidity_placeholder">Likvidliyiniz burada görünəcək</string>
Expand Down
6 changes: 0 additions & 6 deletions common/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<string name="common_activity">Activity</string>
<string name="common_and">und</string>
<string name="common_app_version">App-Version</string>
<string name="common_apy">APY</string>
<string name="common_arab">Arabisch</string>
<string name="common_azerbaijani">Azerbaijani</string>
<string name="common_back">Zurück</string>
Expand Down Expand Up @@ -341,8 +340,6 @@
<string name="polkaswap_insufficient_liqudity">Unzureichende Liquidität</string>
<string name="polkaswap_liquidity_fee">LP-Gebühr</string>
<string name="polkaswap_liquidity_fee_info">Ein Teil jeder Trade geht als Protokollanreiz an die Liquiditätsanbieter.</string>
<string name="polkaswap_liquidity_synthetic_fee">Synthetic fee</string>
<string name="polkaswap_liquidity_synthetic_fee_desc">The synthetic fee is composed of a synthetic asset fee and a dynamic fee to prevent front-running. The synthetic asset fee is determined upon the asset registration and can be changed at any time through governance. The dynamic fee is based on the percentage change in the oracle price.</string>
<string name="polkaswap_liquidity_total_fee">Swap fee</string>
<string name="polkaswap_liquidity_total_fee_desc">Your swap involves both a Synthetic fee and an LP fee.\nThe Synthetic fee is accounted when the swap goes through the XST liquidity source for synthetic assets, and the LP fee when the swap goes through liquidity pools.</string>
<string name="polkaswap_market">Markt</string>
Expand All @@ -365,9 +362,6 @@
<string name="polkaswap_smart">Smart</string>
<string name="polkaswap_swap_title">Tausch</string>
<string name="polkaswap_swapped">Getauscht</string>
<string name="polkaswap_tbc">TBC</string>
<string name="polkaswap_xyk">XYK</string>
<string name="pool_apy_title">Strategischer Bonus APY</string>
<string name="pool_button_remove">Entfernen</string>
<string name="pool_details">Pool details</string>
<string name="pool_liquidity_placeholder">Du hast noch keine aktiven Pools.\nFüge Liquidität hinzu, um Belohnungen zu erhalten</string>
Expand Down
6 changes: 0 additions & 6 deletions common/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<string name="common_activity">Activity</string>
<string name="common_and">y</string>
<string name="common_app_version">App version</string>
<string name="common_apy">APY</string>
<string name="common_arab">Árabe</string>
<string name="common_azerbaijani">Azerbaijani</string>
<string name="common_back">Atrás</string>
Expand Down Expand Up @@ -341,8 +340,6 @@
<string name="polkaswap_insufficient_liqudity">Liquidez insuficiente</string>
<string name="polkaswap_liquidity_fee">Tarifa LP</string>
<string name="polkaswap_liquidity_fee_info">Una porción de cada trade va a los proveedores de liquidez como incentivo del protocolo</string>
<string name="polkaswap_liquidity_synthetic_fee">Synthetic fee</string>
<string name="polkaswap_liquidity_synthetic_fee_desc">The synthetic fee is composed of a synthetic asset fee and a dynamic fee to prevent front-running. The synthetic asset fee is determined upon the asset registration and can be changed at any time through governance. The dynamic fee is based on the percentage change in the oracle price.</string>
<string name="polkaswap_liquidity_total_fee">Swap fee</string>
<string name="polkaswap_liquidity_total_fee_desc">Your swap involves both a Synthetic fee and an LP fee.\nThe Synthetic fee is accounted when the swap goes through the XST liquidity source for synthetic assets, and the LP fee when the swap goes through liquidity pools.</string>
<string name="polkaswap_market">Mercado</string>
Expand All @@ -365,9 +362,6 @@
<string name="polkaswap_smart">Inteligente</string>
<string name="polkaswap_swap_title">Intercambiar</string>
<string name="polkaswap_swapped">Intercambiado</string>
<string name="polkaswap_tbc">TBC</string>
<string name="polkaswap_xyk">XYK</string>
<string name="pool_apy_title">Strategic bonus apy</string>
<string name="pool_button_remove">Remove</string>
<string name="pool_details">Detalles de la Liquidez</string>
<string name="pool_liquidity_placeholder">You don\'t have any active pools yet.\nAdd liquidity to earn rewards</string>
Expand Down
6 changes: 0 additions & 6 deletions common/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<string name="common_activity">Activity</string>
<string name="common_and">و</string>
<string name="common_app_version">نسخه App</string>
<string name="common_apy">APY</string>
<string name="common_arab">عرب</string>
<string name="common_azerbaijani">Azerbaijani</string>
<string name="common_back">بازگشت</string>
Expand Down Expand Up @@ -341,8 +340,6 @@
<string name="polkaswap_insufficient_liqudity">نقدینگی ناکافی</string>
<string name="polkaswap_liquidity_fee">هزینه LP</string>
<string name="polkaswap_liquidity_fee_info">بخشی از هر معامله به عنوان مشوق پروتکل به ارائه دهندگان نقدینگی می‌رسد.</string>
<string name="polkaswap_liquidity_synthetic_fee">Synthetic fee</string>
<string name="polkaswap_liquidity_synthetic_fee_desc">The synthetic fee is composed of a synthetic asset fee and a dynamic fee to prevent front-running. The synthetic asset fee is determined upon the asset registration and can be changed at any time through governance. The dynamic fee is based on the percentage change in the oracle price.</string>
<string name="polkaswap_liquidity_total_fee">Swap fee</string>
<string name="polkaswap_liquidity_total_fee_desc">Your swap involves both a Synthetic fee and an LP fee.\nThe Synthetic fee is accounted when the swap goes through the XST liquidity source for synthetic assets, and the LP fee when the swap goes through liquidity pools.</string>
<string name="polkaswap_market">بازار</string>
Expand All @@ -365,9 +362,6 @@
<string name="polkaswap_smart">هوشمند</string>
<string name="polkaswap_swap_title">تبدیل</string>
<string name="polkaswap_swapped">مبادله شد</string>
<string name="polkaswap_tbc">TBC</string>
<string name="polkaswap_xyk">XYK</string>
<string name="pool_apy_title">نرخ سود سالانه پاداش استراتژیک</string>
<string name="pool_button_remove">حذف</string>
<string name="pool_details">Pool details</string>
<string name="pool_liquidity_placeholder">شما هنوز هیچ مخزن فعالی ندارید. برای کسب پاداش، نقدینگی اضافه کنید</string>
Expand Down
6 changes: 0 additions & 6 deletions common/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<string name="common_activity">Activity</string>
<string name="common_and">ja</string>
<string name="common_app_version">Sovelluksen versio</string>
<string name="common_apy">APY</string>
<string name="common_arab">Arab</string>
<string name="common_azerbaijani">Azerbaijani</string>
<string name="common_back">Takaisin</string>
Expand Down Expand Up @@ -341,8 +340,6 @@
<string name="polkaswap_insufficient_liqudity">Riittämätön likviditeetti</string>
<string name="polkaswap_liquidity_fee">LP-maksu</string>
<string name="polkaswap_liquidity_fee_info">Osa jokaisesta kaupasta menee likviditeetin tarjoajille protokollakannustimena.</string>
<string name="polkaswap_liquidity_synthetic_fee">Synthetic fee</string>
<string name="polkaswap_liquidity_synthetic_fee_desc">The synthetic fee is composed of a synthetic asset fee and a dynamic fee to prevent front-running. The synthetic asset fee is determined upon the asset registration and can be changed at any time through governance. The dynamic fee is based on the percentage change in the oracle price.</string>
<string name="polkaswap_liquidity_total_fee">Swap fee</string>
<string name="polkaswap_liquidity_total_fee_desc">Your swap involves both a Synthetic fee and an LP fee.\nThe Synthetic fee is accounted when the swap goes through the XST liquidity source for synthetic assets, and the LP fee when the swap goes through liquidity pools.</string>
<string name="polkaswap_market">Market</string>
Expand All @@ -365,9 +362,6 @@
<string name="polkaswap_smart">Smart</string>
<string name="polkaswap_swap_title">Swap</string>
<string name="polkaswap_swapped">Swapped</string>
<string name="polkaswap_tbc">TBC</string>
<string name="polkaswap_xyk">XYK</string>
<string name="pool_apy_title">Strateginen bonus apy</string>
<string name="pool_button_remove">Poista</string>
<string name="pool_details">Pool details</string>
<string name="pool_liquidity_placeholder">Likviditeettisi näkyy täällä</string>
Expand Down
Loading