Fix / simplify account content warning

This commit is contained in:
Thomas Ricouard 2023-11-19 08:26:07 +01:00
parent 12d92ab1ec
commit 71ab8d558a
3 changed files with 2 additions and 24 deletions

View file

@ -98,7 +98,6 @@ struct AccountSettingsView: View {
} }
.sheet(isPresented: $isEditingAccount, content: { .sheet(isPresented: $isEditingAccount, content: {
EditAccountView() EditAccountView()
.environment(\.contentSettingsFactory, AnyView(ContentSettingsView()))
}) })
.sheet(isPresented: $isEditingFilters, content: { .sheet(isPresented: $isEditingFilters, content: {
FiltersListView() FiltersListView()

View file

@ -10,15 +10,13 @@ public struct EditAccountView: View {
@Environment(Client.self) private var client @Environment(Client.self) private var client
@Environment(Theme.self) private var theme @Environment(Theme.self) private var theme
@Environment(UserPreferences.self) private var userPrefs @Environment(UserPreferences.self) private var userPrefs
@Environment(\.contentSettingsFactory) private var contentSettings
@State private var viewModel = EditAccountViewModel() @State private var viewModel = EditAccountViewModel()
@State private var showContentSettings = false
public init() {} public init() {}
public var body: some View { public var body: some View {
NavigationStack { NavigationStack{
Form { Form {
if viewModel.isLoading { if viewModel.isLoading {
loadingSection loadingSection
@ -77,17 +75,7 @@ public struct EditAccountView: View {
private var postSettingsSection: some View { private var postSettingsSection: some View {
Section("account.edit.post-settings.section-title") { Section("account.edit.post-settings.section-title") {
if !userPrefs.useInstanceContentSettings { if !userPrefs.useInstanceContentSettings {
HStack { Text("account.edit.post-settings.content-settings-reference")
Button("account.edit.post-settings.content-settings-reference") {showContentSettings.toggle()}
.buttonStyle(.plain)
.navigationDestination(isPresented: $showContentSettings) {
contentSettings
}
Spacer()
Image(systemName: "chevron.right")
.font(.caption)
}
.foregroundStyle(Color.accentColor)
} }
Picker(selection: $viewModel.postPrivacy) { Picker(selection: $viewModel.postPrivacy) {
ForEach(Models.Visibility.supportDefault, id: \.rawValue) { privacy in ForEach(Models.Visibility.supportDefault, id: \.rawValue) { privacy in

View file

@ -29,10 +29,6 @@ private struct IndentationLevel: EnvironmentKey {
static let defaultValue: UInt = 0 static let defaultValue: UInt = 0
} }
private struct ContentSettingsFactory: EnvironmentKey {
static let defaultValue: AnyView = AnyView(EmptyView())
}
public extension EnvironmentValues { public extension EnvironmentValues {
var isSecondaryColumn: Bool { var isSecondaryColumn: Bool {
get { self[SecondaryColumnKey.self] } get { self[SecondaryColumnKey.self] }
@ -68,9 +64,4 @@ public extension EnvironmentValues {
get { self[IndentationLevel.self] } get { self[IndentationLevel.self] }
set { self[IndentationLevel.self] = newValue } set { self[IndentationLevel.self] = newValue }
} }
var contentSettingsFactory: AnyView {
get { self[ContentSettingsFactory.self] }
set { self[ContentSettingsFactory.self] = newValue }
}
} }