-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e1cec4
commit 4d3cb44
Showing
45 changed files
with
167 additions
and
1,957 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar+Config.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// RichTextKeyboardToolbar+Config.swift | ||
// RichTextKit | ||
// | ||
// Created by Ryan Jarvis on 2024-02-24. | ||
// | ||
|
||
#if iOS || macOS || os(visionOS) | ||
import SwiftUI | ||
|
||
/// This struct can configure a ``RichTextKeyboardToolbar``. | ||
public struct RichTextKeyboardToolbarConfig { | ||
|
||
/// Create a custom keyboard toolbar configuration. | ||
/// | ||
/// - Parameters: | ||
/// - alwaysDisplayToolbar: Whether or not to always show the toolbar, by default `false`. | ||
/// - leadingActions: The leading actions, by default `.undo` and `.redo`. | ||
/// - trailingActions: The trailing actions, by default `.dismissKeyboard`. | ||
public init( | ||
alwaysDisplayToolbar: Bool = false, | ||
leadingActions: [RichTextAction] = [.undo, .redo], | ||
trailingActions: [RichTextAction] = [.dismissKeyboard] | ||
) { | ||
self.alwaysDisplayToolbar = alwaysDisplayToolbar | ||
self.leadingActions = leadingActions | ||
self.trailingActions = trailingActions | ||
} | ||
|
||
/// Whether or not to always show the toolbar. | ||
public var alwaysDisplayToolbar: Bool | ||
|
||
/// The leading toolbar actions. | ||
public var leadingActions: [RichTextAction] | ||
|
||
/// The trailing toolbar actions. | ||
public var trailingActions: [RichTextAction] | ||
} | ||
|
||
public extension RichTextKeyboardToolbarConfig { | ||
|
||
/// A standard rich text keyboard toolbar configuration. | ||
/// | ||
/// You can override this to change the global default. | ||
static var standard = RichTextKeyboardToolbarConfig() | ||
} | ||
|
||
public extension View { | ||
|
||
/// Apply a ``RichTextKeyboardToolbar`` configuration. | ||
func richTextKeyboardToolbarConfig( | ||
_ config: RichTextKeyboardToolbarConfig | ||
) -> some View { | ||
self.environment(\.richTextKeyboardToolbarConfig, config) | ||
} | ||
} | ||
|
||
extension RichTextKeyboardToolbarConfig { | ||
|
||
struct Key: EnvironmentKey { | ||
|
||
public static var defaultValue: RichTextKeyboardToolbarConfig = .standard | ||
} | ||
} | ||
|
||
public extension EnvironmentValues { | ||
|
||
var richTextKeyboardToolbarConfig: RichTextKeyboardToolbarConfig { | ||
get { self [RichTextKeyboardToolbarConfig.Key.self] } | ||
set { self [RichTextKeyboardToolbarConfig.Key.self] = newValue } | ||
} | ||
} | ||
#endif |
61 changes: 0 additions & 61 deletions
61
Sources/RichTextKit/Keyboard/RichTextKeyboardToolbar+Configuration.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.