Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions FRW.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,8 @@
4E722F362ED9A96600627AAD /* EOAPrivateKeyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E722F342ED9A96600627AAD /* EOAPrivateKeyView.swift */; };
4E722F382ED9AF8B00627AAD /* LinkedAccountDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E722F372ED9AF8B00627AAD /* LinkedAccountDetailViewModel.swift */; };
4E722F392ED9AF8B00627AAD /* LinkedAccountDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E722F372ED9AF8B00627AAD /* LinkedAccountDetailViewModel.swift */; };
4E73FAC12F2A378200AF2711 /* EarnButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E73FAC02F2A378200AF2711 /* EarnButton.swift */; };
4E73FAC22F2A378200AF2711 /* EarnButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E73FAC02F2A378200AF2711 /* EarnButton.swift */; };
4E7712E12E3B2AD70011C1DA /* RNBridgeError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7712E02E3B2AD70011C1DA /* RNBridgeError.swift */; };
4E7712E22E3B2AD70011C1DA /* RNBridgeError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7712E02E3B2AD70011C1DA /* RNBridgeError.swift */; };
4E777CAE2B1ECF8900300A3E /* SyncInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E777CAD2B1ECF8900300A3E /* SyncInfo.swift */; };
Expand Down Expand Up @@ -3226,6 +3228,7 @@
4E7153232E97564D00C5D0BA /* RouteMap+Dev.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RouteMap+Dev.swift"; sourceTree = "<group>"; };
4E722F342ED9A96600627AAD /* EOAPrivateKeyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EOAPrivateKeyView.swift; sourceTree = "<group>"; };
4E722F372ED9AF8B00627AAD /* LinkedAccountDetailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkedAccountDetailViewModel.swift; sourceTree = "<group>"; };
4E73FAC02F2A378200AF2711 /* EarnButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EarnButton.swift; sourceTree = "<group>"; };
4E7712E02E3B2AD70011C1DA /* RNBridgeError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNBridgeError.swift; sourceTree = "<group>"; };
4E777CAD2B1ECF8900300A3E /* SyncInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncInfo.swift; sourceTree = "<group>"; };
4E777CB02B1EE69E00300A3E /* WalletConnect+SyncDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WalletConnect+SyncDevice.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4185,6 +4188,7 @@
15362A172DA02BA1008F4E51 /* VisualEffectView.swift */,
15362A1A2DA02BCD008F4E51 /* CoinCell.swift */,
4EB2C3092DC0E2F900E79FC5 /* FilterButton.swift */,
4E73FAC02F2A378200AF2711 /* EarnButton.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -9273,6 +9277,7 @@
4ED4831B2DA515FC00AA23E6 /* BlocklistHandler.swift in Sources */,
6A06CB1128AA54A600C81BE1 /* NFTUIKitGridStyleHandler.swift in Sources */,
1586370D2D6BF1EC0083A068 /* TokenBalanceListView.swift in Sources */,
4E73FAC22F2A378200AF2711 /* EarnButton.swift in Sources */,
6AC476ED28F40E50008503E6 /* BrowserBookmarkView.swift in Sources */,
4E1A8B702B71A7FA00485EDE /* MultiBackupConfirmPinViewModel.swift in Sources */,
6A8FA4B4285B192900EE5BE3 /* ScrollView+SnappableModifier.swift in Sources */,
Expand Down Expand Up @@ -10374,6 +10379,7 @@
15C58BAD2868A4EE00BD4FC6 /* ScrollView+SnappableModifier.swift in Sources */,
4ED4831A2DA515FC00AA23E6 /* BlocklistHandler.swift in Sources */,
6AC476EC28F40E50008503E6 /* BrowserBookmarkView.swift in Sources */,
4E73FAC12F2A378200AF2711 /* EarnButton.swift in Sources */,
1586370C2D6BF1EC0083A068 /* TokenBalanceListView.swift in Sources */,
15C58BAE2868A4EE00BD4FC6 /* VNavigationViewNavigationBar.swift in Sources */,
4E1A8B6F2B71A7FA00485EDE /* MultiBackupConfirmPinViewModel.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions FRW/Foundation/Define/AppUrl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ import Foundation
enum AppUrl {
static let cadenceSwapUrl = "https://app.increment.fi"
static let evmSwapUrl = "https://swap.flow.com"
static let earnUrl = "" //TODO: #six 3.1.1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The earnUrl is set to an empty string with a TODO comment. This will cause the button to always show an error message ("don't have earn url") when clicked since URL(string: "") returns nil. Consider either:

  1. Setting showEarnButton to false until the URL is available
  2. Adding a proper placeholder URL
  3. Hiding the button when the URL is empty

}
37 changes: 37 additions & 0 deletions FRW/Modules/Wallet/View/EarnButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// EarnButton.swift
// FRW
//
// Created by cat on 28/1/26.
//

import SwiftUI

struct EarnButton: View {
var body: some View {
Button {
if let url = URL(string: AppUrl.earnUrl) {
Router.route(to: RouteMap.Explore.browser(url))
} else {
HUD.error(title: "don't have earn url")
}
} label: {
HStack(spacing: 10) {
Text("earn".localized)
.font(.inter(size: 16, weight: .medium))
.foregroundStyle(Color.Brain.Core.icons)
Image("earn_icon")
.resizable()
.frame(width: 20, height: 20)
}
.frame(height: 40)
.padding(.horizontal, 12)
.background(Color.Brain.Light.lines10)
.cornerRadius(20)
}
}
}

#Preview {
EarnButton()
}
6 changes: 5 additions & 1 deletion FRW/Modules/Wallet/WalletHomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,11 @@ struct WalletHomeView: View {
.font(.inter(size: 18, weight: .bold))
.foregroundStyle(Color.Theme.Text.black3)
Spacer()


if vm.showEarnButton {
EarnButton()
}

CircleButton(image: .menu) {
vm.onClickManagerToken()
}
Expand Down
5 changes: 4 additions & 1 deletion FRW/Modules/Wallet/WalletViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ final class WalletViewModel: ObservableObject {

@Published
var walletAccount: WalletAccount? = nil


@Published
var showEarnButton: Bool = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The showEarnButton is hardcoded to true. Consider deriving this value from whether AppUrl.earnUrl is empty or not, e.g., var showEarnButton: Bool { !AppUrl.earnUrl.isEmpty }. This would prevent showing a non-functional button.


var needShowPlaceholder: Bool {
isMock || walletState == .noAddress
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "earn_icon.svg",
"idiom" : "universal"
}
],
"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.