Skip to content

Commit

Permalink
v1.2.0 : Add appLinks (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
kohlivarun5 authored May 27, 2021
1 parent 5461291 commit a921d05
Show file tree
Hide file tree
Showing 18 changed files with 361 additions and 32 deletions.
18 changes: 16 additions & 2 deletions NFTY.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
4F4C6982264F6483005B9A23 /* AutoglyphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F4C6981264F6483005B9A23 /* AutoglyphView.swift */; };
4F4CA8012635D806001534A6 /* FavButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F4CA8002635D806001534A6 /* FavButton.swift */; };
4F4CA8062635D813001534A6 /* BackButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F4CA8052635D813001534A6 /* BackButton.swift */; };
4F4DD21B265DDE3C00AD320D /* NftUrlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F4DD21A265DDE3C00AD320D /* NftUrlView.swift */; };
4F4DD21D265DF1F400AD320D /* UserUrlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F4DD21C265DF1F400AD320D /* UserUrlView.swift */; };
4F4DD21F265F480A00AD320D /* AddressLabelWithShare.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F4DD21E265F480A00AD320D /* AddressLabelWithShare.swift */; };
4F55A8E62648BB17007C8002 /* WalletView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F55A8E52648BB17007C8002 /* WalletView.swift */; };
4F55A8E82648D1DF007C8002 /* WalletTokensView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F55A8E72648D1DF007C8002 /* WalletTokensView.swift */; };
4F55A8EA2648D343007C8002 /* ConnectWalletSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F55A8E92648D343007C8002 /* ConnectWalletSheet.swift */; };
Expand Down Expand Up @@ -141,6 +144,9 @@
4F4C6981264F6483005B9A23 /* AutoglyphView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoglyphView.swift; sourceTree = "<group>"; };
4F4CA8002635D806001534A6 /* FavButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavButton.swift; sourceTree = "<group>"; };
4F4CA8052635D813001534A6 /* BackButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackButton.swift; sourceTree = "<group>"; };
4F4DD21A265DDE3C00AD320D /* NftUrlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NftUrlView.swift; sourceTree = "<group>"; };
4F4DD21C265DF1F400AD320D /* UserUrlView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserUrlView.swift; sourceTree = "<group>"; };
4F4DD21E265F480A00AD320D /* AddressLabelWithShare.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressLabelWithShare.swift; sourceTree = "<group>"; };
4F55A8E52648BB17007C8002 /* WalletView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletView.swift; sourceTree = "<group>"; };
4F55A8E72648D1DF007C8002 /* WalletTokensView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletTokensView.swift; sourceTree = "<group>"; };
4F55A8E92648D343007C8002 /* ConnectWalletSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectWalletSheet.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -396,6 +402,7 @@
children = (
4F468F682645FECB00CA6525 /* AddFavSheet.swift */,
4F5F8F5F265331AB00FAD814 /* AddressLabel.swift */,
4F4DD21E265F480A00AD320D /* AddressLabelWithShare.swift */,
4F43153E263E4E9500C16872 /* AsciiPunkView.swift */,
4F4C6981264F6483005B9A23 /* AutoglyphView.swift */,
4F4CA8052635D813001534A6 /* BackButton.swift */,
Expand All @@ -411,6 +418,7 @@
4FB9A7E3262B31D300C58AF9 /* MapView.swift */,
4FB9A81D262B53DE00C58AF9 /* NftDetail.swift */,
4F6D3974262BE4F3007E79BB /* NftImage.swift */,
4F4DD21A265DDE3C00AD320D /* NftUrlView.swift */,
4F667F6F264B2C0200E7A214 /* ObservedPromiseView.swift */,
4F5F8F5B26532BE200FAD814 /* OpenSeaLink.swift */,
4FA20037264DE73700E81BE6 /* OwnerProfileLinkButton.swift */,
Expand All @@ -420,6 +428,7 @@
4F5F8F5926531D3A00FAD814 /* TextFieldAlertView.swift */,
4F43153C2638EF7400C16872 /* TokenPrice.swift */,
4FB9A810262B508700C58AF9 /* UsdText.swift */,
4F4DD21C265DF1F400AD320D /* UserUrlView.swift */,
4F55A8E72648D1DF007C8002 /* WalletTokensView.swift */,
4F55A8E52648BB17007C8002 /* WalletView.swift */,
4F5F8F5D26532D9C00FAD814 /* WebView.swift */,
Expand Down Expand Up @@ -765,6 +774,7 @@
buildActionMask = 2147483647;
files = (
4FB9A811262B508700C58AF9 /* UsdText.swift in Sources */,
4F4DD21F265F480A00AD320D /* AddressLabelWithShare.swift in Sources */,
4FA20038264DE73700E81BE6 /* OwnerProfileLinkButton.swift in Sources */,
4FC7446A2630F9130060FC6D /* TokenProtocols.swift in Sources */,
4F667F6E264B291000E7A214 /* ObservablePromise.swift in Sources */,
Expand All @@ -787,6 +797,7 @@
4F08724B2651E740002DD748 /* PrivateCollectionView.swift in Sources */,
4FB9A7F3262B3A5700C58AF9 /* NFT.swift in Sources */,
4F08724D2651EAC0002DD748 /* FriendsView.swift in Sources */,
4F4DD21D265DF1F400AD320D /* UserUrlView.swift in Sources */,
4F468F692645FECB00CA6525 /* AddFavSheet.swift in Sources */,
4F55A8EA2648D343007C8002 /* ConnectWalletSheet.swift in Sources */,
4F667F70264B2C0200E7A214 /* ObservedPromiseView.swift in Sources */,
Expand All @@ -796,6 +807,7 @@
4F6D3975262BE4F3007E79BB /* NftImage.swift in Sources */,
4FB9A7B1262B28A300C58AF9 /* NFTYApp.swift in Sources */,
4FB9A7DF262B307C00C58AF9 /* CircleImage.swift in Sources */,
4F4DD21B265DDE3C00AD320D /* NftUrlView.swift in Sources */,
4F6D3962262BD8A8007E79BB /* CollectionView.swift in Sources */,
4FB9A7FB262B3BBA00C58AF9 /* ModelData.swift in Sources */,
4F55A8EC264A0642007C8002 /* BlockTimeLabel.swift in Sources */,
Expand Down Expand Up @@ -1089,6 +1101,7 @@
CODE_SIGN_ENTITLEMENTS = NFTY/NFTY.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
DEVELOPMENT_ASSET_PATHS = "NFTY/Preview\\ Content";
DEVELOPMENT_TEAM = C28QWE5379;
ENABLE_PREVIEWS = YES;
Expand All @@ -1098,7 +1111,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.4;
MARKETING_VERSION = 1.2.0;
PRODUCT_BUNDLE_IDENTIFIER = com.nftygo.NFTY;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1115,6 +1128,7 @@
CODE_SIGN_ENTITLEMENTS = NFTY/NFTY.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
DEVELOPMENT_ASSET_PATHS = "NFTY/Preview\\ Content";
DEVELOPMENT_TEAM = C28QWE5379;
ENABLE_PREVIEWS = YES;
Expand All @@ -1124,7 +1138,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.4;
MARKETING_VERSION = 1.2.0;
PRODUCT_BUNDLE_IDENTIFIER = com.nftygo.NFTY;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<key>DownloadCryptoPunks.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
<integer>1</integer>
</dict>
<key>MyPlayground (Playground) 1.xcscheme</key>
<dict>
Expand All @@ -54,12 +54,12 @@
<key>NFTY.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>4</integer>
</dict>
<key>ParseTokenDistances.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>3</integer>
</dict>
<key>PromiseKit (Playground) 1.xcscheme</key>
<dict>
Expand Down Expand Up @@ -106,12 +106,12 @@
<key>RankImages.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
<integer>5</integer>
</dict>
<key>RarityRanking.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>5</integer>
<integer>0</integer>
</dict>
<key>TestUI.xcscheme_^#shared#^_</key>
<dict>
Expand Down
17 changes: 17 additions & 0 deletions NFTY/Model/NFT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,23 @@ extension String {
}
}

extension URL {
func params() -> [String:Any] {
var dict = [String:Any]()

if let components = URLComponents(url: self, resolvingAgainstBaseURL: false) {
if let queryItems = components.queryItems {
for item in queryItems {
dict[item.name] = item.value!
}
}
return dict
} else {
return [:]
}
}
}

let SAMPLE_WALLET_ADDRESS = try! EthereumAddress(
hex: "0x208b82b04449cd51803fae4b1561450ba13d9510",
eip55:false)
Expand Down
4 changes: 3 additions & 1 deletion NFTY/Model/TokenProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ class CompositeRecentTradesObject : ObservableObject {
collection.data.recentTrades.loadLatest() {
DispatchQueue.main.async {
self.pendingCounterLatest-=1
onDone()
if (self.pendingCounterLatest < 2) {
onDone()
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions NFTY/NFTY.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!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.developer.associated-domains</key>
<array>
<string>applinks:nftygo.com</string>
<string>applinks:*.nftygo.com</string>
</array>
<key>com.apple.developer.icloud-container-identifiers</key>
<array/>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
Expand Down
66 changes: 58 additions & 8 deletions NFTY/NFTYApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import Web3

extension UINavigationController: UIGestureRecognizerDelegate {
override open func viewDidLoad() {
Expand All @@ -20,33 +21,49 @@ extension UINavigationController: UIGestureRecognizerDelegate {

@main
struct NFTYApp: App {
enum SheetStateEnum {
case nft(String,UInt)
case user(EthereumAddress)
}
struct SheetState : Identifiable {
let state : SheetStateEnum

var id : String {
switch state {
case .nft(let address,let tokenId):
return "nft(\(address),\(tokenId))"
case .user(let address):
return "user(\(address.hex(eip55:true)))"
}
}
}

@State private var sheetState : SheetState? = nil

var body: some Scene {
WindowGroup {
TabView {

NavigationView {
CollectionsView(collections:COLLECTIONS)
.navigationBarTitle("Gallery")
FeedView(trades:CompositeCollection)
.navigationBarTitle("Recent")
}
.tabItem {
Label("Gallery",systemImage:"square.grid.3x1.fill.below.line.grid.1x2")
Label("Recent",systemImage:"sparkles.rectangle.stack.fill")
}
.navigationViewStyle(StackNavigationViewStyle())
.accentColor(.secondary)


NavigationView {
FeedView(trades:CompositeCollection)
.navigationBarTitle("Recent")
CollectionsView(collections:COLLECTIONS)
.navigationBarTitle("Gallery")
}
.tabItem {
Label("Recent",systemImage:"sparkles.rectangle.stack.fill")
Label("Gallery",systemImage:"square.grid.3x1.fill.below.line.grid.1x2")
}
.navigationViewStyle(StackNavigationViewStyle())
.accentColor(.secondary)


NavigationView {
FriendsView()
.navigationBarTitle("Friends")
Expand Down Expand Up @@ -78,7 +95,40 @@ struct NFTYApp: App {
.accentColor(.secondary)


}.onOpenURL { url in
print("URL=\(url)") // comes as https://nftygo.com/nft?address=0x5283Fc3a1Aac4DaC6B9581d3Ab65f4EE2f3dE7DC&tokenId=1974
print("URL.last=\(url.pathComponents.last)")
print("URL.params=\(url.params())")

switch url.pathComponents.last {
case .some("nft"):
let params = url.params()
switch (params["address"] as? String,(params["tokenId"] as? String).flatMap { UInt($0) }) {
case (.some(let address),.some(let tokenId)):
self.sheetState = SheetState(state: .nft(address,tokenId))
default:
break
}
case .some("user"):
let params = url.params()
switch (params["address"] as? String).flatMap { try? EthereumAddress(hex:$0,eip55:false) } {
case .some(let address):
self.sheetState = SheetState(state: .user(address))
case .none:
break
}
default:
break
}
}.sheet(item: $sheetState, onDismiss: { self.sheetState = nil }) { (item:SheetState) in
switch item.state {
case .nft(let address,let tokenId):
NftUrlView(address: address, tokenId: tokenId)
case .user(let address):
UserUrlView(address: address)
}
}

}
}
}
5 changes: 5 additions & 0 deletions NFTY/Views/AddressLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ struct AddressLabel: View {
let maxLen : Int

var body: some View {

Text(address.trunc(length:maxLen))
.font(.system(size:12, design: .monospaced))
.foregroundColor(.secondary)
.onTapGesture(count: 2) {
UIPasteboard.general.string = address
}

}
}

Expand Down
50 changes: 50 additions & 0 deletions NFTY/Views/AddressLabelWithShare.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// AddressLabelWithShare.swift
// NFTY
//
// Created by Varun Kohli on 5/26/21.
//

import SwiftUI

struct AddressLabelWithShare: View {
let address : String
let maxLen : Int

var body: some View {
HStack {
Spacer()
AddressLabel(address: address, maxLen: maxLen)

Button(action: {
var components = URLComponents()
components.scheme = "https"
components.host = "nftygo.com"
components.path = "/user"
components.queryItems = [
URLQueryItem(name: "address", value: address)
]
guard let urlShare = components.url else { return }

// https://stackoverflow.com/a/64962982
let shareActivity = UIActivityViewController(activityItems: [urlShare], applicationActivities: nil)
if let vc = UIApplication.shared.windows.first?.rootViewController {
shareActivity.popoverPresentationController?.sourceView = vc.view
//Setup share activity position on screen on bottom center
shareActivity.popoverPresentationController?.sourceRect = CGRect(x: UIScreen.main.bounds.width / 2, y: UIScreen.main.bounds.height, width: 0, height: 0)
shareActivity.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.down
vc.present(shareActivity, animated: true, completion: nil)
}
}, label: {
Image(systemName: "arrowshape.turn.up.forward.circle")
.foregroundColor(.secondary)
}).padding(.leading)
}
}
}

struct AddressLabelWithShare_Previews: PreviewProvider {
static var previews: some View {
AddressLabelWithShare(address:"0x0",maxLen:30)
}
}
3 changes: 2 additions & 1 deletion NFTY/Views/CollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ struct CollectionView: View {
themeColor:info.themeColor,
themeLabelColor:info.themeLabelColor,
similarTokens:info.similarTokens,
rarityRank:info.rarityRank
rarityRank:info.rarityRank,
hideOwnerLink:false
),tag:String(nft.nft.tokenId),selection:$action) {}
.hidden()
}.onAppear {
Expand Down
2 changes: 2 additions & 0 deletions NFTY/Views/FavButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ struct FavButton: View {
}
NSUbiquitousKeyValueStore.default.set(favorites,forKey:CloudDefaultStorageKeys.favoritesDict.rawValue)
}
let impactMed = UIImpactFeedbackGenerator(style: .light)
impactMed.impactOccurred()
}
.padding()
.onAppear {
Expand Down
3 changes: 2 additions & 1 deletion NFTY/Views/FavoritesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ struct FavoritesView: View {
themeColor:info.themeColor,
themeLabelColor:info.themeLabelColor,
similarTokens:info.similarTokens,
rarityRank:info.rarityRank
rarityRank:info.rarityRank,
hideOwnerLink:false
),tag:nft.nft.tokenId,selection:$selectedTokenId) {}
.hidden()
}
Expand Down
Loading

0 comments on commit a921d05

Please sign in to comment.