Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Draft: 169 - Universal Linking Capability #177

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
4 changes: 4 additions & 0 deletions DSNP-Wallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@
B53BD7BF2A01571000967477 /* ChainEnvironment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChainEnvironment.swift; sourceTree = "<group>"; };
B544C0922A5EF15D000A2C77 /* TermsText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsText.swift; sourceTree = "<group>"; };
B544C0942A5EF2A5000A2C77 /* TermsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsView.swift; sourceTree = "<group>"; };
B544C0962A65BBB6000A2C77 /* DSNP-Wallet.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "DSNP-Wallet.entitlements"; sourceTree = "<group>"; };
B5966F242A0007FF00A17F08 /* QAViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QAViewController.swift; sourceTree = "<group>"; };
B5966F262A00080900A17F08 /* QAView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QAView.swift; sourceTree = "<group>"; };
B5A62BE62A0A8F2900A31178 /* Poppins-ExtraBold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Poppins-ExtraBold.ttf"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1119,6 +1120,7 @@
8223AB592818917700DEF1E9 /* DSNP-Wallet */ = {
isa = PBXGroup;
children = (
B544C0962A65BBB6000A2C77 /* DSNP-Wallet.entitlements */,
829960392978C45D009A769F /* Common */,
829960C42978C45F009A769F /* Modules */,
8223ABCD2820808500DEF1E9 /* Resources */,
Expand Down Expand Up @@ -3189,6 +3191,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "DSNP-Wallet/DSNP-Wallet.entitlements";
CODE_SIGN_IDENTITY = "Apple Development: Vitali Krasnik (7WQU5BRP22)";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2;
Expand Down Expand Up @@ -3226,6 +3229,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "DSNP-Wallet/DSNP-Wallet.entitlements";
CODE_SIGN_IDENTITY = "Apple Development: Vitali Krasnik (7WQU5BRP22)";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2;
Expand Down
10 changes: 10 additions & 0 deletions DSNP-Wallet/DSNP-Wallet.entitlements
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.developer.associated-domains</key>
<array>
<string>applinks:dev-custodial-wallet.liberti.social</string>
</array>
</dict>
</plist>
20 changes: 10 additions & 10 deletions DSNP-Wallet/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Foundation
class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
private lazy var dlManager = DeeplinkManager()

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
Expand All @@ -22,6 +21,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
let window = UIWindow(windowScene: windowScene)

var rootViewController: UIViewController?


#if DEBUG
rootViewController = BaseViewController()
Expand All @@ -41,8 +41,14 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
self.window = window
window.makeKeyAndVisible()

if let urlContext = connectionOptions.urlContexts.first {
dlManager.add(url: urlContext.url)
}

// MARK: Handle Universal Link
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
let alert = UIAlertController(title: "Universal Link Detected!", message: "URL recieved: \(userActivity.webpageURL?.absoluteString ?? "url missing") \n ActivityType: \(userActivity.activityType)", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil))
if let vc = window?.rootViewController {
vc.present(alert, animated: true)
}
}

Expand Down Expand Up @@ -70,7 +76,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
//Accounts for when user has already entered pin, and has keys, then notify of retrieved keys.

if let _ = try? AccountKeychain.shared.fetchKey() {
dlManager.viewController = window?.rootViewController
NotificationCenter.default.post(name: Notification.Name(NotificationType.retrievedKeys.rawValue),
object: nil)
}
Expand All @@ -81,10 +86,5 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let urlContext = URLContexts.first else { return }
dlManager.viewController = window?.rootViewController
dlManager.add(url: urlContext.url)
}

}
9 changes: 8 additions & 1 deletion DSNP-Wallet/Source/Modules/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

extension UIApplication {
var firstKeyWindow: UIWindow? {
return UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.filter { $0.activationState == .foregroundActive }
.first?.keyWindow
}
}
160 changes: 111 additions & 49 deletions DSNP-Wallet/Source/Modules/Onboarding/NewUI/SignInView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import SafariServices

extension PresentationDetent {
static let small = Self.height(100)
Expand Down Expand Up @@ -67,39 +68,89 @@ struct SignInView: View {
.frame(maxWidth: .infinity)
}

// MARK: Restore Button

var restoreButton: some View {
VStack {
if !hasAgreedToTerms {
Button {
termsPresented = true
} label: {
Text("Restore Account")
.foregroundColor(.white)
.font(Font(UIFont.Theme.regular(ofSize: 14)))
.underline()
}
.sheet(isPresented: $termsPresented) {
TermsView()
.presentationDetents([.extraLarge])
.presentationDragIndicator(.visible)
.background(Color(uiColor: UIColor.Theme.bgGray))
}
restoreButtonTerms
} else {
NavigationLink(
destination: LazyView(ImportSeedView(viewModel: ImportSeedViewModel()))) {
Text("Restore Account")
.foregroundColor(.white)
.font(Font(UIFont.Theme.regular(ofSize: 14)))
.underline()
}
.padding(.vertical, 12)
.padding(.horizontal, 34)
.accessibilityIdentifier(AccessibilityIdentifier.OnboardingIdentifiers.restoreUserButton)
restoreButtonNavigation
}
}
}

var restoreButtonTerms: some View {
Button {
termsPresented = true
} label: {
Text("Restore Account")
.foregroundColor(.white)
.font(Font(UIFont.Theme.regular(ofSize: 14)))
.underline()
}
.sheet(isPresented: $termsPresented) {
TermsView()
.presentationDetents([.extraLarge])
.presentationDragIndicator(.visible)
.background(Color(uiColor: UIColor.Theme.bgGray))
}
}

var restoreButtonNavigation: some View {
NavigationLink(
destination: LazyView(ImportSeedView(viewModel: ImportSeedViewModel()))) {
Text("Restore Account")
.foregroundColor(.white)
.font(Font(UIFont.Theme.regular(ofSize: 14)))
.underline()
}
.padding(.vertical, 12)
.padding(.horizontal, 34)
.accessibilityIdentifier(AccessibilityIdentifier.OnboardingIdentifiers.restoreUserButton)
}

// MARK: Have an ID Button

var haveAnIdButton: some View {
VStack {
if !hasAgreedToTerms {
haveAnIdButtonTerms
} else {
haveAnIdButtonNavigation
}
}
}

var haveAnIdButtonNavigation: some View {
Button {
if !hasAgreedToTerms {
termsPresented = true
} else {
let vc = SFSafariViewController(url: URL(string: "https://dev-custodial-wallet.liberti.social/access_web/index.html")!)
UIApplication.shared.firstKeyWindow?.rootViewController?.present(vc, animated: true)
}
} label: {
HStack {
Text("I have an ID")
.font(Font(UIFont.Theme.medium(ofSize: 14)))
.padding(.vertical, 16)
.padding(.horizontal, 12)
Image("mewelogo")
.padding(.bottom, 6)
.padding(.leading, -15)
}
}
.frame(maxWidth: .infinity)
.background(Color(uiColor: UIColor.Theme.buttonTeal))
.foregroundColor(.white)
.cornerRadius(30)
.padding(.vertical, 12)
.padding(.horizontal, 34)
.accessibilityIdentifier(AccessibilityIdentifier.OnboardingIdentifiers.createUserMeWeButton)
}

var haveAnIdButtonTerms: some View {
Button {
if !hasAgreedToTerms {
termsPresented = true
Expand Down Expand Up @@ -132,38 +183,49 @@ struct SignInView: View {
}
}

// MARK: Create Identity Button

var createIdentityButton: some View {
VStack {
if !hasAgreedToTerms {
PrimaryButton(title: "Create Identity") {
termsPresented = true
}
.padding(.horizontal, 34)
.sheet(isPresented: $termsPresented) {
TermsView()
.presentationDetents([.extraLarge])
.presentationDragIndicator(.visible)
.background(Color(uiColor: UIColor.Theme.bgGray))
}
createButtonTerms
} else {
NavigationLink(
destination: LazyView(ClaimHandleView(viewModel: ClaimHandleViewModel()))) {
Text("Create Identity")
.font(Font(UIFont.Theme.medium(ofSize: 14)))
.padding(.vertical, 16)
.padding(.horizontal, 34)
.foregroundColor(.white)
}
.accessibilityIdentifier(AccessibilityIdentifier.OnboardingIdentifiers.createNewUserButton)
.frame(maxWidth: .infinity)
.background(Color(uiColor: UIColor.Theme.buttonTeal))
.foregroundColor(.white)
.cornerRadius(30)
.padding(.vertical, 10)
.padding(.horizontal, 34)
createButtonNavigation
}
}
}

var createButtonTerms: some View {
PrimaryButton(title: "Create Identity") {
termsPresented = true
}
.padding(.horizontal, 34)
.sheet(isPresented: $termsPresented) {
TermsView()
.presentationDetents([.extraLarge])
.presentationDragIndicator(.visible)
.background(Color(uiColor: UIColor.Theme.bgGray))
}
}

var createButtonNavigation: some View {
NavigationLink(
destination: LazyView(ClaimHandleView(viewModel: ClaimHandleViewModel()))) {
Text("Create Identity")
.font(Font(UIFont.Theme.medium(ofSize: 14)))
.padding(.vertical, 16)
.padding(.horizontal, 34)
.foregroundColor(.white)
}
.accessibilityIdentifier(AccessibilityIdentifier.OnboardingIdentifiers.createNewUserButton)
.frame(maxWidth: .infinity)
.background(Color(uiColor: UIColor.Theme.buttonTeal))
.foregroundColor(.white)
.cornerRadius(30)
.padding(.vertical, 10)
.padding(.horizontal, 34)
}

}

struct SignInView_Previews: PreviewProvider {
Expand Down