diff --git a/Tusker/Preferences/Preferences.swift b/Tusker/Preferences/Preferences.swift index 1f68f7b5..5f380d14 100644 --- a/Tusker/Preferences/Preferences.swift +++ b/Tusker/Preferences/Preferences.swift @@ -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 diff --git a/Tusker/Screens/Compose/MainComposeTextView.swift b/Tusker/Screens/Compose/MainComposeTextView.swift index 63617f33..7bef6b67 100644 --- a/Tusker/Screens/Compose/MainComposeTextView.swift +++ b/Tusker/Screens/Compose/MainComposeTextView.swift @@ -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 diff --git a/Tusker/Screens/Preferences/ComposingPrefsView.swift b/Tusker/Screens/Preferences/ComposingPrefsView.swift index ef7f35ae..a6a6c137 100644 --- a/Tusker/Screens/Preferences/ComposingPrefsView.swift +++ b/Tusker/Screens/Preferences/ComposingPrefsView.swift @@ -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") + } + } + } }