Skip to content

Commit

Permalink
Implement new design for Markets
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed May 15, 2024
1 parent c049b8c commit 31ab354
Show file tree
Hide file tree
Showing 28 changed files with 1,030 additions and 674 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ dependencies {
implementation 'com.github.horizontalsystems:ethereum-kit-android:3d83900'
implementation 'com.github.horizontalsystems:blockchain-fee-rate-kit-android:1d3bd49'
implementation 'com.github.horizontalsystems:binance-chain-kit-android:c1509a2'
implementation 'com.github.horizontalsystems:market-kit-android:a0361bf'
implementation 'com.github.horizontalsystems:market-kit-android:1327f85'
implementation 'com.github.horizontalsystems:solana-kit-android:d8bb9f2'
implementation 'com.github.horizontalsystems:tron-kit-android:dc3dca7'
// Zcash SDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ class MarketKitWrapper(

fun topMoversSingle(currencyCode: String) = marketKit.topMoversSingle(currencyCode)

fun topCoinsMarketInfosSingle(top: Int, currencyCode: String) = marketKit.topCoinsMarketInfosSingle(top, currencyCode)

// Chart Info

fun chartStartTimeSingle(coinUid: String) = marketKit.chartStartTimeSingle(coinUid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,12 @@ val TimeDuration.statPeriod: StatPeriod

val MarketModule.Tab.statTab: StatTab
get() = when (this) {
MarketModule.Tab.Overview -> StatTab.Overview
MarketModule.Tab.Posts -> StatTab.News
MarketModule.Tab.Watchlist -> StatTab.Watchlist
MarketModule.Tab.Coins -> TODO()
MarketModule.Tab.Platform -> TODO()
MarketModule.Tab.Pairs -> TODO()
MarketModule.Tab.Sectors -> TODO()
}

val MarketSearchSection.statSection: StatSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import io.horizontalsystems.bankwallet.core.stats.statTab
import io.horizontalsystems.bankwallet.modules.balance.ui.BalanceScreen
import io.horizontalsystems.bankwallet.modules.main.MainModule.MainNavigation
import io.horizontalsystems.bankwallet.modules.manageaccount.dialogs.BackupRequiredDialog
import io.horizontalsystems.bankwallet.modules.market.MarketScreen
import io.horizontalsystems.bankwallet.modules.market.overviewxxx.MarketScreenXxx
import io.horizontalsystems.bankwallet.modules.rateapp.RateApp
import io.horizontalsystems.bankwallet.modules.releasenotes.ReleaseNotesFragment
import io.horizontalsystems.bankwallet.modules.rooteddevice.RootedDeviceModule
Expand Down Expand Up @@ -217,7 +217,7 @@ private fun MainScreen(
verticalAlignment = Alignment.Top
) { page ->
when (uiState.mainNavItems[page].mainNavItem) {
MainNavigation.Market -> MarketScreen(fragmentNavController)
MainNavigation.Market -> MarketScreenXxx(fragmentNavController)
MainNavigation.Balance -> BalanceScreen(fragmentNavController)
MainNavigation.Transactions -> TransactionsScreen(
fragmentNavController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ object MarketModule {
}

enum class Tab(@StringRes val titleResId: Int) {
Overview(R.string.Market_Tab_Overview),
Coins(R.string.Market_Tab_Coins),
Watchlist(R.string.Market_Tab_Watchlist),
Posts(R.string.Market_Tab_Posts),
Watchlist(R.string.Market_Tab_Watchlist);
Platform(R.string.Market_Tab_Platform),
Pairs(R.string.Market_Tab_Pairs),
Sectors(R.string.Market_Tab_Sectors);

companion object {
private val map = values().associateBy(Tab::name)
private val map = entries.associateBy(Tab::name)

fun fromString(type: String?): Tab? = map[type]
}
Expand Down Expand Up @@ -142,8 +145,10 @@ enum class MarketField(@StringRes val titleResId: Int) : WithTranslatableTitle,
}

@Parcelize
enum class TopMarket(val value: Int) : WithTranslatableTitle, Parcelable {
Top100(100), Top200(200), Top300(300);
enum class TopMarket(val value: Int, val titleResId: Int) : WithTranslatableTitle, Parcelable {
Top100(100, R.string.Market_Top_100),
Top200(200, R.string.Market_Top_200),
Top300(300, R.string.Market_Top_300);

fun next() = values()[if (ordinal == values().size - 1) 0 else ordinal + 1]

Expand Down Expand Up @@ -195,6 +200,7 @@ fun MarketInfo.priceChangeValue(period: TimePeriod) = when (period) {
TimePeriod.TimePeriod_1W -> priceChange7d
TimePeriod.TimePeriod_2W -> priceChange14d
TimePeriod.TimePeriod_1M -> priceChange30d
TimePeriod.TimePeriod_3M -> priceChange90d
TimePeriod.TimePeriod_6M -> priceChange200d
TimePeriod.TimePeriod_1Y -> priceChange1y
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.horizontalsystems.bankwallet.modules.market
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -17,9 +16,6 @@ import io.horizontalsystems.bankwallet.core.stats.StatEvent
import io.horizontalsystems.bankwallet.core.stats.StatPage
import io.horizontalsystems.bankwallet.core.stats.stat
import io.horizontalsystems.bankwallet.core.stats.statTab
import io.horizontalsystems.bankwallet.modules.market.favorites.MarketFavoritesScreen
import io.horizontalsystems.bankwallet.modules.market.overview.MarketOverviewScreen
import io.horizontalsystems.bankwallet.modules.market.posts.MarketPostsScreen
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.TranslatableString
import io.horizontalsystems.bankwallet.ui.compose.components.AppBar
Expand Down Expand Up @@ -73,15 +69,15 @@ fun MarketScreen(navController: NavController) {
stat(page = StatPage.Markets, event = StatEvent.SwitchTab(it.statTab))
})

HorizontalPager(
state = pagerState,
userScrollEnabled = false
) { page ->
when (tabs[page]) {
MarketModule.Tab.Overview -> MarketOverviewScreen(navController)
MarketModule.Tab.Posts -> MarketPostsScreen()
MarketModule.Tab.Watchlist -> MarketFavoritesScreen(navController)
}
}
// HorizontalPager(
// state = pagerState,
// userScrollEnabled = false
// ) { page ->
// when (tabs[page]) {
// MarketModule.Tab.Overview -> MarketOverviewScreen(navController)
// MarketModule.Tab.Posts -> MarketPostsScreen()
// MarketModule.Tab.Watchlist -> MarketFavoritesScreen(navController)
// }
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import io.horizontalsystems.bankwallet.entities.LaunchPage

class MarketViewModel(private val service: MarketService) : ViewModel() {

Expand All @@ -17,9 +16,10 @@ class MarketViewModel(private val service: MarketService) : ViewModel() {
selectedTab = tab
}

private fun getInitialTab() = when (service.launchPage) {
LaunchPage.Market -> MarketModule.Tab.Overview
LaunchPage.Watchlist -> MarketModule.Tab.Watchlist
else -> service.currentTab ?: MarketModule.Tab.Overview
}
private fun getInitialTab() = MarketModule.Tab.Watchlist
// when (service.launchPage) {
// LaunchPage.Market -> MarketModule.Tab.Overview
// LaunchPage.Watchlist -> MarketModule.Tab.Watchlist
// else -> service.currentTab ?: MarketModule.Tab.Overview
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.horizontalsystems.bankwallet.modules.market.favorites

import androidx.compose.animation.Crossfade
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
Expand All @@ -26,7 +25,6 @@ import io.horizontalsystems.bankwallet.entities.ViewState
import io.horizontalsystems.bankwallet.modules.coin.CoinFragment
import io.horizontalsystems.bankwallet.modules.coin.overview.ui.Loading
import io.horizontalsystems.bankwallet.modules.market.favorites.MarketFavoritesModule.Period
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.HSSwipeRefresh
import io.horizontalsystems.bankwallet.ui.compose.Select
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonSecondaryCircle
Expand Down Expand Up @@ -57,7 +55,6 @@ fun MarketFavoritesScreen(
) {
Crossfade(
targetState = viewState,
modifier = Modifier.background(color = ComposeAppTheme.colors.tyler),
label = ""
) { viewState ->
when (viewState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import androidx.lifecycle.ViewModelProvider
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.App
import io.horizontalsystems.bankwallet.modules.market.MarketItem
import io.horizontalsystems.bankwallet.ui.compose.TranslatableString
import io.horizontalsystems.bankwallet.ui.compose.WithTranslatableTitle
import io.horizontalsystems.marketkit.models.Analytics.TechnicalAdvice.Advice
import io.horizontalsystems.marketkit.models.Blockchain
import io.reactivex.Single
Expand Down Expand Up @@ -150,18 +152,22 @@ enum class Range(@StringRes val titleResId: Int, val values: Pair<Long?, Long?>)
}
}

enum class TimePeriod(@StringRes val titleResId: Int) {
enum class TimePeriod(@StringRes val titleResId: Int): WithTranslatableTitle {
TimePeriod_1D(R.string.Market_Filter_TimePeriod_1D),
TimePeriod_1W(R.string.Market_Filter_TimePeriod_1W),
TimePeriod_2W(R.string.Market_Filter_TimePeriod_2W),
TimePeriod_1M(R.string.Market_Filter_TimePeriod_1M),
TimePeriod_3M(R.string.Market_Filter_TimePeriod_3M),
TimePeriod_6M(R.string.Market_Filter_TimePeriod_6M),
TimePeriod_1Y(R.string.Market_Filter_TimePeriod_1Y),
TimePeriod_1Y(R.string.Market_Filter_TimePeriod_1Y);

override val title: TranslatableString
get() = TranslatableString.ResString(titleResId)
}

enum class PriceChange(
@StringRes val titleResId: Int,
@ColorRes val color: TextColor,
val color: TextColor,
val values: Pair<Long?, Long?>
) {
Positive_10_plus(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import io.horizontalsystems.bankwallet.modules.market.overview.ui.MetricChartsVi
import io.horizontalsystems.bankwallet.modules.market.overview.ui.TopPairsBoardView
import io.horizontalsystems.bankwallet.modules.market.overview.ui.TopPlatformsBoardView
import io.horizontalsystems.bankwallet.modules.market.overview.ui.TopSectorsBoardView
import io.horizontalsystems.bankwallet.modules.market.topcoins.MarketTopCoinsFragment
import io.horizontalsystems.bankwallet.ui.compose.HSSwipeRefresh
import io.horizontalsystems.bankwallet.ui.compose.components.ListErrorView
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer
Expand Down Expand Up @@ -81,14 +80,14 @@ fun MarketOverviewScreen(
listType
)

navController.slideFromBottom(
R.id.marketTopCoinsFragment,
MarketTopCoinsFragment.Input(
sortingField,
topMarket,
marketField
)
)
// navController.slideFromBottom(
// R.id.marketTopCoinsFragment,
// MarketTopCoinsFragment.Input(
// sortingField,
// topMarket,
// marketField
// )
// )

stat(page = StatPage.MarketOverview, section = listType.statSection, event = StatEvent.Open(StatPage.TopCoins))
},
Expand Down Expand Up @@ -129,10 +128,10 @@ fun MarketOverviewScreen(
onClickSeeAll = {
val timeDuration = viewModel.topPlatformsTimeDuration

navController.slideFromBottom(
R.id.marketTopPlatformsFragment,
timeDuration
)
// navController.slideFromBottom(
// R.id.marketTopPlatformsFragment,
// timeDuration
// )

stat(page = StatPage.MarketOverview, event = StatEvent.Open(StatPage.TopPlatforms))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.horizontalsystems.bankwallet.modules.market.overviewxxx

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import io.horizontalsystems.bankwallet.core.App
import io.horizontalsystems.bankwallet.modules.market.MarketModule
import io.horizontalsystems.bankwallet.modules.metricchart.MetricsType

object MarketModuleXxx {

class Factory : ViewModelProvider.Factory {

@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return MarketViewModelXxx(
App.marketStorage,
App.marketKit,
App.currencyManager,
App.localStorage
) as T
}

}

data class UiState(
val selectedTab: MarketModule.Tab,
val marketOverviewItems: List<MarketOverviewViewItem>
)

data class MarketOverviewViewItem(
val title: String,
val value: String,
val change: String,
val changePositive: Boolean,
val metricsType: MetricsType,
)

}
Loading

0 comments on commit 31ab354

Please sign in to comment.