Skip to content

Commit 59841f8

Browse files
Improve UIAlertController titleVisibility handling (#282)
* Improve UIAlertController titleVisibility handling * fix * wip --------- Co-authored-by: Stephen Celis <[email protected]>
1 parent ae208d1 commit 59841f8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Sources/UIKitNavigation/Navigation/UIAlertController.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,20 @@
3737
handler: @escaping (_ action: Action?) -> Void = { (_: Never?) in }
3838
) {
3939
self.init(
40-
title: state.titleVisibility == .visible ? String(state: state.title) : nil,
40+
title: {
41+
switch state.titleVisibility {
42+
case .automatic:
43+
let title = String(state: state.title)
44+
return title.isEmpty ? nil : title
45+
case .hidden:
46+
return nil
47+
case .visible:
48+
return String(state: state.title)
49+
@unknown default:
50+
let title = String(state: state.title)
51+
return title.isEmpty ? nil : title
52+
}
53+
}(),
4154
message: state.message.map { String(state: $0) },
4255
preferredStyle: .actionSheet
4356
)

0 commit comments

Comments
 (0)