Skip to content

Commit 6eb5259

Browse files
committed
refactor(demo): rename Sheet components to Dialog
1 parent e7504c1 commit 6eb5259

22 files changed

Lines changed: 128 additions & 139 deletions

examples/demo/App.xcodeproj/project.pbxproj

Lines changed: 37 additions & 37 deletions
Large diffs are not rendered by default.

examples/demo/App/App.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ class AppDelegate: NSObject, UIApplicationDelegate {
8181

8282
// In-app message click handling
8383
OneSignal.InAppMessages.addClickListener(InAppMessageClickHandler.shared)
84-
85-
// Start with IAM paused
86-
OneSignal.InAppMessages.paused = true
8784
}
8885
}
8986

examples/demo/App/ViewModels/OneSignalViewModel.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,26 @@ final class OneSignalViewModel: ObservableObject {
6262

6363
// MARK: - In-App / Location
6464

65-
@Published var isInAppMessagesPaused: Bool = true
65+
@Published var isInAppMessagesPaused: Bool = false
6666
@Published var isLocationShared: Bool = false
6767

6868
// MARK: - UI State
6969

7070
@Published var isLoading: Bool = false
7171
@Published var toastMessage: String?
7272

73-
@Published var showingAddSheet: Bool = false
73+
@Published var showingAddDialog: Bool = false
7474
@Published var addItemType: AddItemType = .email
7575

76-
@Published var showingMultiAddSheet: Bool = false
76+
@Published var showingMultiAddDialog: Bool = false
7777
@Published var multiAddType: MultiAddItemType = .tags
7878

79-
@Published var showingRemoveMultiSheet: Bool = false
79+
@Published var showingRemoveMultiDialog: Bool = false
8080
@Published var removeMultiType: RemoveMultiItemType = .tags
8181

82-
@Published var showingOutcomeSheet: Bool = false
83-
@Published var showingCustomNotificationSheet: Bool = false
84-
@Published var showingTrackEventSheet: Bool = false
82+
@Published var showingOutcomeDialog: Bool = false
83+
@Published var showingCustomNotificationDialog: Bool = false
84+
@Published var showingTrackEventDialog: Bool = false
8585

8686
@Published var activeTooltip: TooltipData?
8787

@@ -513,21 +513,21 @@ final class OneSignalViewModel: ObservableObject {
513513
activeTooltip = nil
514514
}
515515

516-
// MARK: - Sheet handling
516+
// MARK: - Dialog handling
517517

518-
func showAddSheet(for type: AddItemType) {
518+
func showAddDialog(for type: AddItemType) {
519519
addItemType = type
520-
showingAddSheet = true
520+
showingAddDialog = true
521521
}
522522

523-
func showMultiAddSheet(for type: MultiAddItemType) {
523+
func showMultiAddDialog(for type: MultiAddItemType) {
524524
multiAddType = type
525-
showingMultiAddSheet = true
525+
showingMultiAddDialog = true
526526
}
527527

528-
func showRemoveMultiSheet(for type: RemoveMultiItemType) {
528+
func showRemoveMultiDialog(for type: RemoveMultiItemType) {
529529
removeMultiType = type
530-
showingRemoveMultiSheet = true
530+
showingRemoveMultiDialog = true
531531
}
532532

533533
func handleAddItem(key: String, value: String) {
@@ -545,7 +545,7 @@ final class OneSignalViewModel: ObservableObject {
545545
case .externalUserId:
546546
login(externalId: value)
547547
}
548-
showingAddSheet = false
548+
showingAddDialog = false
549549
}
550550

551551
func handleMultiAdd(_ pairs: [(String, String)]) {
@@ -554,15 +554,15 @@ final class OneSignalViewModel: ObservableObject {
554554
case .tags: addTags(pairs)
555555
case .triggers: addTriggers(pairs)
556556
}
557-
showingMultiAddSheet = false
557+
showingMultiAddDialog = false
558558
}
559559

560560
func handleRemoveMulti(_ keys: [String]) {
561561
switch removeMultiType {
562562
case .tags: removeSelectedTags(keys)
563563
case .triggers: removeSelectedTriggers(keys)
564564
}
565-
showingRemoveMultiSheet = false
565+
showingRemoveMultiDialog = false
566566
}
567567

568568
// MARK: - Toast

examples/demo/App/Views/Components/AddItemSheet.swift renamed to examples/demo/App/Views/Components/AddItemDialog.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
import SwiftUI
2929

30-
/// Reusable dialog for adding items with one or two text fields.
31-
struct AddItemSheet: View {
30+
/// Reusable centered dialog for adding items with one or two text fields.
31+
struct AddItemDialog: View {
3232
let itemType: AddItemType
3333
let onAdd: (String, String) -> Void
3434
let onCancel: () -> Void
@@ -74,7 +74,6 @@ struct AddItemSheet: View {
7474
}
7575
}
7676
}
77-
.osDialogPresentation()
7877
}
7978

8079
private var isValid: Bool {

examples/demo/App/Views/Components/CustomNotificationSheet.swift renamed to examples/demo/App/Views/Components/CustomNotificationDialog.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
import SwiftUI
2929

30-
/// Sheet for composing a custom push notification (title + body).
31-
struct CustomNotificationSheet: View {
30+
/// Centered dialog for composing a custom push notification (title + body).
31+
struct CustomNotificationDialog: View {
3232
let onSend: (String, String) -> Void
3333
let onCancel: () -> Void
3434

@@ -63,7 +63,6 @@ struct CustomNotificationSheet: View {
6363
)
6464
}
6565
}
66-
.osDialogPresentation()
6766
}
6867

6968
private var isValid: Bool {

examples/demo/App/Views/Components/MultiPairInputSheet.swift renamed to examples/demo/App/Views/Components/MultiPairInputDialog.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727

2828
import SwiftUI
2929

30-
/// Sheet that adds multiple key/value pairs at once (Add Multiple Aliases / Tags / Triggers)
31-
struct MultiPairInputSheet: View {
30+
/// Centered dialog that adds multiple key/value pairs at once
31+
/// (Add Multiple Aliases / Tags / Triggers).
32+
struct MultiPairInputDialog: View {
3233
let type: MultiAddItemType
3334
let onAdd: ([(String, String)]) -> Void
3435
let onCancel: () -> Void
@@ -110,7 +111,6 @@ struct MultiPairInputSheet: View {
110111
}
111112
.frame(maxHeight: 320)
112113
}
113-
.osDialogPresentation()
114114
}
115115

116116
private var isValid: Bool {

examples/demo/App/Views/Components/OSDialog.swift

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -193,32 +193,6 @@ struct OSTextEditor: View {
193193
}
194194
}
195195

196-
// MARK: - Sheet presentation helper
197-
198-
extension View {
199-
/// Standard sheet treatment shared by input dialogs: medium detent, 28-corner
200-
/// pull tab on iOS 16.4+, transparent backdrop tinted with `OS.Color.backdrop`.
201-
func osDialogPresentation() -> some View {
202-
modifier(OSDialogPresentation())
203-
}
204-
}
205-
206-
private struct OSDialogPresentation: ViewModifier {
207-
func body(content: Content) -> some View {
208-
if #available(iOS 16.4, *) {
209-
content
210-
.presentationDetents([.medium, .large])
211-
.presentationDragIndicator(.visible)
212-
.presentationCornerRadius(OS.Radius.modal)
213-
.presentationBackground(OS.Color.cardBackground)
214-
} else {
215-
content
216-
.presentationDetents([.medium, .large])
217-
.presentationDragIndicator(.visible)
218-
}
219-
}
220-
}
221-
222196
// MARK: - Centered dialog presentation
223197

224198
extension View {

examples/demo/App/Views/Components/OutcomeSheet.swift renamed to examples/demo/App/Views/Components/OutcomeDialog.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
import SwiftUI
2929

30-
/// Sheet for sending an outcome (normal, unique, or with value).
31-
struct OutcomeSheet: View {
30+
/// Centered dialog for sending an outcome (normal, unique, or with value).
31+
struct OutcomeDialog: View {
3232
let onSend: (String, OutcomeMode, Double?) -> Void
3333
let onCancel: () -> Void
3434

@@ -76,7 +76,6 @@ struct OutcomeSheet: View {
7676
}
7777
}
7878
}
79-
.osDialogPresentation()
8079
}
8180

8281
private var isValid: Bool {

examples/demo/App/Views/Components/RemoveMultiSheet.swift renamed to examples/demo/App/Views/Components/RemoveMultiDialog.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727

2828
import SwiftUI
2929

30-
/// Sheet that lets the user pick multiple keys to remove (Remove Tags / Remove Triggers).
31-
struct RemoveMultiSheet: View {
30+
/// Centered dialog that lets the user pick multiple keys to remove
31+
/// (Remove Tags / Remove Triggers).
32+
struct RemoveMultiDialog: View {
3233
let type: RemoveMultiItemType
3334
let items: [KeyValueItem]
3435
let onRemove: ([String]) -> Void
@@ -80,7 +81,6 @@ struct RemoveMultiSheet: View {
8081
.frame(maxHeight: 320)
8182
}
8283
}
83-
.osDialogPresentation()
8484
}
8585
}
8686

examples/demo/App/Views/Components/SectionCard.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ struct SectionCard<Content: View>: View {
7373
content()
7474
}
7575
}
76+
// SwiftUI does not promote a bare VStack to an accessibility element,
77+
// so a plain `.accessibilityIdentifier` here is invisible to XCUITest /
78+
// Appium queries (e.g. `scrollToEl('user_section')` would loop until it
79+
// hits the scroll cap). `.contain` makes the container queryable while
80+
// keeping every child (Texts, Buttons, toggles) individually accessible.
81+
.accessibilityElement(children: .contain)
7682
.accessibilityIdentifier("\(sectionKey)_section")
7783
}
7884
}

0 commit comments

Comments
 (0)