Skip to content

Commit 6787e87

Browse files
authored
Add configuration option for displaying a format sheet button
Merge pull request #222 from bryan1anderson/patch-1
2 parents 9d091e1 + 6b7d10e commit 6787e87

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar+Config.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,25 @@ public struct RichTextKeyboardToolbarConfig {
1616
///
1717
/// - Parameters:
1818
/// - alwaysDisplayToolbar: Whether or not to always show the toolbar, by default `false`.
19+
/// - displayFormatSheetButton: Whether to show the format sheet button, by default `true`.
1920
/// - leadingActions: The leading actions, by default `.undo` and `.redo`.
2021
/// - trailingActions: The trailing actions, by default `.dismissKeyboard`.
2122
public init(
2223
alwaysDisplayToolbar: Bool = false,
24+
displayFormatSheetButton: Bool = true,
2325
leadingActions: [RichTextAction] = [.undo, .redo],
24-
trailingActions: [RichTextAction] = [.dismissKeyboard]
25-
) {
26+
trailingActions: [RichTextAction] = [.dismissKeyboard]) {
2627
self.alwaysDisplayToolbar = alwaysDisplayToolbar
28+
self.displayFormatSheetButton = displayFormatSheetButton
2729
self.leadingActions = leadingActions
2830
self.trailingActions = trailingActions
2931
}
3032

3133
/// Whether or not to always show the toolbar.
3234
public var alwaysDisplayToolbar: Bool
35+
36+
/// Whether to display the format sheet button.
37+
public var displayFormatSheetButton: Bool
3338

3439
/// The leading toolbar actions.
3540
public var leadingActions: [RichTextAction]

Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,13 @@ private extension RichTextKeyboardToolbar {
181181

182182
divider
183183

184+
if config.displayFormatSheetButton {
184185
Button(action: presentFormatSheet) {
185186
Image.richTextFormat
186187
.contentShape(Rectangle())
187188
}
188-
189+
}
190+
189191
RichTextStyle.ToggleStack(context: context)
190192
.keyboardShortcutsOnly(if: isCompact)
191193

0 commit comments

Comments
 (0)