mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
* collapse long posts * initialize user pref setting in init(), remove onAppear and onChange(pref) from view --------- Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
parent
bd782abb88
commit
3a144b7792
24 changed files with 146 additions and 14 deletions
|
@ -43,7 +43,7 @@ struct ContentSettingsView: View {
|
|||
}
|
||||
}
|
||||
|
||||
Section("settings.content.reading") {
|
||||
Section {
|
||||
Toggle(isOn: $userPreferences.appAutoExpandSpoilers) {
|
||||
Text("settings.content.expand-spoilers")
|
||||
}
|
||||
|
@ -55,7 +55,16 @@ struct ContentSettingsView: View {
|
|||
}
|
||||
}
|
||||
.disabled(userPreferences.useInstanceContentSettings)
|
||||
}.listRowBackground(theme.primaryBackgroundColor)
|
||||
|
||||
Toggle(isOn: $userPreferences.collapseLongPosts) {
|
||||
Text("settings.content.collapse-long-posts")
|
||||
}
|
||||
} header: {
|
||||
Text("settings.content.reading")
|
||||
} footer: {
|
||||
Text("settings.content.collapse-long-posts-hint")
|
||||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
|
||||
Section("settings.content.posting") {
|
||||
Picker("settings.content.default-visibility", selection: $userPreferences.appDefaultPostVisibility) {
|
||||
|
|
|
@ -112,6 +112,8 @@
|
|||
"settings.system" = "Сістэмныя налады";
|
||||
"settings.content.navigation-title" = "Налады змесціву";
|
||||
"settings.content.boosts" = "Павышэння";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Схаваць паўторныя павышэння";
|
||||
"settings.content.instance-settings" = "Налады змесціва серверу";
|
||||
"settings.content.use-instance-settings" = "Ужыць налады серверу";
|
||||
|
@ -462,6 +464,7 @@
|
|||
"status.row.you-boosted" = "Вы ўзмацнілі";
|
||||
"status.show-less" = "Паказваць менш";
|
||||
"status.show-more" = "Паказаць больш";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " а ";
|
||||
"status.summary.edited-time" = "Апошняе рэдагаванне:";
|
||||
"status.summary.n-boosts %lld" = "%lld павышаных";
|
||||
|
|
|
@ -108,6 +108,8 @@
|
|||
"settings.content.navigation-title" = "Configuració del contacte";
|
||||
"settings.content.use-instance-settings" = "Utilitza la configuració del servidor";
|
||||
"settings.content.boosts" = "Impulsos";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Hide repeated boosts";
|
||||
"settings.content.instance-settings" = "Server Content Settings";
|
||||
"settings.content.expand-spoilers" = "Mostra'm sempre els espòilers";
|
||||
|
@ -456,6 +458,7 @@
|
|||
"status.row.you-boosted" = "Heu impulsat";
|
||||
"status.show-less" = "Mostra'n menys";
|
||||
"status.show-more" = "Mostra'n més";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " a les ";
|
||||
"status.summary.edited-time" = "Darrera edició: ";
|
||||
"status.summary.n-boosts %lld" = "%lld impulsos";
|
||||
|
|
|
@ -132,6 +132,8 @@
|
|||
"settings.system" = "Systemeinstellungen";
|
||||
"settings.content.navigation-title" = "Inhaltseinstellungen";
|
||||
"settings.content.boosts" = "Boosts";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Wiederholte Boosts verstecken";
|
||||
"settings.content.instance-settings" = "Serverinhaltseinstellungen";
|
||||
"settings.content.use-instance-settings" = "Servereinstellungen verwenden";
|
||||
|
@ -453,6 +455,7 @@
|
|||
"status.row.you-boosted" = "Du hast geboostet";
|
||||
"status.show-less" = "Weniger anzeigen";
|
||||
"status.show-more" = "Mehr anzeigen";
|
||||
"status.show-full-post" = "Ganzen Beitrag anzeigen";
|
||||
"status.summary.at-time" = " um ";
|
||||
"status.summary.n-boosts %lld" = "%lld Boosts";
|
||||
"status.summary.n-favorites %lld" = "%lld Favoriten";
|
||||
|
|
|
@ -111,6 +111,8 @@
|
|||
"settings.general.content" = "Content Settings";
|
||||
"settings.system" = "System Settings";
|
||||
"settings.content.boosts" = "Boosts";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.navigation-title" = "Content Settings";
|
||||
"settings.content.use-instance-settings" = "Use Server Settings";
|
||||
"settings.content.instance-settings" = "Server Content Settings";
|
||||
|
@ -457,6 +459,7 @@
|
|||
"status.row.you-boosted" = "You boosted";
|
||||
"status.show-less" = "Show less";
|
||||
"status.show-more" = "Show more";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " at ";
|
||||
"status.summary.edited-time" = "Last edited: ";
|
||||
"status.summary.n-boosts %lld" = "%lld boosts";
|
||||
|
|
|
@ -112,6 +112,8 @@
|
|||
"settings.system" = "System Settings";
|
||||
"settings.content.navigation-title" = "Content Settings";
|
||||
"settings.content.boosts" = "Boosts";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Hide Repeated Boosts";
|
||||
"settings.content.instance-settings" = "Server Content Settings";
|
||||
"settings.content.use-instance-settings" = "Use Server Settings";
|
||||
|
@ -458,6 +460,7 @@
|
|||
"status.row.you-boosted" = "You boosted";
|
||||
"status.show-less" = "Show less";
|
||||
"status.show-more" = "Show more";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " at ";
|
||||
"status.summary.edited-time" = "Last edited: ";
|
||||
"status.summary.n-boosts %lld" = "%lld boosts";
|
||||
|
|
|
@ -132,6 +132,8 @@
|
|||
"settings.system" = "Ajustes del sistema";
|
||||
"settings.content.navigation-title" = "Ajustes de contenido";
|
||||
"settings.content.boosts" = "Retoots";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Ocultar retoots repetidos";
|
||||
"settings.content.instance-settings" = "Ajustes de contenido del servidor";
|
||||
"settings.content.use-instance-settings" = "Usar ajustes del servidor";
|
||||
|
@ -458,6 +460,7 @@
|
|||
"status.row.you-boosted" = "Retooteaste";
|
||||
"status.show-less" = "Mostrar menos";
|
||||
"status.show-more" = "Mostrar más";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " a las ";
|
||||
"status.summary.edited-time" = "Última edición: ";
|
||||
"status.summary.n-boosts %lld" = "%lld retoots";
|
||||
|
|
|
@ -132,6 +132,8 @@
|
|||
"settings.system" = "Sistemaren ezarpenak";
|
||||
"settings.content.navigation-title" = "Edukiaren ezarpenak";
|
||||
"settings.content.boosts" = "Bultzadak";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Ezkutatu errepikatutako bultzadak";
|
||||
"settings.content.instance-settings" = "Edukiari buruzko ezarpenak";
|
||||
"settings.content.use-instance-settings" = "Erabili zerbitzariko ezarpenak";
|
||||
|
@ -450,6 +452,7 @@
|
|||
"status.row.you-boosted" = "Zuk bultzatua";
|
||||
"status.show-less" = "Ikusi gutxiago";
|
||||
"status.show-more" = "Ikusi gehiago";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " · ";
|
||||
"status.summary.edited-time" = "Azkenekoz editatua: ";
|
||||
"status.visibility.direct" = "Aipatutakoak";
|
||||
|
|
|
@ -108,6 +108,8 @@
|
|||
"settings.system" = "Paramètres système";
|
||||
"settings.content.navigation-title" = "Paramètres de contenu";
|
||||
"settings.content.boosts" = "Boosts";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Masquer les boosts répétés";
|
||||
"settings.content.instance-settings" = "Réglages de contenu serveur";
|
||||
"settings.content.use-instance-settings" = "Utiliser les paramètres du serveur";
|
||||
|
@ -453,6 +455,7 @@
|
|||
"status.row.you-boosted" = "Vous avez boosté";
|
||||
"status.show-less" = "Afficher moins";
|
||||
"status.show-more" = "Afficher plus";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " à ";
|
||||
"status.summary.edited-time" = "Dernière modification : ";
|
||||
"status.summary.n-boosts %lld" = "%lld boosts";
|
||||
|
|
|
@ -133,6 +133,8 @@
|
|||
"settings.content.navigation-title" = "Impostazioni dei contenuti";
|
||||
"settings.content.use-instance-settings" = "Utilizza le impostazioni del server";
|
||||
"settings.content.boosts" = "Condivisioni";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Nascondi le condivisioni ripetute";
|
||||
"settings.content.instance-settings" = "Configurazione dei contenuti del Server";
|
||||
"settings.content.expand-spoilers" = "Visualizza sempre i contenuti sensibili";
|
||||
|
@ -458,6 +460,7 @@
|
|||
"status.row.you-boosted" = "Tu hai condiviso";
|
||||
"status.show-less" = "Mostra meno";
|
||||
"status.show-more" = "Mostra di più";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " alle ";
|
||||
"status.summary.edited-time" = "Ultima modifica: ";
|
||||
"status.summary.n-boosts %lld" = "%lld condivisioni";
|
||||
|
|
|
@ -112,6 +112,8 @@
|
|||
"settings.system" = "システム設定";
|
||||
"settings.content.navigation-title" = "コンテンツ設定";
|
||||
"settings.content.boosts" = "ブースト";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "度重なるブーストを隠す";
|
||||
"settings.content.instance-settings" = "サーバーコンテンツ設定";
|
||||
"settings.content.use-instance-settings" = "サーバー設定を使用する";
|
||||
|
@ -457,6 +459,7 @@
|
|||
"status.row.you-boosted" = "ブーストしました";
|
||||
"status.show-less" = "表示項目を減らす";
|
||||
"status.show-more" = "表示項目を増やす";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " at ";
|
||||
"status.summary.edited-time" = "最新編集日: ";
|
||||
"status.summary.n-boosts %lld" = "%lld ブースト";
|
||||
|
|
|
@ -108,6 +108,8 @@
|
|||
"settings.system" = "시스템 설정";
|
||||
"settings.content.navigation-title" = "콘텐츠 설정";
|
||||
"settings.content.boosts" = "부스트";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "중복으로 부스트된 글 숨기기";
|
||||
"settings.content.instance-settings" = "인스턴스 콘텐츠 설정";
|
||||
"settings.content.use-instance-settings" = "인스턴스 설정에 맞추기";
|
||||
|
@ -459,6 +461,7 @@
|
|||
"status.row.you-boosted" = "내가 부스트함";
|
||||
"status.show-less" = "간략히 보기";
|
||||
"status.show-more" = "더 보기";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " ";
|
||||
"status.summary.edited-time" = "마지막 수정: ";
|
||||
"status.summary.n-boosts %lld" = "부스트 %lld회";
|
||||
|
|
|
@ -112,6 +112,8 @@
|
|||
"settings.system" = "Systeminnstillinger";
|
||||
"settings.content.navigation-title" = "Innholdsinnstillinger";
|
||||
"settings.content.boosts" = "Forsterkninger";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Hide repeated boosts";
|
||||
"settings.content.instance-settings" = "Server Content Settings";
|
||||
"settings.content.use-instance-settings" = "Bruk serverinnstillinger";
|
||||
|
@ -457,6 +459,7 @@
|
|||
"status.row.you-boosted" = "Du forsterket";
|
||||
"status.show-less" = "Vis mindre";
|
||||
"status.show-more" = "Vis mer";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = "kl ";
|
||||
"status.summary.edited-time" = "Sist redigert: ";
|
||||
"status.summary.n-boosts %lld" = "%lld forsterkninger";
|
||||
|
|
|
@ -132,6 +132,8 @@
|
|||
"settings.system" = "Systeeminstellingen";
|
||||
"settings.content.navigation-title" = "Inhoud";
|
||||
"settings.content.boosts" = "Boosts";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Verberg herhaalde boosts";
|
||||
"settings.content.instance-settings" = "Serverinstellingen voor inhoud";
|
||||
"settings.content.use-instance-settings" = "Gebruik serverinstellingen";
|
||||
|
@ -451,6 +453,7 @@
|
|||
"status.row.you-boosted" = "Je boostte";
|
||||
"status.show-less" = "Toon minder";
|
||||
"status.show-more" = "Toon meer";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " om ";
|
||||
"status.summary.edited-time" = "Laatst gewijzigd: ";
|
||||
"status.summary.n-boosts %lld" = "%lld boosts";
|
||||
|
|
|
@ -108,6 +108,8 @@
|
|||
"settings.system" = "Ustawienia systemowe";
|
||||
"settings.content.navigation-title" = "Ustawienia treści";
|
||||
"settings.content.boosts" = "Podbicia";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Ukryj powtórzone podbicia";
|
||||
"settings.content.instance-settings" = "Ustawienia treści serwera";
|
||||
"settings.content.use-instance-settings" = "Zastosuj ustawienia serwera";
|
||||
|
@ -451,6 +453,7 @@
|
|||
"status.row.you-boosted" = "Podbiłeś(aś)";
|
||||
"status.show-less" = "Pokaż mniej";
|
||||
"status.show-more" = "Pokaż więcej";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " o ";
|
||||
"status.summary.edited-time" = "Ostatnia edycja: ";
|
||||
"status.visibility.direct" = "Post bezpośredni";
|
||||
|
|
|
@ -108,6 +108,8 @@
|
|||
"settings.system" = "Ajustes do Sistema";
|
||||
"settings.content.navigation-title" = "Configurações de Conteúdo";
|
||||
"settings.content.boosts" = "Boosts";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "Ocultar boosts repetidos";
|
||||
"settings.content.instance-settings" = "Configurações de conteúdo do servidor";
|
||||
"settings.content.use-instance-settings" = "Usar configurações do servidor";
|
||||
|
@ -457,6 +459,7 @@
|
|||
"status.row.you-boosted" = "Você deu boost";
|
||||
"status.show-less" = "Exibir menos";
|
||||
"status.show-more" = "Exibir mais";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " as ";
|
||||
"status.summary.edited-time" = "Última edição: ";
|
||||
"status.summary.n-boosts %lld" = "%lld boosts";
|
||||
|
|
|
@ -107,6 +107,8 @@
|
|||
"settings.general.content" = "Content Settings";
|
||||
"settings.system" = "System Settings";
|
||||
"settings.content.navigation-title" = "Content Settings";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.boosts" = "Yükseltmeler";
|
||||
"settings.content.hide-repeated-boosts" = "Hide repeated boosts";
|
||||
"settings.content.instance-settings" = "Server Content Settings";
|
||||
|
@ -453,6 +455,7 @@
|
|||
"status.row.you-boosted" = "Yükselttin";
|
||||
"status.show-less" = "Daha az göster";
|
||||
"status.show-more" = "Daha fazla göster";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " de ";
|
||||
"status.summary.edited-time" = "Son düzenleme: ";
|
||||
"status.summary.n-boosts %lld" = "%lld yükseltmeler";
|
||||
|
|
|
@ -111,6 +111,8 @@
|
|||
"settings.general.content" = "Налаштування вмісту";
|
||||
"settings.system" = "Системні налаштування";
|
||||
"settings.content.navigation-title" = "Налаштування вмісту";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.boosts" = "Поширення";
|
||||
"settings.content.hide-repeated-boosts" = "Не відображати повторні поширення";
|
||||
"settings.content.instance-settings" = "Налаштування відображення сервера";
|
||||
|
@ -458,6 +460,7 @@
|
|||
"status.row.you-boosted" = "Ви поширили";
|
||||
"status.show-less" = "Показати менше";
|
||||
"status.show-more" = "Показати більше";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " о ";
|
||||
"status.summary.edited-time" = "Востаннє змінено: ";
|
||||
"status.summary.n-boosts %lld" = "%lld поширень";
|
||||
|
|
|
@ -133,6 +133,8 @@
|
|||
"settings.system" = "系统设置";
|
||||
"settings.content.navigation-title" = "内容设置";
|
||||
"settings.content.boosts" = "转发";
|
||||
"settings.content.collapse-long-posts" = "Collapse long posts";
|
||||
"settings.content.collapse-long-posts-hint" = "Collapsed posts only display a limited number of lines together with a button to show the full post";
|
||||
"settings.content.hide-repeated-boosts" = "隐藏重复的转发";
|
||||
"settings.content.instance-settings" = "服务器内容设置";
|
||||
"settings.content.use-instance-settings" = "使用服务器设置";
|
||||
|
@ -456,6 +458,7 @@
|
|||
"status.row.you-boosted" = "你转发了";
|
||||
"status.show-less" = "显示更少";
|
||||
"status.show-more" = "显示更多";
|
||||
"status.show-full-post" = "Show full post";
|
||||
"status.summary.at-time" = " 在 ";
|
||||
"status.summary.edited-time" = "上次编辑:";
|
||||
"status.summary.n-boosts %lld" = "%lld 转发";
|
||||
|
|
|
@ -8,11 +8,13 @@ public struct EmojiTextApp: View {
|
|||
private let emojis: [any CustomEmoji]
|
||||
private let language: String?
|
||||
private let append: (() -> Text)?
|
||||
private let lineLimit: Int?
|
||||
|
||||
public init(_ markdown: HTMLString, emojis: [Emoji], language: String? = nil, append: (() -> Text)? = nil) {
|
||||
public init(_ markdown: HTMLString, emojis: [Emoji], language: String? = nil, lineLimit: Int? = nil, append: (() -> Text)? = nil) {
|
||||
self.markdown = markdown
|
||||
self.emojis = emojis.map { RemoteEmoji(shortcode: $0.shortcode, url: $0.url) }
|
||||
self.language = language
|
||||
self.lineLimit = lineLimit
|
||||
self.append = append
|
||||
}
|
||||
|
||||
|
@ -22,11 +24,14 @@ public struct EmojiTextApp: View {
|
|||
.append {
|
||||
append()
|
||||
}
|
||||
.lineLimit(lineLimit)
|
||||
} else if emojis.isEmpty {
|
||||
Text(markdown.asSafeMarkdownAttributedString)
|
||||
.lineLimit(lineLimit)
|
||||
.environment(\.layoutDirection, isRTL() ? .rightToLeft : .leftToRight)
|
||||
} else {
|
||||
EmojiText(markdown: markdown.asMarkdown, emojis: emojis)
|
||||
.lineLimit(lineLimit)
|
||||
.environment(\.layoutDirection, isRTL() ? .rightToLeft : .leftToRight)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ public class UserPreferences: ObservableObject {
|
|||
|
||||
@AppStorage("requested_review") public var requestedReview = false
|
||||
|
||||
@AppStorage("collapse-long-posts") public var collapseLongPosts = true
|
||||
|
||||
public enum SwipeActionsIconStyle: String, CaseIterable {
|
||||
case iconWithText, iconOnly
|
||||
|
||||
|
|
|
@ -37,6 +37,31 @@ public class StatusRowViewModel: ObservableObject {
|
|||
@Published var localStatusId: String?
|
||||
@Published var localStatus: Status?
|
||||
|
||||
// used by the button to expand a collapsed post
|
||||
@Published var isCollapsed: Bool = true {
|
||||
didSet {
|
||||
recalcCollapse()
|
||||
}
|
||||
}
|
||||
// number of lines to show, nil means show the whole post
|
||||
@Published var lineLimit: Int? = nil
|
||||
// post length determining if the post should be collapsed
|
||||
let collapseThresholdLength : Int = 750
|
||||
// number of text lines to show on a collpased post
|
||||
let collapsedLines: Int = 8
|
||||
// user preference, set in init
|
||||
var collapseLongPosts: Bool = false
|
||||
|
||||
private func recalcCollapse() {
|
||||
let hasContentWarning = !status.spoilerText.asRawText.isEmpty
|
||||
let showCollapseButton = collapseLongPosts && isCollapsed && !hasContentWarning
|
||||
&& (status.reblog?.content ?? status.content).asRawText.unicodeScalars.count > collapseThresholdLength
|
||||
let newlineLimit = showCollapseButton && isCollapsed ? collapsedLines : nil
|
||||
if newlineLimit != lineLimit {
|
||||
lineLimit = newlineLimit
|
||||
}
|
||||
}
|
||||
|
||||
private let theme = Theme.shared
|
||||
private let userMentionned: Bool
|
||||
|
||||
|
@ -112,6 +137,9 @@ public class StatusRowViewModel: ObservableObject {
|
|||
isEmbedLoading = false
|
||||
embeddedStatus = embed
|
||||
}
|
||||
|
||||
collapseLongPosts = UserPreferences.shared.collapseLongPosts
|
||||
recalcCollapse()
|
||||
}
|
||||
|
||||
func markSeen() {
|
||||
|
|
|
@ -29,6 +29,7 @@ struct StatusRowSpoilerView: View {
|
|||
.accessibility(label: displaySpoiler ? Text("status.show-more") : Text("status.show-less"))
|
||||
.accessibilityHidden(true)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { // make whole row tapable to make up for smaller button size
|
||||
withAnimation {
|
||||
displaySpoiler.toggle()
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import Models
|
||||
import SwiftUI
|
||||
|
||||
struct StatusRowTextView: View {
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var preferences: UserPreferences
|
||||
|
||||
let status: AnyStatus
|
||||
let viewModel: StatusRowViewModel
|
||||
@ObservedObject var viewModel: StatusRowViewModel
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
EmojiTextApp(status.content, emojis: status.emojis, language: status.language)
|
||||
EmojiTextApp(status.content, emojis: status.emojis, language: status.language, lineLimit: viewModel.lineLimit)
|
||||
.font(.scaledBody)
|
||||
.emojiSize(Font.scaledBodyPointSize)
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
|
@ -18,5 +21,35 @@ struct StatusRowTextView: View {
|
|||
})
|
||||
Spacer()
|
||||
}
|
||||
makeCollapseButton()
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
func makeCollapseButton() -> some View {
|
||||
if let _ = viewModel.lineLimit {
|
||||
HStack(alignment: .top) {
|
||||
Text("status.show-full-post")
|
||||
.font(.system(.subheadline, weight: .bold))
|
||||
.foregroundColor(.secondary)
|
||||
Spacer()
|
||||
Button {
|
||||
withAnimation {
|
||||
viewModel.isCollapsed.toggle()
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "chevron.down")
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.accessibility(label: Text("status.show-full-post"))
|
||||
.accessibilityHidden(true)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { // make whole row tapable to make up for smaller button size
|
||||
withAnimation {
|
||||
viewModel.isCollapsed.toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue