mirror of
https://github.com/block/buzz.git
synced 2026-10-30 14:01:37 +00:00
feat(push-demo): add temporary action icons
Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
@@ -73,10 +73,15 @@ enum BuzzPushNotificationResponseCoordinator {
|
||||
|
||||
enum BuzzPushNotificationCategoryRegistrar {
|
||||
static func register(with center: UNUserNotificationCenter) {
|
||||
center.setNotificationCategories([messageCategory()])
|
||||
}
|
||||
|
||||
static func messageCategory() -> UNNotificationCategory {
|
||||
let reply = UNTextInputNotificationAction(
|
||||
identifier: BuzzPushNotificationActions.replyActionIdentifier,
|
||||
title: "Reply",
|
||||
options: [],
|
||||
icon: UNNotificationActionIcon(systemImageName: "arrowshape.turn.up.left"),
|
||||
textInputButtonTitle: "Send",
|
||||
textInputPlaceholder: "Reply to Buzz"
|
||||
)
|
||||
@@ -84,17 +89,16 @@ enum BuzzPushNotificationCategoryRegistrar {
|
||||
UNNotificationAction(
|
||||
identifier: preset.actionIdentifier,
|
||||
title: preset.actionTitle,
|
||||
options: []
|
||||
options: [],
|
||||
icon: UNNotificationActionIcon(systemImageName: preset.systemImageName)
|
||||
)
|
||||
}
|
||||
center.setNotificationCategories([
|
||||
UNNotificationCategory(
|
||||
identifier: BuzzPushNotificationActions.messageCategoryIdentifier,
|
||||
actions: [reply] + reminderActions,
|
||||
intentIdentifiers: [],
|
||||
options: []
|
||||
)
|
||||
])
|
||||
return UNNotificationCategory(
|
||||
identifier: BuzzPushNotificationActions.messageCategoryIdentifier,
|
||||
actions: [reply] + reminderActions,
|
||||
intentIdentifiers: [],
|
||||
options: []
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,8 +131,16 @@ enum BuzzPushReminderPreset: CaseIterable, Equatable {
|
||||
var actionTitle: String {
|
||||
switch self {
|
||||
case .oneHour: "Remind Me in 1 Hour"
|
||||
case .tomorrowAt9AM: "Remind Me Tomorrow at 9 AM"
|
||||
case .nextMondayAt9AM: "Remind Me Next Monday at 9 AM"
|
||||
case .tomorrowAt9AM: "Remind Me Tomorrow"
|
||||
case .nextMondayAt9AM: "Remind Me Next Week"
|
||||
}
|
||||
}
|
||||
|
||||
var systemImageName: String {
|
||||
switch self {
|
||||
case .oneHour: "clock"
|
||||
case .tomorrowAt9AM: "sun.max"
|
||||
case .nextMondayAt9AM: "calendar"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,6 +217,17 @@ final class BuzzPushSnapshotEnrichmentTests: XCTestCase {
|
||||
}
|
||||
|
||||
final class BuzzPushNotificationResponseTests: XCTestCase {
|
||||
func testMessageCategoryUsesConciseTitlesAndPublicActionIcons() {
|
||||
let category = BuzzPushNotificationCategoryRegistrar.messageCategory()
|
||||
|
||||
XCTAssertEqual(category.identifier, BuzzPushNotificationActions.messageCategoryIdentifier)
|
||||
XCTAssertEqual(
|
||||
category.actions.map(\.title),
|
||||
["Reply", "Remind Me in 1 Hour", "Remind Me Tomorrow", "Remind Me Next Week"]
|
||||
)
|
||||
XCTAssertTrue(category.actions.allSatisfy { $0.icon != nil })
|
||||
}
|
||||
|
||||
func testBackgroundCompletionReturnsToMainThreadExactlyOnce() {
|
||||
let completed = expectation(description: "completion returned on main thread")
|
||||
var completionCount = 0
|
||||
|
||||
Reference in New Issue
Block a user