react-native-candle 0.1.31 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -28,6 +28,11 @@ struct CandleLinkSheetWrapper: View {
|
|
|
28
28
|
) { newLinkedAccount in
|
|
29
29
|
viewModel.linkedAccount = newLinkedAccount
|
|
30
30
|
}
|
|
31
|
+
.onChange(of: viewModel.showSheet) { _, newValue in
|
|
32
|
+
Task { @MainActor in
|
|
33
|
+
viewModel.isPresented = newValue
|
|
34
|
+
}
|
|
35
|
+
}
|
|
31
36
|
.environment(candleClient)
|
|
32
37
|
} else {
|
|
33
38
|
Spacer()
|
|
@@ -15,6 +15,12 @@ extension UIViewController {
|
|
|
15
15
|
child.view.pinEdges(to: view)
|
|
16
16
|
child.didMove(toParent: self)
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
func removeEmbedded(_ child: UIViewController) {
|
|
20
|
+
child.willMove(toParent: nil)
|
|
21
|
+
child.view.removeFromSuperview()
|
|
22
|
+
child.removeFromParent()
|
|
23
|
+
}
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
extension UIView {
|
|
@@ -39,14 +39,6 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
39
39
|
)
|
|
40
40
|
let hostingVC = UIHostingController(rootView: wrapperView)
|
|
41
41
|
self.rootVC = hostingVC
|
|
42
|
-
guard
|
|
43
|
-
let rootViewController = UIApplication.keyWindow?
|
|
44
|
-
.rootViewController
|
|
45
|
-
else {
|
|
46
|
-
throw RNClientError.badInitialization(
|
|
47
|
-
message: "Application root view was not initialized.")
|
|
48
|
-
}
|
|
49
|
-
rootViewController.embed(hostingVC)
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
44
|
|
|
@@ -68,7 +60,15 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
68
60
|
try viewModel.showDynamicLoading = showDynamicLoading
|
|
69
61
|
try viewModel.presentationBackground = presentationBackground
|
|
70
62
|
try viewModel.presentationStyle = presentationStyle
|
|
71
|
-
|
|
63
|
+
guard
|
|
64
|
+
let rootViewController = UIApplication.keyWindow?
|
|
65
|
+
.rootViewController
|
|
66
|
+
else {
|
|
67
|
+
throw RNClientError.badInitialization(
|
|
68
|
+
message: "Application root view was not initialized.")
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let parentVC = rootViewController.candleTopMost
|
|
72
72
|
DispatchQueue.main.async { [weak self] in
|
|
73
73
|
guard let self else {
|
|
74
74
|
#if DEBUG
|
|
@@ -76,7 +76,11 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
76
76
|
#endif
|
|
77
77
|
return
|
|
78
78
|
}
|
|
79
|
+
|
|
79
80
|
do {
|
|
81
|
+
if let rootVC = self.rootVC {
|
|
82
|
+
parentVC.embed(rootVC)
|
|
83
|
+
}
|
|
80
84
|
try self.viewModel.showSheet = isPresented
|
|
81
85
|
} catch {
|
|
82
86
|
#if DEBUG
|
|
@@ -84,6 +88,15 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
84
88
|
#endif
|
|
85
89
|
}
|
|
86
90
|
}
|
|
91
|
+
try viewModel.$isPresented
|
|
92
|
+
.removeDuplicates()
|
|
93
|
+
.receive(on: RunLoop.main)
|
|
94
|
+
.sink(receiveValue: { [weak self] isPresented in
|
|
95
|
+
if let rootVC = self?.rootVC, !isPresented {
|
|
96
|
+
parentVC.removeEmbedded(rootVC)
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
.store(in: &cancellables)
|
|
87
100
|
try viewModel.$linkedAccount
|
|
88
101
|
.removeDuplicates()
|
|
89
102
|
.compactMap(\.?.toLinkedAccount)
|
|
@@ -116,7 +129,8 @@ final class HybridRNCandle: HybridRNCandleSpec {
|
|
|
116
129
|
"\(#function) \(#line): Candle client was not initialized."
|
|
117
130
|
)
|
|
118
131
|
}
|
|
119
|
-
rootHostingVC.
|
|
132
|
+
let parentVC = rootHostingVC.candleTopMost
|
|
133
|
+
parentVC.embedOnTop(hostingVC)
|
|
120
134
|
let tradeQuote = try tradeQuote.toCandleModel
|
|
121
135
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
|
122
136
|
wrapperView.viewModel.tradeQuote = tradeQuote
|
|
@@ -1261,3 +1275,13 @@ extension Models.LinkedAccountStatusRef {
|
|
|
1261
1275
|
)
|
|
1262
1276
|
}
|
|
1263
1277
|
}
|
|
1278
|
+
|
|
1279
|
+
extension UIViewController {
|
|
1280
|
+
fileprivate var candleTopMost: UIViewController {
|
|
1281
|
+
var top = self
|
|
1282
|
+
while let presented = top.presentedViewController {
|
|
1283
|
+
top = presented
|
|
1284
|
+
}
|
|
1285
|
+
return top
|
|
1286
|
+
}
|
|
1287
|
+
}
|