Skip to content

Commit

Permalink
code refactored, moved to AppStructureFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Hassan committed Sep 9, 2024
1 parent c1caf02 commit 5223a5b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
22 changes: 0 additions & 22 deletions Example/QuranEngineApp/Classes/Container.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,6 @@ class Container: AppDependencies {
var logsDirectory: URL { FileManager.documentsURL.appendingPathComponent("logs") }

var supportsCloudKit: Bool { false }

// MARK: Public
func handleIncomingUrl(urlContext: UIOpenURLContext) {
let url = urlContext.url

if url.scheme == "quran" || url.scheme == "quran-ios" {
let path: String

if #available(iOS 16.0, *) {
path = url.path(percentEncoded: true)
} else {
path = url.path
}

_ = navigateTo(path: path)
}
}

// MARK: Private

Expand All @@ -83,11 +66,6 @@ class Container: AppDependencies {
}
return stack
}()

private func navigateTo(path: String) -> Bool {
// Implement the actual navigation or handling logic in follow up pr
return true
}
}

private enum Constant {
Expand Down
9 changes: 5 additions & 4 deletions Example/QuranEngineApp/Classes/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// MARK: Internal

var window: UIWindow?
private var launchBuilder: LaunchBuilder?

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
Expand All @@ -21,9 +22,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window.overrideUserInterfaceStyle = ThemeService.shared.theme.userInterfaceStyle
self.window = window

let launchBuilder = LaunchBuilder(container: container)
let launchStartup = launchBuilder.launchStartup()
launchStartup.launch(from: window)
self.launchBuilder = LaunchBuilder(container: container)
let launchStartup = launchBuilder?.launchStartup()
launchStartup?.launch(from: window)

self.launchStartup = launchStartup
}
Expand Down Expand Up @@ -60,7 +61,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let urlContext: UIOpenURLContext = URLContexts.first else {
return
}
container.handleIncomingUrl(urlContext: urlContext)
launchBuilder?.handleIncomingUrl(urlContext: urlContext)
}

// MARK: Private
Expand Down
23 changes: 23 additions & 0 deletions Features/AppStructureFeature/Launch/LaunchBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import AppMigrationFeature
import AudioUpdater
import ReciterService
import SettingsService
import UIKit

@MainActor
public struct LaunchBuilder {
Expand All @@ -36,8 +37,30 @@ public struct LaunchBuilder {
reviewService: ReviewService(analytics: container.analytics)
)
}

public func handleIncomingUrl(urlContext: UIOpenURLContext) {
let url = urlContext.url

if url.scheme == "quran" || url.scheme == "quran-ios" {
let path: String

if #available(iOS 16.0, *) {
path = url.path(percentEncoded: true)
} else {
path = url.path
}

_ = navigateTo(path: path)
}
}

// MARK: Internal

let container: AppDependencies

// MARK: Public
private func navigateTo(path: String) -> Bool {
// Implement the actual navigation or handling logic in follow up pr
return true
}
}

0 comments on commit 5223a5b

Please sign in to comment.