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

Asset transfer choose asset #520

Merged
merged 13 commits into from
May 29, 2023

Conversation

GhenadieVP
Copy link
Contributor

@GhenadieVP GhenadieVP commented May 25, 2023

Asset selection for Asset Transfer.

  • Extracted AssetsView as a separate feature, by adding also the selection mode which allows selecting multiple assets.
  • Integrated Assets selection in AssetTransfer.

@GhenadieVP GhenadieVP changed the title Fix/abw 1484 i os token transfer choose asset WIP - Asset transfer choose asset - WIP May 25, 2023
@GhenadieVP GhenadieVP changed the title WIP - Asset transfer choose asset - WIP Asset transfer choose asset May 25, 2023
@GhenadieVP GhenadieVP marked this pull request as ready for review May 27, 2023 14:15
@GhenadieVP GhenadieVP requested review from kugel3 and CyonAlexRDX and removed request for kugel3 May 27, 2023 14:28
let heights = subviews.map { $0.sizeThatFits(.init(width: container.width, height: nil)).height }
let height: CGFloat = {
if !isExpanded {
return heights[0] + CGFloat(collapsedViewsCount - 1) * collapsedSpacing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be sure that heights is nonEmpty here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, if subviews is nonEmpty, for which we guard above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could i miss that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could i miss that

/// Number of visible views in Collapsed state
var collapsedViewsCount: Int

public init(isExpanded: Bool, spacing: CGFloat = 10, collapsedSpacing: CGFloat = 10, collapsedViewsCount: Int = 3) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose collapsedSpacing is more like an offset? Btw, it looked like there was space between the subrows when expanded, I don't think that's the original design.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at implementation level, yes, it is offset actually, used spacing to be aligned in terminology.
There is spacing between subrows though, but maybe not that much, will double-check,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's an offset also visually, right? Isn't this the amount that stacked cards extend below the one above? A spacing is an empty space between two things.

Comment on lines +43 to +46
if let isSelected = state.isSelected {
state.isSelected?.toggle()
return .none
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're not using isSelected. And why do we only send the delegate action if isSelected is nil`? Rather than say false or nil?

Copy link
Contributor

@kugel3 kugel3 May 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it using the same logic as in my recent PR? If isSelected is nil it means that it can't be toggled, only selected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the same logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, but then here it's enough to check if it's nil i guess

Comment on lines 42 to 47
if selectedAssets.contains(token) {
selectedAssets.remove(token)
} else {
selectedAssets.append(token)
}
state.selectedAssets = selectedAssets
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such a common pattern, swift should have a .toggle(Element) method on Set or even Collection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added as extension on IdentifiedArray for this particular case.

Copy link
Contributor

@kugel3 kugel3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to get rid of the old asset list!

@CyonAlexRDX
Copy link
Contributor

LGTM! Good job!

@GhenadieVP GhenadieVP merged commit d4f4b90 into main May 29, 2023
@GhenadieVP GhenadieVP deleted the fix/ABW-1484-i-os-token-transfer-choose-asset branch May 29, 2023 07:29
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants