forked from LoopKit/LoopKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActivityIndicator.swift
More file actions
32 lines (26 loc) · 1004 Bytes
/
ActivityIndicator.swift
File metadata and controls
32 lines (26 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// ActivityIndicator.swift
// DashKitUI
//
// Created by Pete Schwamb on 2/10/20.
// Copyright © 2020 LoopKit Authors. All rights reserved.
//
import SwiftUI
public struct ActivityIndicator: UIViewRepresentable {
@Binding var isAnimating: Bool
let style: UIActivityIndicatorView.Style
let color: UIColor?
public init(isAnimating: Binding<Bool>, style: UIActivityIndicatorView.Style, color: UIColor? = nil) {
self._isAnimating = isAnimating
self.style = style
self.color = color
}
public func makeUIView(context: UIViewRepresentableContext<ActivityIndicator>) -> UIActivityIndicatorView {
let activityIndicator = UIActivityIndicatorView(style: style)
activityIndicator.color = color
return activityIndicator
}
public func updateUIView(_ uiView: UIActivityIndicatorView, context: UIViewRepresentableContext<ActivityIndicator>) {
isAnimating ? uiView.startAnimating() : uiView.stopAnimating()
}
}