Default posting visibility
This commit is contained in:
parent
81793f9842
commit
9f9307b053
@ -12,15 +12,17 @@ class UserPreferences: Codable, ObservableObject {
|
|||||||
var profilePictureShape: ProfilePictureShape = .circle
|
var profilePictureShape: ProfilePictureShape = .circle
|
||||||
|
|
||||||
var browserType: BrowserType = .inApp
|
var browserType: BrowserType = .inApp
|
||||||
|
var defaultVisibility: Visibility = .pub
|
||||||
|
|
||||||
// Experimental
|
// Experimental
|
||||||
var showExperimental: Bool = false
|
var showExperimental: Bool = false
|
||||||
var experimental: UserPreferences.Experimental
|
var experimental: UserPreferences.Experimental
|
||||||
|
|
||||||
init(displayedName: DisplayedName = .username, profilePictureShape: ProfilePictureShape = .circle, browserType: BrowserType = .inApp, showExperimental: Bool = false, experimental: UserPreferences.Experimental = .init()) {
|
init(displayedName: DisplayedName = .username, profilePictureShape: ProfilePictureShape = .circle, browserType: BrowserType = .inApp, defaultVisibility: Visibility = .pub, showExperimental: Bool = false, experimental: UserPreferences.Experimental = .init()) {
|
||||||
self.displayedName = displayedName
|
self.displayedName = displayedName
|
||||||
self.profilePictureShape = profilePictureShape
|
self.profilePictureShape = profilePictureShape
|
||||||
self.browserType = browserType
|
self.browserType = browserType
|
||||||
|
self.defaultVisibility = defaultVisibility
|
||||||
|
|
||||||
self.showExperimental = showExperimental
|
self.showExperimental = showExperimental
|
||||||
self.experimental = experimental
|
self.experimental = experimental
|
||||||
|
@ -696,7 +696,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"coming-soon" : {
|
"coming-soon" : {
|
||||||
|
"localizations" : {
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Coming Soon"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fr" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Bientôt"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"discovery" : {
|
"discovery" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
@ -1466,6 +1479,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"setting.privacy.default-visibility" : {
|
||||||
|
"localizations" : {
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Default posting visibility"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fr" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Visibilité par défaut des publications"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"setting.support" : {
|
"setting.support" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"en" : {
|
"en" : {
|
||||||
@ -1572,7 +1601,7 @@
|
|||||||
},
|
},
|
||||||
"fr" : {
|
"fr" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
"state" : "needs_review",
|
"state" : "translated",
|
||||||
"value" : "Supprimer"
|
"value" : "Supprimer"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ struct PostingView: View {
|
|||||||
|
|
||||||
@State private var hasKeyboard: Bool = true
|
@State private var hasKeyboard: Bool = true
|
||||||
@State private var visibility: Visibility = .pub
|
@State private var visibility: Visibility = .pub
|
||||||
|
@State private var pref: UserPreferences = .defaultPreferences
|
||||||
|
|
||||||
@State private var selectingPhotos: Bool = false
|
@State private var selectingPhotos: Bool = false
|
||||||
@State private var mediaContainers: [MediaContainer] = []
|
@State private var mediaContainers: [MediaContainer] = []
|
||||||
@ -161,6 +162,9 @@ struct PostingView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
|
self.pref = try! UserPreferences.loadAsCurrent()!
|
||||||
|
self.visibility = pref.defaultVisibility
|
||||||
|
|
||||||
if !initialString.isEmpty && editId == nil {
|
if !initialString.isEmpty && editId == nil {
|
||||||
viewModel.append(text: initialString + " ") // add space for quick typing
|
viewModel.append(text: initialString + " ") // add space for quick typing
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,14 +4,38 @@ import SwiftUI
|
|||||||
import Nuke
|
import Nuke
|
||||||
|
|
||||||
struct PrivacyView: View {
|
struct PrivacyView: View {
|
||||||
|
@ObservedObject private var userPreferences: UserPreferences = .defaultPreferences
|
||||||
@EnvironmentObject private var navigator: Navigator
|
@EnvironmentObject private var navigator: Navigator
|
||||||
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
|
||||||
@State private var clearedCache: Bool = false
|
@State private var clearedCache: Bool = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
//TODO: Visibilty, Blocklist & Mutelist
|
//TODO: Blocklist & Mutelist
|
||||||
|
|
||||||
|
Picker(LocalizedStringKey("setting.privacy.default-visibility"), selection: $userPreferences.defaultVisibility) {
|
||||||
|
ForEach(Visibility.allCases, id: \.self) { visibility in
|
||||||
|
switch (visibility) {
|
||||||
|
case .pub:
|
||||||
|
Text("status.posting.visibility.public")
|
||||||
|
case .priv:
|
||||||
|
Text("status.posting.visibility.private")
|
||||||
|
case .unlisted:
|
||||||
|
Text("status.posting.visibility.unlisted")
|
||||||
|
case .direct:
|
||||||
|
Text("status.posting.visibility.direct")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.pickerStyle(.inline)
|
||||||
|
.listRowThreaded()
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
.frame(height: 30)
|
||||||
|
.listRowThreaded()
|
||||||
|
|
||||||
|
Section {
|
||||||
HStack {
|
HStack {
|
||||||
Text("settings.privacy.clear-cache")
|
Text("settings.privacy.clear-cache")
|
||||||
|
|
||||||
@ -30,9 +54,50 @@ struct PrivacyView: View {
|
|||||||
.buttonStyle(LargeButton(filled: true, filledColor: clearedCache ? Color.green : Color(uiColor: UIColor.label), height: 7.5))
|
.buttonStyle(LargeButton(filled: true, filledColor: clearedCache ? Color.green : Color(uiColor: UIColor.label), height: 7.5))
|
||||||
.disabled(clearedCache)
|
.disabled(clearedCache)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.listRowThreaded()
|
.listRowThreaded()
|
||||||
}
|
}
|
||||||
.listThreaded()
|
.listThreaded()
|
||||||
|
.navigationTitle(Text("privacy"))
|
||||||
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
.navigationBarBackButtonHidden()
|
||||||
|
.onAppear {
|
||||||
|
loadOld()
|
||||||
|
}
|
||||||
|
.toolbar {
|
||||||
|
ToolbarItem(placement: .cancellationAction) {
|
||||||
|
Button {
|
||||||
|
loadOld()
|
||||||
|
dismiss()
|
||||||
|
} label: {
|
||||||
|
Text("settings.cancel")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolbarItem(placement: .primaryAction) {
|
||||||
|
Button {
|
||||||
|
do {
|
||||||
|
try userPreferences.saveAsCurrent()
|
||||||
|
dismiss()
|
||||||
|
} catch {
|
||||||
|
print(error)
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Text("settings.done")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func loadOld() {
|
||||||
|
do {
|
||||||
|
let oldPreferences = try UserPreferences.loadAsCurrent() ?? UserPreferences.defaultPreferences
|
||||||
|
|
||||||
|
userPreferences.defaultVisibility = oldPreferences.defaultVisibility
|
||||||
|
} catch {
|
||||||
|
print(error)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user