mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-22 23:26:37 +00:00
Add a preview toot to the top of the display settings page. (#716)
* Add a preview toot tot the top of the display settings page. * DisplayModel doesn't need to be @State * Disable hitTest * Example Post --------- Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
parent
0c359f2b79
commit
8f6e6853aa
20 changed files with 54 additions and 14 deletions
|
@ -6,15 +6,22 @@ import SwiftUI
|
||||||
|
|
||||||
struct DisplaySettingsView: View {
|
struct DisplaySettingsView: View {
|
||||||
typealias FontState = Theme.FontState
|
typealias FontState = Theme.FontState
|
||||||
|
|
||||||
@Environment(\.colorScheme) private var colorScheme
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
@EnvironmentObject private var theme: Theme
|
@EnvironmentObject private var theme: Theme
|
||||||
@EnvironmentObject private var userPreferences: UserPreferences
|
@EnvironmentObject private var userPreferences: UserPreferences
|
||||||
|
|
||||||
@State private var isFontSelectorPresented = false
|
@State private var isFontSelectorPresented = false
|
||||||
|
|
||||||
|
private var previewStatusViewModel = StatusRowViewModel(status: Status.placeholder(parseMarkdown: true))
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
|
Section("settings.display.example-toot") {
|
||||||
|
StatusRowView(viewModel: previewStatusViewModel)
|
||||||
|
.allowsHitTesting(false)
|
||||||
|
}
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
Toggle("settings.display.theme.systemColor", isOn: $theme.followSystemColorScheme)
|
Toggle("settings.display.theme.systemColor", isOn: $theme.followSystemColorScheme)
|
||||||
themeSelectorButton
|
themeSelectorButton
|
||||||
|
@ -33,7 +40,7 @@ struct DisplaySettingsView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.listRowBackground(theme.primaryBackgroundColor)
|
.listRowBackground(theme.primaryBackgroundColor)
|
||||||
|
|
||||||
Section("settings.display.section.display") {
|
Section("settings.display.section.display") {
|
||||||
Picker("settings.display.font", selection: .init(get: { () -> FontState in
|
Picker("settings.display.font", selection: .init(get: { () -> FontState in
|
||||||
if userPreferences.chosenFont?.fontName == "OpenDyslexic-Regular" {
|
if userPreferences.chosenFont?.fontName == "OpenDyslexic-Regular" {
|
||||||
|
@ -74,7 +81,7 @@ struct DisplaySettingsView: View {
|
||||||
Text(buttonStyle.description).tag(buttonStyle)
|
Text(buttonStyle.description).tag(buttonStyle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Picker("settings.display.status.media-style", selection: $theme.statusDisplayStyle) {
|
Picker("settings.display.status.media-style", selection: $theme.statusDisplayStyle) {
|
||||||
ForEach(Theme.StatusDisplayStyle.allCases, id: \.rawValue) { buttonStyle in
|
ForEach(Theme.StatusDisplayStyle.allCases, id: \.rawValue) { buttonStyle in
|
||||||
Text(buttonStyle.description).tag(buttonStyle)
|
Text(buttonStyle.description).tag(buttonStyle)
|
||||||
|
@ -97,7 +104,7 @@ struct DisplaySettingsView: View {
|
||||||
Toggle("settings.display.show-ipad-column", isOn: $userPreferences.showiPadSecondaryColumn)
|
Toggle("settings.display.show-ipad-column", isOn: $userPreferences.showiPadSecondaryColumn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
Button {
|
Button {
|
||||||
theme.followSystemColorScheme = true
|
theme.followSystemColorScheme = true
|
||||||
|
@ -115,7 +122,7 @@ struct DisplaySettingsView: View {
|
||||||
.scrollContentBackground(.hidden)
|
.scrollContentBackground(.hidden)
|
||||||
.background(theme.secondaryBackgroundColor)
|
.background(theme.secondaryBackgroundColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var themeSelectorButton: some View {
|
private var themeSelectorButton: some View {
|
||||||
NavigationLink(destination: ThemePreviewView()) {
|
NavigationLink(destination: ThemePreviewView()) {
|
||||||
HStack {
|
HStack {
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
"settings.app.source" = "Font (enllaç a GitHub)";
|
"settings.app.source" = "Font (enllaç a GitHub)";
|
||||||
"settings.app.support" = "Dona suport a l'aplicació";
|
"settings.app.support" = "Dona suport a l'aplicació";
|
||||||
"settings.app.about" = "About";
|
"settings.app.about" = "About";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "Posició de les fotos de perfil";
|
"settings.display.avatar.position" = "Posició de les fotos de perfil";
|
||||||
"settings.display.avatar.shape" = "Forma de les fotos de perfil";
|
"settings.display.avatar.shape" = "Forma de les fotos de perfil";
|
||||||
"settings.display.navigation-title" = "Configuració de l'aparença";
|
"settings.display.navigation-title" = "Configuració de l'aparença";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Quellcode (auf GitHub)";
|
"settings.app.source" = "Quellcode (auf GitHub)";
|
||||||
"settings.app.support" = "Unterstütze die App";
|
"settings.app.support" = "Unterstütze die App";
|
||||||
"settings.app.about" = "About";
|
"settings.app.about" = "About";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "Profilbild-Position";
|
"settings.display.avatar.position" = "Profilbild-Position";
|
||||||
"settings.display.avatar.shape" = "Profilbild-Form";
|
"settings.display.avatar.shape" = "Profilbild-Form";
|
||||||
"settings.display.navigation-title" = "Anzeigeeinstellungen";
|
"settings.display.navigation-title" = "Anzeigeeinstellungen";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Source (GitHub link)";
|
"settings.app.source" = "Source (GitHub link)";
|
||||||
"settings.app.support" = "Support the app";
|
"settings.app.support" = "Support the app";
|
||||||
"settings.app.about" = "About";
|
"settings.app.about" = "About";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.font" = "Timeline Font";
|
"settings.display.font" = "Timeline Font";
|
||||||
"settings.display.font.system" = "System";
|
"settings.display.font.system" = "System";
|
||||||
"settings.display.font.custom" = "Custom";
|
"settings.display.font.custom" = "Custom";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Source (GitHub link)";
|
"settings.app.source" = "Source (GitHub link)";
|
||||||
"settings.app.support" = "Support the app";
|
"settings.app.support" = "Support the app";
|
||||||
"settings.app.about" = "About";
|
"settings.app.about" = "About";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.font" = "Timeline Font";
|
"settings.display.font" = "Timeline Font";
|
||||||
"settings.display.font.system" = "System";
|
"settings.display.font.system" = "System";
|
||||||
"settings.display.font.custom" = "Custom";
|
"settings.display.font.custom" = "Custom";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Código fuente (Enlace a GitHub)";
|
"settings.app.source" = "Código fuente (Enlace a GitHub)";
|
||||||
"settings.app.support" = "Apoya a Ice Cubes";
|
"settings.app.support" = "Apoya a Ice Cubes";
|
||||||
"settings.app.about" = "Acerca de";
|
"settings.app.about" = "Acerca de";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "Posición del avatar";
|
"settings.display.avatar.position" = "Posición del avatar";
|
||||||
"settings.display.avatar.shape" = "Forma del avatar";
|
"settings.display.avatar.shape" = "Forma del avatar";
|
||||||
"settings.display.navigation-title" = "Ajustes de apariencia";
|
"settings.display.navigation-title" = "Ajustes de apariencia";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Source (lien GitHub)";
|
"settings.app.source" = "Source (lien GitHub)";
|
||||||
"settings.app.support" = "Soutenir l'application";
|
"settings.app.support" = "Soutenir l'application";
|
||||||
"settings.app.about" = "À propos";
|
"settings.app.about" = "À propos";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "Position de l'avatar";
|
"settings.display.avatar.position" = "Position de l'avatar";
|
||||||
"settings.display.avatar.shape" = "Forme de l'avatar";
|
"settings.display.avatar.shape" = "Forme de l'avatar";
|
||||||
"settings.display.navigation-title" = "Paramètres d'affichage";
|
"settings.display.navigation-title" = "Paramètres d'affichage";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Sorgenti (link GitHub)";
|
"settings.app.source" = "Sorgenti (link GitHub)";
|
||||||
"settings.app.support" = "Supporta l'applicazione";
|
"settings.app.support" = "Supporta l'applicazione";
|
||||||
"settings.app.about" = "Informazioni";
|
"settings.app.about" = "Informazioni";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "Posizione dell'avatar";
|
"settings.display.avatar.position" = "Posizione dell'avatar";
|
||||||
"settings.display.avatar.shape" = "Forma dell'avatar";
|
"settings.display.avatar.shape" = "Forma dell'avatar";
|
||||||
"settings.display.navigation-title" = "Impostazioni di visualizzazione";
|
"settings.display.navigation-title" = "Impostazioni di visualizzazione";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "ソース (GitHub link)";
|
"settings.app.source" = "ソース (GitHub link)";
|
||||||
"settings.app.support" = "アプリを支援する";
|
"settings.app.support" = "アプリを支援する";
|
||||||
"settings.app.about" = "アプリについて";
|
"settings.app.about" = "アプリについて";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.font" = "タイムラインのフォント";
|
"settings.display.font" = "タイムラインのフォント";
|
||||||
"settings.display.font.system" = "システムフォント";
|
"settings.display.font.system" = "システムフォント";
|
||||||
"settings.display.font.custom" = "カスタム";
|
"settings.display.font.custom" = "カスタム";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "소스 코드 (GitHub)";
|
"settings.app.source" = "소스 코드 (GitHub)";
|
||||||
"settings.app.support" = "이 앱 지원하기";
|
"settings.app.support" = "이 앱 지원하기";
|
||||||
"settings.app.about" = "이 앱에 관해";
|
"settings.app.about" = "이 앱에 관해";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "프로필 사진 위치";
|
"settings.display.avatar.position" = "프로필 사진 위치";
|
||||||
"settings.display.avatar.shape" = "프로필 사진 모양";
|
"settings.display.avatar.shape" = "프로필 사진 모양";
|
||||||
"settings.display.navigation-title" = "화면 설정";
|
"settings.display.navigation-title" = "화면 설정";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Kilde (GitHub-lenke)";
|
"settings.app.source" = "Kilde (GitHub-lenke)";
|
||||||
"settings.app.support" = "Støtt denne appen";
|
"settings.app.support" = "Støtt denne appen";
|
||||||
"settings.app.about" = "About";
|
"settings.app.about" = "About";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.font" = "Tidslinjefont";
|
"settings.display.font" = "Tidslinjefont";
|
||||||
"settings.display.font.system" = "System";
|
"settings.display.font.system" = "System";
|
||||||
"settings.display.font.custom" = "Tilpasset";
|
"settings.display.font.custom" = "Tilpasset";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Broncode (GitHub-link)";
|
"settings.app.source" = "Broncode (GitHub-link)";
|
||||||
"settings.app.support" = "De app steunen";
|
"settings.app.support" = "De app steunen";
|
||||||
"settings.app.about" = "Info";
|
"settings.app.about" = "Info";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "Avatarpositie";
|
"settings.display.avatar.position" = "Avatarpositie";
|
||||||
"settings.display.avatar.shape" = "Avatarvorm";
|
"settings.display.avatar.shape" = "Avatarvorm";
|
||||||
"settings.display.navigation-title" = "Weergaveopties";
|
"settings.display.navigation-title" = "Weergaveopties";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Źródło (link do GitHub)";
|
"settings.app.source" = "Źródło (link do GitHub)";
|
||||||
"settings.app.support" = "Wspieraj aplikację";
|
"settings.app.support" = "Wspieraj aplikację";
|
||||||
"settings.app.about" = "O aplikacji";
|
"settings.app.about" = "O aplikacji";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "Położenie awatara";
|
"settings.display.avatar.position" = "Położenie awatara";
|
||||||
"settings.display.avatar.shape" = "Kształt awatara";
|
"settings.display.avatar.shape" = "Kształt awatara";
|
||||||
"settings.display.navigation-title" = "Ustawienia ekranu";
|
"settings.display.navigation-title" = "Ustawienia ekranu";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Código fonte (link GitHub)";
|
"settings.app.source" = "Código fonte (link GitHub)";
|
||||||
"settings.app.support" = "Apoie o app";
|
"settings.app.support" = "Apoie o app";
|
||||||
"settings.app.about" = "About";
|
"settings.app.about" = "About";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "Posição do avatar";
|
"settings.display.avatar.position" = "Posição do avatar";
|
||||||
"settings.display.avatar.shape" = "Formato do avatar";
|
"settings.display.avatar.shape" = "Formato do avatar";
|
||||||
"settings.display.navigation-title" = "Ver Configurações";
|
"settings.display.navigation-title" = "Ver Configurações";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "Kaynak Kodu (GitHub link)";
|
"settings.app.source" = "Kaynak Kodu (GitHub link)";
|
||||||
"settings.app.support" = "Uygulamayı Destekleyin";
|
"settings.app.support" = "Uygulamayı Destekleyin";
|
||||||
"settings.app.about" = "About";
|
"settings.app.about" = "About";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "Avatar Pozisyonu";
|
"settings.display.avatar.position" = "Avatar Pozisyonu";
|
||||||
"settings.display.avatar.shape" = "Avatar Şekli";
|
"settings.display.avatar.shape" = "Avatar Şekli";
|
||||||
"settings.display.navigation-title" = "Gösterim Ayarları";
|
"settings.display.navigation-title" = "Gösterim Ayarları";
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
"settings.app.source" = "源代码(GitHub 链接)";
|
"settings.app.source" = "源代码(GitHub 链接)";
|
||||||
"settings.app.support" = "支持本应用";
|
"settings.app.support" = "支持本应用";
|
||||||
"settings.app.about" = "关于";
|
"settings.app.about" = "关于";
|
||||||
|
"settings.display.example-toot" = "Example Post";
|
||||||
"settings.display.avatar.position" = "头像位置";
|
"settings.display.avatar.position" = "头像位置";
|
||||||
"settings.display.avatar.shape" = "头像边框";
|
"settings.display.avatar.shape" = "头像边框";
|
||||||
"settings.display.navigation-title" = "显示设置";
|
"settings.display.navigation-title" = "显示设置";
|
||||||
|
|
|
@ -54,10 +54,10 @@ public struct Account: Codable, Identifiable, Equatable, Hashable {
|
||||||
public static func placeholder() -> Account {
|
public static func placeholder() -> Account {
|
||||||
.init(id: UUID().uuidString,
|
.init(id: UUID().uuidString,
|
||||||
username: "Username",
|
username: "Username",
|
||||||
displayName: "Display Name",
|
displayName: "John Mastodon",
|
||||||
avatar: URL(string: "https://files.mastodon.social/media_attachments/files/003/134/405/original/04060b07ddf7bb0b.png")!,
|
avatar: URL(string: "https://files.mastodon.social/media_attachments/files/003/134/405/original/04060b07ddf7bb0b.png")!,
|
||||||
header: URL(string: "https://files.mastodon.social/media_attachments/files/003/134/405/original/04060b07ddf7bb0b.png")!,
|
header: URL(string: "https://files.mastodon.social/media_attachments/files/003/134/405/original/04060b07ddf7bb0b.png")!,
|
||||||
acct: "account@account.com",
|
acct: "johnm@example.com",
|
||||||
note: .init(stringValue: "Some content"),
|
note: .init(stringValue: "Some content"),
|
||||||
createdAt: "2022-12-16T10:20:54.000Z",
|
createdAt: "2022-12-16T10:20:54.000Z",
|
||||||
followersCount: 10,
|
followersCount: 10,
|
||||||
|
|
|
@ -77,12 +77,24 @@ public struct HTMLString: Codable, Equatable, Hashable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(stringValue: String) {
|
public init(stringValue: String, parseMarkdown:Bool = false) {
|
||||||
htmlValue = stringValue
|
htmlValue = stringValue
|
||||||
asMarkdown = stringValue
|
asMarkdown = stringValue
|
||||||
asRawText = stringValue
|
asRawText = stringValue
|
||||||
statusesURLs = []
|
statusesURLs = []
|
||||||
asSafeMarkdownAttributedString = AttributedString(stringLiteral: htmlValue)
|
|
||||||
|
if parseMarkdown {
|
||||||
|
do {
|
||||||
|
let options = AttributedString.MarkdownParsingOptions(allowsExtendedAttributes: true,
|
||||||
|
interpretedSyntax: .inlineOnlyPreservingWhitespace)
|
||||||
|
asSafeMarkdownAttributedString = try AttributedString(markdown: asMarkdown, options: options)
|
||||||
|
} catch {
|
||||||
|
asSafeMarkdownAttributedString = AttributedString(stringLiteral: htmlValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
asSafeMarkdownAttributedString = AttributedString(stringLiteral: htmlValue)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|
|
@ -3,6 +3,11 @@ import Foundation
|
||||||
public typealias ServerDate = String
|
public typealias ServerDate = String
|
||||||
|
|
||||||
extension ServerDate {
|
extension ServerDate {
|
||||||
|
|
||||||
|
public static var sampleDate: ServerDate {
|
||||||
|
createdAtDateFormatter.string(from: Date()-100)
|
||||||
|
}
|
||||||
|
|
||||||
private static var createdAtDateFormatter: DateFormatter = {
|
private static var createdAtDateFormatter: DateFormatter = {
|
||||||
let dateFormatter = DateFormatter()
|
let dateFormatter = DateFormatter()
|
||||||
dateFormatter.calendar = .init(identifier: .iso8601)
|
dateFormatter.calendar = .init(identifier: .iso8601)
|
||||||
|
|
|
@ -100,11 +100,12 @@ public struct Status: AnyStatus, Codable, Identifiable, Equatable, Hashable, Sta
|
||||||
public let sensitive: Bool
|
public let sensitive: Bool
|
||||||
public let language: String?
|
public let language: String?
|
||||||
|
|
||||||
public static func placeholder() -> Status {
|
public static func placeholder(parseMarkdown:Bool = false) -> Status {
|
||||||
.init(id: UUID().uuidString,
|
.init(id: UUID().uuidString,
|
||||||
content: .init(stringValue: "This is a #toot\nWith some @content\nAnd some more content for your #eyes @only"),
|
content: .init(stringValue: "Lorem ipsum [#dolor](#) sit amet\nconsectetur [@adipiscing](#) elit\nAsed do eiusmod tempor incididunt ut labore.", parseMarkdown: parseMarkdown),
|
||||||
|
|
||||||
account: .placeholder(),
|
account: .placeholder(),
|
||||||
createdAt: "2022-12-16T10:20:54.000Z",
|
createdAt: ServerDate.sampleDate,
|
||||||
editedAt: nil,
|
editedAt: nil,
|
||||||
reblog: nil,
|
reblog: nil,
|
||||||
mediaAttachments: [],
|
mediaAttachments: [],
|
||||||
|
|
Loading…
Reference in a new issue