-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleRoute.swift
More file actions
51 lines (43 loc) · 1.08 KB
/
ModuleRoute.swift
File metadata and controls
51 lines (43 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// File.swift
// ModuleRoute
//
// Created by GIKI on 2025/2/15.
//
import Foundation
import UIKit
// MARK: - Core Protocols
public protocol MRRoute {
static var name: String { get }
var params: [String: Any] { get }
var callback: ((Any?) -> Void)? { get }
}
public enum RouteResult {
case navigator(UIViewController)
case handler(() -> Void)
case service(Any)
case value(Any)
case none
}
public protocol MRModule {
static var supportedRoutes: [MRRoute.Type] { get }
func handle(route: MRRoute) -> RouteResult
}
// MARK: - Basic Route Implementation
public struct BasicRoute: MRRoute {
public static var name: String { "" }
public let params: [String: Any]
public let callback: ((Any?) -> Void)?
public init(params: [String: Any] = [:], callback: ((Any?) -> Void)? = nil) {
self.params = params
self.callback = callback
}
}
// MARK: - Navigation Types
public enum NavigationType {
case push
case present
case modal
case replace
case custom((UIViewController, UIViewController) -> Void)
}