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-1695 Pool Unit asset type #657

Merged
merged 50 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
204e5d8
Add the tab and a placeholder view
maciek-rdx Jul 31, 2023
fc0d596
Add one more missing bit
maciek-rdx Jul 31, 2023
48958dd
Add the boilerplate for PoolUnitsLis
maciek-rdx Jul 31, 2023
bb03b95
Add the initial boilerplate for the feature
maciek-rdx Jul 31, 2023
3b0db0e
Add LSURow
maciek-rdx Jul 31, 2023
50d3a11
Add the Preview
maciek-rdx Jul 31, 2023
e6018a9
Add some initial preview
maciek-rdx Jul 31, 2023
837b6df
Adjust Preview to work with View only
maciek-rdx Jul 31, 2023
d4b8182
Model the ViewState
maciek-rdx Jul 31, 2023
c82e855
Make Unit a singleton
maciek-rdx Jul 31, 2023
a41f9d5
Display liquid stake units in ForEach
maciek-rdx Jul 31, 2023
3bbc877
Flesh out the UI a bit
maciek-rdx Aug 1, 2023
af7f038
Make claims look good
maciek-rdx Aug 1, 2023
6118432
Add the lok for a single unit
maciek-rdx Aug 1, 2023
56108bd
Add the initial version of the stack behavior
maciek-rdx Aug 1, 2023
ccd36a2
Merge branch 'main' into ABW-1807-pool-units
maciek-rdx Aug 1, 2023
eecdc51
Add a single card under the header
maciek-rdx Aug 2, 2023
c57b6be
Simoplify the impelmentation a bit
maciek-rdx Aug 2, 2023
8607bda
Fix the spacings
maciek-rdx Aug 2, 2023
0fc7a76
Add the component image
maciek-rdx Aug 2, 2023
d831ed8
Simplify ViewState
maciek-rdx Aug 3, 2023
7ef35ef
Improve the structure of code
maciek-rdx Aug 3, 2023
3d864f0
Rename files accordingly
maciek-rdx Aug 3, 2023
3ca08ca
Move view to a separate file
maciek-rdx Aug 3, 2023
5149b40
Structure
maciek-rdx Aug 3, 2023
f013c1c
Adjust the external wiring of the feature
maciek-rdx Aug 3, 2023
6af5e6a
Embed it properly in the UI
maciek-rdx Aug 3, 2023
d1ef148
Fix some embedding issues
maciek-rdx Aug 3, 2023
7c7f43c
Make it work with preference propagation for equal header and card be…
maciek-rdx Aug 3, 2023
3636075
Move code where it should be
maciek-rdx Aug 3, 2023
100e7e3
Use explicit id and URLs
maciek-rdx Aug 3, 2023
becf1bc
Insert Fixmes for localization
maciek-rdx Aug 3, 2023
3b4dd3c
Fix tests
maciek-rdx Aug 4, 2023
24a1b7c
Add some FIXMEs related to rewiring
maciek-rdx Aug 4, 2023
404c1fa
Discard unwanted change
maciek-rdx Aug 4, 2023
673603f
Eliminate some duplication
maciek-rdx Aug 4, 2023
0168189
Add PoolUnitToken
maciek-rdx Aug 4, 2023
12925e2
Wire up initial display of LP Token cards
maciek-rdx Aug 4, 2023
df34a93
PoolUnitToken -> LPToken
maciek-rdx Aug 4, 2023
9c09f4e
Add resources
maciek-rdx Aug 4, 2023
bf2ee8d
Make pool unit token views look good
maciek-rdx Aug 4, 2023
a73c7ca
Extrac shared Token view
maciek-rdx Aug 4, 2023
1388bb9
Implement header for both pool unints
maciek-rdx Aug 4, 2023
245a3e1
LPToken -> Pool Unit
maciek-rdx Aug 4, 2023
e23ec33
WIP
maciek-rdx Aug 4, 2023
fe9d68d
Increase spacing on top of STAKE CLAIM NFTS
maciek-rdx Aug 7, 2023
de333f9
Cleanup code
maciek-rdx Aug 7, 2023
e286819
One last cleanup
maciek-rdx Aug 7, 2023
864aab2
Fix the minor issues
maciek-rdx Aug 7, 2023
83ad5b6
Add one more Optional
maciek-rdx Aug 8, 2023
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
549 changes: 542 additions & 7 deletions App/BabylonWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AE68BE1D2A77F01B006024B8"
BuildableName = "AssetsFeaturePreview.app"
BlueprintName = "AssetsFeaturePreview"
ReferencedContainer = "container:BabylonWallet.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug-Dev"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug-Dev"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AE68BE1D2A77F01B006024B8"
BuildableName = "AssetsFeaturePreview.app"
BlueprintName = "AssetsFeaturePreview"
ReferencedContainer = "container:BabylonWallet.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AE68BE1D2A77F01B006024B8"
BuildableName = "AssetsFeaturePreview.app"
BlueprintName = "AssetsFeaturePreview"
ReferencedContainer = "container:BabylonWallet.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug-Dev">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
18 changes: 18 additions & 0 deletions App/Previews/AssetsFeaturePreview/AssetsFeaturePreviewApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import AssetsFeature
import ComposableArchitecture
import SwiftUI

// MARK: - AssetsFeaturePreviewApp
@main
struct AssetsFeaturePreviewApp: App {
var body: some Scene {
WindowGroup {
AssetsView.View(
store: .init(
initialState: .init(account: .previewValue0),
reducer: AssetsView.init
)
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
22 changes: 18 additions & 4 deletions Sources/Core/DesignSystem/Layouts/StackedViewsLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public struct StackedViewsLayout: Layout {
return properties
}

public func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
public func sizeThatFits(
proposal: ProposedViewSize,
subviews: Subviews,
cache: inout ()
) -> CGSize {
let container = proposal.replacingUnspecifiedDimensions()
guard !subviews.isEmpty else {
return container
Expand All @@ -47,15 +51,25 @@ public struct StackedViewsLayout: Layout {
return .init(width: container.width, height: height)
}

public func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
public func placeSubviews(
in bounds: CGRect,
proposal: ProposedViewSize,
subviews: Subviews,
cache: inout ()
) {
let container = proposal.replacingUnspecifiedDimensions()
var offset: CGFloat = 0
for (index, subview) in subviews.enumerated() {
let place = CGPoint(x: bounds.minX, y: bounds.minY + offset)
subview.place(at: place, proposal: .init(width: container.width, height: nil))
subview.place(
at: place,
proposal: .init(width: container.width, height: nil)
)

if isExpanded {
let subviewSize = subview.sizeThatFits(.init(width: container.width, height: nil))
let subviewSize = subview.sizeThatFits(
.init(width: container.width, height: nil)
)
offset += subviewSize.height + spacing
} else {
// The rest of the cards that go over `collapsedViewsCount` will go behind the last card.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import SwiftUI
// MARK: - TokenRowShadow
extension View {
public func tokenRowShadow(_ show: Bool = true) -> some View {
shadow(color: show ? .app.shadowBlack : .clear, radius: .small2, x: .zero, y: .small2)
shadow(
color: show ? .app.shadowBlack : .clear,
radius: .small2,
x: .zero,
y: .small2
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extension TaskResult where Success == Prelude.Unit {
public init(catching body: @Sendable () async throws -> Void) async {
do {
try await body()
self = .success(Prelude.Unit())
self = .success(Prelude.Unit.instance)
} catch {
self = .failure(error)
}
Expand Down
31 changes: 27 additions & 4 deletions Sources/Features/AssetsFeature/AssetsView+Reducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@ public struct AssetsView: Sendable, FeatureReducer {
public enum AssetKind: String, Sendable, Hashable, CaseIterable, Identifiable {
case fungible
case nonFungible
case poolUnits

var displayText: String {
switch self {
case .fungible:
return L10n.Account.tokens
case .nonFungible:
return L10n.Account.nfts
case .poolUnits:
return L10n.Account.poolUnits
}
}
}

public var activeAssetKind: AssetKind
public var assetKinds: NonEmpty<[AssetKind]>

public var fungibleTokenList: FungibleAssetList.State
public var nonFungibleTokenList: NonFungibleAssetList.State
public var poolUnitsList: PoolUnitsList.State

public let account: Profile.Network.Account
public var isLoadingResources: Bool = false
Expand All @@ -33,22 +38,26 @@ public struct AssetsView: Sendable, FeatureReducer {
account: account,
fungibleTokenList: .init(),
nonFungibleTokenList: .init(rows: []),
// FIXME: Rewire
poolUnitsList: .preview,
mode: mode
)
}

init(
account: Profile.Network.Account,
assetKinds: NonEmpty<[AssetKind]> = .init([.fungible, .nonFungible])!,
assetKinds: NonEmpty<[AssetKind]> = .init(rawValue: AssetKind.allCases)!,
fungibleTokenList: FungibleAssetList.State,
nonFungibleTokenList: NonFungibleAssetList.State,
poolUnitsList: PoolUnitsList.State,
mode: Mode
) {
self.account = account
self.assetKinds = assetKinds
self.activeAssetKind = assetKinds.first
self.fungibleTokenList = fungibleTokenList
self.nonFungibleTokenList = nonFungibleTokenList
self.poolUnitsList = poolUnitsList
self.mode = mode
}
}
Expand All @@ -64,6 +73,7 @@ public struct AssetsView: Sendable, FeatureReducer {
public enum ChildAction: Sendable, Equatable {
case fungibleTokenList(FungibleAssetList.Action)
case nonFungibleTokenList(NonFungibleAssetList.Action)
case poolUnitsList(PoolUnitsList.Action)
}

public enum InternalAction: Sendable, Equatable {
Expand All @@ -80,12 +90,25 @@ public struct AssetsView: Sendable, FeatureReducer {
public init() {}

public var body: some ReducerProtocolOf<Self> {
Scope(state: \.nonFungibleTokenList, action: /Action.child .. ChildAction.nonFungibleTokenList) {
Scope(
state: \.fungibleTokenList,
action: /Action.child .. ChildAction.fungibleTokenList
) {
FungibleAssetList()
}
Scope(
state: \.nonFungibleTokenList,
action: /Action.child .. ChildAction.nonFungibleTokenList
) {
NonFungibleAssetList()
}
Scope(state: \.fungibleTokenList, action: /Action.child .. ChildAction.fungibleTokenList) {
FungibleAssetList()
Scope(
state: \.poolUnitsList,
action: /Action.child .. ChildAction.poolUnitsList
) {
PoolUnitsList()
}

Reduce(core)
}

Expand Down
17 changes: 15 additions & 2 deletions Sources/Features/AssetsFeature/AssetsView+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension AssetsView {
}

public var body: some SwiftUI.View {
WithViewStore(store, observe: { $0 }, send: { .view($0) }) { viewStore in
WithViewStore(store, observe: identity, send: FeatureAction.view) { viewStore in
ScrollView {
VStack(spacing: .medium3) {
assetTypeSelectorView(viewStore)
Expand All @@ -38,6 +38,13 @@ extension AssetsView {
action: { .child(.nonFungibleTokenList($0)) }
)
)
case .poolUnits:
PoolUnitsList.View(
store: store.scope(
state: \.poolUnitsList,
action: { .child(.poolUnitsList($0)) }
)
)
}
}
.padding(.bottom, .medium1)
Expand Down Expand Up @@ -101,7 +108,13 @@ struct AssetsView_Preview: PreviewProvider {
static var previews: some View {
AssetsView.View(
store: .init(
initialState: .init(account: .previewValue0, fungibleTokenList: .init(), nonFungibleTokenList: .init(rows: []), mode: .normal),
initialState: .init(
account: .previewValue0,
fungibleTokenList: .init(),
nonFungibleTokenList: .init(rows: []),
poolUnitsList: .init(),
mode: .normal
),
reducer: AssetsView()
)
)
Expand Down
Loading