Skip to content

Commit

Permalink
Refactor list item view (#40)
Browse files Browse the repository at this point in the history
* Project strucutre updates
* Refactored ListItemView, added previews with different states moved ListItemVIew to Lists folder
* Moved ListItemProgressView from ListItemView, since it has more then 1 dependency.  Also used in TransactionsScene separately
* Moved System Image to Styles, added necessary imports Style, removed SystemImage.infoCircle. Since it's repeated image and we don't need it
* TextStyle moved from Components package to Style package, added necessary Style package imports to Gem
ListItemView minor change
* Refactored ListItemView & Text Style added defaults value, ListItemView decorated with TextValueView instead of combo text & style. 
* Added defaults values for TextStyle, Added TextStyle.Preview - to have ability see colors in packages previews
* Updated Gem dependency with style init
* Renamed TextValueView to TextValue. Created Types folder, moved Value Types(not views) to Types
* git submodules updated
  • Loading branch information
gemdev111 authored Jun 10, 2024
1 parent b1efeec commit c3480e0
Show file tree
Hide file tree
Showing 24 changed files with 297 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import SwiftUI
import Primitives
import Components
import Style

struct SelectAssetSceneNavigationStack: View {

Expand Down
1 change: 1 addition & 0 deletions Gem/Assets/Scenes/SelectAssetScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Components
import Settings
import Store
import GRDBQuery
import Style

struct SelectAssetScene: View {

Expand Down
12 changes: 6 additions & 6 deletions Gem/Assets/ViewModels/AssetListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ struct AssetListViewModel: AssetListViewable {
switch type {
case .wallet:
return .price(
price: TextValueView(
price: TextValue(
text: assetDataModel.priceAmountText,
style: TextStyle(font: .system(size: 14), color: Colors.gray)
),
priceChangePercentage24h: TextValueView(
priceChangePercentage24h: TextValue(
text: assetDataModel.priceChangeText,
style: TextStyle(font: .system(size: 14), color: assetDataModel.priceChangeTextColor)
)
Expand All @@ -64,9 +64,9 @@ struct AssetListViewModel: AssetListViewable {
return .none
case .token:
return .type(
TextValueView(
TextValue(
text: assetDataModel.asset.chain.asset.name,
style: TextStyle(font: Font.system(.callout), color: .secondary)
style: .calloutSecondary
)
)
}
Expand All @@ -77,11 +77,11 @@ struct AssetListViewModel: AssetListViewable {
switch type {
case .wallet, .view:
return .balance(
balance: TextValueView(
balance: TextValue(
text: assetDataModel.totalBalanceTextWithSymbol,
style: TextStyle(font: .system(size: 16, weight: .semibold), color: assetDataModel.balanceTextColor)
),
totalFiat: TextValueView(
totalFiat: TextValue(
text: assetDataModel.fiatBalanceText,
style: TextStyle(font: .system(size: 14), color: Colors.gray)
)
Expand Down
14 changes: 5 additions & 9 deletions Gem/Assets/ViewModels/AssetSceneViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,14 @@ class AssetSceneViewModel: ObservableObject {
return AssetIdViewModel(assetId: assetModel.asset.chain.assetId).assetImage
}

var priceView: TextValueView {
return TextValueView(
var priceView: TextValue {
return TextValue(
text: assetDataModel.priceAmountText,
style: TextStyle(
font: .callout,
color: .secondary
)
)
style: .calloutSecondary)
}

var priceChangeView: TextValueView {
return TextValueView(
var priceChangeView: TextValue {
return TextValue(
text: assetDataModel.priceChangeText,
style: TextStyle(
font: .callout,
Expand Down
1 change: 1 addition & 0 deletions Gem/Connections/Scenes/ConnectionsScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Store
import Primitives
import Components
import QRScanner
import Style

struct ConnectionsScene: View {

Expand Down
1 change: 1 addition & 0 deletions Gem/Connections/Views/ConnectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import SwiftUI
import Components
import Style

struct ConnectionView: View {

Expand Down
1 change: 1 addition & 0 deletions Gem/Core/Views/AddressListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import SwiftUI
import Primitives
import GemstonePrimitives
import Components
import Style

struct SimpleAccount {
let name: String?
Expand Down
2 changes: 1 addition & 1 deletion Gem/Stake/Scenes/StakeScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct StakeScene: View {
titleStyleExtra: TextStyle(font: .footnote, color: delegation.stateTextColor),
subtitle: delegation.balanceText,
subtitleExtra: delegation.completionDateText,
subtitleStyleExtra: TextStyle(font: .footnote, color: .secondary)
subtitleStyleExtra: .footnote
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Gem/Stake/ViewModels/StakeDelegationViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct StakeDelegationViewModel {
}

var balanceTextStyle: TextStyle {
TextStyle(font: Font.system(.body), color: .primary)
.body
}

var validatorText: String {
Expand Down
2 changes: 1 addition & 1 deletion Gem/Stake/ViewModels/StakeDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct StakeDetailViewModel {
if stakeApr > 0 {
return TextStyle(font: .callout, color: Colors.green)
}
return TextStyle(font: .callout, color: .secondary)
return .callout
}

var validatorText: String {
Expand Down
2 changes: 1 addition & 1 deletion Gem/Transactions/ViewModels/TransactionViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ struct TransactionViewModel {
}

var subtitleExtraStyle: TextStyle {
TextStyle(font: Font.system(.footnote), color: .secondary)
.footnote
}

var participant: String {
Expand Down
1 change: 1 addition & 0 deletions Gem/Transactions/Views/TransactionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import SwiftUI
import Components
import Primitives
import Style

struct TransactionView: View {
let model: TransactionViewModel
Expand Down
1 change: 1 addition & 0 deletions Gem/Transfer/ViewsModels/ConfirmTransferViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Blockchain
import BigInt
import Components
import Signer
import Style
import GemstonePrimitives

class ConfirmTransferViewModel: ObservableObject {
Expand Down
2 changes: 1 addition & 1 deletion Gem/Wallet/Views/WalletHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct WalletHeaderView: View {
Button {
UIApplication.shared.open(Docs.url(.whatIsWatchWallet))
} label: {
Image(systemName: SystemImage.infoCircle)
Image(systemName: SystemImage.info)
.tint(Colors.black)
}
}
Expand Down
10 changes: 5 additions & 5 deletions Packages/Components/Sources/AssetListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import SwiftUI
import Style

public enum AssetListRightView {
case balance(balance: TextValueView, totalFiat: TextValueView)
case balance(balance: TextValue, totalFiat: TextValue)
case toggle(Bool)
case copy
}

public enum AssetListSubtitleView {
case price(price: TextValueView, priceChangePercentage24h: TextValueView)
case type(TextValueView)
case price(price: TextValue, priceChangePercentage24h: TextValue)
case type(TextValue)
case none
}

Expand Down Expand Up @@ -201,8 +201,8 @@ struct AssetListView_Previews: PreviewProvider {
),
subtitleView: .none,
rightView: .balance(
balance: TextValueView(text: "test", style: TextStyle(font: .title, color: .accentColor)),
totalFiat: TextValueView(text: "test2", style: TextStyle(font: .title, color: .accentColor))
balance: TextValue(text: "test", style: TextStyle(font: .title, color: .accentColor)),
totalFiat: TextValue(text: "test2", style: TextStyle(font: .title, color: .accentColor))
)
)
)
Expand Down
Loading

0 comments on commit c3480e0

Please sign in to comment.