Skip to content

Commit

Permalink
Add AddressComponent
Browse files Browse the repository at this point in the history
Use address component in home screen

Use address component in new entity

Use address component in fungible token details

Use address component in nft details

wip

wip

Replace AddressComponent with AddressView

Fix tests

Refactor

Minor updates

wip

wip

Move to enum

Clean up

Update context menu

Use existing init
  • Loading branch information
nikola-milicevic committed May 2, 2023
1 parent 3a96e01 commit 04fc27f
Show file tree
Hide file tree
Showing 55 changed files with 701 additions and 729 deletions.
290 changes: 135 additions & 155 deletions .swiftpm/xcode/xcshareddata/xcschemes/Unit Tests.xcscheme

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ package.addModules([
dependencies: [
"AccountPortfoliosClient",
],
tests: .yes()
tests: .no
),
.feature(
name: "AccountPreferencesFeature",
Expand Down Expand Up @@ -632,7 +632,7 @@ package.addModules([
.package(url: "https://github.com/davdroman/TextBuilder", from: "2.2.0")
},
],
tests: .yes()
tests: .no
),
.core(
name: "Resources",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ extension AccountPortfoliosClient {

let nonFungibleResources = try await rawItems.parallelMap { resource in
// Load the nftIds from the resource vault
let nftIds = try await {
let nonFungibleLocalIds = try await {
// Resources of an account always have one single vault which stores the value.
guard let vault = resource.vaults.items.first else {
return [AccountPortfolio.NonFungibleResource.NonFungibleTokenId]()
return [AccountPortfolio.NonFungibleResource.NonFungibleLocalId]()
}

// Fetch all nft ids pages from the vault
Expand All @@ -261,7 +261,7 @@ extension AccountPortfoliosClient {
)
)
.map {
AccountPortfolio.NonFungibleResource.NonFungibleTokenId($0.nonFungibleId)
AccountPortfolio.NonFungibleResource.NonFungibleLocalId($0.nonFungibleId)
}

}()
Expand All @@ -273,7 +273,7 @@ extension AccountPortfoliosClient {
resourceAddress: .init(address: resource.resourceAddress),
name: metadata?.name,
description: metadata?.description,
nftIds: nftIds
localIds: nonFungibleLocalIds
)
}

Expand Down
73 changes: 0 additions & 73 deletions Sources/Core/DesignSystem/Components/AccountButton.swift

This file was deleted.

89 changes: 0 additions & 89 deletions Sources/Core/DesignSystem/Components/AddressView.swift

This file was deleted.

16 changes: 16 additions & 0 deletions Sources/Core/DesignSystem/Extensions/Button+Extra.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Resources
import SwiftUI

extension Button where Label == SwiftUI.Label<Text, Image> {
public init(_ titleKey: LocalizedStringKey, asset: ImageAsset, action: @escaping () -> Void) {
self.init(action: action) {
SwiftUI.Label(titleKey, asset: asset)
}
}

public init<S>(_ title: S, asset: ImageAsset, action: @escaping () -> Void) where S: StringProtocol {
self.init(action: action) {
SwiftUI.Label(title, asset: asset)
}
}
}
22 changes: 22 additions & 0 deletions Sources/Core/DesignSystem/Extensions/Label+Extra.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Resources
import SwiftUI

extension Label where Title == Text, Icon == Image {
public init(_ titleKey: LocalizedStringKey, asset: ImageAsset) {
self.init {
Text(titleKey)
} icon: {
Image(asset: asset)
.renderingMode(.template)
}
}

public init<S>(_ title: S, asset: ImageAsset) where S: StringProtocol {
self.init {
Text(title)
} icon: {
Image(asset: asset)
.renderingMode(.template)
}
}
}
28 changes: 28 additions & 0 deletions Sources/Core/FeaturePrelude/AddressView/AddressFormat.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Foundation

// MARK: - AddressFormat
public enum AddressFormat: String, Sendable {
case `default`
case nonFungibleLocalId
}

extension String {
public func truncatedMiddle(keepFirst first: Int, last: Int) -> Self {
guard count > first + last else { return self }
return prefix(first) + "..." + suffix(last)
}

public func colonSeparated() -> Self {
guard let index = range(of: ":")?.upperBound else { return self }
return String(self[index...])
}

public func formatted(_ format: AddressFormat) -> Self {
switch format {
case .default:
return truncatedMiddle(keepFirst: 4, last: 6)
case .nonFungibleLocalId:
return colonSeparated()
}
}
}
Loading

0 comments on commit 04fc27f

Please sign in to comment.