Skip to content

Commit

Permalink
added deeplink routing
Browse files Browse the repository at this point in the history
  • Loading branch information
sidorov-panda committed Feb 3, 2020
1 parent 4ffae4f commit be67cc7
Show file tree
Hide file tree
Showing 19 changed files with 178 additions and 65 deletions.
12 changes: 8 additions & 4 deletions MinterWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,6 @@
FA3948862350924B002AD8DE /* ConfirmPopupViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmPopupViewModel.swift; sourceTree = "<group>"; };
FA3CD61723ABBEFC004DDF29 /* MinterWallet.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MinterWallet.entitlements; sourceTree = "<group>"; };
FA3CD61823ABBEFC004DDF29 /* PassKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PassKit.framework; path = System/Library/Frameworks/PassKit.framework; sourceTree = SDKROOT; };
FA3CD61A23ABBF03004DDF29 /* MinterWalletTestnet.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MinterWalletTestnet.entitlements; sourceTree = "<group>"; };
FA3CD61C23ABC138004DDF29 /* PassbookManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassbookManager.swift; sourceTree = "<group>"; };
FA3E1B8C2376FBF6008C4717 /* RawTransactionViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawTransactionViewModelTests.swift; sourceTree = "<group>"; };
FA428C5420BD8D5F00EF662D /* String+RawTransactionAddress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+RawTransactionAddress.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1758,7 +1757,6 @@
FA669B5C207239F100AD110A = {
isa = PBXGroup;
children = (
FA3CD61A23ABBF03004DDF29 /* MinterWalletTestnet.entitlements */,
FA669B67207239F200AD110A /* MinterWallet */,
FA669B7E207239F200AD110A /* MinterWalletTests */,
FA669B89207239F200AD110A /* MinterWalletUITests */,
Expand Down Expand Up @@ -2541,6 +2539,7 @@
"${BUILT_PRODUCTS_DIR}/AlamofireImage/AlamofireImage.framework",
"${BUILT_PRODUCTS_DIR}/BigInt/BigInt.framework",
"${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework",
"${BUILT_PRODUCTS_DIR}/DeckTransition/DeckTransition.framework",
"${BUILT_PRODUCTS_DIR}/Differentiator/Differentiator.framework",
"${BUILT_PRODUCTS_DIR}/GoldenKeystore/GoldenKeystore.framework",
"${BUILT_PRODUCTS_DIR}/GrowingTextView/GrowingTextView.framework",
Expand Down Expand Up @@ -2580,6 +2579,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AlamofireImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BigInt.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DeckTransition.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Differentiator.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoldenKeystore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GrowingTextView.framework",
Expand Down Expand Up @@ -2665,6 +2665,7 @@
"${BUILT_PRODUCTS_DIR}/AlamofireImage/AlamofireImage.framework",
"${BUILT_PRODUCTS_DIR}/BigInt/BigInt.framework",
"${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework",
"${BUILT_PRODUCTS_DIR}/DeckTransition/DeckTransition.framework",
"${BUILT_PRODUCTS_DIR}/Differentiator/Differentiator.framework",
"${BUILT_PRODUCTS_DIR}/GoldenKeystore/GoldenKeystore.framework",
"${BUILT_PRODUCTS_DIR}/GrowingTextView/GrowingTextView.framework",
Expand Down Expand Up @@ -2704,6 +2705,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AlamofireImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BigInt.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DeckTransition.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Differentiator.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoldenKeystore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GrowingTextView.framework",
Expand Down Expand Up @@ -2797,6 +2799,7 @@
"${BUILT_PRODUCTS_DIR}/AlamofireImage/AlamofireImage.framework",
"${BUILT_PRODUCTS_DIR}/BigInt/BigInt.framework",
"${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework",
"${BUILT_PRODUCTS_DIR}/DeckTransition/DeckTransition.framework",
"${BUILT_PRODUCTS_DIR}/Differentiator/Differentiator.framework",
"${BUILT_PRODUCTS_DIR}/GoldenKeystore/GoldenKeystore.framework",
"${BUILT_PRODUCTS_DIR}/GrowingTextView/GrowingTextView.framework",
Expand Down Expand Up @@ -2836,6 +2839,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AlamofireImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BigInt.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DeckTransition.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Differentiator.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoldenKeystore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GrowingTextView.framework",
Expand Down Expand Up @@ -3610,7 +3614,7 @@
CODE_SIGN_ENTITLEMENTS = MinterWalletTestnet.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 244;
CURRENT_PROJECT_VERSION = 245;
DEVELOPMENT_TEAM = A26H28FPZU;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -3645,7 +3649,7 @@
CODE_SIGN_ENTITLEMENTS = MinterWalletTestnet.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 244;
CURRENT_PROJECT_VERSION = 245;
DEVELOPMENT_TEAM = A26H28FPZU;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
13 changes: 13 additions & 0 deletions MinterWallet/Classes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationWillTerminate(_ application: UIApplication) {
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
if let url = userActivity.webpageURL {
var components = URLComponents(url: url, resolvingAgainstBaseURL: true)
components?.host = ""

if let newURL = try? components?.asURL() {
applicationOpenWithURL.onNext(())
(window?.rootViewController as? RootViewController)?.viewModel.input.proceedURL.onNext(newURL)
}
}
return true
}

var applicationOpenWithURL = PublishSubject<Void>()
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
applicationOpenWithURL.onNext(())
Expand Down
5 changes: 4 additions & 1 deletion MinterWallet/Classes/Common/Helper/SendRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class SendRouter: BaseRouter {
}

static func viewController(path: [String], param: [String: Any]) -> UIViewController? {
return Storyboards.Send.instantiateInitialViewController()
let viewModel = SendViewModel(dependency: SendViewModel.Dependency())
let sendVC = Storyboards.Send.instantiateSendViewController()
sendVC.viewModel = viewModel
return sendVC
}

static func sendViewController(viewModel: SendViewModel) -> UIViewController? {
Expand Down
5 changes: 4 additions & 1 deletion MinterWallet/Classes/Common/Helper/SettingsRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class SettingsRouter: BaseRouter {
}

static func viewController(path: [String], param: [String: Any]) -> UIViewController? {
return Storyboards.Send.instantiateInitialViewController()
let viewModel = SettingsViewModel()
let settingsVC = Storyboards.Settings.instantiateSettingsViewController()
settingsVC.viewModel = viewModel
return settingsVC
}

static func settingsViewController(viewModel: SettingsViewModel) -> UIViewController? {
Expand Down
4 changes: 3 additions & 1 deletion MinterWallet/Classes/Common/Helper/TransactionsRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class TransactionsRouter: BaseRouter {
}

static func viewController(path: [String], param: [String: Any]) -> UIViewController? {
return Storyboards.Coins.instantiateInitialViewController()
let coinsVC = Storyboards.Transactions.instantiateTransactionsViewController()
coinsVC.viewModel = TransactionsViewModel()
return coinsVC
}

static func transactionsViewController(viewModel: TransactionsViewModel) -> UIViewController? {
Expand Down
7 changes: 3 additions & 4 deletions MinterWallet/Classes/Common/Router/BaseRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Router {
let urlPattern = (url.host ?? "").appending(url.path)

var matches = false
var params = [String : Any]()
var params = [String: Any]()
var path = [String]()

let router = routers.filter { (router) -> Bool in
Expand Down Expand Up @@ -105,7 +105,7 @@ class Router {

// MARK: -

private func matches(pattern: String, origin: String) -> (Bool, [String : Any], [String]) {
private func matches(pattern: String, origin: String) -> (Bool, [String: Any], [String]) {
let components1 = pattern.components(separatedBy: "/").filter { (str) -> Bool in
return str != ""
}
Expand Down Expand Up @@ -159,8 +159,7 @@ class Router {
} else {
if c2 != c1 {
return (false, [:], [])
}
else {
} else {
resPathDict.append(c2)
}
}
Expand Down
5 changes: 4 additions & 1 deletion MinterWallet/Classes/Receive/Router/ReceiveRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class ReceiveRouter: BaseRouter {
}

static func viewController(path: [String], param: [String: Any]) -> UIViewController? {
return Storyboards.Receive.instantiateInitialViewController()
let viewModel = ReceiveViewModel(dependency: ReceiveViewModel.Dependency(accounts: Session.shared.accounts.asObservable()))
let receiveVC = Storyboards.Receive.instantiateReceiveViewController()
receiveVC.viewModel = viewModel
return receiveVC
}

static func receiveViewController(viewModel: ReceiveViewModel) -> UIViewController? {
Expand Down
22 changes: 18 additions & 4 deletions MinterWallet/Classes/Root/ViewController/RootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import RxSwift
import Reachability
import NotificationBannerSwift
import MinterMy
import DeckTransition

class RootViewController: UIViewController, ControllerType {

Expand Down Expand Up @@ -67,13 +68,26 @@ class RootViewController: UIViewController, ControllerType {
.drive(onNext: { [weak self] (url) in
self?.viewModel.input.didOpenURL.onNext(url)
guard let url = url else { return }
if let vc = Router.viewController(by: url) {
if let oldVC = self?.presentedViewController {
if let viewController = Router.viewController(by: url) {
if (self?.presentedViewController) != nil {
UIApplication.shared.keyWindow?.rootViewController?.dismiss(animated: true, completion: {
self?.show(vc, sender: self)
self?.show(viewController, sender: self)
})
} else {
self?.show(vc, sender: self)
if let index = self?.tabbarVC.viewControllers?.firstIndex(where: { (controller) -> Bool in
if let classForCoder = (controller as? UINavigationController)?.viewControllers.first?.classForCoder {
return classForCoder == viewController.classForCoder
}
return false
}) {
self?.tabbarVC.selectedIndex = index
return
}

let transitionDelegate = DeckTransitioningDelegate()
viewController.transitioningDelegate = transitionDelegate
viewController.modalPresentationStyle = .custom
self?.present(viewController, animated: true, completion: nil)
}
} else {
if url.host == "tx" || url.path.contains("tx") {
Expand Down
2 changes: 1 addition & 1 deletion MinterWallet/Classes/Root/ViewModel/RootViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class RootViewModel: BaseViewModel, ViewModelProtocol {
if let sendVC = SendRouter.sendViewController(viewModel: sendVM) {
vcs.append(sendVC)
}

let receiveVM = ReceiveViewModel(dependency: ReceiveViewModel.Dependency(accounts: Session.shared.accounts.asObservable()))
if let receiveVC = ReceiveRouter.receiveViewController(viewModel: receiveVM) {
vcs.append(receiveVC)
Expand Down
33 changes: 17 additions & 16 deletions MinterWallet/Classes/Send/View/AmountTextFieldTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
Expand All @@ -19,42 +17,44 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="110" id="hDh-eC-pEM" customClass="AmountTextFieldTableViewCell" customModule="MinterWallet" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="375" height="110"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="101" id="hDh-eC-pEM" customClass="AmountTextFieldTableViewCell" customModule="MinterWallet" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="375" height="101"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="hDh-eC-pEM" id="83j-Qc-TsO">
<rect key="frame" x="0.0" y="0.0" width="375" height="109.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="101"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dre-gy-gzx">
<rect key="frame" x="20" y="2" width="28" height="33"/>
<rect key="frame" x="20" y="6" width="28" height="15"/>
<constraints>
<constraint firstAttribute="height" constant="15" id="xOK-eJ-jye"/>
</constraints>
<fontDescription key="fontDescription" name="Ubuntu-Medium" family="Ubuntu" pointSize="11"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="H5j-b4-ihl">
<rect key="frame" x="58" y="18.5" width="307" height="0.0"/>
<rect key="frame" x="58" y="13.5" width="307" height="0.0"/>
<fontDescription key="fontDescription" name="Ubuntu-Medium" family="Ubuntu" pointSize="12"/>
<color key="textColor" red="0.95693963770000001" green="0.23488524559999999" blue="0.21839424969999999" alpha="1" colorSpace="deviceRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Ond-CZ-BlM" customClass="ValidatableTextField" customModule="MinterWallet" customModuleProvider="target">
<rect key="frame" x="10" y="43.5" width="355" height="46"/>
<rect key="frame" x="10" y="29.5" width="355" height="46"/>
<constraints>
<constraint firstAttribute="height" constant="46" id="tZr-V1-rnK"/>
</constraints>
<nil key="textColor"/>
<fontDescription key="fontDescription" name="Ubuntu-Medium" family="Ubuntu" pointSize="16"/>
<textInputTraits key="textInputTraits"/>
<connections>
<outlet property="delegate" destination="hDh-eC-pEM" id="oah-yG-WdO"/>
</connections>
</textField>
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="4Vh-DY-qeM">
<rect key="frame" x="260" y="56.5" width="20" height="20"/>
<rect key="frame" x="260" y="42.5" width="20" height="20"/>
</activityIndicatorView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aKF-ms-b8X">
<rect key="frame" x="286" y="52.5" width="63" height="28"/>
<rect key="frame" x="286" y="38.5" width="63" height="28"/>
<fontDescription key="fontDescription" name="Ubuntu-Bold" family="Ubuntu" pointSize="14"/>
<state key="normal" title="USE MAX">
<color key="titleColor" red="0.31372549019607843" green="0.1803921568627451" blue="0.76078431372549016" alpha="1" colorSpace="deviceRGB"/>
Expand All @@ -67,7 +67,8 @@
</subviews>
<constraints>
<constraint firstItem="H5j-b4-ihl" firstAttribute="leading" secondItem="dre-gy-gzx" secondAttribute="trailing" constant="10" id="0p3-WJ-Ykx"/>
<constraint firstItem="dre-gy-gzx" firstAttribute="top" secondItem="83j-Qc-TsO" secondAttribute="top" constant="2" id="5wR-Cd-0vO"/>
<constraint firstItem="Ond-CZ-BlM" firstAttribute="top" secondItem="83j-Qc-TsO" secondAttribute="top" constant="29.5" id="1N4-Gn-ZV1"/>
<constraint firstItem="dre-gy-gzx" firstAttribute="top" secondItem="83j-Qc-TsO" secondAttribute="top" constant="6" id="5wR-Cd-0vO"/>
<constraint firstItem="H5j-b4-ihl" firstAttribute="trailing" secondItem="Ond-CZ-BlM" secondAttribute="trailing" id="8MS-0k-fKt"/>
<constraint firstItem="aKF-ms-b8X" firstAttribute="trailing" secondItem="Ond-CZ-BlM" secondAttribute="trailing" constant="-16" id="8bm-bq-4oE"/>
<constraint firstItem="H5j-b4-ihl" firstAttribute="centerY" secondItem="dre-gy-gzx" secondAttribute="centerY" id="AsD-98-LZB"/>
Expand All @@ -88,7 +89,7 @@
<outlet property="title" destination="dre-gy-gzx" id="KJr-wI-OeO"/>
<outlet property="useMaxButton" destination="aKF-ms-b8X" id="NO2-Zu-bGU"/>
</connections>
<point key="canvasLocation" x="-102.5" y="-98"/>
<point key="canvasLocation" x="-103.2" y="-102.09895052473765"/>
</tableViewCell>
</objects>
</document>
Loading

0 comments on commit be67cc7

Please sign in to comment.