mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 09:41:00 +00:00
Refactoring
This commit is contained in:
parent
56f1b63fb9
commit
f1ef5def5b
11 changed files with 87 additions and 86 deletions
|
@ -138,8 +138,12 @@ extension IdentitiesViewModel {
|
||||||
static let development = SecondaryNavigationViewModel.development.identitiesViewModel()
|
static let development = SecondaryNavigationViewModel.development.identitiesViewModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
extension IdentityPreferencesViewModel {
|
extension PreferencesViewModel {
|
||||||
static let development = SecondaryNavigationViewModel.development.identityPreferencesViewModel()
|
static let development = SecondaryNavigationViewModel.development.preferencesViewModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
extension PostingReadingPreferencesViewModel {
|
||||||
|
static let development = PreferencesViewModel.development.postingReadingPreferencesViewModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
// swiftlint:enable force_try
|
// swiftlint:enable force_try
|
||||||
|
|
|
@ -7,10 +7,14 @@
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
D0091B6824DC10B30040E8D2 /* IdentityPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B6724DC10B30040E8D2 /* IdentityPreferencesView.swift */; };
|
D0091B6824DC10B30040E8D2 /* PostingReadingPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B6724DC10B30040E8D2 /* PostingReadingPreferencesView.swift */; };
|
||||||
D0091B6924DC10B30040E8D2 /* IdentityPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B6724DC10B30040E8D2 /* IdentityPreferencesView.swift */; };
|
D0091B6924DC10B30040E8D2 /* PostingReadingPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B6724DC10B30040E8D2 /* PostingReadingPreferencesView.swift */; };
|
||||||
D0091B6B24DC10CE0040E8D2 /* IdentityPreferencesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B6A24DC10CE0040E8D2 /* IdentityPreferencesViewModel.swift */; };
|
D0091B6B24DC10CE0040E8D2 /* PostingReadingPreferencesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B6A24DC10CE0040E8D2 /* PostingReadingPreferencesViewModel.swift */; };
|
||||||
D0091B6C24DC10CE0040E8D2 /* IdentityPreferencesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B6A24DC10CE0040E8D2 /* IdentityPreferencesViewModel.swift */; };
|
D0091B6C24DC10CE0040E8D2 /* PostingReadingPreferencesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B6A24DC10CE0040E8D2 /* PostingReadingPreferencesViewModel.swift */; };
|
||||||
|
D0091B6E24DD68090040E8D2 /* PreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B6D24DD68090040E8D2 /* PreferencesView.swift */; };
|
||||||
|
D0091B6F24DD68090040E8D2 /* PreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B6D24DD68090040E8D2 /* PreferencesView.swift */; };
|
||||||
|
D0091B7124DD68220040E8D2 /* PreferencesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B7024DD68220040E8D2 /* PreferencesViewModel.swift */; };
|
||||||
|
D0091B7224DD68220040E8D2 /* PreferencesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0091B7024DD68220040E8D2 /* PreferencesViewModel.swift */; };
|
||||||
D047FAAE24C3E21200AF17C5 /* MetatextApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D047FA8524C3E21000AF17C5 /* MetatextApp.swift */; };
|
D047FAAE24C3E21200AF17C5 /* MetatextApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D047FA8524C3E21000AF17C5 /* MetatextApp.swift */; };
|
||||||
D047FAAF24C3E21200AF17C5 /* MetatextApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D047FA8524C3E21000AF17C5 /* MetatextApp.swift */; };
|
D047FAAF24C3E21200AF17C5 /* MetatextApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D047FA8524C3E21000AF17C5 /* MetatextApp.swift */; };
|
||||||
D047FAB224C3E21200AF17C5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D047FA8724C3E21200AF17C5 /* Assets.xcassets */; };
|
D047FAB224C3E21200AF17C5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D047FA8724C3E21200AF17C5 /* Assets.xcassets */; };
|
||||||
|
@ -163,8 +167,10 @@
|
||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
D0091B6724DC10B30040E8D2 /* IdentityPreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityPreferencesView.swift; sourceTree = "<group>"; };
|
D0091B6724DC10B30040E8D2 /* PostingReadingPreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostingReadingPreferencesView.swift; sourceTree = "<group>"; };
|
||||||
D0091B6A24DC10CE0040E8D2 /* IdentityPreferencesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdentityPreferencesViewModel.swift; sourceTree = "<group>"; };
|
D0091B6A24DC10CE0040E8D2 /* PostingReadingPreferencesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostingReadingPreferencesViewModel.swift; sourceTree = "<group>"; };
|
||||||
|
D0091B6D24DD68090040E8D2 /* PreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesView.swift; sourceTree = "<group>"; };
|
||||||
|
D0091B7024DD68220040E8D2 /* PreferencesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesViewModel.swift; sourceTree = "<group>"; };
|
||||||
D047FA8524C3E21000AF17C5 /* MetatextApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetatextApp.swift; sourceTree = "<group>"; };
|
D047FA8524C3E21000AF17C5 /* MetatextApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MetatextApp.swift; sourceTree = "<group>"; };
|
||||||
D047FA8724C3E21200AF17C5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
D047FA8724C3E21200AF17C5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
D047FA8C24C3E21200AF17C5 /* Metatext.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Metatext.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
D047FA8C24C3E21200AF17C5 /* Metatext.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Metatext.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
@ -385,7 +391,8 @@
|
||||||
children = (
|
children = (
|
||||||
D0DB6EF324C5228A00D965FE /* AddIdentityView.swift */,
|
D0DB6EF324C5228A00D965FE /* AddIdentityView.swift */,
|
||||||
D06BAB5024D942CF0081B8FD /* IdentitiesView.swift */,
|
D06BAB5024D942CF0081B8FD /* IdentitiesView.swift */,
|
||||||
D0091B6724DC10B30040E8D2 /* IdentityPreferencesView.swift */,
|
D0091B6724DC10B30040E8D2 /* PostingReadingPreferencesView.swift */,
|
||||||
|
D0091B6D24DD68090040E8D2 /* PreferencesView.swift */,
|
||||||
D0BEC93A24C96FD500E864C4 /* RootView.swift */,
|
D0BEC93A24C96FD500E864C4 /* RootView.swift */,
|
||||||
D04FD73224D48F37007D572D /* SecondaryNavigationView.swift */,
|
D04FD73224D48F37007D572D /* SecondaryNavigationView.swift */,
|
||||||
D0BEC94924CA231200E864C4 /* TimelineView.swift */,
|
D0BEC94924CA231200E864C4 /* TimelineView.swift */,
|
||||||
|
@ -412,7 +419,8 @@
|
||||||
D0DB6F0824C65AC000D965FE /* AddIdentityViewModel.swift */,
|
D0DB6F0824C65AC000D965FE /* AddIdentityViewModel.swift */,
|
||||||
D06BAB4D24D942BC0081B8FD /* IdentitiesViewModel.swift */,
|
D06BAB4D24D942BC0081B8FD /* IdentitiesViewModel.swift */,
|
||||||
D052BBDF24D805E300A80A7A /* MainNavigationViewModel.swift */,
|
D052BBDF24D805E300A80A7A /* MainNavigationViewModel.swift */,
|
||||||
D0091B6A24DC10CE0040E8D2 /* IdentityPreferencesViewModel.swift */,
|
D0091B6A24DC10CE0040E8D2 /* PostingReadingPreferencesViewModel.swift */,
|
||||||
|
D0091B7024DD68220040E8D2 /* PreferencesViewModel.swift */,
|
||||||
D0BEC93724C9632800E864C4 /* RootViewModel.swift */,
|
D0BEC93724C9632800E864C4 /* RootViewModel.swift */,
|
||||||
D04FD73524D49506007D572D /* SecondaryNavigationViewModel.swift */,
|
D04FD73524D49506007D572D /* SecondaryNavigationViewModel.swift */,
|
||||||
D0BEC94624CA22C400E864C4 /* TimelineViewModel.swift */,
|
D0BEC94624CA22C400E864C4 /* TimelineViewModel.swift */,
|
||||||
|
@ -714,9 +722,11 @@
|
||||||
D0DC177724D0CF2600A75C65 /* FakeKeychain.swift in Sources */,
|
D0DC177724D0CF2600A75C65 /* FakeKeychain.swift in Sources */,
|
||||||
D0C963FB24CC359D003BD330 /* AlertItem.swift in Sources */,
|
D0C963FB24CC359D003BD330 /* AlertItem.swift in Sources */,
|
||||||
D0DC174624CFEC2000A75C65 /* StubbingURLProtocol.swift in Sources */,
|
D0DC174624CFEC2000A75C65 /* StubbingURLProtocol.swift in Sources */,
|
||||||
|
D0091B7124DD68220040E8D2 /* PreferencesViewModel.swift in Sources */,
|
||||||
D0DC174D24CFF1F100A75C65 /* Stubbing.swift in Sources */,
|
D0DC174D24CFF1F100A75C65 /* Stubbing.swift in Sources */,
|
||||||
D0091B6B24DC10CE0040E8D2 /* IdentityPreferencesViewModel.swift in Sources */,
|
D0091B6B24DC10CE0040E8D2 /* PostingReadingPreferencesViewModel.swift in Sources */,
|
||||||
D0666A5724C6C63400F3F04B /* MastodonDecoder.swift in Sources */,
|
D0666A5724C6C63400F3F04B /* MastodonDecoder.swift in Sources */,
|
||||||
|
D0091B6E24DD68090040E8D2 /* PreferencesView.swift in Sources */,
|
||||||
D0DB6EF424C5228A00D965FE /* AddIdentityView.swift in Sources */,
|
D0DB6EF424C5228A00D965FE /* AddIdentityView.swift in Sources */,
|
||||||
D0DC177424D0B58800A75C65 /* Keychain.swift in Sources */,
|
D0DC177424D0B58800A75C65 /* Keychain.swift in Sources */,
|
||||||
D06BAB5124D942CF0081B8FD /* IdentitiesView.swift in Sources */,
|
D06BAB5124D942CF0081B8FD /* IdentitiesView.swift in Sources */,
|
||||||
|
@ -736,7 +746,7 @@
|
||||||
D0CD847C24DBEA9F00CF380C /* Unknowable.swift in Sources */,
|
D0CD847C24DBEA9F00CF380C /* Unknowable.swift in Sources */,
|
||||||
D0666A6F24C6DFB300F3F04B /* AccessToken.swift in Sources */,
|
D0666A6F24C6DFB300F3F04B /* AccessToken.swift in Sources */,
|
||||||
D0ED1BCB24CF744200B4899C /* MastodonClient.swift in Sources */,
|
D0ED1BCB24CF744200B4899C /* MastodonClient.swift in Sources */,
|
||||||
D0091B6824DC10B30040E8D2 /* IdentityPreferencesView.swift in Sources */,
|
D0091B6824DC10B30040E8D2 /* PostingReadingPreferencesView.swift in Sources */,
|
||||||
D0CD847624DBDF3C00CF380C /* Status.swift in Sources */,
|
D0CD847624DBDF3C00CF380C /* Status.swift in Sources */,
|
||||||
D052BBE024D805E300A80A7A /* MainNavigationViewModel.swift in Sources */,
|
D052BBE024D805E300A80A7A /* MainNavigationViewModel.swift in Sources */,
|
||||||
);
|
);
|
||||||
|
@ -786,9 +796,11 @@
|
||||||
D0DC177824D0CF2600A75C65 /* FakeKeychain.swift in Sources */,
|
D0DC177824D0CF2600A75C65 /* FakeKeychain.swift in Sources */,
|
||||||
D0C963FC24CC359D003BD330 /* AlertItem.swift in Sources */,
|
D0C963FC24CC359D003BD330 /* AlertItem.swift in Sources */,
|
||||||
D0DC174724CFEC2000A75C65 /* StubbingURLProtocol.swift in Sources */,
|
D0DC174724CFEC2000A75C65 /* StubbingURLProtocol.swift in Sources */,
|
||||||
|
D0091B7224DD68220040E8D2 /* PreferencesViewModel.swift in Sources */,
|
||||||
D0DC174E24CFF1F100A75C65 /* Stubbing.swift in Sources */,
|
D0DC174E24CFF1F100A75C65 /* Stubbing.swift in Sources */,
|
||||||
D0091B6C24DC10CE0040E8D2 /* IdentityPreferencesViewModel.swift in Sources */,
|
D0091B6C24DC10CE0040E8D2 /* PostingReadingPreferencesViewModel.swift in Sources */,
|
||||||
D0666A5824C6C63400F3F04B /* MastodonDecoder.swift in Sources */,
|
D0666A5824C6C63400F3F04B /* MastodonDecoder.swift in Sources */,
|
||||||
|
D0091B6F24DD68090040E8D2 /* PreferencesView.swift in Sources */,
|
||||||
D0DB6EF524C5233E00D965FE /* AddIdentityView.swift in Sources */,
|
D0DB6EF524C5233E00D965FE /* AddIdentityView.swift in Sources */,
|
||||||
D0DC177524D0B58800A75C65 /* Keychain.swift in Sources */,
|
D0DC177524D0B58800A75C65 /* Keychain.swift in Sources */,
|
||||||
D06BAB5224D942CF0081B8FD /* IdentitiesView.swift in Sources */,
|
D06BAB5224D942CF0081B8FD /* IdentitiesView.swift in Sources */,
|
||||||
|
@ -808,7 +820,7 @@
|
||||||
D0CD847D24DBEA9F00CF380C /* Unknowable.swift in Sources */,
|
D0CD847D24DBEA9F00CF380C /* Unknowable.swift in Sources */,
|
||||||
D0666A7024C6DFB300F3F04B /* AccessToken.swift in Sources */,
|
D0666A7024C6DFB300F3F04B /* AccessToken.swift in Sources */,
|
||||||
D0ED1BCC24CF744200B4899C /* MastodonClient.swift in Sources */,
|
D0ED1BCC24CF744200B4899C /* MastodonClient.swift in Sources */,
|
||||||
D0091B6924DC10B30040E8D2 /* IdentityPreferencesView.swift in Sources */,
|
D0091B6924DC10B30040E8D2 /* PostingReadingPreferencesView.swift in Sources */,
|
||||||
D0CD847724DBDF3C00CF380C /* Status.swift in Sources */,
|
D0CD847724DBDF3C00CF380C /* Status.swift in Sources */,
|
||||||
D052BBE124D805E300A80A7A /* MainNavigationViewModel.swift in Sources */,
|
D052BBE124D805E300A80A7A /* MainNavigationViewModel.swift in Sources */,
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
"add-identity.instance-url" = "Instance URL";
|
"add-identity.instance-url" = "Instance URL";
|
||||||
"oauth.error.code-not-found" = "OAuth error: code not found";
|
"oauth.error.code-not-found" = "OAuth error: code not found";
|
||||||
"secondary-navigation.accounts" = "Accounts";
|
"secondary-navigation.accounts" = "Accounts";
|
||||||
"secondary-navigation.identity-preferences" = "Preferences";
|
"secondary-navigation.preferences" = "Preferences";
|
||||||
"preferences.title.%@" = "Preferences for %@";
|
"preferences" = "Preferences";
|
||||||
|
"preferences.posting-reading" = "Posting and Reading";
|
||||||
"preferences.posting" = "Posting";
|
"preferences.posting" = "Posting";
|
||||||
"preferences.use-preferences-from-server" = "Use preferences from server";
|
"preferences.use-preferences-from-server" = "Use preferences from server";
|
||||||
"preferences.posting-default-visiblility" = "Default visibility";
|
"preferences.posting-default-visiblility" = "Default visibility";
|
||||||
|
|
|
@ -31,11 +31,10 @@ extension Identity {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Preferences: Codable, Hashable {
|
struct Preferences: Codable, Hashable {
|
||||||
var useServerPostingPreferences = true
|
var useServerPostingReadingPreferences = true
|
||||||
var postingDefaultVisibility = Status.Visibility.public
|
var postingDefaultVisibility = Status.Visibility.public
|
||||||
var postingDefaultSensitive = false
|
var postingDefaultSensitive = false
|
||||||
var postingDefaultLanguage: String?
|
var postingDefaultLanguage: String?
|
||||||
var useServerReadingPreferences = true
|
|
||||||
var readingExpandMedia = MastodonPreferences.ExpandMedia.default
|
var readingExpandMedia = MastodonPreferences.ExpandMedia.default
|
||||||
var readingExpandSpoilers = false
|
var readingExpandSpoilers = false
|
||||||
}
|
}
|
||||||
|
@ -54,18 +53,12 @@ extension Identity {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Identity.Preferences {
|
extension Identity.Preferences {
|
||||||
var shouldUseAnyServerPreferences: Bool {
|
|
||||||
useServerPostingPreferences || useServerReadingPreferences
|
|
||||||
}
|
|
||||||
|
|
||||||
func updated(from serverPreferences: MastodonPreferences) -> Self {
|
func updated(from serverPreferences: MastodonPreferences) -> Self {
|
||||||
var mutable = self
|
var mutable = self
|
||||||
if useServerPostingPreferences {
|
|
||||||
|
if useServerPostingReadingPreferences {
|
||||||
mutable.postingDefaultVisibility = serverPreferences.postingDefaultVisibility
|
mutable.postingDefaultVisibility = serverPreferences.postingDefaultVisibility
|
||||||
mutable.postingDefaultSensitive = serverPreferences.postingDefaultSensitive
|
mutable.postingDefaultSensitive = serverPreferences.postingDefaultSensitive
|
||||||
}
|
|
||||||
|
|
||||||
if useServerReadingPreferences {
|
|
||||||
mutable.readingExpandMedia = serverPreferences.readingExpandMedia
|
mutable.readingExpandMedia = serverPreferences.readingExpandMedia
|
||||||
mutable.readingExpandSpoilers = serverPreferences.readingExpandSpoilers
|
mutable.readingExpandSpoilers = serverPreferences.readingExpandSpoilers
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ extension MainNavigationViewModel {
|
||||||
.sink(receiveValue: {})
|
.sink(receiveValue: {})
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
if identity.preferences.shouldUseAnyServerPreferences {
|
if identity.preferences.useServerPostingReadingPreferences {
|
||||||
let capturedPreferences = identity.preferences
|
let capturedPreferences = identity.preferences
|
||||||
|
|
||||||
environment.networkClient.request(PreferencesEndpoint.preferences)
|
environment.networkClient.request(PreferencesEndpoint.preferences)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
class IdentityPreferencesViewModel: ObservableObject {
|
class PostingReadingPreferencesViewModel: ObservableObject {
|
||||||
@Published var preferences: Identity.Preferences
|
@Published var preferences: Identity.Preferences
|
||||||
@Published var alertItem: AlertItem?
|
@Published var alertItem: AlertItem?
|
||||||
let handle: String
|
let handle: String
|
||||||
|
@ -20,7 +20,7 @@ class IdentityPreferencesViewModel: ObservableObject {
|
||||||
.dropFirst()
|
.dropFirst()
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
.handleEvents(receiveOutput: { [weak self] in
|
.handleEvents(receiveOutput: { [weak self] in
|
||||||
if $0.shouldUseAnyServerPreferences {
|
if $0.useServerPostingReadingPreferences {
|
||||||
self?.refreshPreferences()
|
self?.refreshPreferences()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -37,7 +37,7 @@ class IdentityPreferencesViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension IdentityPreferencesViewModel {
|
extension PostingReadingPreferencesViewModel {
|
||||||
func refreshPreferences() {
|
func refreshPreferences() {
|
||||||
let id = environment.identity.id
|
let id = environment.identity.id
|
||||||
let capturedPreferences = preferences
|
let capturedPreferences = preferences
|
20
Shared/View Models/PreferencesViewModel.swift
Normal file
20
Shared/View Models/PreferencesViewModel.swift
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright © 2020 Metabolist. All rights reserved.
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class PreferencesViewModel: ObservableObject {
|
||||||
|
let handle: String
|
||||||
|
|
||||||
|
private let environment: IdentifiedEnvironment
|
||||||
|
|
||||||
|
init(environment: IdentifiedEnvironment) {
|
||||||
|
self.environment = environment
|
||||||
|
handle = environment.identity.handle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension PreferencesViewModel {
|
||||||
|
func postingReadingPreferencesViewModel() -> PostingReadingPreferencesViewModel {
|
||||||
|
PostingReadingPreferencesViewModel(environment: environment)
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ extension SecondaryNavigationViewModel {
|
||||||
IdentitiesViewModel(environment: environment)
|
IdentitiesViewModel(environment: environment)
|
||||||
}
|
}
|
||||||
|
|
||||||
func identityPreferencesViewModel() -> IdentityPreferencesViewModel {
|
func preferencesViewModel() -> PreferencesViewModel {
|
||||||
IdentityPreferencesViewModel(environment: environment)
|
PreferencesViewModel(environment: environment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,16 @@
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct IdentityPreferencesView: View {
|
struct PostingReadingPreferencesView: View {
|
||||||
@StateObject var viewModel: IdentityPreferencesViewModel
|
@StateObject var viewModel: PostingReadingPreferencesViewModel
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
Section(header: Text("preferences.posting")) {
|
Section {
|
||||||
Toggle("preferences.use-preferences-from-server",
|
Toggle("preferences.use-preferences-from-server",
|
||||||
isOn: $viewModel.preferences.useServerPostingPreferences)
|
isOn: $viewModel.preferences.useServerPostingReadingPreferences)
|
||||||
|
}
|
||||||
|
Section(header: Text("preferences.posting")) {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Text("preferences.posting-default-visiblility")
|
Text("preferences.posting-default-visiblility")
|
||||||
Picker("", selection: $viewModel.preferences.postingDefaultVisibility,
|
Picker("", selection: $viewModel.preferences.postingDefaultVisibility,
|
||||||
|
@ -20,14 +22,11 @@ struct IdentityPreferencesView: View {
|
||||||
})
|
})
|
||||||
.pickerStyle(SegmentedPickerStyle())
|
.pickerStyle(SegmentedPickerStyle())
|
||||||
}
|
}
|
||||||
.disabled(viewModel.preferences.useServerPostingPreferences)
|
|
||||||
Toggle("preferences.posting-default-sensitive",
|
Toggle("preferences.posting-default-sensitive",
|
||||||
isOn: $viewModel.preferences.postingDefaultSensitive)
|
isOn: $viewModel.preferences.postingDefaultSensitive)
|
||||||
.disabled(viewModel.preferences.useServerPostingPreferences)
|
|
||||||
}
|
}
|
||||||
|
.disabled(viewModel.preferences.useServerPostingReadingPreferences)
|
||||||
Section(header: Text("preferences.reading")) {
|
Section(header: Text("preferences.reading")) {
|
||||||
Toggle("preferences.use-preferences-from-server",
|
|
||||||
isOn: $viewModel.preferences.useServerReadingPreferences)
|
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Text("preferences.reading-expand-media")
|
Text("preferences.reading-expand-media")
|
||||||
Picker("", selection: $viewModel.preferences.readingExpandMedia,
|
Picker("", selection: $viewModel.preferences.readingExpandMedia,
|
||||||
|
@ -38,19 +37,18 @@ struct IdentityPreferencesView: View {
|
||||||
})
|
})
|
||||||
.pickerStyle(SegmentedPickerStyle())
|
.pickerStyle(SegmentedPickerStyle())
|
||||||
}
|
}
|
||||||
.disabled(viewModel.preferences.useServerReadingPreferences)
|
|
||||||
Toggle("preferences.reading-expand-spoilers",
|
Toggle("preferences.reading-expand-spoilers",
|
||||||
isOn: $viewModel.preferences.readingExpandSpoilers)
|
isOn: $viewModel.preferences.readingExpandSpoilers)
|
||||||
.disabled(viewModel.preferences.useServerReadingPreferences)
|
|
||||||
}
|
}
|
||||||
|
.disabled(viewModel.preferences.useServerPostingReadingPreferences)
|
||||||
}
|
}
|
||||||
.navigationTitle("preferences.title.\(viewModel.handle)")
|
.navigationTitle("preferences.posting-reading")
|
||||||
.alertItem($viewModel.alertItem)
|
.alertItem($viewModel.alertItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PreferencesView_Previews: PreviewProvider {
|
struct PostingReadingPreferencesViewView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
IdentityPreferencesView(viewModel: .development)
|
PostingReadingPreferencesView(viewModel: .development)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,53 +2,23 @@
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct IdentityPreferencesView: View {
|
struct PreferencesView: View {
|
||||||
@StateObject var viewModel: IdentityPreferencesViewModel
|
@StateObject var viewModel: PreferencesViewModel
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
Section(header: Text("preferences.posting")) {
|
Section(header: Text(viewModel.handle)) {
|
||||||
Toggle("preferences.use-preferences-from-server",
|
NavigationLink("preferences.posting-reading",
|
||||||
isOn: $viewModel.preferences.useServerPostingPreferences)
|
destination: PostingReadingPreferencesView(
|
||||||
VStack(alignment: .leading) {
|
viewModel: viewModel.postingReadingPreferencesViewModel()))
|
||||||
Text("preferences.posting-default-visiblility")
|
|
||||||
Picker("", selection: $viewModel.preferences.postingDefaultVisibility,
|
|
||||||
content: {
|
|
||||||
Text("status.visibility.public").tag(Status.Visibility.public)
|
|
||||||
Text("status.visibility.unlisted").tag(Status.Visibility.unlisted)
|
|
||||||
Text("status.visibility.private").tag(Status.Visibility.private)
|
|
||||||
})
|
|
||||||
.pickerStyle(SegmentedPickerStyle())
|
|
||||||
}
|
|
||||||
.disabled(viewModel.preferences.useServerPostingPreferences)
|
|
||||||
Toggle("preferences.posting-default-sensitive",
|
|
||||||
isOn: $viewModel.preferences.postingDefaultSensitive)
|
|
||||||
.disabled(viewModel.preferences.useServerPostingPreferences)
|
|
||||||
}
|
|
||||||
Section(header: Text("preferences.reading")) {
|
|
||||||
Toggle("preferences.use-preferences-from-server",
|
|
||||||
isOn: $viewModel.preferences.useServerReadingPreferences)
|
|
||||||
VStack(alignment: .leading) {
|
|
||||||
Text("preferences.reading-expand-media")
|
|
||||||
Picker("", selection: $viewModel.preferences.readingExpandMedia,
|
|
||||||
content: {
|
|
||||||
Text("preferences.expand-media.default").tag(MastodonPreferences.ExpandMedia.default)
|
|
||||||
Text("preferences.expand-media.show-all").tag(MastodonPreferences.ExpandMedia.showAll)
|
|
||||||
Text("preferences.expand-media.hide-all").tag(MastodonPreferences.ExpandMedia.hideAll)
|
|
||||||
})
|
|
||||||
.pickerStyle(SegmentedPickerStyle())
|
|
||||||
}
|
|
||||||
.disabled(viewModel.preferences.useServerReadingPreferences)
|
|
||||||
Toggle("preferences.reading-expand-spoilers",
|
|
||||||
isOn: $viewModel.preferences.readingExpandSpoilers)
|
|
||||||
.disabled(viewModel.preferences.useServerReadingPreferences)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle("preferences.title.\(viewModel.handle)")
|
.navigationTitle("preferences")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PreferencesView_Previews: PreviewProvider {
|
struct PreferencesView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
IdentityPreferencesView(viewModel: .development)
|
PreferencesView(viewModel: .development)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,12 @@ struct SecondaryNavigationView: View {
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
Section {
|
||||||
NavigationLink(
|
NavigationLink(
|
||||||
"secondary-navigation.identity-preferences",
|
"secondary-navigation.preferences",
|
||||||
destination: IdentityPreferencesView(viewModel: viewModel.identityPreferencesViewModel()))
|
destination: PreferencesView(
|
||||||
|
viewModel: viewModel.preferencesViewModel()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationItems(presentationMode: presentationMode)
|
.navigationItems(presentationMode: presentationMode)
|
||||||
|
|
Loading…
Reference in a new issue