Skip to content

Commit aaf56cc

Browse files
committed
Merge branch 'dev' into cameron/LOOP-4884-pulsing-loop-status
1 parent 0ebc9ff commit aaf56cc

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

LoopUI/Views/LoopStateView.swift

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,31 @@ class WrappedLoopStateViewModel: ObservableObject {
3030
}
3131
}
3232

33+
struct WrappedLoopCircleView: View {
34+
35+
@ObservedObject var viewModel: WrappedLoopStateViewModel
36+
37+
var body: some View {
38+
LoopCircleView(closedLoop: $viewModel.closedLoop, freshness: $viewModel.freshness, animating: $viewModel.animating)
39+
.environment(\.loopStatusColorPalette, viewModel.loopStatusColors)
40+
}
41+
}
42+
43+
class LoopCircleHostingController: UIHostingController<WrappedLoopCircleView> {
44+
init(viewModel: WrappedLoopStateViewModel) {
45+
super.init(
46+
rootView: WrappedLoopCircleView(
47+
viewModel: viewModel
48+
)
49+
)
50+
}
51+
52+
required init?(coder aDecoder: NSCoder) {
53+
fatalError()
54+
}
55+
}
56+
57+
3358
final class LoopStateView: UIView {
3459

3560
override init(frame: CGRect) {
@@ -71,14 +96,7 @@ final class LoopStateView: UIView {
7196
private let viewModel = WrappedLoopStateViewModel()
7297

7398
private func setupViews() {
74-
let hostingController = UIHostingController(
75-
rootView: LoopCircleView(
76-
closedLoop: viewModel.closedLoop,
77-
freshness: viewModel.freshness,
78-
animating: viewModel.animating
79-
)
80-
.environment(\.loopStatusColorPalette, viewModel.loopStatusColors)
81-
)
99+
let hostingController = LoopCircleHostingController(viewModel: viewModel)
82100

83101
hostingController.view.backgroundColor = .clear
84102
hostingController.view.translatesAutoresizingMaskIntoConstraints = false

0 commit comments

Comments
 (0)