Skip to content

Commit

Permalink
Use the Info.plist scheme for router. And updated Abacus (#14)
Browse files Browse the repository at this point in the history
* Use the Info.plist scheme for router.
And updated Abacus

* Replaces other occurrences of AbacusStateManager.shared.appSetting?.scheme

* Update Cocoapods
  • Loading branch information
johnqh authored and mike-dydx committed Aug 21, 2024
1 parent adeea56 commit 4ee94a0
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 28 deletions.
22 changes: 15 additions & 7 deletions Utilities/Utilities/_Extensions/Bundle+UIBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public extension Bundle {
var bundles = [Bundle]()
bundles.append(Bundle.main)
if let json = JsonLoader.load(bundle: Bundle.main, fileName: "ui.json") as? [String] {
let names = json.map({ (name) -> String in
let names = json.map({ name -> String in
name.lowercased()
})
let set = Set(names)
Expand All @@ -52,9 +52,9 @@ public extension Bundle {
}
return bundles
}()
@objc static func load(xib name: String, owner: Any?, options: [UINib.OptionsKey : Any]? = nil) -> [Any]? {
var result: [Any]? = nil

@objc static func load(xib name: String, owner: Any?, options: [UINib.OptionsKey: Any]? = nil) -> [Any]? {
var result: [Any]?
for bundle in particles {
result = bundle.safeLoad(xib: name, owner: owner, options: options)
}
Expand All @@ -68,6 +68,14 @@ public extension Bundle {
}
return nil
}

var scheme: String? {
return parser.asStrings(
parser.asDictionary(
parser.asArray(Bundle.main.infoDictionary?["CFBundleURLTypes"])?.first
)?["CFBundleURLSchemes"]
)?.first
}
}

public extension Bundle {
Expand All @@ -76,7 +84,7 @@ public extension Bundle {
object(forInfoDictionaryKey: "CFBundleName") as? String
}

@objc func safeLoad(xib: String, owner: Any? = nil, options: [UINib.OptionsKey : Any]? = nil) -> [Any]? {
@objc func safeLoad(xib: String, owner: Any? = nil, options: [UINib.OptionsKey: Any]? = nil) -> [Any]? {
let file = path(forResource: xib, ofType: "nib")
if File.exists(file) {
return loadNibNamed(xib, owner: owner, options: options)
Expand All @@ -93,7 +101,7 @@ public extension Bundle {
var build: String? {
return infoDictionary?["CFBundleVersion"] as? String
}

var versionAndBuild: String? {
if let version = version {
if let build = build {
Expand All @@ -111,7 +119,7 @@ public extension Bundle {
}
return nil
}

func versionCompare(otherVersion: String) -> ComparisonResult {
guard let version = version else {
return .orderedAscending
Expand Down
2 changes: 1 addition & 1 deletion dydx/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: a4f25d50f2991cc8e84eca8d34be23b37908132b

COCOAPODS: 1.13.0
COCOAPODS: 1.14.2
2 changes: 1 addition & 1 deletion dydx/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extension WalletConnectV2Config {
guard let projectId = environment.walletConnection?.walletConnect?.v2?.projectId,
let clientName = environment.walletConnection?.walletConnect?.client.name,
let clientDescription = environment.walletConnection?.walletConnect?.client.description,
let scheme = AbacusStateManager.shared.appSetting?.scheme
let scheme = Bundle.main.scheme
else {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private class dydxDebugViewPresenter: SettingsViewPresenter {
init() {
super.init(definitionFile: "debug.json",
keyValueStore: FeatureFlagsStore.shared,
appScheme: AbacusStateManager.shared.appSetting?.scheme)
appScheme: Bundle.main.scheme)

let header = SettingHeaderViewModel()
header.text = "Debug Settings"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private class dydxFeatureFlagsViewPresenter: SettingsViewPresenter {
init() {
super.init(definitionFile: "features.json",
keyValueStore: FeatureFlagsStore.shared,
appScheme: AbacusStateManager.shared.appSetting?.scheme)
appScheme: Bundle.main.scheme)

let header = SettingHeaderViewModel()
header.text = "Feature Flags"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private class dydxSettingsLandingViewPresenter: SettingsLandingViewPresenter {
}
super.init(definitionFile: definitionFile,
keyValueStore: SettingsStore.shared,
appScheme: AbacusStateManager.shared.appSetting?.scheme)
appScheme: Bundle.main.scheme)

let header = SettingHeaderViewModel()
header.text = DataLocalizer.localize(path: "APP.EMAIL_NOTIFICATIONS.SETTINGS")
Expand Down
30 changes: 15 additions & 15 deletions dydxV4/dydxV4/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
// Copyright © 2018 dYdX. All rights reserved.
//

import Cartera
import CoinbaseWalletSDK
import Combine
import dydxFormatter
import dydxPresenters
import dydxStateManager
import dydxViews
import ParticlesKit
import PlatformParticles
import PlatformRouting
import PlatformUI
import RoutingKit
import UIAppToolkits
import UIToolkits
import Utilities
import CoinbaseWalletSDK
import PlatformUI
import dydxViews
import dydxStateManager
import Cartera
import Combine
import dydxFormatter
import dydxPresenters

#if _iOS
import FirebaseStaticInjections
import Foundation
import UIKit
import FirebaseStaticInjections
import Foundation
import UIKit
#endif

public class dydxAppInjection: ParticlesPlatformAppInjection {
Expand Down Expand Up @@ -138,9 +138,9 @@ class AppDelegate: CommonAppDelegate {
override func router() -> RouterProtocol? {
let routingFile = "routing_swiftui.json"

if let scheme = AbacusStateManager.shared.appSetting?.scheme,
let file = Bundle.dydxPresenters.path(forResource: routingFile, ofType: ""),
let jsonString = try? String(contentsOfFile: file).replacingOccurrences(of: "{APP_SCHEME}", with: scheme) {
let scheme = Bundle.main.scheme ?? "dydxv4"
if let file = Bundle.dydxPresenters.path(forResource: routingFile, ofType: ""),
let jsonString = try? String(contentsOfFile: file).replacingOccurrences(of: "{APP_SCHEME}", with: scheme) {
let router = MappedUIKitAppRouter(jsonString: jsonString)
router.appState = AppState.shared
// sets up web app routing path
Expand All @@ -155,7 +155,7 @@ class AppDelegate: CommonAppDelegate {
}

override func deepLinkHandled(deeplink: URL, successful: Bool) {
let data = ["url": deeplink.absoluteString]
let data = ["url": deeplink.absoluteString]
if successful {
if let type = deeplink.params?["notification_type"] {
Tracking.shared?.view("/notification/deeplink/" + type, data: data)
Expand Down

0 comments on commit 4ee94a0

Please sign in to comment.