Skip to content

Commit 1ff0e60

Browse files
committed
Add unverified NFT collections footer to CollectionsScene
1 parent fc2436a commit 1ff0e60

File tree

8 files changed

+66
-36
lines changed

8 files changed

+66
-36
lines changed

Features/NFT/Sources/Protocols/CollectionsViewable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public protocol CollectionsViewable: AnyObject, Observable {
1414

1515
var title: String { get }
1616
var columns: [GridItem] { get }
17-
var items: [GridPosterViewItem] { get }
17+
var content: CollectionsContent { get }
1818
var emptyContentModel: EmptyContentTypeViewModel { get }
1919

2020
var wallet: Wallet { get set }

Features/NFT/Sources/Scenes/CollectibleScene.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ extension CollectibleScene {
6363
Spacer()
6464
} footer: {
6565
HeaderButtonsView(buttons: model.headerButtons, action: model.onSelectHeaderButton(type:))
66-
.padding(.top, .small)
66+
.padding(.top, .medium)
67+
.padding(.bottom, .small)
6768
}
6869
.frame(maxWidth: .infinity)
6970
.textCase(nil)

Features/NFT/Sources/Scenes/CollectionsScene.swift

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Store
88
import Components
99
import Style
1010
import PrimitivesComponents
11+
import Localization
1112

1213
public struct CollectionsScene<ViewModel: CollectionsViewable>: View {
1314
@State private var model: ViewModel
@@ -17,15 +18,35 @@ public struct CollectionsScene<ViewModel: CollectionsViewable>: View {
1718
}
1819

1920
public var body: some View {
20-
ScrollView {
21-
LazyVGrid(columns: model.columns) {
22-
collectionsView
21+
GeometryReader { geometry in
22+
ScrollView {
23+
VStack(spacing: .zero) {
24+
LazyVGrid(columns: model.columns) {
25+
collectionsView
26+
}
27+
.padding(.horizontal, .medium)
28+
29+
Spacer(minLength: .medium)
30+
31+
if let unverifiedCount = model.content.unverifiedCount {
32+
List {
33+
NavigationLink(value: Scenes.UnverifiedCollections()) {
34+
ListItemView(
35+
title: Localized.Asset.Verification.unverified,
36+
subtitle: unverifiedCount
37+
)
38+
}
39+
}
40+
.scrollDisabled(true)
41+
.frame(height: .list.minHeight)
42+
}
43+
}
44+
.frame(minHeight: geometry.size.height)
2345
}
24-
.padding(.horizontal, Spacing.medium)
2546
}
2647
.observeQuery(request: $model.request, value: $model.nftDataList)
2748
.overlay {
28-
if model.items.isEmpty {
49+
if model.content.items.isEmpty {
2950
EmptyContentView(model: model.emptyContentModel)
3051
}
3152
}
@@ -41,7 +62,7 @@ public struct CollectionsScene<ViewModel: CollectionsViewable>: View {
4162

4263
extension CollectionsScene {
4364
private var collectionsView: some View {
44-
ForEach(model.items) { item in
65+
ForEach(model.content.items) { item in
4566
NavigationLink(value: item.destination) {
4667
GridPosterView(
4768
assetImage: item.assetImage,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c). Gem Wallet. All rights reserved.
2+
3+
import Foundation
4+
5+
public struct CollectionsContent: Sendable {
6+
public let items: [GridPosterViewItem]
7+
public let unverifiedCount: String?
8+
9+
public init(
10+
items: [GridPosterViewItem],
11+
unverifiedCount: String? = nil
12+
) {
13+
self.items = items
14+
self.unverifiedCount = unverifiedCount
15+
}
16+
}

Features/NFT/Sources/ViewModels/CollectionViewModel.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ public final class CollectionViewModel: CollectionsViewable, Sendable {
3131

3232
public var title: String { collectionName }
3333

34-
public var items: [GridPosterViewItem] {
35-
nftDataList.flatMap { data in
36-
data.assets.map { buildGridItem(collection: data.collection, asset: $0) }
37-
}
34+
public var content: CollectionsContent {
35+
CollectionsContent(
36+
items: nftDataList.flatMap { data in
37+
data.assets.map { buildGridItem(collection: data.collection, asset: $0) }
38+
}
39+
)
3840
}
3941

4042
}

Features/NFT/Sources/ViewModels/CollectionsViewModel.swift

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ public final class CollectionsViewModel: CollectionsViewable, Sendable {
4141
walletService.currentWallet
4242
}
4343

44-
public var items: [GridPosterViewItem] {
45-
verifiedItems + unverifiedItem
44+
public var content: CollectionsContent {
45+
CollectionsContent(
46+
items: verifiedItems,
47+
unverifiedCount: unverifiedCount
48+
)
4649
}
47-
50+
4851
// MARK: - Private
4952

5053
private var verifiedItems: [GridPosterViewItem] {
@@ -53,13 +56,10 @@ public final class CollectionsViewModel: CollectionsViewable, Sendable {
5356
.map { buildGridItem(from: $0) }
5457
}
5558

56-
private var unverifiedItem: [GridPosterViewItem] {
57-
let ids = nftDataList
58-
.filter { $0.collection.isVerified == false }
59-
.map(\.collection.id)
60-
61-
guard ids.isNotEmpty else { return [] }
62-
return [.unverified(collectionIds: ids)]
59+
private var unverifiedCount: String? {
60+
let unverified = nftDataList.filter { !$0.collection.isVerified }
61+
guard unverified.isNotEmpty else { return nil }
62+
return unverified.count.asString
6363
}
6464

6565
// MARK: - Actions
@@ -74,14 +74,3 @@ public final class CollectionsViewModel: CollectionsViewable, Sendable {
7474
}
7575
}
7676

77-
extension GridPosterViewItem {
78-
static func unverified(collectionIds: [String]) -> GridPosterViewItem {
79-
GridPosterViewItem(
80-
id: collectionIds.joined(separator: "-").hash.asString,
81-
destination: Scenes.UnverifiedCollections(),
82-
assetImage: .image(Images.TokenStatus.warning),
83-
title: Localized.Asset.Verification.unverified,
84-
count: collectionIds.count
85-
)
86-
}
87-
}

Features/NFT/Sources/ViewModels/UnverifiedCollectionsViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public final class UnverifiedCollectionsViewModel: CollectionsViewable, Sendable
2525

2626
public var title: String { Localized.Asset.Verification.unverified }
2727

28-
public var items: [GridPosterViewItem] {
29-
nftDataList.map { buildGridItem(from: $0) }
28+
public var content: CollectionsContent {
29+
CollectionsContent(items: nftDataList.map { buildGridItem(from: $0) })
3030
}
3131
}

Packages/Style/Sources/Spacing.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public extension Spacing {
5252
public static let top: CGFloat = space16
5353
/// 8
5454
public static let bottom: CGFloat = space8
55-
5655
/// 72
5756
public static let bannerHeight: CGFloat = 72
5857

@@ -107,6 +106,8 @@ public extension Sizing {
107106
}
108107

109108
struct list {
109+
/// 100
110+
public static let minHeight: CGFloat = 100
110111
/// 16
111112
public static let accessory: CGFloat = 16
112113
/// 22

0 commit comments

Comments
 (0)