-
Notifications
You must be signed in to change notification settings - Fork 7
feat: earn button on home #2337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
| .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() | ||
| } | ||
| 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() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,7 +184,10 @@ final class WalletViewModel: ObservableObject { | |
|
|
||
| @Published | ||
| var walletAccount: WalletAccount? = nil | ||
|
|
||
|
|
||
| @Published | ||
| var showEarnButton: Bool = true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
| var needShowPlaceholder: Bool { | ||
| isMock || walletState == .noAddress | ||
| } | ||
|
|
||
| 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 | ||
| } | ||
| } |
| 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 | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
earnUrlis 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 sinceURL(string: "")returnsnil. Consider either:showEarnButtontofalseuntil the URL is available