Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Add support for default keyboard in composition view #268

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Localizations/ca.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Cal que toquis dues vegades per fer-ho favorit";
"preferences.show-reblog-and-favorite-counts" = "Mostra el recompte d’impulsos i favorits";
"preferences.status-word" = "Paraula d’estat";
"preferences.keyboard-type" = "Teclat";
"preferences.keyboard-type.twitter" = "Amb clau hash";
"preferences.keyboard-type.default-text" = "Amb la tecla enter";
"filters.active" = "Actiu";
"filters.expired" = "Caducat";
"filter.add-new" = "Afegeix un filtre nou";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/cs.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Vyžadovat dvojité klepnutí pro oblíbené";
"preferences.show-reblog-and-favorite-counts" = "Zobrazit boostů a počet oblíbených";
"preferences.status-word" = "Toot/Příspěvek";
"preferences.keyboard-type" = "Klávesnice";
"preferences.keyboard-type.twitter" = "S hash klíčem";
"preferences.keyboard-type.default-text" = "S klávesou enter";
"filters.active" = "Aktivní";
"filters.expired" = "Platnost vypršela";
"filter.add-new" = "Přidat nový filtr";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Doppelklick zum Favorisieren";
"preferences.show-reblog-and-favorite-counts" = "Boosts und Favoriten anzeigen";
"preferences.status-word" = "Statuswort";
"preferences.keyboard-type" = "Tastatur";
"preferences.keyboard-type.twitter" = "Mit Rautetaste";
"preferences.keyboard-type.default-text" = "Mit Eingabetaste";
"filters.active" = "Aktiv";
"filters.expired" = "Abgelaufen";
"filter.add-new" = "Neuer Filter";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/el.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Να απαιτείται διπλό πάτημα για προσθήκη στα αγαπημένα";
"preferences.show-reblog-and-favorite-counts" = "Εμφάνιση μετρήσεων των boosts και αγαπημένων";
"preferences.status-word" = "Λέξη κατάστασης";
"preferences.keyboard-type" = "Πληκτρολόγιο";
"preferences.keyboard-type.twitter" = "Με κλειδί κατακερματισμού";
"preferences.keyboard-type.default-text" = "Με το πλήκτρο enter";
"filters.active" = "Ενεργό";
"filters.expired" = "Έληξε";
"filter.add-new" = "Προσθήκη Νέου Φίλτρου";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Require double tap to favorite";
"preferences.show-reblog-and-favorite-counts" = "Show boost and favorite counts";
"preferences.status-word" = "Status word";
"preferences.keyboard-type" = "Keyboard";
"preferences.keyboard-type.twitter" = "With hash key";
"preferences.keyboard-type.default-text" = "With enter key";
"filters.active" = "Active";
"filters.expired" = "Expired";
"filter.add-new" = "Add New Filter";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Requerir doble toque para añadir a favoritos";
"preferences.show-reblog-and-favorite-counts" = "Mostrar boost y cuentas favoritas";
"preferences.status-word" = "Palabra de estado";
"preferences.keyboard-type" = "Teclado";
"preferences.keyboard-type.twitter" = "Con clave hash";
"preferences.keyboard-type.default-text" = "Con tecla enter";
"filters.active" = "Activo";
"filters.expired" = "Ha caducado";
"filter.add-new" = "Añadir un filtro nuevo";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/eu.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Gogoko egiteko birritan sakatu behar da";
"preferences.show-reblog-and-favorite-counts" = "Erakutsi bultzada eta gogoko kopurua";
"preferences.status-word" = "Nahiago duzun hitza";
"preferences.keyboard-type" = "Teklatua";
"preferences.keyboard-type.twitter" = "Hash giltzarekin";
"preferences.keyboard-type.default-text" = "Sartu teklarekin";
"filters.active" = "Aktibo";
"filters.expired" = "Iraungita";
"filter.add-new" = "Gehitu iragazki berria";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Nécessite un double appui pour ajouter aux favoris";
"preferences.show-reblog-and-favorite-counts" = "Afficher le nombre de partages/favoris";
"preferences.status-word" = "Mot de statut";
"preferences.keyboard-type" = "Clavier";
"preferences.keyboard-type.twitter" = "Avec clé de hachage";
"preferences.keyboard-type.default-text" = "Avec la touche entrée";
"filters.active" = "Actifs";
"filters.expired" = "Expirés";
"filter.add-new" = "Ajouter un nouveau filtre";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/gd.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Thoir gnogag dhùbailte airson annsachd a chruthachadh";
"preferences.show-reblog-and-favorite-counts" = "Seall cunntas nam brosnachaidhean ’s nan annsachdan";
"preferences.status-word" = "Facal puist";
"preferences.keyboard-type" = "Meur-chlàr";
"preferences.keyboard-type.twitter" = "Le iuchair hash";
"preferences.keyboard-type.default-text" = "Leis an iuchair cuir a-steach";
"filters.active" = "Gnìomhach";
"filters.expired" = "Thàinig e gu crìoch";
"filter.add-new" = "Cuir criathrag ùr ris";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/he.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "דרוש לחיצה כפולה כדי להדהד";
"preferences.show-reblog-and-favorite-counts" = "הצג מספר הדהודים וחיבובים";
"preferences.status-word" = "מילת סטטוס";
"preferences.keyboard-type" = "מקלדת";
"preferences.keyboard-type.twitter" = "עם מפתח hash";
"preferences.keyboard-type.default-text" = "עם מקש אנטר";
"filters.active" = "פעיל";
"filters.expired" = "פג תוקף";
"filter.add-new" = "הוספת מסנן חדש";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "ダブルタップでお気に入り";
"preferences.show-reblog-and-favorite-counts" = "ブースト・お気に入り数を表示";
"preferences.status-word" = "ステータスを表す言葉";
"preferences.keyboard-type" = "キーボード";
"preferences.keyboard-type.twitter" = "ハッシュキーあり";
"preferences.keyboard-type.default-text" = "エンターキーあり";
"filters.active" = "有効";
"filters.expired" = "期限切れ";
"filter.add-new" = "新しいフィルターを追加";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "두 번 탭 해서 즐겨찾기";
"preferences.show-reblog-and-favorite-counts" = "부스트 및 즐겨찾기 수 표시";
"preferences.status-word" = "상태를 나타내는 말";
"preferences.keyboard-type" = "건반";
"preferences.keyboard-type.twitter" = "해시 키 사용";
"preferences.keyboard-type.default-text" = "엔터키로";
"filters.active" = "활성화";
"filters.expired" = "만료됨";
"filter.add-new" = "새 필터 추가";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/pl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Wymagaj podwójnego stuknięcia do polubienia";
"preferences.show-reblog-and-favorite-counts" = "Pokazuj licznik podbić i polubień";
"preferences.status-word" = "Używaj jako nazwy statusu";
"preferences.keyboard-type" = "Klawiatura";
"preferences.keyboard-type.twitter" = "Z kluczem krzyżykowym";
"preferences.keyboard-type.default-text" = "Z klawiszem Enter";
"filters.active" = "Aktywny";
"filters.expired" = "Wygasły";
"filter.add-new" = "Dodaj nowy filtr";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Solicitar toque duplo para favoritar";
"preferences.show-reblog-and-favorite-counts" = "Mostrar contagem de boosts e favoritos";
"preferences.status-word" = "Estado da palavra";
"preferences.keyboard-type" = "Teclado";
"preferences.keyboard-type.twitter" = "Com chave hash";
"preferences.keyboard-type.default-text" = "Predefinição";
"filters.active" = "Ativo";
"filters.expired" = "Expirados";
"filter.add-new" = "Adicionar Novo Filtro";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Требуется двойное нажатие для добавления в избранное";
"preferences.show-reblog-and-favorite-counts" = "Показать счётчик продвижений и добавлений в избранное";
"preferences.status-word" = "Название статусов";
"preferences.keyboard-type" = "Клавиатура";
"preferences.keyboard-type.twitter" = "С хэш-ключом";
"preferences.keyboard-type.default-text" = "С клавишей ввода";
"filters.active" = "Активный";
"filters.expired" = "Истёк";
"filter.add-new" = "Добавить новый фильтр";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/sv.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "Kräv dubbeltryck för att favoritmarkera";
"preferences.show-reblog-and-favorite-counts" = "Visa antal boosts och favoritmarkeringar";
"preferences.status-word" = "Statusord";
"preferences.keyboard-type" = "Tangentbord";
"preferences.keyboard-type.twitter" = "Med hash-nyckel";
"preferences.keyboard-type.default-text" = "Standard";
"filters.active" = "Aktiv";
"filters.expired" = "Upphört";
"filter.add-new" = "Lägg till nytt filter";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "需要双击才能点赞";
"preferences.show-reblog-and-favorite-counts" = "显示转发与点赞的计数";
"preferences.status-word" = "表述状态用的词";
"preferences.keyboard-type" = "键盘";
"preferences.keyboard-type.twitter" = "带散列键";
"preferences.keyboard-type.default-text" = "用回车键";
"filters.active" = "已启用";
"filters.expired" = "已过期";
"filter.add-new" = "添加新筛选器";
Expand Down
3 changes: 3 additions & 0 deletions Localizations/zh-Hant.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
"preferences.require-double-tap-to-favorite" = "需要點按兩次才能收藏";
"preferences.show-reblog-and-favorite-counts" = "顯示轉嘟與收藏的次數";
"preferences.status-word" = "狀態字";
"preferences.keyboard-type" = "鍵盤";
"preferences.keyboard-type.twitter" = "使用哈希鍵";
"preferences.keyboard-type.default-text" = "用回車鍵";
"filters.active" = "已啟用";
"filters.expired" = "已過期";
"filter.add-new" = "新增篩選器";
Expand Down
20 changes: 20 additions & 0 deletions ServiceLayer/Sources/ServiceLayer/Utilities/AppPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public extension AppPreferences {
public var id: String { rawValue }
}

enum KeyboardType: String, CaseIterable, Identifiable {
case twitter
case defaultText

public var id: String { rawValue }
}

enum Autoplay: String, CaseIterable, Identifiable {
case always
case wifi
Expand Down Expand Up @@ -91,6 +98,18 @@ public extension AppPreferences {
set { self[.animateAvatars] = newValue.rawValue }
}

var keyboardType: KeyboardType {
blazer82 marked this conversation as resolved.
Show resolved Hide resolved
get {
if let rawValue = self[.keyboardType] as String?,
let value = KeyboardType(rawValue: rawValue) {
return value
}

return .twitter
}
set { self[.keyboardType] = newValue.rawValue }
}

var animateHeaders: Bool {
get { self[.animateHeaders] ?? !systemReduceMotion() }
set { self[.animateHeaders] = newValue }
Expand Down Expand Up @@ -210,6 +229,7 @@ private extension AppPreferences {
case requireDoubleTapToReblog
case requireDoubleTapToFavorite
case animateAvatars
case keyboardType
case animateHeaders
case animateCustomEmojis
case autoplayGIFs
Expand Down
17 changes: 17 additions & 0 deletions Views/SwiftUI/PreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ struct PreferencesView: View {
Text(option.localizedStringKey).tag(option)
}
}
Picker("preferences.keyboard-type",
selection: $identityContext.appPreferences.keyboardType) {
ForEach(AppPreferences.KeyboardType.allCases) { option in
Text(option.localizedStringKey).tag(option)
}
}
Toggle("preferences.show-reblog-and-favorite-counts",
isOn: $identityContext.appPreferences.showReblogAndFavoriteCounts)
Toggle("preferences.require-double-tap-to-reblog",
Expand Down Expand Up @@ -195,6 +201,17 @@ extension AppPreferences.AnimateAvatars {
}
}

extension AppPreferences.KeyboardType {
var localizedStringKey: LocalizedStringKey {
switch self {
case .twitter:
return "preferences.keyboard-type.twitter"
case .defaultText:
return "preferences.keyboard-type.default-text"
}
}
}

extension AppPreferences.Autoplay {
var localizedStringKey: LocalizedStringKey {
switch self {
Expand Down
4 changes: 3 additions & 1 deletion Views/UIKit/CompositionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ private extension CompositionView {
autocompleteQueryPublisher: viewModel.$autocompleteQuery.eraseToAnyPublisher())

stackView.addArrangedSubview(textView)
textView.keyboardType = .twitter
textView.keyboardType = parentViewModel.identityContext.appPreferences.keyboardType == .twitter
? .twitter
: .default
textView.isScrollEnabled = false
textView.adjustsFontForContentSizeCategory = true
textView.font = textViewFont
Expand Down