Skip to content

Commit

Permalink
Change watchlist buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ant013 committed Feb 13, 2025
1 parent 9fa31b8 commit 03f188a
Show file tree
Hide file tree
Showing 19 changed files with 155 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "heart [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "heart [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "heart [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "heart [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum LaunchScreen: String, CaseIterable {
case .auto: return "settings_24"
case .balance: return "wallet_24"
case .marketOverview: return "markets_24"
case .watchlist: return "star_24"
case .watchlist: return "heart_24"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct CoinPageView: View {
Button(action: {
viewModel.isFavorite.toggle()
}) {
Image(viewModel.isFavorite ? "filled_star_24" : "star_24")
Image(viewModel.isFavorite ? "heart_filled_24" : "heart_24")
.renderingMode(.template)
.foregroundColor(viewModel.isFavorite ? .themeJacob : .themeGray)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ struct MarketAdvancedSearchResultsView: View {
diff: marketInfo.priceChangeValue(timePeriod: viewModel.timePeriod)
)
}
.watchlistSwipeActions(viewModel: watchlistViewModel, coinUid: coin.uid)
}
.onChange(of: viewModel.sortBy) { _ in withAnimation { proxy.scrollTo(themeListTopViewId) } }
}
Expand Down Expand Up @@ -140,30 +139,35 @@ struct MarketAdvancedSearchResultsView: View {
@ViewBuilder private func itemContent(coin: Coin?, indicatorResult: TechnicalAdvice.Advice?, marketCap: Decimal?, price: String, rank: Int?, diff: Decimal?) -> some View {
CoinIconView(coin: coin)

VStack(spacing: 1) {
HStack(spacing: .margin8) {
Text(coin?.code ?? "CODE").textBody()
HStack(spacing: .margin16) {
VStack(spacing: 1) {
HStack(spacing: .margin8) {
Text(coin?.code ?? "CODE").textBody()

if viewModel.showSignals, let signal = indicatorResult {
MarketWatchlistSignalBadge(signal: signal)
}
if viewModel.showSignals, let signal = indicatorResult {
MarketWatchlistSignalBadge(signal: signal)
}

Spacer()
Text(price).textBody()
}
Spacer()
Text(price).textBody()
}

HStack(spacing: .margin8) {
HStack(spacing: .margin4) {
if let rank {
BadgeViewNew(text: "\(rank)")
}
HStack(spacing: .margin8) {
HStack(spacing: .margin4) {
if let rank {
BadgeViewNew(text: "\(rank)")
}

if let marketCap, let formatted = ValueFormatter.instance.formatShort(currency: viewModel.currency, value: marketCap) {
Text(formatted).textSubhead2()
if let marketCap, let formatted = ValueFormatter.instance.formatShort(currency: viewModel.currency, value: marketCap) {
Text(formatted).textSubhead2()
}
}
Spacer()
DiffText(diff)
}
Spacer()
DiffText(diff)
}
if let coin {
WatchlistView.watchButton(viewModel: watchlistViewModel, coinUid: coin.uid)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ struct MarketSearchView: View {
Text(coin.code).themeBody()
Text(coin.name).themeSubhead2()
}

Spacer()

WatchlistView.watchButton(viewModel: watchlistViewModel, coinUid: coin.uid)
.contentShape(Rectangle())
.onTapGesture {}
}
.watchlistSwipeActions(viewModel: watchlistViewModel, coinUid: coin.uid)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct MarketWatchlistView: View {
}
case let .loaded(marketInfos, signals):
if marketInfos.isEmpty {
PlaceholderViewNew(image: Image("rate_48"), text: "market.watchlist.empty".localized)
PlaceholderViewNew(image: Image("heart_48"), text: "market.watchlist.empty".localized)
} else {
VStack(spacing: 0) {
header()
Expand Down Expand Up @@ -173,7 +173,7 @@ struct MarketWatchlistView: View {
Button(role: .destructive) {
viewModel.remove(coinUid: coin.uid)
} label: {
Image("star_off_24").renderingMode(.template)
Image("heart_broke_24").renderingMode(.template)
}
.tint(.themeLucian)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ struct WatchlistModifier: ViewModifier {
Button {
viewModel.remove(coinUid: coinUid)
} label: {
Image("star_off_24").renderingMode(.template)
Image("heart_broke_24").renderingMode(.template)
}
.tint(.themeLucian)
} else {
Button {
viewModel.add(coinUid: coinUid)
} label: {
Image("star_24").renderingMode(.template)
Image("heart_24").renderingMode(.template)
}
.tint(.themeJacob)
}
Expand All @@ -31,3 +31,33 @@ extension View {
modifier(WatchlistModifier(viewModel: viewModel, coinUid: coinUid))
}
}

enum WatchlistView {
@ViewBuilder static func watchButton(viewModel: WatchlistViewModel, coinUid: String) -> some View {
if viewModel.coinUids.contains(coinUid) {
Button {
viewModel.remove(coinUid: coinUid)
} label: {
Image("heart_fill_20")
.renderingMode(.template)
.foregroundColor(.themeJacob)
.frame(width: .iconSize20, height: .iconSize20)
}
.tappablePadding(.margin12, onTap: {
viewModel.remove(coinUid: coinUid)
})
} else {
Button {
viewModel.add(coinUid: coinUid)
} label: {
Image("heart_20")
.renderingMode(.template)
.foregroundColor(.themeGray)
.frame(width: .iconSize20, height: .iconSize20)
}
.tappablePadding(.margin12, onTap: {
viewModel.add(coinUid: coinUid)
})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ extension HudHelper {
var icon: UIImage? {
let image: UIImage?
switch self {
case .addedToWatchlist: image = UIImage(named: "star_24")
case .removedFromWatchlist: image = UIImage(named: "star_off_24")
case .addedToWatchlist: image = UIImage(named: "heart_24")
case .removedFromWatchlist: image = UIImage(named: "heart_broke_24")
case .addedToWallet: image = UIImage(named: "add_to_wallet_2_24")
case .removedFromWallet: image = UIImage(named: "empty_wallet_24")
case .alreadyAddedToWallet: image = UIImage(named: "warning_2_24")
Expand Down

0 comments on commit 03f188a

Please sign in to comment.