Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
12 changes: 12 additions & 0 deletions FRW.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,10 @@
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 */; };
4E73FAC42F2A3C1200AF2711 /* EarnBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E73FAC32F2A3C1200AF2711 /* EarnBanner.swift */; };
4E73FAC52F2A3C1200AF2711 /* EarnBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E73FAC32F2A3C1200AF2711 /* EarnBanner.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 +3230,8 @@
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>"; };
4E73FAC32F2A3C1200AF2711 /* EarnBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EarnBanner.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 +4191,8 @@
15362A172DA02BA1008F4E51 /* VisualEffectView.swift */,
15362A1A2DA02BCD008F4E51 /* CoinCell.swift */,
4EB2C3092DC0E2F900E79FC5 /* FilterButton.swift */,
4E73FAC02F2A378200AF2711 /* EarnButton.swift */,
4E73FAC32F2A3C1200AF2711 /* EarnBanner.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -8675,6 +8683,7 @@
153749082E26FDD60040E3F8 /* SPPopoverController.swift in Sources */,
153749092E26FDD60040E3F8 /* SPDimmedButton+Colorise.swift in Sources */,
1537490A2E26FDD60040E3F8 /* UISwitchExtension.swift in Sources */,
4E73FAC52F2A3C1200AF2711 /* EarnBanner.swift in Sources */,
1537490B2E26FDD60040E3F8 /* UIFontExtension.swift in Sources */,
1537490C2E26FDD60040E3F8 /* SPCollectionViewController.swift in Sources */,
1537490D2E26FDD60040E3F8 /* CollectionExtension.swift in Sources */,
Expand Down Expand Up @@ -9273,6 +9282,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 @@ -9776,6 +9786,7 @@
153749602E26FDD60040E3F8 /* SPPopoverController.swift in Sources */,
153749612E26FDD60040E3F8 /* SPDimmedButton+Colorise.swift in Sources */,
153749622E26FDD60040E3F8 /* UISwitchExtension.swift in Sources */,
4E73FAC42F2A3C1200AF2711 /* EarnBanner.swift in Sources */,
153749632E26FDD60040E3F8 /* UIFontExtension.swift in Sources */,
153749642E26FDD60040E3F8 /* SPCollectionViewController.swift in Sources */,
153749652E26FDD60040E3F8 /* CollectionExtension.swift in Sources */,
Expand Down Expand Up @@ -10374,6 +10385,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
Copy link
Copy Markdown

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

}
4 changes: 4 additions & 0 deletions FRW/Modules/Wallet/TokenDetail/TokenDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ struct TokenDetailView: RouteableView {
.visibility(showAccessibleWarning() ? .visible : .gone)

summaryView
if vm.showEarnBanner {
EarnBanner()
}

unverifiedTokenView
.visibility(vm.token.isVerifiedValue ? .gone : .visible)

Expand Down
4 changes: 3 additions & 1 deletion FRW/Modules/Wallet/TokenDetail/TokenDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ class TokenDetailViewModel: ObservableObject {
var showStorageView: Bool { token.isFlowCoin && wallet.selectedAccount?.type == .main }

var isTokenDetailsButtonEnabled: Bool { token.website.isNotNullNorEmpty }


@Published
var showEarnBanner: Bool = !AppUrl.earnUrl.isEmpty
// MARK: Private

private var cancelSets = Set<AnyCancellable>()
Expand Down
63 changes: 63 additions & 0 deletions FRW/Modules/Wallet/View/EarnBanner.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// EarnBanner.swift
// FRW
//
// Created by cat on 28/1/26.
//

import SwiftUI

struct EarnBanner: 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(alignment: .center, spacing: 0) {
VStack(alignment: .leading, spacing: 4) {
Text("Don’t miss out on $1,203 this year")
.font(.inter(size: 14))
.lineLimit(1)
.foregroundStyle(Color.white)

Text("Earn 15% APY on Flow Vaults")
.font(.inter(size: 16, weight: .semibold))
.lineLimit(1)
.foregroundStyle(Color.Brain.Primary.main)
}
Spacer()
Image("earn_icon_36")
.resizable()
.frame(width: 20, height: 20)
.padding(8)
.background(Color.Brain.Primary.main)
.clipShape(Circle())
}
.padding(18)
.frame(width: .infinity, alignment: .leading)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using .frame(width: .infinity, ...) is incorrect syntax. To make the view expand to fill available width, use .frame(maxWidth: .infinity, alignment: .leading) instead.

.background(
LinearGradient(
stops: [
Gradient.Stop(color: Color(red: 0.1, green: 0.1, blue: 0.1), location: 0.00),
Gradient.Stop(color: Color(red: 0, green: 0.94, blue: 0.55), location: 1.00),
],
startPoint: UnitPoint(x: 0.75, y: 1),
endPoint: UnitPoint(x: 0.75, y: -5)
)
)
.cornerRadius(16)
.overlay(
RoundedRectangle(cornerRadius: 16)
.inset(by: 0.25)
.stroke(Color(red: 0.09, green: 1, blue: 0.6), lineWidth: 0.5)
)
}
}
}

#Preview {
EarnBanner()
}
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 = !AppUrl.earnUrl.isEmpty

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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "earn_icon_36.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.