From d8096f5986e1d5fbc072d639c1fdb5d563cbaadf Mon Sep 17 00:00:00 2001 From: Lumaa Date: Tue, 25 Jun 2024 14:33:37 +0200 Subject: [PATCH] Move function + WordFilter --- Threaded/Data/Accounts/LoggedAccounts.swift | 8 -------- Threaded/Data/Content/ContentFilter.swift | 4 ++++ Threaded/ThreadedApp.swift | 8 ++++++++ Threaded/Views/Settings/FilterView.swift | 13 +++++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 Threaded/Views/Settings/FilterView.swift diff --git a/Threaded/Data/Accounts/LoggedAccounts.swift b/Threaded/Data/Accounts/LoggedAccounts.swift index 7eca887..dee7d27 100644 --- a/Threaded/Data/Accounts/LoggedAccounts.swift +++ b/Threaded/Data/Accounts/LoggedAccounts.swift @@ -25,14 +25,6 @@ class LoggedAccount { } } -public extension View { - @ViewBuilder - func modelData() -> some View { - self - .modelContainer(for: LoggedAccount.self) - } -} - public struct AppAccount: Codable, Identifiable, Hashable { public let server: String public var accountName: String? diff --git a/Threaded/Data/Content/ContentFilter.swift b/Threaded/Data/Content/ContentFilter.swift index f97ae2b..c3d5902 100644 --- a/Threaded/Data/Content/ContentFilter.swift +++ b/Threaded/Data/Content/ContentFilter.swift @@ -2,6 +2,7 @@ import Foundation import SwiftUI +import SwiftData /// A content filter designed for posts and its author protocol PostFilter { @@ -59,6 +60,9 @@ extension PostFilter { } class ContentFilter { + static let defaultFilter: ContentFilter.WordFilter = .init(categoryName: "Default", words: []) + + @Model class WordFilter: PostFilter { let categoryName: String var content: [String] diff --git a/Threaded/ThreadedApp.swift b/Threaded/ThreadedApp.swift index 972c347..32f3e8b 100644 --- a/Threaded/ThreadedApp.swift +++ b/Threaded/ThreadedApp.swift @@ -39,6 +39,14 @@ struct ThreadedApp: App { } } +public extension View { + @ViewBuilder + func modelData() -> some View { + self + .modelContainer(for: [LoggedAccount.self, ContentFilter.WordFilter.self]) + } +} + extension AppInfo { static var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown" } diff --git a/Threaded/Views/Settings/FilterView.swift b/Threaded/Views/Settings/FilterView.swift new file mode 100644 index 0000000..3594830 --- /dev/null +++ b/Threaded/Views/Settings/FilterView.swift @@ -0,0 +1,13 @@ +//Made by Lumaa + +import SwiftUI + +struct FilterView: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +#Preview { + FilterView() +}