diff --git a/Features/Stake/Sources/Scenes/EarnScene.swift b/Features/Stake/Sources/Scenes/EarnScene.swift index 299a6ec8b..207a727dd 100644 --- a/Features/Stake/Sources/Scenes/EarnScene.swift +++ b/Features/Stake/Sources/Scenes/EarnScene.swift @@ -15,6 +15,8 @@ public struct EarnScene: View { public var body: some View { List { + ListAssetHeaderView(model: model.assetModel) + switch model.providersState { case .noData: Section { @@ -24,7 +26,7 @@ public struct EarnScene: View { ListItemLoadingView() .id(UUID()) case .data: - Section(model.assetTitle) { + Section { ListItemView( title: model.aprModel.title, subtitle: model.aprModel.subtitle diff --git a/Features/Stake/Sources/Scenes/StakeScene.swift b/Features/Stake/Sources/Scenes/StakeScene.swift index 0dc4f9821..81303903d 100644 --- a/Features/Stake/Sources/Scenes/StakeScene.swift +++ b/Features/Stake/Sources/Scenes/StakeScene.swift @@ -17,6 +17,7 @@ public struct StakeScene: View { public var body: some View { List { + headerSection stakeInfoSection if model.showManage { stakeSection @@ -42,6 +43,10 @@ public struct StakeScene: View { // MARK: - UI Components extension StakeScene { + private var headerSection: some View { + ListAssetHeaderView(model: model.assetModel) + } + private var stakeSection: some View { Section(Localized.Common.manage) { if model.showStake { @@ -97,7 +102,7 @@ extension StakeScene { } private var stakeInfoSection: some View { - Section(model.assetTitle) { + Section { ListItemView( title: model.stakeAprModel.title, subtitle: model.stakeAprModel.subtitle, diff --git a/Features/Stake/Sources/ViewModels/EarnSceneViewModel.swift b/Features/Stake/Sources/ViewModels/EarnSceneViewModel.swift index 068c07dba..1b80efa79 100644 --- a/Features/Stake/Sources/ViewModels/EarnSceneViewModel.swift +++ b/Features/Stake/Sources/ViewModels/EarnSceneViewModel.swift @@ -49,7 +49,10 @@ public final class EarnSceneViewModel { } var title: String { Localized.Common.earn } - var assetTitle: String { AssetViewModel(asset: asset).title } + + var assetModel: AssetViewModel { + AssetViewModel(asset: asset) + } private var apr: Double? { providers.first.map(\.apr).flatMap { $0 > 0 ? $0 : nil } diff --git a/Features/Stake/Sources/ViewModels/StakeSceneViewModel.swift b/Features/Stake/Sources/ViewModels/StakeSceneViewModel.swift index bb977f64c..3f60dd244 100644 --- a/Features/Stake/Sources/ViewModels/StakeSceneViewModel.swift +++ b/Features/Stake/Sources/ViewModels/StakeSceneViewModel.swift @@ -59,7 +59,6 @@ public final class StakeSceneViewModel { var stakeTitle: String { Localized.Transfer.Stake.title } var claimRewardsTitle: String { Localized.Transfer.ClaimRewards.title } - var assetTitle: String { assetModel.title } var delegationsTitle: String { Localized.Stake.delegations } var stakeAprModel: AprViewModel { @@ -240,7 +239,7 @@ extension StakeSceneViewModel { return formatter }() - private var assetModel: AssetViewModel { + var assetModel: AssetViewModel { AssetViewModel(asset: asset) } diff --git a/Features/WalletConnector/Sources/WalletConnector/Scenes/ConnectionProposalScene.swift b/Features/WalletConnector/Sources/WalletConnector/Scenes/ConnectionProposalScene.swift index 72a3e06cc..f2f474fad 100644 --- a/Features/WalletConnector/Sources/WalletConnector/Scenes/ConnectionProposalScene.swift +++ b/Features/WalletConnector/Sources/WalletConnector/Scenes/ConnectionProposalScene.swift @@ -21,12 +21,7 @@ public struct ConnectionProposalScene: View { public var body: some View { List { - Section { } header: { - AssetPreviewView(model: model.appPreview, subtitleLayout: .vertical) - .frame(maxWidth: .infinity) - .padding(.bottom, .small) - } - .cleanListRow() + ListAssetHeaderView(model: model.appPreview, subtitleLayout: .vertical) Section { NavigationLink(value: Scenes.SelectWallet()) { diff --git a/Features/WalletConnector/Sources/WalletConnector/Scenes/SignMessageScene.swift b/Features/WalletConnector/Sources/WalletConnector/Scenes/SignMessageScene.swift index 0bf11f72d..71435cd56 100644 --- a/Features/WalletConnector/Sources/WalletConnector/Scenes/SignMessageScene.swift +++ b/Features/WalletConnector/Sources/WalletConnector/Scenes/SignMessageScene.swift @@ -21,12 +21,7 @@ public struct SignMessageScene: View { public var body: some View { List { - Section { } header: { - AssetPreviewView(model: model.appPreview, subtitleLayout: .vertical) - .frame(maxWidth: .infinity) - .padding(.bottom, .small) - } - .cleanListRow() + ListAssetHeaderView(model: model.appPreview, subtitleLayout: .vertical) Section { ListItemImageView( diff --git a/Packages/PrimitivesComponents/Sources/Views/ListAssetHeaderView.swift b/Packages/PrimitivesComponents/Sources/Views/ListAssetHeaderView.swift new file mode 100644 index 000000000..7fd8e7933 --- /dev/null +++ b/Packages/PrimitivesComponents/Sources/Views/ListAssetHeaderView.swift @@ -0,0 +1,24 @@ +// Copyright (c). Gem Wallet. All rights reserved. + +import SwiftUI +import Components +import Style + +public struct ListAssetHeaderView: View { + private let model: Model + private let subtitleLayout: AssetPreviewView.SubtitleLayout + + public init(model: Model, subtitleLayout: AssetPreviewView.SubtitleLayout = .horizontal) { + self.model = model + self.subtitleLayout = subtitleLayout + } + + public var body: some View { + Section { } header: { + AssetPreviewView(model: model, subtitleLayout: subtitleLayout) + .frame(maxWidth: .infinity) + .padding(.bottom, .small) + } + .cleanListRow() + } +}