//
//  MediaPrefsView.swift
//  Tusker
//
//  Created by Shadowfacts on 2/22/20.
//  Copyright © 2020 Shadowfacts. All rights reserved.
//

import SwiftUI

struct MediaPrefsView: View {
    @ObservedObject var preferences = Preferences.shared
    
    var body: some View {
        List {
            viewingSection
        }
        .listStyle(.insetGrouped)
        .appGroupedListBackground(container: PreferencesNavigationController.self)
        .navigationBarTitle("Media")
    }
    
    var viewingSection: some View {
        Section(header: Text("Viewing")) {
            Picker(selection: $preferences.attachmentBlurMode) {
                ForEach(Preferences.AttachmentBlurMode.allCases, id: \.self) { mode in
                    Text(mode.displayName).tag(mode)
                }
            } label: {
                Text("Blur Media")
            }
            
            Toggle(isOn: $preferences.blurMediaBehindContentWarning) {
                Text("Blur Media Behind Content Warning")
            }
            .disabled(preferences.attachmentBlurMode != .useStatusSetting)
            
            Toggle(isOn: $preferences.automaticallyPlayGifs) {
                Text("Automatically Play GIFs")
            }
            
            Toggle(isOn: $preferences.showUncroppedMediaInline) {
                Text("Show Uncropped Media Inline")
            }
            
            Toggle(isOn: $preferences.showAttachmentBadges) {
                Text("Show GIF/ALT Badges")
            }
        }
        .appGroupedListRowBackground()
    }
}

struct MediaPrefsView_Previews: PreviewProvider {
    static var previews: some View {
        MediaPrefsView()
    }
}
