-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
fdb45dc
commit 535caf5
Showing
48 changed files
with
561 additions
and
697 deletions.
There are no files selected for viewing
290 changes: 135 additions & 155 deletions
290
.swiftpm/xcode/xcshareddata/xcschemes/Unit Tests.xcscheme
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
Sources/Core/FeaturePrelude/AddressView/AddressFormat.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
Oops, something went wrong.