Skip to content
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

ABW-1671 Info Buttons and Sheet #1293

Merged
merged 41 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
182a73b
works
kugel3 Aug 12, 2024
a72c469
minor
kugel3 Aug 13, 2024
fd4f9f7
with parsing
kugel3 Aug 13, 2024
521e2ca
parsing complete
kugel3 Aug 13, 2024
a9035b0
glossary anchor
kugel3 Aug 13, 2024
3d59e64
infolink
kugel3 Aug 14, 2024
fc9fe7a
wip
kugel3 Aug 14, 2024
c80a532
wip
kugel3 Aug 14, 2024
0728d4f
wip
kugel3 Aug 21, 2024
1724a6d
cleanup
kugel3 Aug 22, 2024
c865ef7
refactoring
kugel3 Aug 22, 2024
e15b70c
Infobutton
kugel3 Aug 22, 2024
0a79290
wip
kugel3 Aug 22, 2024
614f3f5
with strings
kugel3 Aug 22, 2024
ffa1e24
Scroll to top
kugel3 Aug 22, 2024
63504fd
faster fade
kugel3 Aug 23, 2024
e520ae8
transaction fee button
kugel3 Aug 23, 2024
6a48766
Empty asset list buttons
kugel3 Aug 26, 2024
395f0e7
Personas
kugel3 Aug 26, 2024
2ca8fb4
AuthorizedDapps
kugel3 Aug 26, 2024
8058dd8
in customize guarantees
kugel3 Aug 26, 2024
052ceb9
gateways
kugel3 Aug 26, 2024
7cb7184
intro to personas
kugel3 Aug 26, 2024
24f1de7
create/edit persona
kugel3 Aug 26, 2024
9de808c
Eliminate SlideUpPanel
kugel3 Aug 26, 2024
d757361
Remove debug code
kugel3 Aug 26, 2024
669cce0
behaviours
kugel3 Aug 26, 2024
a38aa0b
works
kugel3 Aug 27, 2024
386e299
refactor
kugel3 Aug 27, 2024
7574fa0
Move closebutton
kugel3 Aug 27, 2024
6f8960a
Move hebaviours button
kugel3 Aug 27, 2024
deb8461
Use string
kugel3 Aug 27, 2024
558c365
aligment
kugel3 Aug 28, 2024
d204205
Move files
kugel3 Aug 28, 2024
8467c66
Allow expanding
kugel3 Aug 28, 2024
2d38468
Show/hide title
kugel3 Aug 28, 2024
4da5cb1
Add blur
kugel3 Aug 28, 2024
7322011
XRD icon
kugel3 Aug 28, 2024
302ae04
Merge branch 'main' into ABW-1671_Info-sheet
GhenadieVP Sep 2, 2024
1930a04
address comments
GhenadieVP Sep 2, 2024
159eb14
wip
GhenadieVP Sep 2, 2024
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
48 changes: 30 additions & 18 deletions RadixWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

131 changes: 131 additions & 0 deletions RadixWallet/Clients/OverlayWindowClient/InfoLink.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import Foundation

// MARK: - OverlayWindowClient.GlossaryItem
extension OverlayWindowClient {
public enum GlossaryItem: String, Sendable {
kugel3 marked this conversation as resolved.
Show resolved Hide resolved
case tokens
case nfts
case networkstaking
case personas
case dapps
case guarantees
case badges
case poolunits
case gateways
case radixconnect
case transactionfee
case behaviors
case claimnfts
case liquidstakeunits
case radixnetwork
case accounts
case radixwallet
case transactions
case dex
case validators
case radixconnector
case connectbutton
case xrd
case web3
case transfers
case dashboard
case bridging
case payingaccount
}
}

extension OverlayWindowClient.GlossaryItem {
private static let fieldName = "glossaryAnchor"

public init?(url: URL) {
guard url.scheme == nil, url.host == nil, url.pathComponents.isEmpty, let query = url.query() else {
return nil
}

let parts = query.split(separator: "=")
guard parts.count == 2, String(parts[0]) == Self.fieldName else { return nil }

guard let item = Self(rawValue: String(parts[1])) else { return nil }
self = item
}

var image: ImageAsset? {
switch self {
case .nfts:
AssetResource.nft
case .networkstaking:
AssetResource.stakes
case .badges:
AssetResource.iconPackageOwnerBadge
case .poolunits:
AssetResource.poolUnits
case .radixnetwork:
AssetResource.fungibleTokens
case .xrd:
AssetResource.xrd
default:
nil
}
}

var string: String {
switch self {
case .tokens:
L10n.InfoLink.Glossary.tokens
case .nfts:
L10n.InfoLink.Glossary.nfts
case .networkstaking:
L10n.InfoLink.Glossary.networkstaking
case .personas:
L10n.InfoLink.Glossary.personas
case .dapps:
L10n.InfoLink.Glossary.dapps
case .guarantees:
L10n.InfoLink.Glossary.guarantees
case .badges:
L10n.InfoLink.Glossary.badges
case .poolunits:
L10n.InfoLink.Glossary.poolunits
case .gateways:
L10n.InfoLink.Glossary.gateways
case .radixconnect:
L10n.InfoLink.Glossary.radixconnect
case .transactionfee:
L10n.InfoLink.Glossary.transactionfee
case .behaviors:
L10n.InfoLink.Glossary.behaviors
case .claimnfts:
L10n.InfoLink.Glossary.claimnfts
case .liquidstakeunits:
L10n.InfoLink.Glossary.liquidstakeunits
case .radixnetwork:
L10n.InfoLink.Glossary.radixnetwork
case .accounts:
L10n.InfoLink.Glossary.accounts
case .radixwallet:
L10n.InfoLink.Glossary.radixwallet
case .transactions:
L10n.InfoLink.Glossary.transactions
case .dex:
L10n.InfoLink.Glossary.dex
case .validators:
L10n.InfoLink.Glossary.validators
case .radixconnector:
L10n.InfoLink.Glossary.radixconnector
case .connectbutton:
L10n.InfoLink.Glossary.connectbutton
case .xrd:
L10n.InfoLink.Glossary.xrd
case .web3:
L10n.InfoLink.Glossary.web3
case .transfers:
L10n.InfoLink.Glossary.transfers
case .dashboard:
L10n.InfoLink.Glossary.dashboard
case .bridging:
L10n.InfoLink.Glossary.bridging
case .payingaccount:
L10n.InfoLink.Glossary.payingaccount
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public struct OverlayWindowClient: Sendable {
/// Usually to be called from the Main Window.
public var scheduleHUD: ScheduleHUD

/// Schedule a sheet to be shown in the Overlay Window.
/// Usually to be called from the Main Window.
public var scheduleSheet: ScheduleSheet

/// Schedule a FullScreen to be shown in the Overlay Window.
/// Usually to be called from the Main Window.
public var scheduleFullScreen: ScheduleFullScreen
Expand All @@ -33,6 +37,7 @@ public struct OverlayWindowClient: Sendable {
scheduleAlert: @escaping ScheduleAlert,
scheduleAlertAndIgnoreAction: @escaping ScheduleAlertAndIgnoreAction,
scheduleHUD: @escaping ScheduleHUD,
scheduleSheet: @escaping ScheduleSheet,
scheduleFullScreen: @escaping ScheduleFullScreen,
sendAlertAction: @escaping SendAlertAction,
sendFullScreenAction: @escaping SendFullScreenAction,
Expand All @@ -43,6 +48,7 @@ public struct OverlayWindowClient: Sendable {
self.scheduleAlert = scheduleAlert
self.scheduleAlertAndIgnoreAction = scheduleAlertAndIgnoreAction
self.scheduleHUD = scheduleHUD
self.scheduleSheet = scheduleSheet
self.scheduleFullScreen = scheduleFullScreen
self.sendAlertAction = sendAlertAction
self.sendFullScreenAction = sendFullScreenAction
Expand All @@ -58,6 +64,7 @@ extension OverlayWindowClient {
public typealias ScheduleAlert = @Sendable (Item.AlertState) async -> Item.AlertAction
public typealias ScheduleAlertAndIgnoreAction = @Sendable (Item.AlertState) -> Void
public typealias ScheduleHUD = @Sendable (Item.HUD) -> Void
public typealias ScheduleSheet = @Sendable (SheetOverlayCoordinator.Root.State, SheetBehavior) -> Void
public typealias ScheduleFullScreen = @Sendable (FullScreenOverlayCoordinator.State) async -> FullScreenAction
public typealias SendAlertAction = @Sendable (Item.AlertAction, Item.AlertState.ID) -> Void
public typealias SendFullScreenAction = @Sendable (FullScreenAction, FullScreenID) -> Void
Expand All @@ -83,24 +90,6 @@ extension OverlayWindowClient {
public let text: String
public let icon: Icon?

public struct Icon: Hashable, Sendable {
public enum Kind: Hashable, Sendable {
case asset(ImageAsset)
case system(String)
}

public let kind: Kind
public let foregroundColor: Color

public init(
kind: Kind,
foregroundColor: Color = .app.green1
) {
self.kind = kind
self.foregroundColor = foregroundColor
}
}

public init(
text: String,
icon: Icon? = Icon(
Expand All @@ -113,10 +102,34 @@ extension OverlayWindowClient {
}
}

public struct Icon: Hashable, Sendable {
public enum Kind: Hashable, Sendable {
case asset(ImageAsset)
case system(String)
}

public let kind: Kind
public let foregroundColor: Color

public init(
kind: Kind,
foregroundColor: Color = .app.green1
) {
self.kind = kind
self.foregroundColor = foregroundColor
}
}

case hud(HUD)
case alert(AlertState)
case sheet(SheetOverlayCoordinator.Root.State, SheetBehavior)
case fullScreen(FullScreenOverlayCoordinator.State)
}

public enum SheetBehavior: Sendable {
GhenadieVP marked this conversation as resolved.
Show resolved Hide resolved
case enqueue
case replace
}
}

extension DependencyValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ extension OverlayWindowClient: DependencyKey {
return Item.alert(.init(
title: { TextState(L10n.Common.errorAlertTitle) },
actions: {
let buttons: [ButtonState<OverlayWindowClient.Item.AlertAction>] = [
.init(role: .cancel, action: .dismissed, label: { TextState(L10n.Common.cancel) }),
.init(action: .emailSupport(additionalInfo: error.localizedDescription), label: { TextState(L10n.Error.emailSupportButtonTitle) }),
]
return buttons
ButtonState(role: .cancel, action: .dismissed) {
TextState(L10n.Common.cancel)
}
ButtonState(action: .emailSupport(additionalInfo: error.localizedDescription)) { TextState(L10n.Error.emailSupportButtonTitle)
}
},
message: { TextState(message) }
))
Expand All @@ -50,6 +50,7 @@ extension OverlayWindowClient: DependencyKey {
},
scheduleAlertAndIgnoreAction: scheduleAlertAndIgnoreAction,
scheduleHUD: { items.send(.hud($0)) },
scheduleSheet: { items.send(.sheet($0, $1)) },
scheduleFullScreen: { fullScreen in
items.send(.fullScreen(fullScreen))
return await fullScreenActions.first { $0.id == fullScreen.id }?.action ?? .dismiss
Expand All @@ -62,6 +63,12 @@ extension OverlayWindowClient: DependencyKey {
}()
}

extension OverlayWindowClient {
public func showInfoLink(_ item: GlossaryItem) {
scheduleSheet(.infoLink(.init(image: item.image, text: item.string)), .replace)
}
}

extension OverlayWindowClient.Item.HUD {
public static let updatedAccount = Self(text: L10n.AccountSettings.updatedAccountHUDMessage)
public static let copied = Self(text: L10n.AddressAction.copiedToClipboard)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extension OverlayWindowClient: TestDependencyKey {
scheduleAlert: unimplemented("\(Self.self).scheduleAlert"),
scheduleAlertAndIgnoreAction: unimplemented("\(Self.self).scheduleAlertAndIgnoreAction"),
scheduleHUD: unimplemented("\(Self.self).scheduleHUD"),
scheduleSheet: unimplemented("\(Self.self).scheduleSheet"),
scheduleFullScreen: unimplemented("\(Self.self).scheduleFullScreen"),
sendAlertAction: unimplemented("\(Self.self).sendAlertAction"),
sendFullScreenAction: unimplemented("\(Self.self).sendFullScreenAction"),
Expand Down
2 changes: 1 addition & 1 deletion RadixWallet/Core/DesignSystem/Components/CloseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public struct CloseButtonBar: View {

public var body: some View {
HStack {
Spacer()
CloseButton(action: action)
.padding(.small2)
Spacer()
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions RadixWallet/Core/DesignSystem/Components/InfoButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import SwiftUI

public struct InfoButton: View {
public let item: OverlayWindowClient.GlossaryItem
public let label: String?

public init(_ item: OverlayWindowClient.GlossaryItem, label: String? = nil) {
self.item = item
self.label = label
}

public var body: some View {
Button(action: showInfo) {
if let label {
Text(label)
}
}
.buttonStyle(.info)
}

private func showInfo() {
@Dependency(\.overlayWindowClient) var overlayWindowClient
overlayWindowClient.showInfoLink(item)
}
}
10 changes: 7 additions & 3 deletions RadixWallet/Core/DesignSystem/Measure+Position.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import Foundation

extension View {
public func measurePosition(_ id: AnyHashable, coordSpace: String) -> some View {
public func measurePosition(_ id: AnyHashable?, coordSpace: String) -> some View {
background {
GeometryReader { proxy in
if let id {
GeometryReader { proxy in
Color.clear
.preference(key: PositionsPreferenceKey.self, value: [id: proxy.frame(in: .named(coordSpace))])
}
} else {
Color.clear
.preference(key: PositionsPreferenceKey.self, value: [id: proxy.frame(in: .named(coordSpace))])
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion RadixWallet/Core/DesignSystem/Styles/InfoButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public struct InfoButtonStyle: ButtonStyle {
configuration.label
.textStyle(.body1StandaloneLink)
} icon: {
Image(asset: AssetResource.info)
Image(.info)
}
.labelStyle(.titleAndIcon)
.foregroundColor(.app.blue2)
Expand Down

This file was deleted.

Loading