Skip to content

Commit

Permalink
sca-8
Browse files Browse the repository at this point in the history
  • Loading branch information
arvifox committed Oct 4, 2023
1 parent 93f4a79 commit a7a92b9
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import jp.co.soramitsu.feature_select_node_api.SelectNodeRouter
import jp.co.soramitsu.feature_select_node_impl.presentation.nodeAddress
import jp.co.soramitsu.feature_select_node_impl.presentation.nodeName
import jp.co.soramitsu.feature_select_node_impl.presentation.pinCodeChecked
import jp.co.soramitsu.feature_sora_card_impl.presentation.get.card.GetSoraCardFragment
import jp.co.soramitsu.feature_sora_card_impl.presentation.GetSoraCardFragment
import jp.co.soramitsu.feature_wallet_api.launcher.WalletRouter
import jp.co.soramitsu.sora.R

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/navigation/main_nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

<fragment
android:id="@+id/soraCardDetailsFragment"
android:name="jp.co.soramitsu.feature_sora_card_impl.presentation.get.card.details.SoraCardDetailsFragment" />
android:name="jp.co.soramitsu.feature_sora_card_impl.presentation.details.SoraCardDetailsFragment" />

<include app:graph="@navigation/activities_nav_graph" />
<include app:graph="@navigation/profile_nav_graph" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import kotlin.math.pow
private const val DECIMAL_PATTERN_BASE = "###,###."
private const val TWO_DIGITS_PATTERN = "00"
const val nbspace = ' '
const val euro = ''

private const val DEFAULT_PRECISION = 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ interface SoraCardInteractor {

suspend fun fetchUserIbanAccount(): Result<String>

suspend fun fetchIbanBalance(): Result<Long>

suspend fun logOutFromSoraCard()
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ internal class SoraCardInteractorImpl @Inject constructor(
sorted.first().iban
}

override suspend fun fetchIbanBalance(): Result<Long> =
soraCardClientProxy.getIBAN().mapCatching { wrapper ->
val sorted = wrapper.ibans.sortedByDescending { it.createdDate }
sorted.first().availableBalance
}

override suspend fun logOutFromSoraCard() {
soraCardClientProxy.logout()
setLogout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

import android.os.Bundle
import android.view.View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.clickable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

data class GetSoraCardState(
val xorRatioAvailable: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.LiveData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
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
package jp.co.soramitsu.feature_sora_card_impl.presentation.details

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
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
package jp.co.soramitsu.feature_sora_card_impl.presentation.details

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
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
package jp.co.soramitsu.feature_sora_card_impl.presentation.details

import android.os.Bundle
import android.view.View
Expand Down Expand Up @@ -86,6 +86,7 @@ class SoraCardDetailsFragment : SoraBaseFragment<SoraCardDetailsViewModel>() {
composable(theOnlyRoute) {
val state = viewModel.soraCardDetailsScreenState.collectAsStateWithLifecycle()
SoraCardDetailsScreen(
scrollState = scrollState,
soraCardDetailsScreenState = state.value,
onShowSoraCardDetailsClick = viewModel::onShowSoraCardDetailsClick,
onSoraCardMenuActionClick = viewModel::onSoraCardMenuActionClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,34 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
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
package jp.co.soramitsu.feature_sora_card_impl.presentation.details

import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
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.BasicBannerCard
import jp.co.soramitsu.ui_core.resources.Dimens
import jp.co.soramitsu.ui_core.theme.customColors

data class SoraCardDetailsScreenState(
val soraCardMainSoraContentCardState: SoraCardMainSoraContentCardState,
val soraCardReferralBannerCardState: SoraCardReferralBannerCardState? = null,
val soraCardReferralBannerCardState: Boolean = false,
val soraCardRecentActivitiesCardState: SoraCardRecentActivitiesCardState? = null,
val soraCardIBANCardState: SoraCardIBANCardState? = null,
val soraCardSettingsCard: SoraCardSettingsCardState? = null,
Expand All @@ -60,6 +66,7 @@ data class SoraCardDetailsScreenState(

@Composable
fun SoraCardDetailsScreen(
scrollState: ScrollState,
soraCardDetailsScreenState: SoraCardDetailsScreenState,
onShowSoraCardDetailsClick: () -> Unit,
onSoraCardMenuActionClick: (position: Int) -> Unit,
Expand All @@ -71,66 +78,58 @@ fun SoraCardDetailsScreen(
onIbanCardClick: () -> Unit,
onSettingsOptionClick: (position: Int) -> Unit
) {
LazyColumn(
Column(
modifier = Modifier
.verticalScroll(scrollState)
.fillMaxSize()
.padding(horizontal = Dimens.x2),
verticalArrangement = Arrangement
.spacedBy(Dimens.x2),
horizontalAlignment = Alignment
.CenterHorizontally
.CenterHorizontally,
) {
item {
SoraCardMainSoraContentCard(
soraCardMainSoraContentCardState = soraCardDetailsScreenState.soraCardMainSoraContentCardState,
onShowMoreClick = onShowSoraCardDetailsClick,
onIconButtonClick = onSoraCardMenuActionClick
SoraCardMainSoraContentCard(
soraCardMainSoraContentCardState = soraCardDetailsScreenState.soraCardMainSoraContentCardState,
onShowMoreClick = onShowSoraCardDetailsClick,
onIconButtonClick = onSoraCardMenuActionClick
)
if (soraCardDetailsScreenState.soraCardReferralBannerCardState) {
BasicBannerCard(
imageContent = R.drawable.sora_card_referral_banner,
title = stringResource(id = R.string.sora_card_referral_headline),
description = "",
button = stringResource(id = R.string.sora_card_refer_and_earn_action),
onButtonClicked = onReferralBannerClick,
onCloseCard = onCloseReferralBannerClick,
)
}
soraCardDetailsScreenState.soraCardReferralBannerCardState?.let { state ->
item {
SoraCardReferralBannerCard(
soraCardReferralBannerCardState = state,
onReferAndEarnClick = onReferralBannerClick,
onCloseClick = onCloseReferralBannerClick
)
}
}
soraCardDetailsScreenState.soraCardRecentActivitiesCardState?.let { state ->
if (state.data.isNotEmpty())
item {
SoraCardRecentActivitiesCard(
soraCardRecentActivitiesCardState = state,
onListTileClick = onRecentActivityClick,
onShowMoreClick = onShowMoreRecentActivitiesClick
)
}
SoraCardRecentActivitiesCard(
soraCardRecentActivitiesCardState = state,
onListTileClick = onRecentActivityClick,
onShowMoreClick = onShowMoreRecentActivitiesClick
)
}
soraCardDetailsScreenState.soraCardIBANCardState?.let { state ->
item {
SoraCardIBANCard(
soraCardIBANCardState = state,
onShareClick = onIbanCardShareClick,
onCardClick = onIbanCardClick,
)
}
SoraCardIBANCard(
soraCardIBANCardState = state,
onShareClick = onIbanCardShareClick,
onCardClick = onIbanCardClick,
)
}
soraCardDetailsScreenState.soraCardSettingsCard?.let { state ->
if (state.settings.isNotEmpty())
item {
SoraCardSettingsCard(
state = state,
onItemClick = onSettingsOptionClick
)
}
}
item {
Spacer(
modifier = Modifier
.fillMaxWidth()
.height(Dimens.x5)
)
SoraCardSettingsCard(
state = state,
onItemClick = onSettingsOptionClick
)
}
Spacer(
modifier = Modifier
.fillMaxWidth()
.height(Dimens.x5)
)
}
}

Expand All @@ -145,13 +144,14 @@ private fun PreviewSoraCardDetailsScreen() {
.fillMaxSize()
) {
SoraCardDetailsScreen(
scrollState = rememberScrollState(),
soraCardDetailsScreenState = SoraCardDetailsScreenState(
soraCardMainSoraContentCardState = SoraCardMainSoraContentCardState(
balance = 3665.50f,
isCardEnabled = false,
soraCardMenuActions = SoraCardMenuAction.values().toList()
),
soraCardReferralBannerCardState = SoraCardReferralBannerCardState(),
soraCardReferralBannerCardState = true,
soraCardRecentActivitiesCardState = SoraCardRecentActivitiesCardState(
data = listOf()
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
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
package jp.co.soramitsu.feature_sora_card_impl.presentation.details

import androidx.lifecycle.LiveData
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -65,10 +65,10 @@ class SoraCardDetailsViewModel @Inject constructor(
soraCardMainSoraContentCardState = SoraCardMainSoraContentCardState(
balance = 0f,
isCardEnabled = false,
soraCardMenuActions = SoraCardMenuAction.values().toList()
soraCardMenuActions = SoraCardMenuAction.entries
),
soraCardSettingsCard = SoraCardSettingsCardState(
soraCardSettingsOptions = SoraCardSettingsOption.values().toList()
soraCardSettingsOptions = SoraCardSettingsOption.entries
),
logoutDialog = false,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
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
package jp.co.soramitsu.feature_sora_card_impl.presentation.details

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
Expand Down
Loading

0 comments on commit a7a92b9

Please sign in to comment.