Fix modals not re-appearing in iOS 16

- Paywall
- Error handler

Expose setLater/enableLater.
This commit is contained in:
Davide 2024-11-27 00:58:33 +01:00
parent a92c2c2c64
commit 4fcac3c95a
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
9 changed files with 33 additions and 16 deletions

View File

@ -187,7 +187,10 @@ extension AppCoordinator {
present(.editProviderEntity($0, pair.module, pair.selection))
},
onPurchaseRequired: {
paywallReason = .init($0, needsConfirmation: true)
// FIXME: #951, use of setLater/enableLater
setLater(.init($0, needsConfirmation: true)) {
paywallReason = $0
}
}
)
)
@ -279,7 +282,7 @@ extension AppCoordinator {
func present(_ route: ModalRoute?) {
// XXX: this is a workaround for #791 on iOS 16
// FIXME: #951, use of setLater/enableLater
setLater(route) {
modalRoute = $0
}

View File

@ -208,7 +208,7 @@ private struct ToggleButton: View {
.scaleEffect(1.5, anchor: .trailing)
}
)
// TODO: #584, necessary to avoid cell selection
// XXX: #584, necessary to avoid cell selection
.buttonStyle(.plain)
.foregroundStyle(tunnel.statusColor(theme))
.opaque(isOpaque)

View File

@ -37,7 +37,7 @@ struct ProfileInfoButton: View {
} label: {
ThemeImage(.info)
}
// TODO: #584, necessary to avoid cell selection
// XXX: #584, necessary to avoid cell selection
.buttonStyle(.borderless)
}
}

View File

@ -190,7 +190,7 @@ private extension ProfileRowView {
ThemeImage(.moreDetails)
.imageScale(.large)
}
// TODO: #584, necessary to avoid cell selection
// XXX: #584, necessary to avoid cell selection
#if os(iOS)
.menuStyle(.borderlessButton)
#else

View File

@ -51,7 +51,10 @@ public final class ErrorHandler: ObservableObject {
message: composedMessage,
dismissAction: onDismiss
)
isPresented = true
// FIXME: #951, use of setLater/enableLater
enableLater {
self.isPresented = $0
}
}
public func handle(title: String, message: String, onDismiss: (() -> Void)? = nil) {
@ -60,7 +63,10 @@ public final class ErrorHandler: ObservableObject {
message: message,
dismissAction: onDismiss
)
isPresented = true
// FIXME: #951, use of setLater/enableLater
enableLater {
self.isPresented = $0
}
}
}

View File

@ -32,10 +32,6 @@ extension View {
}
}
public func setLater<T>(_ value: T?, millis: Int = 50, block: @escaping (T?) -> Void) {
globalSetLater(value, millis: millis, block: block)
}
@ViewBuilder
public func `if`(_ condition: Bool) -> some View {
if condition {
@ -88,13 +84,19 @@ extension ViewModifier {
Self._printChanges()
}
}
}
public func setLater<T>(_ value: T?, millis: Int = 50, block: @escaping (T?) -> Void) {
globalSetLater(value, millis: millis, block: block)
@MainActor
public func enableLater(millis: Int = 50, block: @escaping (Bool) -> Void) {
Task {
block(false)
try await Task.sleep(for: .milliseconds(millis))
block(true)
}
}
private func globalSetLater<T>(_ value: T?, millis: Int = 50, block: @escaping (T?) -> Void) {
@MainActor
public func setLater<T>(_ value: T?, millis: Int = 50, block: @escaping (T?) -> Void) {
Task {
block(nil)
try await Task.sleep(for: .milliseconds(millis))

View File

@ -120,7 +120,12 @@ extension Theme.ImageName {
case .tunnelRestart: return "arrow.clockwise"
case .tunnelToggle: return "power"
case .tunnelUninstall: return "arrow.uturn.down"
case .tvOff: return "tv.slash"
case .tvOff:
if #available(iOS 17, macOS 14, tvOS 17, *) {
return "tv.slash"
} else {
return "tv"
}
case .tvOn: return "tv"
case .upgrade: return "arrow.up.circle"
case .warning: return "exclamationmark.triangle"

View File

@ -324,7 +324,7 @@ public struct ThemeCopiableText<Value, ValueView>: View where Value: CustomStrin
} label: {
ThemeImage(.copy)
}
// TODO: #584, necessary to avoid cell selection
// TODO: #XXX, necessary to avoid cell selection
.buttonStyle(.borderless)
}
}

View File

@ -54,6 +54,7 @@ private extension PurchaseRequiredButton {
guard let features, !isEligible else {
return
}
// FIXME: #951, use of setLater/enableLater
setLater(.init(features, suggestedProduct: suggestedProduct)) {
paywallReason = $0
}