Skip to content

Commit 3dafa67

Browse files
committed
feat(custom_width): new argument to set custom width for pop-ups
1 parent 87651d8 commit 3dafa67

File tree

23 files changed

+1071
-224
lines changed

23 files changed

+1071
-224
lines changed

Notification Agent Core/Controllers/HelpBuilder.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public final class HelpBuilder {
4646
"-retain_values".yellow(),
4747
"-background_panel".yellow(),
4848
"-unmovable".yellow(),
49-
"-disable_quit".yellow()]
49+
"-disable_quit".yellow(),
50+
"-custom_width".yellow()]
5051
static let bannerArguments: [String] = ["-type".green(),
5152
"-title".yellow(),
5253
"-subtitle".yellow(),
@@ -135,7 +136,8 @@ public final class HelpBuilder {
135136
"\n Flag that tells the agent to print the available accessory view outputs on any exit (main or secondary button clicked).",
136137
"[ opaque | translucent ]".red() + "\n The style for the background panel that will cover all the screens.\n Example: -background_panel opaque",
137138
"\n Flag that make the UI unmovable for the user.\n Example: -unmovable",
138-
"\n Flag that tells the agent to ignore cmd+q shortcut.\n Example: -disable_quit"]
139+
"\n Flag that tells the agent to ignore cmd+q shortcut.\n Example: -disable_quit",
140+
"\n A custom width for the UI.\n Example: -custom_width 1000"]
139141
static let bannerDescriptions: [String] = ["[ banner | alert ]".red() + "\n The UI type of the notification.\n Example: -type banner",
140142
"\n The title of the notification.\n Example: -title \"Title\"",
141143
"\n The subtitle of the notification. It supports MarkDown text.\n Example: -subtitle \"Subtitle\"",

Notification Agent Onboarding UI Tests/NAOUITests.swift

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,42 @@ import XCTest
1212
class NAOUITests: XCTestCase {
1313

1414
/// Testing simple Onboarding UI
15-
func test1Onboarding() throws {
16-
let useCase = "eyJub3RpZmljYXRpb24iOnsidG9waWNJRCI6InVudHJhY2tlZCIsIm1haW5CdXR0b24iOnsibGFiZWwiOiJPSyIsImNhbGxUb0FjdGlvblR5cGUiOiJub25lIiwiY2FsbFRvQW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GFiZWwgb25seSJ9LHsiaWQiOiJUaGlyZCBsYWJlbCBvbmx5IiwibGFiZWwiOiJUaGlyZCBsYWJlbCBvbmx5In1dfSwiYm9keSI6IlNlY29uZCBwYWdlJ3MgYm9keSJ9LHsiYm9keSI6IlRoaXJkIHBhZ2UncyBib2R5IiwidGl0bGUiOiJUaGlyZCBwYWdlJ3MgdGl0bGUiLCJzdWJ0aXRsZSI6IlRoaXJkIHBhZ2UncyBzdWJ0aXRsZSIsInNpbmdsZUNoYW5nZSI6dHJ1ZX0seyJ0aXRsZSI6IkZvdXJ0aCBwYWdlJ3MgdGl0bGUiLCJzdWJ0aXRsZSI6IkZvdXJ0aCBwYWdlJ3Mgc3VidGl0bGUiLCJib2R5IjoiRm91cnRoIHBhZ2UncyBib2R5In1dLCJwcm9ncmVzc0JhclBheWxvYWQiOiJhdXRvbWF0aWMifSwiaXNNb3ZhYmxlIjp0cnVlLCJhbHdheXNPblRvcCI6ZmFsc2UsInR5cGUiOiJvbmJvYXJkaW5nIiwic2lsZW50IjpmYWxzZSwic2hvd1N1cHByZXNzaW9uQnV0dG9uIjpmYWxzZSwibWluaWF0dXJpemFibGUiOmZhbHNlLCJiYXJUaXRsZSI6Ik1hY0BJQk0gTm90aWZpY2F0aW9ucyIsImZvcmNlTGlnaHRNb2RlIjpmYWxzZSwiaGlkZVRpdGxlQmFyQnV0dG9ucyI6ZmFsc2V9LCJzZXR0aW5ncyI6eyJpc1ZlcmJvc2VNb2RlRW5hYmxlZCI6ZmFsc2UsImVudmlyb25tZW50IjoicHJvZCJ9fQ==" // pragma: allowlist-secret
17-
let app = XCUIApplication()
18-
app.launchArguments = [useCase]
19-
app.launch()
20-
XCTAssert(app.staticTexts["onboarding_title"].exists)
21-
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
22-
XCTAssert(app.staticTexts["onboarding_body"].exists)
23-
XCTAssert(app.buttons["main_button"].exists)
24-
XCTAssert(!app.buttons["secondary_button"].exists)
25-
XCTAssert(app.buttons["help_button"].exists)
26-
app.buttons["main_button"].tap()
27-
XCTAssert(app.staticTexts["onboarding_title"].exists)
28-
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
29-
XCTAssert(app.staticTexts["onboarding_body"].exists)
30-
XCTAssert(app.buttons["main_button"].exists)
31-
XCTAssert(app.buttons["secondary_button"].exists)
32-
XCTAssert(app.buttons["tertiary_button"].exists)
33-
XCTAssert(app.buttons["help_button"].exists)
34-
app.buttons["main_button"].tap()
35-
XCTAssert(app.staticTexts["onboarding_title"].exists)
36-
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
37-
XCTAssert(app.staticTexts["onboarding_body"].exists)
38-
XCTAssert(app.buttons["main_button"].exists)
39-
XCTAssert(!app.buttons["secondary_button"].exists)
40-
app.buttons["main_button"].tap()
41-
XCTAssert(app.staticTexts["onboarding_title"].exists)
42-
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
43-
XCTAssert(app.staticTexts["onboarding_body"].exists)
44-
XCTAssert(app.buttons["main_button"].exists)
45-
XCTAssert(!app.buttons["secondary_button"].exists)
15+
func testA1Onboarding() throws {
16+
let useCase = """
17+
{"notification":{"retainValues":false,"isMovable":true,"type":"onboarding","mainButton":{"label":"OK","callToActionType":"none","callToActionPayload":""},"barTitle":"IBM Notifier","alwaysOnTop":false,"showSuppressionButton":false,"hideTitleBarButtons":false,"accessoryViews":[],"payload":{"pages":[{"infoSection":{"fields":[{"id":"BE8ACDC6-1159-421E-8ECA-F84B6B6785ED","label":"Some Description Some"},{"id":"4C045585-72C2-428B-B574-F55CF86E5DCA","label":"Some Description Some"},{"id":"EF546A45-64CA-473D-8BEA-4BF18C3D624F","label":"Some Description Some"}]},"topIcon":"square.and.arrow.up","subtitle":"First page's subtitle","title":"First page's title","body":"First page's body"},{"singleChange":true,"infoSection":{"fields":[{"label":"First label only","id":"031F8516-F122-4A7D-A53C-4F41C9A6C86A"},{"id":"9A2DE192-E512-484E-B42B-2215C84A0B97","label":"Second label only"},{"label":"Third label only","id":"B9F441F5-E55D-4C71-B0BC-53347A4CE6A4"}]},"tertiaryButton":{"callToActionPayload":"https:\\/\\/www.google.com","label":"Tertiary","callToActionType":"link"},"title":"Second page's title","body":"Second page's body","primaryButtonLabel":"Some","subtitle":"Second page's subtitle"},{"title":"Third page's title","body":"Third page's body","singleChange":true,"subtitle":"Third page's subtitle"},{"body":"Fourth page's body","subtitle":"Fourth page's subtitle","title":"Fourth page's title"}],"progressBarPayload":"automatic"},"silent":false,"forceLightMode":false,"disableQuit":false,"miniaturizable":false,"topicID":"untracked","notificationID":"untracked"},"settings":{"isVerboseModeEnabled":false,"environment":"prod"}}
18+
""" // pragma: allowlist-secret
19+
if let useCaseData = useCase.data(using: .utf8) {
20+
let app = XCUIApplication()
21+
app.launchArguments = [useCaseData.base64EncodedString()]
22+
app.launch()
23+
XCTAssert(app.staticTexts["onboarding_title"].exists)
24+
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
25+
XCTAssert(app.staticTexts["onboarding_body"].exists)
26+
XCTAssert(app.buttons["main_button"].exists)
27+
XCTAssert(!app.buttons["secondary_button"].exists)
28+
XCTAssert(app.buttons["help_button"].exists)
29+
app.buttons["main_button"].tap()
30+
XCTAssert(app.staticTexts["onboarding_title"].exists)
31+
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
32+
XCTAssert(app.staticTexts["onboarding_body"].exists)
33+
XCTAssert(app.buttons["main_button"].exists)
34+
XCTAssert(app.buttons["secondary_button"].exists)
35+
XCTAssert(app.buttons["tertiary_button"].exists)
36+
XCTAssert(app.buttons["help_button"].exists)
37+
app.buttons["main_button"].tap()
38+
XCTAssert(app.staticTexts["onboarding_title"].exists)
39+
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
40+
XCTAssert(app.staticTexts["onboarding_body"].exists)
41+
XCTAssert(app.buttons["main_button"].exists)
42+
XCTAssert(!app.buttons["secondary_button"].exists)
43+
app.buttons["main_button"].tap()
44+
XCTAssert(app.staticTexts["onboarding_title"].exists)
45+
XCTAssert(app.staticTexts["onboarding_subtitle"].exists)
46+
XCTAssert(app.staticTexts["onboarding_body"].exists)
47+
XCTAssert(app.buttons["main_button"].exists)
48+
XCTAssert(!app.buttons["secondary_button"].exists)
49+
} else {
50+
XCTAssert(false, "Failed to encode the usecase.")
51+
}
4652
}
4753
}

Notification Agent Onboarding/Views/PageView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct PageView: View {
9494
HStack(alignment: .top) {
9595
ForEach(row, id: \.hashValue) { accessoryView in
9696
accessoryView
97+
.environmentObject(viewModel.viewSpec)
9798
}
9899
}
99100
}

Notification Agent Onboarding/Views/PageViewModel.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class PageViewModel: ObservableObject {
1919
var primaryButtonStates: [[SwiftUIButtonState]]
2020
var secondaryButtonStates: [[SwiftUIButtonState]]
2121
var accessoryViewsMatrix: [[AccessoryViewWrapper]]
22+
var viewSpec: ViewSpec
2223

2324
// MARK: - Binded Variables
2425

@@ -39,6 +40,7 @@ final class PageViewModel: ObservableObject {
3940
self._outputs = outp
4041
self._primaryButtonState = primaryButtonState
4142
self._secondaryButtonState = secondaryButtonState
43+
self.viewSpec = ViewSpec(mainViewWidth: 832, contentMode: .fit, iconSize: CGSize(width: 86, height: 86))
4244

4345
primaryButtonStates = []
4446
secondaryButtonStates = []
@@ -72,7 +74,7 @@ final class PageViewModel: ObservableObject {
7274
guard newValue != secondaryButtonState else { return }
7375
secondaryButtonState = newValue
7476
self.evaluateBindings()
75-
}), accessoryView: accessoryView), contentMode: .fit))
77+
}), accessoryView: accessoryView)))
7678
}
7779
primaryButtonStates.append(primaryButtonStatesRow)
7880
secondaryButtonStates.append(secondaryButtonStatesRow)

0 commit comments

Comments
 (0)