Skip to content

Commit 9786883

Browse files
authored
Ios15 (#203)
1 parent 8cf0981 commit 9786883

14 files changed

+217
-128
lines changed

NFTY.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@
13861386
CODE_SIGN_ENTITLEMENTS = NFTY/NFTY.entitlements;
13871387
CODE_SIGN_IDENTITY = "Apple Development";
13881388
CODE_SIGN_STYLE = Automatic;
1389-
CURRENT_PROJECT_VERSION = 12;
1389+
CURRENT_PROJECT_VERSION = 1;
13901390
DEVELOPMENT_ASSET_PATHS = "NFTY/Preview\\ Content";
13911391
DEVELOPMENT_TEAM = C28QWE5379;
13921392
ENABLE_PREVIEWS = YES;
@@ -1396,7 +1396,7 @@
13961396
"$(inherited)",
13971397
"@executable_path/Frameworks",
13981398
);
1399-
MARKETING_VERSION = 1.4.0;
1399+
MARKETING_VERSION = 1.5.0;
14001400
PRODUCT_BUNDLE_IDENTIFIER = com.nftygo.NFTY;
14011401
PRODUCT_NAME = "$(TARGET_NAME)";
14021402
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -1413,7 +1413,7 @@
14131413
CODE_SIGN_ENTITLEMENTS = NFTY/NFTY.entitlements;
14141414
CODE_SIGN_IDENTITY = "Apple Development";
14151415
CODE_SIGN_STYLE = Automatic;
1416-
CURRENT_PROJECT_VERSION = 12;
1416+
CURRENT_PROJECT_VERSION = 1;
14171417
DEVELOPMENT_ASSET_PATHS = "NFTY/Preview\\ Content";
14181418
DEVELOPMENT_TEAM = C28QWE5379;
14191419
ENABLE_PREVIEWS = YES;
@@ -1423,7 +1423,7 @@
14231423
"$(inherited)",
14241424
"@executable_path/Frameworks",
14251425
);
1426-
MARKETING_VERSION = 1.4.0;
1426+
MARKETING_VERSION = 1.5.0;
14271427
PRODUCT_BUNDLE_IDENTIFIER = com.nftygo.NFTY;
14281428
PRODUCT_NAME = "$(TARGET_NAME)";
14291429
PROVISIONING_PROFILE_SPECIFIER = "";

NFTY/Model/NFT.swift

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,38 @@ struct NFT: Identifiable {
137137

138138
struct NFTPriceInfo {
139139
let price : BigUInt?
140-
let blockNumber : BigUInt?
140+
141+
enum BlockTimeStamp {
142+
case none
143+
case some(BigUInt)
144+
case date(Date)
145+
}
146+
147+
let blockNumber : BlockTimeStamp
141148
let type : TradeEventType
149+
150+
init(price:BigUInt?, blockNumber:BigUInt?,type:TradeEventType) {
151+
self.price = price
152+
self.type = type
153+
switch(blockNumber) {
154+
case .some(let x):
155+
self.blockNumber = BlockTimeStamp.some(x)
156+
case .none:
157+
self.blockNumber = BlockTimeStamp.none
158+
}
159+
}
160+
161+
init(price:BigUInt?, date:Date?,type:TradeEventType) {
162+
self.price = price
163+
self.type = type
164+
switch(date) {
165+
case .some(let x):
166+
self.blockNumber = .date(x)
167+
case .none:
168+
self.blockNumber = .none
169+
}
170+
171+
}
142172
}
143173

144174
enum NFTPriceStatus {

NFTY/Model/OpenSeaApi.swift

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,22 @@ struct OpenSeaApi {
111111

112112
//print(orders)
113113
// remove duplicates, we request ordered by highest first
114-
if (contract == nil || tokenIds == nil) {
115-
var uniqueOrdersDict : [String:AssetOrder] = [:]
116-
orders.orders.forEach { order in
117-
let key = "\(order.asset.asset_contract.address):\(order.asset.token_id)"
118-
uniqueOrdersDict[key] = uniqueOrdersDict[key] ?? order
119-
}
114+
115+
var dict : [String:AssetOrder] = [:]
116+
// print(orders)
117+
orders.orders.forEach { order in
120118

121-
orders = Orders(orders: uniqueOrdersDict.map { $1 })
119+
let key = "\(order.asset.asset_contract.address):\(order.asset.token_id):\(order.side)"
120+
dict[key] = dict[key] ??
121+
orders.orders.filter {
122+
"\($0.asset.asset_contract.address):\($0.asset.token_id):\($0.side)" == key
123+
}.sorted {
124+
$0.payment_token == $1.payment_token && $0.current_price > $1.current_price
125+
}.first!
122126
}
123127

128+
orders = Orders(orders: dict.map { $1 })
129+
124130
seal.fulfill(orders.orders)
125131

126132
} catch {
@@ -145,7 +151,7 @@ struct OpenSeaApi {
145151
let ask = $0.first { $0.side == .sell }.flatMap { (order:AssetOrder) -> AskInfo? in
146152
switch(order.payment_token,Double(order.current_price).map { BigUInt($0) }) {
147153
case (ETH_ADDRESS,.some(let wei)),
148-
(WETH_ADDRESS,.some(let wei)):
154+
(WETH_ADDRESS,.some(let wei)):
149155
return AskInfo(wei: wei)
150156
default:
151157
return nil
@@ -155,7 +161,7 @@ struct OpenSeaApi {
155161
let bid = $0.first { $0.side == .buy }.flatMap { (order:AssetOrder) -> BidInfo? in
156162
switch(order.payment_token,Double(order.current_price).map { BigUInt($0) }) {
157163
case (ETH_ADDRESS,.some(let wei)),
158-
(WETH_ADDRESS,.some(let wei)):
164+
(WETH_ADDRESS,.some(let wei)):
159165
return BidInfo(wei: wei)
160166
default:
161167
return nil
@@ -172,7 +178,7 @@ struct OpenSeaApi {
172178
let ask = $0.first { $0.side == .sell }.flatMap { (order:AssetOrder) -> AskInfo? in
173179
switch(order.payment_token,Double(order.current_price).map { BigUInt($0) }) {
174180
case (ETH_ADDRESS,.some(let wei)),
175-
(WETH_ADDRESS,.some(let wei)):
181+
(WETH_ADDRESS,.some(let wei)):
176182
return AskInfo(wei: wei)
177183
default:
178184
return nil
@@ -182,7 +188,7 @@ struct OpenSeaApi {
182188
let bid = $0.first { $0.side == .buy }.flatMap { (order:AssetOrder) -> BidInfo? in
183189
switch(order.payment_token,Double(order.current_price).map { BigUInt($0) }) {
184190
case (ETH_ADDRESS,.some(let wei)),
185-
(WETH_ADDRESS,.some(let wei)):
191+
(WETH_ADDRESS,.some(let wei)):
186192
return BidInfo(wei: wei)
187193
default:
188194
return nil
@@ -196,7 +202,7 @@ struct OpenSeaApi {
196202
static func userOrders(address:QueryAddress,side:Side?) -> Promise<[NFTWithLazyPrice]> {
197203
OpenSeaApi.getOrders(contract: nil, tokenIds: nil, user: address, side: side)
198204
.map(on:DispatchQueue.global(qos:.userInteractive)) { orders in
199-
orders
205+
return orders
200206
.sorted {
201207
switch($0.expiration_time,$1.expiration_time) {
202208
case (0,0):
@@ -209,7 +215,7 @@ struct OpenSeaApi {
209215
return $0.expiration_time < $1.expiration_time
210216
}
211217
}
212-
218+
213219
.map { order in
214220
collectionsFactory
215221
.getByAddress(
@@ -223,15 +229,15 @@ struct OpenSeaApi {
223229
.flatMap { (nft:NFT) -> NFTWithLazyPrice? in
224230
switch(order.payment_token,Double(order.current_price).map { BigUInt($0) }) {
225231
case (ETH_ADDRESS,.some(let wei)),
226-
(WETH_ADDRESS,.some(let wei)):
232+
(WETH_ADDRESS,.some(let wei)):
227233
return NFTWithLazyPrice(
228234
nft: nft,
229235
getPrice: {
230236
ObservablePromise<NFTPriceStatus>(
231237
resolved: NFTPriceStatus.known(
232238
NFTPriceInfo(
233239
price: wei,
234-
blockNumber: nil,
240+
date:order.expiration_time == 0 ? nil : Date(timeIntervalSince1970:Double(order.expiration_time)),
235241
type:AssetOrder.sideToEvent(order.side))
236242
)
237243
)

NFTY/NFTYApp.swift

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ struct NFTYApp: App {
4646
WindowGroup {
4747
TabView {
4848

49+
NavigationView {
50+
WalletView()
51+
}
52+
.tabItem {
53+
Label("Wallet",systemImage:"lock.rectangle.stack.fill")
54+
}
55+
.navigationViewStyle(StackNavigationViewStyle())
56+
57+
NavigationView {
58+
FavoritesView()
59+
.navigationBarTitle("Favorites")
60+
}
61+
.tabItem {
62+
Label("Favorites",systemImage:"heart.fill")
63+
}
64+
.navigationViewStyle(StackNavigationViewStyle())
65+
4966
NavigationView {
5067
FeedView(trades:CompositeCollection)
5168
.navigationBarTitle("Recent")
@@ -76,22 +93,7 @@ struct NFTYApp: App {
7693
.navigationViewStyle(StackNavigationViewStyle())
7794
}
7895

79-
NavigationView {
80-
FavoritesView()
81-
.navigationBarTitle("Favorites")
82-
}
83-
.tabItem {
84-
Label("Favorites",systemImage:"heart.fill")
85-
}
86-
.navigationViewStyle(StackNavigationViewStyle())
8796

88-
NavigationView {
89-
WalletView()
90-
}
91-
.tabItem {
92-
Label("Wallet",systemImage:"lock.rectangle.stack.fill")
93-
}
94-
.navigationViewStyle(StackNavigationViewStyle())
9597
}
9698
// .preferredColorScheme(.dark)
9799
.accentColor(.orange)

NFTY/Views/ConnectWalletSheet.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ struct UserWalletConnectorView : View {
111111
}
112112
}
113113
.padding()
114-
.animation(.easeIn)
115114
}
116115

117116
}
@@ -182,9 +181,9 @@ struct ConnectWalletSheet: View {
182181
Text(badAddressError)
183182
.font(.footnote)
184183
.foregroundColor(.secondary)
184+
.animation(.easeIn)
185185
}
186186
.padding()
187-
.animation(.easeIn)
188187

189188
Spacer()
190189
}

NFTY/Views/FeedView.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ struct FeedView: View {
7070
self.refreshButton = .loading
7171
self.trades.loadLatest() {
7272
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { self.refreshButton = .loaded }
73+
74+
// trigger refresh again after 30 seconds
75+
DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 30) { self.triggerRefresh() }
7376
}
74-
let impactMed = UIImpactFeedbackGenerator(style: .light)
75-
impactMed.impactOccurred()
7677
}
7778

7879
var body: some View {
@@ -130,6 +131,8 @@ struct FeedView: View {
130131
ScrollView {
131132
PullToRefresh(coordinateSpaceName: "RefreshControl") {
132133
self.triggerRefresh()
134+
let impactMed = UIImpactFeedbackGenerator(style: .light)
135+
impactMed.impactOccurred()
133136
}
134137
LazyVStack {
135138
ForEach(trades.recentTrades.indices,id:\.self) { index in
@@ -171,7 +174,8 @@ struct FeedView: View {
171174
self.trades.getRecentTrades(currentIndex:index)
172175
}
173176
}
174-
}.textCase(nil)
177+
}
178+
.textCase(nil)
175179
}
176180
}.coordinateSpace(name: "RefreshControl")
177181
}
@@ -185,7 +189,11 @@ struct FeedView: View {
185189
case .loading:
186190
ProgressView()
187191
case .loaded:
188-
Button(action: self.triggerRefresh) {
192+
Button(action: {
193+
self.triggerRefresh()
194+
let impactMed = UIImpactFeedbackGenerator(style: .light)
195+
impactMed.impactOccurred()
196+
}) {
189197
Image(systemName:"arrow.clockwise.circle.fill")
190198
.font(.title3)
191199
.foregroundColor(.accentColor)
@@ -200,6 +208,7 @@ struct FeedView: View {
200208
DispatchQueue.main.async {
201209
self.isLoading = false
202210
self.refreshButton = .loaded
211+
DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 30) { self.triggerRefresh() }
203212
}
204213
}
205214
}

NFTY/Views/FriendsView.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ struct FriendsView: View {
3535
HStack() {
3636
Text(name)
3737
.font(.title3)
38-
Spacer()
39-
AddressLabel(address:address,maxLen:15)
4038
}
4139
.padding()
4240
}

NFTY/Views/NftDetail.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ struct NftDetail: View {
229229
label: {
230230
Image(systemName: "arrowshape.turn.up.forward.circle")
231231
.foregroundColor(themeLabelColor)
232-
.font(.title)
232+
.font(.title3)
233233
}
234234
)
235235
)

NFTY/Views/RoundedImage.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ struct RoundedImage: View {
127127
}
128128
}
129129

130-
.animation(.default)
131-
132130
.border(Color.secondary)
133131
.frame(width:frameWidth(width))
134132
.clipShape(RoundedRectangle(cornerRadius:cornerRadius(width), style: .continuous))

NFTY/Views/TokenListView.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ struct TokenListView: View {
2020
init(collection:Collection,tokenIds:[UInt]) {
2121
self.collection = collection
2222
self.nfts = NftTokenList(contract:collection.data.contract,tokenIds:tokenIds)
23-
}
24-
25-
init(collection:Collection,nfts:NftTokenList) {
26-
self.collection = collection
27-
self.nfts = nfts
23+
self.nfts.loadMore { }
2824
}
2925

3026
var body: some View {
@@ -66,8 +62,6 @@ struct TokenListView: View {
6662
}
6763
}
6864
}
69-
}.onAppear {
70-
nfts.loadMore {} // TODO
7165
}
7266
}
7367
}

0 commit comments

Comments
 (0)