Add preference for using twitter-style keyboard

This commit is contained in:
Shadowfacts 2022-11-22 11:06:21 -05:00
parent ab19922530
commit b5c8a38b9b
3 changed files with 15 additions and 0 deletions

View File

@ -50,6 +50,7 @@ class Preferences: Codable, ObservableObject {
self.requireAttachmentDescriptions = try container.decode(Bool.self, forKey: .requireAttachmentDescriptions)
self.contentWarningCopyMode = try container.decode(ContentWarningCopyMode.self, forKey: .contentWarningCopyMode)
self.mentionReblogger = try container.decode(Bool.self, forKey: .mentionReblogger)
self.useTwitterKeyboard = try container.decodeIfPresent(Bool.self, forKey: .useTwitterKeyboard) ?? false
self.blurAllMedia = try container.decode(Bool.self, forKey: .blurAllMedia)
self.blurMediaBehindContentWarning = try container.decodeIfPresent(Bool.self, forKey: .blurMediaBehindContentWarning) ?? true
@ -91,6 +92,7 @@ class Preferences: Codable, ObservableObject {
try container.encode(requireAttachmentDescriptions, forKey: .requireAttachmentDescriptions)
try container.encode(contentWarningCopyMode, forKey: .contentWarningCopyMode)
try container.encode(mentionReblogger, forKey: .mentionReblogger)
try container.encode(useTwitterKeyboard, forKey: .useTwitterKeyboard)
try container.encode(blurAllMedia, forKey: .blurAllMedia)
try container.encode(blurMediaBehindContentWarning, forKey: .blurMediaBehindContentWarning)
@ -131,6 +133,7 @@ class Preferences: Codable, ObservableObject {
@Published var requireAttachmentDescriptions = false
@Published var contentWarningCopyMode = ContentWarningCopyMode.asIs
@Published var mentionReblogger = false
@Published var useTwitterKeyboard = false
// MARK: Media
@Published var blurAllMedia = false {
@ -181,6 +184,7 @@ class Preferences: Codable, ObservableObject {
case requireAttachmentDescriptions
case contentWarningCopyMode
case mentionReblogger
case useTwitterKeyboard
case blurAllMedia
case blurMediaBehindContentWarning

View File

@ -79,6 +79,7 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
@EnvironmentObject var uiState: ComposeUIState
@EnvironmentObject var mastodonController: MastodonController
@ObservedObject var preferences = Preferences.shared
@Environment(\.isEnabled) var isEnabled: Bool
func makeUIView(context: Context) -> UITextView {
@ -101,6 +102,7 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
}
uiView.isEditable = isEnabled
uiView.keyboardType = preferences.useTwitterKeyboard ? .twitter : .default
context.coordinator.text = $text
context.coordinator.didChange = textDidChange

View File

@ -17,6 +17,7 @@ struct ComposingPrefsView: View {
visibilitySection
composingSection
replyingSection
writingSection
}
.listStyle(InsetGroupedListStyle())
.navigationBarTitle("Composing")
@ -75,6 +76,14 @@ struct ComposingPrefsView: View {
}
}
}
var writingSection: some View {
Section {
Toggle(isOn: $preferences.useTwitterKeyboard) {
Text("Show @ and # on Keyboard")
}
}
}
}