@capgo/capacitor-pretty-toast 8.1.2 → 8.1.4
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.
package/README.md
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Native-first pretty toast notifications for Capacitor and the web.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Demo
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<img
|
|
8
|
+
src="./media/pretty-toast-demo.webp"
|
|
9
|
+
alt="Animated Pretty Toast demo showing Android cutout and centered island-style toast flows side by side"
|
|
10
|
+
/>
|
|
8
11
|
|
|
9
12
|
This package keeps the familiar `toast.*` surface from `react-native-pretty-toast`, but ships as a Capacitor plugin with:
|
|
10
13
|
|
|
@@ -11,6 +11,7 @@ class PassThroughWindow: UIWindow, ObservableObject {
|
|
|
11
11
|
@Published var isPresented: Bool = false
|
|
12
12
|
@Published var useDynamicIsland: Bool = true
|
|
13
13
|
@Published var enableSwipeDismiss: Bool = true
|
|
14
|
+
@Published var swipeDismissRequested: Bool = false
|
|
14
15
|
@Published var wasTapped: Bool = false
|
|
15
16
|
@Published var actionTapped: Bool = false
|
|
16
17
|
@Published var toastHitFrame: CGRect = .zero
|
|
@@ -28,7 +28,7 @@ struct PrettyToastView: View {
|
|
|
28
28
|
|
|
29
29
|
let swipeGesture = DragGesture(minimumDistance: 2).onEnded { value in
|
|
30
30
|
if value.translation.height < -8 || value.predictedEndTranslation.height < -40 {
|
|
31
|
-
window.
|
|
31
|
+
window.swipeDismissRequested = true
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -10,6 +10,7 @@ import UIKit
|
|
|
10
10
|
private var hostingController: CustomHostingView?
|
|
11
11
|
private var autoDismissTimer: Timer?
|
|
12
12
|
private var dismissCancellable: AnyCancellable?
|
|
13
|
+
private var swipeDismissCancellable: AnyCancellable?
|
|
13
14
|
private var tapCancellable: AnyCancellable?
|
|
14
15
|
private var actionCancellable: AnyCancellable?
|
|
15
16
|
// Guards against double-firing onDismiss when a programmatic dismiss
|
|
@@ -200,6 +201,7 @@ import UIKit
|
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
observeDismiss()
|
|
204
|
+
observeSwipeDismiss()
|
|
203
205
|
observeTap()
|
|
204
206
|
observeAction()
|
|
205
207
|
}
|
|
@@ -224,6 +226,19 @@ import UIKit
|
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
228
|
|
|
229
|
+
private func observeSwipeDismiss() {
|
|
230
|
+
guard let overlayWindow else { return }
|
|
231
|
+
|
|
232
|
+
swipeDismissCancellable = overlayWindow.$swipeDismissRequested
|
|
233
|
+
.dropFirst()
|
|
234
|
+
.filter { $0 }
|
|
235
|
+
.sink { [weak self] _ in
|
|
236
|
+
guard let self else { return }
|
|
237
|
+
self.overlayWindow?.swipeDismissRequested = false
|
|
238
|
+
self.dismiss()
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
227
242
|
private func observeTap() {
|
|
228
243
|
guard let overlayWindow else { return }
|
|
229
244
|
|
|
@@ -352,6 +367,7 @@ import UIKit
|
|
|
352
367
|
// main, so hop over before breaking the retain cycle.
|
|
353
368
|
let window = overlayWindow
|
|
354
369
|
let dismissCancel = dismissCancellable
|
|
370
|
+
let swipeDismissCancel = swipeDismissCancellable
|
|
355
371
|
let tapCancel = tapCancellable
|
|
356
372
|
let actionCancel = actionCancellable
|
|
357
373
|
let timer = autoDismissTimer
|
|
@@ -361,6 +377,7 @@ import UIKit
|
|
|
361
377
|
timer?.invalidate()
|
|
362
378
|
workItem?.cancel()
|
|
363
379
|
dismissCancel?.cancel()
|
|
380
|
+
swipeDismissCancel?.cancel()
|
|
364
381
|
tapCancel?.cancel()
|
|
365
382
|
actionCancel?.cancel()
|
|
366
383
|
loadTask?.cancel()
|
package/package.json
CHANGED