Skip to content

Commit

Permalink
Hide download settings from the users who don't have download access
Browse files Browse the repository at this point in the history
fix issue razeware#495
  • Loading branch information
Zoha131 committed Oct 11, 2020
1 parent ca77200 commit 5ca95cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Emitron/Emitron/UI/Settings/SettingsList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ import SwiftUI

struct SettingsList {
@ObservedObject private var settingsManager: SettingsManager
private var canDownload: Bool
}

// MARK: - View
extension SettingsList: View {
var body: some View {
VStack(spacing: 0) {
ForEach(SettingsOption.allCases) { self[$0] }
ForEach(SettingsOption.getOptions(for: canDownload)) { self[$0] }
}
}
}
Expand All @@ -48,15 +49,16 @@ struct SettingsList_Previews: PreviewProvider {
}

static var list: some View {
SettingsList( settingsManager: .init(initialValue: .current) )
SettingsList(settingsManager: .init(initialValue: .current), canDownload: true)
.background(Color.backgroundColor)
}
}

// MARK: - internal
extension SettingsList {
init(settingsManager: ObservedObject<SettingsManager>) {
init(settingsManager: ObservedObject<SettingsManager>, canDownload: Bool) {
_settingsManager = settingsManager
self.canDownload = canDownload
}
}

Expand Down
5 changes: 4 additions & 1 deletion Emitron/Emitron/UI/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ struct SettingsView: View {
var body: some View {
NavigationView {
VStack {
SettingsList(settingsManager: _settingsManager)
SettingsList(
settingsManager: _settingsManager,
canDownload: sessionController.user?.canDownload ?? false
)
.navigationBarTitle(String.settings)
.navigationBarItems(trailing: dismissButton)
.padding([.horizontal], 20)
Expand Down

0 comments on commit 5ca95cd

Please sign in to comment.