Files
xcodesApp-mirror/Xcodes/Frontend/Common/ProgressIndicator.swift
2021-01-01 15:36:20 -07:00

41 lines
1.1 KiB
Swift

import SwiftUI
import AppKit
/// You probably want ProgressView unless you need more of NSProgressIndicator's API, which this exposes.
struct ProgressIndicator: NSViewRepresentable {
typealias NSViewType = NSProgressIndicator
let minValue: Double
let maxValue: Double
let doubleValue: Double
let controlSize: NSControl.ControlSize
let isIndeterminate: Bool
let style: NSProgressIndicator.Style
func makeNSView(context: Context) -> NSViewType {
NSProgressIndicator()
}
func updateNSView(_ nsView: NSViewType, context: Context) {
nsView.minValue = minValue
nsView.maxValue = maxValue
nsView.doubleValue = doubleValue
nsView.controlSize = controlSize
nsView.isIndeterminate = isIndeterminate
nsView.style = style
}
}
struct ProgressIndicator_Previews: PreviewProvider {
static var previews: some View {
ProgressIndicator(
minValue: 0,
maxValue: 1,
doubleValue: 0.4,
controlSize: .small,
isIndeterminate: false,
style: .spinning
)
}
}