Skip to content

Commit df9d8ec

Browse files
authored
Remove dead code and minor cleanups (#537)
iOS: delete unused StateView; use displayScale in AsyncImageView; build TransactionStateViewModel once in titleTagTextValue. Android: hoist LocalUriHandler/LocalContext out of links list items; drop duplicate flow.map import; remove dead commented code in AssetItem and ImportScreen.
1 parent 1c054ad commit df9d8ec

7 files changed

Lines changed: 13 additions & 57 deletions

File tree

android/features/asset/presents/src/main/kotlin/com/gemwallet/android/features/asset/presents/chart/AssetChartScene.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.gemwallet.android.features.asset.presents.chart
22

3+
import android.content.Context
34
import androidx.compose.foundation.clickable
45
import com.gemwallet.android.ext.AddressFormatter
56
import androidx.compose.foundation.layout.Column
@@ -16,6 +17,7 @@ import androidx.compose.ui.Alignment
1617
import androidx.compose.ui.Modifier
1718
import androidx.compose.ui.platform.LocalContext
1819
import androidx.compose.ui.platform.LocalUriHandler
20+
import androidx.compose.ui.platform.UriHandler
1921
import androidx.compose.ui.platform.testTag
2022
import androidx.compose.ui.res.stringResource
2123
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
@@ -77,6 +79,8 @@ fun AssetChartScene(
7779
val isChartRefreshing by chartViewModel.isRefreshing.collectAsStateWithLifecycle()
7880
val pullToRefreshState = rememberPullToRefreshState()
7981
val snackbar = rememberSnackbarState(message = toastMessage, onShown = onToastShown)
82+
val uriHandler = LocalUriHandler.current
83+
val context = LocalContext.current
8084

8185
Scene(
8286
title = title,
@@ -112,7 +116,7 @@ fun AssetChartScene(
112116
assetContract(it.asset, it.explorerName)
113117
assetSupply(it.asset, it.marketInfo)
114118
assetAllTime(it.currency, it.asset, it.marketInfo)
115-
links(it.assetLinks)
119+
links(it.assetLinks, uriHandler, context)
116120
}
117121
}
118122
}
@@ -157,12 +161,10 @@ private fun PriceAlertsItem(
157161
)
158162
}
159163

160-
private fun LazyListScope.links(links: List<AssetMarketUIModel.Link>) {
164+
private fun LazyListScope.links(links: List<AssetMarketUIModel.Link>, uriHandler: UriHandler, context: Context) {
161165
if (links.isEmpty()) return
162166
item { SubheaderItem(R.string.social_links) }
163167
itemsIndexed(links) { index, item ->
164-
val uriHandler = LocalUriHandler.current
165-
val context = LocalContext.current
166168
PropertyItem(
167169
modifier = Modifier.clickable { uriHandler.open(context, item.url) },
168170
title = { PropertyTitleText(item.label, trailing = { AsyncImage(model = item.icon, size = smallIconSize) }) },

android/features/confirm/viewmodels/src/main/kotlin/com/gemwallet/android/features/confirm/viewmodels/ConfirmViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import kotlinx.coroutines.flow.flatMapLatest
4848
import kotlinx.coroutines.flow.map
4949
import kotlinx.coroutines.flow.flowOf
5050
import kotlinx.coroutines.flow.flowOn
51-
import kotlinx.coroutines.flow.map
5251
import kotlinx.coroutines.flow.mapNotNull
5352
import kotlinx.coroutines.flow.stateIn
5453
import kotlinx.coroutines.flow.update

android/features/import_wallet/presents/src/main/kotlin/com/gemwallet/android/features/import_wallet/views/ImportScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ private fun TypeSelection(
298298
modifier = Modifier.fillMaxWidth().clip(RoundedCornerShape(4.dp)),
299299
selectedTabIndex = importTypeTabIndex(importType.walletType, importType.chain),
300300
indicator = { Box {} },
301-
containerColor = Color.Transparent,//(0xFFEBEBEB),
301+
containerColor = Color.Transparent,
302302
divider = {}
303303
) {
304304
importWalletTabs(importType.chain).forEach { walletType ->

android/ui/src/main/kotlin/com/gemwallet/android/ui/components/list_item/AssetItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fun PriceInfo(
190190
Modifier.background(color.copy(alpha = alpha10), MaterialTheme.shapes.small)
191191
} else {
192192
Modifier
193-
},//.padding(horizontal = 4.dp),
193+
},
194194
text = changes,
195195
color = color,
196196
style = style,

ios/Packages/Components/Sources/AsyncImageView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Style
44
import SwiftUI
55

66
public struct AsyncImageView: View {
7+
@Environment(\.displayScale) private var displayScale
8+
79
let url: URL?
810
let size: CGFloat
911
let placeholder: Placeholder
@@ -23,7 +25,7 @@ public struct AsyncImageView: View {
2325
}
2426

2527
public var body: some View {
26-
CachedAsyncImage(url: url, scale: UIScreen.main.scale) {
28+
CachedAsyncImage(url: url, scale: displayScale) {
2729
$0.resizable()
2830
} placeholder: {
2931
switch placeholder {

ios/Packages/Components/Sources/StateView/StateView.swift

Lines changed: 0 additions & 43 deletions
This file was deleted.

ios/Packages/PrimitivesComponents/Sources/ViewModels/TransactionViewModel.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ public struct TransactionViewModel: Sendable {
154154
}
155155

156156
public var titleTagTextValue: TextValue? {
157+
let model = TransactionStateViewModel(state: transaction.transaction.state)
157158
let title: String? = switch transaction.transaction.state {
158159
case .confirmed: .none
159-
case .pending, .inTransit, .failed, .reverted: TransactionStateViewModel(state: transaction.transaction.state).title
160+
case .pending, .inTransit, .failed, .reverted: model.title
160161
}
161-
let model = TransactionStateViewModel(state: transaction.transaction.state)
162162
return title.map {
163163
TextValue(
164164
text: $0,
@@ -312,10 +312,6 @@ public struct TransactionViewModel: Sendable {
312312
}
313313
}
314314

315-
private var addressLink: BlockExplorerLink {
316-
explorerService.addressUrl(chain: assetId.chain, address: participant)
317-
}
318-
319315
private var assetId: AssetId {
320316
transaction.transaction.assetId
321317
}

0 commit comments

Comments
 (0)