Skip to content

Commit

Permalink
sn-2862 rtl
Browse files Browse the repository at this point in the history
  • Loading branch information
arvifox committed Sep 13, 2023
1 parent d7ae6d4 commit 65a9270
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
This file is part of the SORA network and Polkaswap app.
Copyright (c) 2020, 2021, Polka Biome Ltd. All rights reserved.
SPDX-License-Identifier: BSD-4-Clause
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
All advertising materials mentioning features or use of this software must display
the following acknowledgement: This product includes software developed by Polka Biome
Ltd., SORA, and Polkaswap.
Neither the name of the Polka Biome Ltd. nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY Polka Biome Ltd. AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Polka Biome Ltd. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package jp.co.soramitsu.common.presentation.compose.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import jp.co.soramitsu.common.R
import jp.co.soramitsu.ui_core.resources.Dimens

@Composable
fun SoraCardImage(
modifier: Modifier = Modifier,
) {
Box(
modifier = modifier,
) {
Image(
modifier = Modifier.fillMaxWidth(),
painter = painterResource(id = R.drawable.sora_card),
contentDescription = "",
contentScale = ContentScale.FillWidth,
)
Image(
modifier = Modifier
.padding(start = Dimens.x2, top = Dimens.x2)
.wrapContentSize(),
painter = painterResource(id = R.drawable.ic_sora_on_card),
contentDescription = "",
contentScale = ContentScale.Fit,
)
}
}

@Composable
@Preview(locale = "en")
private fun PreviewSoraCardImage1() {
SoraCardImage(
modifier = Modifier.fillMaxWidth().wrapContentHeight()
)
}

@Composable
@Preview(locale = "ar")
private fun PreviewSoraCardImage2() {
SoraCardImage(
modifier = Modifier.fillMaxWidth().wrapContentHeight()
)
}

@Composable
@Preview(locale = "he")
private fun PreviewSoraCardImage3() {
SoraCardImage(
modifier = Modifier.fillMaxWidth().wrapContentHeight()
)
}
Binary file modified common/src/main/res/drawable-hdpi/sora_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed common/src/main/res/drawable-ldpi/sora_card.png
Binary file not shown.
Binary file not shown.
Binary file modified common/src/main/res/drawable-mdpi/sora_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified common/src/main/res/drawable-xhdpi/sora_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified common/src/main/res/drawable-xxhdpi/sora_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified common/src/main/res/drawable-xxxhdpi/sora_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions common/src/main/res/drawable/ic_sora_on_card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="89dp"
android:height="18dp"
android:viewportWidth="89"
android:viewportHeight="18">
<path
android:pathData="M71.189,9.184L72.456,8.623C73.027,9.857 73.562,11.092 74.061,12.314L72.765,12.831C72.331,11.784 71.802,10.568 71.189,9.184ZM79.228,8.61C79.18,10.437 78.936,11.909 78.491,13.018C78.051,14.128 77.373,14.97 76.457,15.55C75.542,16.129 74.311,16.516 72.759,16.728L72.509,15.431C73.52,15.275 74.346,15.057 74.995,14.777C75.637,14.496 76.172,14.085 76.606,13.542C77.034,13 77.349,12.333 77.551,11.541C77.741,10.749 77.848,9.745 77.884,8.536L79.228,8.61Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M80.43,11.315L88.349,11.315L88.349,11.564C88.349,13.242 87.832,14.532 86.797,15.424C85.763,16.315 84.175,16.82 82.035,16.939L81.833,15.673C83.307,15.592 84.467,15.305 85.311,14.819C86.155,14.333 86.678,13.591 86.881,12.587L80.43,12.587L80.43,11.321L80.43,11.315ZM81.167,9.837L81.167,8.572L87.743,8.572L87.743,9.837L81.167,9.837Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M0,12.009L2.735,12.009C2.735,13.405 3.704,14.827 6.374,14.827C8.805,14.827 9.947,13.63 9.947,12.164C9.947,10.949 8.954,10.157 6.932,9.951L5.446,9.814C2.497,9.564 0.606,7.806 0.606,5.1C0.606,2.008 2.842,0 6.267,0C9.691,0 11.968,2.052 11.968,5.238L9.233,5.238C9.233,3.86 8.288,2.55 6.267,2.55C4.245,2.55 3.318,3.748 3.318,5.1C3.318,6.185 4.073,7.083 5.684,7.22L7.17,7.357C10.482,7.675 12.682,9.321 12.682,12.164C12.682,15.257 10.208,17.376 6.38,17.376C2.289,17.376 0.012,15.12 0.012,12.009L0,12.009Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M15.163,8.916L15.163,8.417C15.163,4.42 17.898,-0 23.404,-0C28.909,-0 31.644,4.42 31.644,8.417L31.644,8.916C31.644,12.569 29.04,17.376 23.404,17.376C17.743,17.376 15.163,12.569 15.163,8.916ZM28.826,8.691C28.826,5.306 26.739,2.712 23.404,2.712C20.068,2.712 17.958,5.306 17.958,8.691C17.958,11.896 20.044,14.67 23.404,14.67C26.763,14.67 28.826,11.896 28.826,8.691Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M45.211,16.945L41.358,11.302L38.367,11.302L38.367,16.945L35.591,16.945L35.591,0.36L41.209,0.36C44.89,0.36 47.232,2.05 47.232,5.666L47.232,6.028C47.232,8.534 46.091,10.111 44.176,10.835L48.481,16.951L45.211,16.951L45.211,16.945ZM38.367,8.889L41.554,8.889C43.32,8.889 44.438,7.674 44.438,5.891C44.438,4.107 43.32,2.867 41.554,2.867L38.367,2.867L38.367,8.889Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M61.044,12.413L54.028,12.413L52.566,16.952L49.789,16.952L55.235,0.48L59.795,0.48L65.408,16.952L62.548,16.952L61.044,12.413ZM60.206,9.932L57.881,2.961L57.084,2.961L54.825,9.932L60.206,9.932Z"
android:fillColor="#ffffff"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package jp.co.soramitsu.feature_sora_card_impl.presentation.get.card

import androidx.compose.foundation.Image
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
Expand All @@ -47,12 +46,12 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.tooling.preview.Preview
import jp.co.soramitsu.common.R
import jp.co.soramitsu.common.presentation.compose.components.SoraCardImage
import jp.co.soramitsu.common.util.ext.testTagAsId
import jp.co.soramitsu.ui_core.component.button.FilledButton
import jp.co.soramitsu.ui_core.component.button.properties.Order
Expand Down Expand Up @@ -84,10 +83,8 @@ fun GetSoraCardScreen(
.fillMaxSize()
.padding(Dimens.x2)
) {
Image(
SoraCardImage(
modifier = Modifier.fillMaxWidth(),
painter = painterResource(R.drawable.sora_card),
contentDescription = null
)

Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,27 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package jp.co.soramitsu.feature_sora_card_impl.presentation.get.card.details

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import jp.co.soramitsu.common.R
import jp.co.soramitsu.common.presentation.compose.components.SoraCardImage
import jp.co.soramitsu.common.presentation.compose.uikit.tokens.Image
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.button.BleachedButton
import jp.co.soramitsu.ui_core.component.button.properties.Order
import jp.co.soramitsu.ui_core.component.button.properties.Size
Expand All @@ -70,34 +68,9 @@ enum class SoraCardMenuAction {
data class SoraCardMainSoraContentCardState(
val balance: Float,
val isCardEnabled: Boolean,
val soraCardMenuActions: List<SoraCardMenuAction>
val soraCardMenuActions: List<SoraCardMenuAction>,
) {

val soraImage: Image
get() = Image.ResImage(
id = R.drawable.sora_card
)

val showDetailsText: Text
get() = Text.StringRes(
id = R.string.show_more
)

val soraCardText: Text
get() = Text.StringRes(
id = R.string.more_menu_sora_card_title
)

val soraCardBalanceText: Text
get() = Text.SimpleText(
text = "$balance"
)

val soraCardManagementComingSoonText: Text
get() = Text.StringRes(
id = R.string.sora_card_details_card_management_coming_soon
)

val menuState: List<IconButtonMenuState>
get() = soraCardMenuActions.map {
when (it) {
Expand Down Expand Up @@ -141,7 +114,6 @@ fun SoraCardMainSoraContentCard(
) {
ContentCard(
cornerRadius = Dimens.x4,
onClick = remember { { /* DO NOTHING */ } }
) {
Column(
modifier = Modifier
Expand All @@ -153,12 +125,7 @@ fun SoraCardMainSoraContentCard(
Box(
modifier = Modifier.wrapContentSize()
) {
Image(
modifier = Modifier.fillMaxWidth(),
painter = soraCardMainSoraContentCardState.soraImage.retrievePainter(),
contentDescription = "",
contentScale = ContentScale.FillWidth
)
SoraCardImage(modifier = Modifier.fillMaxWidth().wrapContentHeight())
if (soraCardMainSoraContentCardState.isCardEnabled)
BleachedButton(
modifier = Modifier
Expand All @@ -168,7 +135,7 @@ fun SoraCardMainSoraContentCard(
shape = CircleShape,
size = Size.Small,
order = Order.SECONDARY,
text = soraCardMainSoraContentCardState.showDetailsText.retrieveString(),
text = stringResource(id = R.string.show_more),
onClick = onShowMoreClick
)
}
Expand All @@ -182,20 +149,20 @@ fun SoraCardMainSoraContentCard(
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = soraCardMainSoraContentCardState.soraCardText.retrieveString(),
text = stringResource(id = R.string.more_menu_sora_card_title),
style = MaterialTheme.customTypography.headline2,
color = MaterialTheme.customColors.fgPrimary
)
Text(
text = soraCardMainSoraContentCardState.soraCardBalanceText.retrieveString(),
text = "%.5f".format(soraCardMainSoraContentCardState.balance),
style = MaterialTheme.customTypography.headline2,
color = MaterialTheme.customColors.fgPrimary
)
}
else
Text(
modifier = Modifier.fillMaxWidth(),
text = soraCardMainSoraContentCardState.soraCardManagementComingSoonText.retrieveString(),
text = stringResource(id = R.string.sora_card_details_card_management_coming_soon),
style = MaterialTheme.customTypography.textS,
color = MaterialTheme.customColors.fgSecondary,
textAlign = TextAlign.Center
Expand All @@ -208,13 +175,27 @@ fun SoraCardMainSoraContentCard(
}
}

@Preview
@Preview(locale = "ru")
@Composable
private fun PreviewMainSoraContentCard() {
SoraCardMainSoraContentCard(
soraCardMainSoraContentCardState = SoraCardMainSoraContentCardState(
balance = 3644.50f,
isCardEnabled = false,
isCardEnabled = true,
soraCardMenuActions = SoraCardMenuAction.values().toList()
),
onShowMoreClick = {},
onIconButtonClick = { _ -> }
)
}

@Preview(locale = "ar")
@Composable
private fun PreviewMainSoraContentCard2() {
SoraCardMainSoraContentCard(
soraCardMainSoraContentCardState = SoraCardMainSoraContentCardState(
balance = 3644.50f,
isCardEnabled = true,
soraCardMenuActions = SoraCardMenuAction.values().toList()
),
onShowMoreClick = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package jp.co.soramitsu.feature_wallet_impl.presentation.cardshub

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -45,11 +44,11 @@ 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.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import jp.co.soramitsu.common.R
import jp.co.soramitsu.common.presentation.compose.components.SoraCardImage
import jp.co.soramitsu.common.util.ext.testTagAsId
import jp.co.soramitsu.common_wallet.presentation.compose.states.SoraCardState
import jp.co.soramitsu.ui_core.component.button.BleachedButton
Expand All @@ -74,11 +73,8 @@ fun SoraCard(
.clickable { onCardStateClicked() }
.fillMaxWidth()
) {
Image(
SoraCardImage(
modifier = Modifier.fillMaxWidth(),
painter = painterResource(R.drawable.sora_card),
contentDescription = null,
contentScale = ContentScale.FillWidth
)

CardStateButton(
Expand Down Expand Up @@ -149,12 +145,23 @@ private fun CardStateButton(
}

@Composable
@Preview
private fun PreviewSoraCard() {
@Preview(locale = "en")
private fun PreviewSoraCard1() {
SoraCard(
modifier = Modifier.fillMaxWidth(),
state = SoraCardState(kycStatus = "", success = true, visible = true),
onCloseClicked = {},
onCardStateClicked = {}
)
}

@Composable
@Preview(locale = "he")
private fun PreviewSoraCard2() {
SoraCard(
modifier = Modifier.fillMaxWidth(),
state = SoraCardState(kycStatus = "Pending", success = false, visible = true),
onCloseClicked = {},
onCardStateClicked = {}
)
}

0 comments on commit 65a9270

Please sign in to comment.