mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-02-06 20:28:39 +01:00
41 lines
1.1 KiB
Swift
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
|
|
)
|
|
}
|
|
}
|