Skip to content

Commit eeac213

Browse files
committed
swift format
1 parent f4c2dad commit eeac213

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3949
-3676
lines changed

ios/beartracks/Packages/RealityKitContent/Package.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
import PackageDescription
55

66
let package = Package(
7-
name: "RealityKitContent",
8-
products: [
9-
// Products define the executables and libraries a package produces, and make them visible to other packages.
10-
.library(
11-
name: "RealityKitContent",
12-
targets: ["RealityKitContent"]),
13-
],
14-
dependencies: [
15-
// Dependencies declare other packages that this package depends on.
16-
// .package(url: /* package url */, from: "1.0.0"),
17-
],
18-
targets: [
19-
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20-
// Targets can depend on other targets in this package, and on products in packages this package depends on.
21-
.target(
22-
name: "RealityKitContent",
23-
dependencies: []),
24-
]
25-
)
7+
name: "RealityKitContent",
8+
products: [
9+
// Products define the executables and libraries a package produces, and make them visible to other packages.
10+
.library(
11+
name: "RealityKitContent",
12+
targets: ["RealityKitContent"])
13+
],
14+
dependencies: [
15+
// Dependencies declare other packages that this package depends on.
16+
// .package(url: /* package url */, from: "1.0.0"),
17+
],
18+
targets: [
19+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
21+
.target(
22+
name: "RealityKitContent",
23+
dependencies: [])
24+
]
25+
)

ios/beartracks/SystemStatus/SystemStatusBundle.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
// Created by Jayen Agrawal on 2/27/24.
66
//
77

8-
import WidgetKit
98
import SwiftUI
9+
import WidgetKit
1010

1111
@main
1212
struct SystemStatusBundle: WidgetBundle {
13-
var body: some Widget {
14-
SystemStatusLiveActivity()
15-
}
13+
var body: some Widget {
14+
SystemStatusLiveActivity()
15+
}
1616
}

ios/beartracks/SystemStatus/SystemStatusLiveActivity.swift

Lines changed: 117 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -6,117 +6,141 @@
66
//
77

88
import ActivityKit
9-
import WidgetKit
109
import SwiftUI
10+
import WidgetKit
1111

1212
struct SystemStatusAttributes: ActivityAttributes {
13-
public struct ContentState: Codable, Hashable {
14-
var total_mem: Int
15-
var used_mem: Int
16-
var total_swap: Int
17-
var used_swap: Int
18-
var uptime: Int
19-
var load_one: Double
20-
var load_five: Double
21-
var load_fifteen: Double
22-
var sessions: Int
23-
}
24-
var hostname: String
13+
public struct ContentState: Codable, Hashable {
14+
var total_mem: Int
15+
var used_mem: Int
16+
var total_swap: Int
17+
var used_swap: Int
18+
var uptime: Int
19+
var load_one: Double
20+
var load_five: Double
21+
var load_fifteen: Double
22+
var sessions: Int
23+
}
24+
var hostname: String
2525
}
2626

2727
struct SystemStatusLiveActivity: Widget {
28-
var body: some WidgetConfiguration {
29-
ActivityConfiguration(for: SystemStatusAttributes.self) { context in
30-
// Lock screen/banner UI goes here
31-
VStack {
32-
HStack {
33-
ProgressView(value: Float(context.state.used_mem) / Float(context.state.total_mem), total: 1.0) {
34-
Text("RAM\n\(Int(Float(context.state.used_mem) / Float(context.state.total_mem) * 100))%")
35-
}
36-
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.used_mem) / Float(context.state.total_mem))))
37-
Spacer()
38-
ProgressView(value: context.state.load_five, total: 1.0) {
39-
Text("CPU\n\(Int(context.state.load_five * 100))%")
40-
}
41-
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
42-
}
43-
Text("\(context.state.sessions) active sessions")
44-
}
45-
.padding()
46-
.activityBackgroundTint(Color.black)
47-
.activitySystemActionForegroundColor(Color.white)
28+
var body: some WidgetConfiguration {
29+
ActivityConfiguration(for: SystemStatusAttributes.self) { context in
30+
// Lock screen/banner UI goes here
31+
VStack {
32+
HStack {
33+
ProgressView(
34+
value: Float(context.state.used_mem) / Float(context.state.total_mem), total: 1.0
35+
) {
36+
Text(
37+
"RAM\n\(Int(Float(context.state.used_mem) / Float(context.state.total_mem) * 100))%")
38+
}
39+
.progressViewStyle(
40+
CircularProgressViewStyle(
41+
tint: getColor(value: Float(context.state.used_mem) / Float(context.state.total_mem)))
42+
)
43+
Spacer()
44+
ProgressView(value: context.state.load_five, total: 1.0) {
45+
Text("CPU\n\(Int(context.state.load_five * 100))%")
46+
}
47+
.progressViewStyle(
48+
CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
49+
}
50+
Text("\(context.state.sessions) active sessions")
51+
}
52+
.padding()
53+
.activityBackgroundTint(Color.black)
54+
.activitySystemActionForegroundColor(Color.white)
4855

49-
} dynamicIsland: { context in
50-
DynamicIsland {
51-
DynamicIslandExpandedRegion(.leading) {
52-
ProgressView(value: Float(context.state.used_mem) / Float(context.state.total_mem), total: 1.0) {
53-
Text("RAM\n\(Int(100 * Float(context.state.used_mem) / Float(context.state.total_mem)))%")
54-
}
55-
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.used_mem) / Float(context.state.total_mem))))
56-
}
57-
DynamicIslandExpandedRegion(.trailing) {
58-
ProgressView(value: context.state.load_five, total: 1.0) {
59-
Text("CPU\n\(Int((context.state.load_five * 100).rounded()))%")
60-
}
61-
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
62-
}
63-
DynamicIslandExpandedRegion(.bottom) {
64-
Text("\(context.state.sessions) active sessions")
65-
}
66-
} compactLeading: {
67-
ProgressView(value: Float(context.state.used_mem) / Float(context.state.total_mem), total: 1.0) {
68-
Label("RAM", systemImage: "memorychip")
69-
.labelStyle(.iconOnly)
70-
}
71-
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.used_mem) / Float(context.state.total_mem))))
72-
} compactTrailing: {
73-
ProgressView(value: context.state.load_five, total: 1.0) {
74-
Label("5m Load", systemImage: "gauge.open.with.lines.needle.33percent")
75-
.labelStyle(.iconOnly)
76-
}
77-
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
78-
} minimal: {
79-
ProgressView(value: context.state.load_five, total: 1.0) {
80-
Label("5m Load", systemImage: "gauge.open.with.lines.needle.33percent")
81-
.labelStyle(.iconOnly)
82-
}
83-
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
84-
}
85-
.widgetURL(URL(string: "https://beartracks.io"))
86-
.keylineTint(Color.red)
56+
} dynamicIsland: { context in
57+
DynamicIsland {
58+
DynamicIslandExpandedRegion(.leading) {
59+
ProgressView(
60+
value: Float(context.state.used_mem) / Float(context.state.total_mem), total: 1.0
61+
) {
62+
Text(
63+
"RAM\n\(Int(100 * Float(context.state.used_mem) / Float(context.state.total_mem)))%")
64+
}
65+
.progressViewStyle(
66+
CircularProgressViewStyle(
67+
tint: getColor(value: Float(context.state.used_mem) / Float(context.state.total_mem)))
68+
)
8769
}
88-
}
89-
90-
private func getColor(value: Float) -> Color {
91-
if value > 0.9 {
92-
return Color.red
93-
} else if value > 0.8 {
94-
return Color.yellow
95-
} else {
96-
return Color.green
70+
DynamicIslandExpandedRegion(.trailing) {
71+
ProgressView(value: context.state.load_five, total: 1.0) {
72+
Text("CPU\n\(Int((context.state.load_five * 100).rounded()))%")
73+
}
74+
.progressViewStyle(
75+
CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
76+
}
77+
DynamicIslandExpandedRegion(.bottom) {
78+
Text("\(context.state.sessions) active sessions")
79+
}
80+
} compactLeading: {
81+
ProgressView(
82+
value: Float(context.state.used_mem) / Float(context.state.total_mem), total: 1.0
83+
) {
84+
Label("RAM", systemImage: "memorychip")
85+
.labelStyle(.iconOnly)
9786
}
87+
.progressViewStyle(
88+
CircularProgressViewStyle(
89+
tint: getColor(value: Float(context.state.used_mem) / Float(context.state.total_mem))))
90+
} compactTrailing: {
91+
ProgressView(value: context.state.load_five, total: 1.0) {
92+
Label("5m Load", systemImage: "gauge.open.with.lines.needle.33percent")
93+
.labelStyle(.iconOnly)
94+
}
95+
.progressViewStyle(
96+
CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
97+
} minimal: {
98+
ProgressView(value: context.state.load_five, total: 1.0) {
99+
Label("5m Load", systemImage: "gauge.open.with.lines.needle.33percent")
100+
.labelStyle(.iconOnly)
101+
}
102+
.progressViewStyle(
103+
CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
104+
}
105+
.widgetURL(URL(string: "https://beartracks.io"))
106+
.keylineTint(Color.red)
107+
}
108+
}
109+
110+
private func getColor(value: Float) -> Color {
111+
if value > 0.9 {
112+
return Color.red
113+
} else if value > 0.8 {
114+
return Color.yellow
115+
} else {
116+
return Color.green
98117
}
118+
}
99119
}
100120

101121
extension SystemStatusAttributes {
102-
fileprivate static var preview: SystemStatusAttributes {
103-
SystemStatusAttributes(hostname: "beartracks.io")
104-
}
122+
fileprivate static var preview: SystemStatusAttributes {
123+
SystemStatusAttributes(hostname: "beartracks.io")
124+
}
105125
}
106126

107127
extension SystemStatusAttributes.ContentState {
108-
fileprivate static var smiley: SystemStatusAttributes.ContentState {
109-
SystemStatusAttributes.ContentState.init(total_mem: 1000, used_mem: 839, total_swap: 0, used_swap: 0, uptime: 2313124, load_one: 0.02, load_five: 0.40, load_fifteen: 0.93, sessions: 2)
110-
}
111-
112-
fileprivate static var starEyes: SystemStatusAttributes.ContentState {
113-
SystemStatusAttributes.ContentState.init(total_mem: 1000, used_mem: 839, total_swap: 100, used_swap: 0, uptime: 2313124, load_one: 0.02, load_five: 0.40, load_fifteen: 0.93, sessions: 2)
114-
}
128+
fileprivate static var smiley: SystemStatusAttributes.ContentState {
129+
SystemStatusAttributes.ContentState.init(
130+
total_mem: 1000, used_mem: 839, total_swap: 0, used_swap: 0, uptime: 2_313_124,
131+
load_one: 0.02, load_five: 0.40, load_fifteen: 0.93, sessions: 2)
132+
}
133+
134+
fileprivate static var starEyes: SystemStatusAttributes.ContentState {
135+
SystemStatusAttributes.ContentState.init(
136+
total_mem: 1000, used_mem: 839, total_swap: 100, used_swap: 0, uptime: 2_313_124,
137+
load_one: 0.02, load_five: 0.40, load_fifteen: 0.93, sessions: 2)
138+
}
115139
}
116140

117141
#Preview("Notification", as: .content, using: SystemStatusAttributes.preview) {
118-
SystemStatusLiveActivity()
142+
SystemStatusLiveActivity()
119143
} contentStates: {
120-
SystemStatusAttributes.ContentState.smiley
121-
SystemStatusAttributes.ContentState.starEyes
144+
SystemStatusAttributes.ContentState.smiley
145+
SystemStatusAttributes.ContentState.starEyes
122146
}

ios/beartracks/bearTracks/AppState.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
// Created by Jayen Agrawal on 2/7/24.
66
//
77

8-
import Foundation
98
import Combine
9+
import Foundation
1010

1111
class AppState: ObservableObject {
12-
#if targetEnvironment(macCatalyst)
12+
#if targetEnvironment(macCatalyst)
1313
@Published public var selectedTab: Tab? = .teams
14-
#elseif os(watchOS)
15-
#else
14+
#elseif os(watchOS)
15+
#else
1616
@Published public var selectedTab: Tab = .teams
17-
#endif
18-
@Published public var loginRequired: Bool = false
19-
private var cancellables: Set<AnyCancellable> = []
17+
#endif
18+
@Published public var loginRequired: Bool = false
19+
private var cancellables: Set<AnyCancellable> = []
2020

21-
#if !os(watchOS)
21+
#if !os(watchOS)
2222
init() {
23-
$selectedTab
24-
.receive(on: DispatchQueue.main)
25-
.sink { _ in }
26-
.store(in: &cancellables)
23+
$selectedTab
24+
.receive(on: DispatchQueue.main)
25+
.sink { _ in }
26+
.store(in: &cancellables)
2727
}
28-
#endif
28+
#endif
2929
}

0 commit comments

Comments
 (0)