Skip to content

Commit

Permalink
Initial implementation of Infineat watch face; other minor UI enhance…
Browse files Browse the repository at this point in the history
…ments and bug fixes
  • Loading branch information
liamcharger committed Mar 5, 2024
1 parent 7b29ba2 commit bdd3be1
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 108 deletions.
2 changes: 1 addition & 1 deletion InfiniLink.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@
E0C0E8622B96D4DF0021E4AE /* Core */ = {
isa = PBXGroup;
children = (
E0C0E8632B96D4E90021E4AE /* Home */,
E0C0E87B2B96E9310021E4AE /* Settings */,
E03544142B59648D00FEA7AA /* Weather */,
E0C0E8652B96D5260021E4AE /* Welcome */,
E0C0E8632B96D4E90021E4AE /* Home */,
);
path = Core;
sourceTree = "<group>";
Expand Down
21 changes: 21 additions & 0 deletions InfiniLink/Assets.xcassets/bluetooth.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icons8-bluetooth-30 2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion InfiniLink/Core/Home/DeviceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ struct DeviceView: View {
.foregroundColor(.white)
.cornerRadius(15)
}
// .disabled(bleManagerVal.loadingWeather)
Spacer()
.frame(height: 6)
}
Expand Down
96 changes: 80 additions & 16 deletions InfiniLink/Core/Home/WatchFace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ struct WatchFaceView: View {
case 3:
TerminalWF(geometry: .constant(geometry))
case 4:
// Infineat
EmptyView()
InfineatWF(geometry: .constant(geometry))
case 5:
// Casio G7710
EmptyView()
default:
UnknownWF(geometry: .constant(geometry))
ProgressView()
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .bottomLeading)
Expand Down Expand Up @@ -316,6 +316,82 @@ struct DigitalWF: View {
}
}

struct InfineatWF: View {
@ObservedObject var bleManagerVal = BLEManagerVal.shared
@Environment(\.colorScheme) var colorScheme
@Binding var geometry: GeometryProxy

var hour24: Bool {
switch bleManagerVal.timeFormat {
case .H12:
return false
case .H24:
return true
default:
return true
}
}

var body: some View {
ZStack {
if hour24 {
CustomTextView(text: Calendar.current.component(.hour, from: Date()) > 12 ? "PM" : "AM", font: .custom("Teko-Light", size: geometry.size.width * 0.125), lineSpacing: 0)
.foregroundColor(.white)
.frame(width: geometry.size.width, height: geometry.size.height / 1.35, alignment: .topTrailing)
}
if Calendar.current.component(.hour, from: Date()) > 12 && !hour24 {
VStack(alignment: .center, spacing: -28) {
Text("\(String(format: "%02d", Calendar.current.component(.hour, from: Date()) - 12))")
Text("\(String(format: "%02d", Calendar.current.component(.minute, from: Date())))")
}
.font(.custom("BebasNeue-Regular", size: geometry.size.width * 0.44))
.foregroundColor(.white)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
.position(x: geometry.size.width / 2.0, y: geometry.size.height / 1.9)
} else {
VStack(alignment: .center, spacing: -28) {
Text("\(String(format: "%02d", Calendar.current.component(.hour, from: Date())))")
Text("\(String(format: "%02d", Calendar.current.component(.minute, from: Date())))")
}
.font(.custom("BebasNeue-Regular", size: geometry.size.width * 0.44))
.foregroundColor(.white)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
.position(x: geometry.size.width / 2.0, y: geometry.size.height / 1.9)

}
CustomTextView(
text: {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "E dd"
return dateFormatter.string(from: Date())
}(),
font: .custom("Teko-Light", size: geometry.size.width * 0.118),
lineSpacing: 0
)
.foregroundColor(.gray)
.frame(width: geometry.size.width, height: geometry.size.height / 2.2, alignment: .trailing)
Image("bluetooth")
.resizable()
.frame(width: 18, height: 20)
.frame(width: geometry.size.width / 1.14, height: geometry.size.height / 2.8, alignment: .bottomTrailing)
Image("pine_logo")
.resizable()
.frame(width: 20, height: 26)
.frame(width: geometry.size.width / 1.15, height: geometry.size.height, alignment: .leading)
HStack(spacing: 4) {
Image(systemName: "shoeprints.fill")
.rotationEffect(Angle(degrees: 90))
.font(.system(size: geometry.size.width * 0.08))
CustomTextView(text: "\(bleManagerVal.stepCount)", font: .custom("Teko-Light", size: geometry.size.width * 0.118), lineSpacing: 0)
}
.foregroundColor(.gray)
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .bottom)
.padding(.bottom, -16)
}
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}

struct TerminalWF: View {
@ObservedObject var bleManagerVal = BLEManagerVal.shared
@ObservedObject var bleManager = BLEManager.shared
Expand Down Expand Up @@ -400,18 +476,6 @@ struct TerminalWF: View {
}
}

struct UnknownWF: View {
@Environment(\.colorScheme) var colorScheme
@Binding var geometry: GeometryProxy

var body: some View {
VStack {
ProgressView()
}
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
}
}

struct CustomTextView: View {
var text: String
var font: Font
Expand All @@ -430,7 +494,7 @@ struct CustomTextView: View {
#Preview {
NavigationView {
GeometryReader { geometry in
WatchFaceView(watchface: .constant(3))
WatchFaceView(watchface: .constant(4))
.padding(22)
.frame(width: geometry.size.width / 1.65, height: geometry.size.width / 1.65, alignment: .center)
.clipped(antialiased: true)
Expand Down
153 changes: 74 additions & 79 deletions InfiniLink/Core/Weather/Views/WeatherDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,106 +48,101 @@ struct WeatherDetailView: View {
.frame(maxWidth: .infinity, alignment: .trailing)
Divider()
VStack {
VStack(spacing: 8) {
Image(systemName: getIcon(icon: bleManagerVal.weatherInformation.icon))
.font(.system(size: 45).weight(.medium))
HStack {
Group {
if celsius {
Text(String(Int(round(bleManagerVal.weatherInformation.minTemperature))) + "°" + "C")
} else {
Text(String(Int(round(bleManagerVal.weatherInformation.minTemperature * 1.8 + 32))) + "°" + "F")
if bleManagerVal.loadingWeather {
Spacer()
ProgressView(NSLocalizedString("loading_weather", comment: ""))
Spacer()
} else {
VStack(spacing: 8) {
Image(systemName: getIcon(icon: bleManagerVal.weatherInformation.icon))
.font(.system(size: 45).weight(.medium))
HStack {
Group {
if celsius {
Text(String(Int(round(bleManagerVal.weatherInformation.minTemperature))) + "°" + "C")
} else {
Text(String(Int(round(bleManagerVal.weatherInformation.minTemperature * 1.8 + 32))) + "°" + "F")
}
}
}
.foregroundColor(.gray)
Group {
if celsius {
Text(String(Int(round(bleManagerVal.weatherInformation.temperature))) + "°" + "C")
} else {
Text(String(Int(round(bleManagerVal.weatherInformation.temperature * 1.8 + 32))) + "°" + "F")
.foregroundColor(.gray)
Group {
if celsius {
Text(String(Int(round(bleManagerVal.weatherInformation.temperature))) + "°" + "C")
} else {
Text(String(Int(round(bleManagerVal.weatherInformation.temperature * 1.8 + 32))) + "°" + "F")
}
}
}
.font(.system(size: 35).weight(.semibold))
Group {
if celsius {
Text(String(Int(round(bleManagerVal.weatherInformation.maxTemperature))) + "°" + "C")
} else {
Text(String(Int(round(bleManagerVal.weatherInformation.maxTemperature * 1.8 + 32))) + "°" + "F")
.font(.system(size: 35).weight(.semibold))
Group {
if celsius {
Text(String(Int(round(bleManagerVal.weatherInformation.maxTemperature))) + "°" + "C")
} else {
Text(String(Int(round(bleManagerVal.weatherInformation.maxTemperature * 1.8 + 32))) + "°" + "F")
}
}
.foregroundColor(.gray)
}
.foregroundColor(.gray)
Text(bleManagerVal.weatherInformation.shortDescription)
.foregroundColor(.gray)
.font(.body.weight(.semibold))
}
Text(bleManagerVal.weatherInformation.shortDescription)
.foregroundColor(.gray)
.font(.body.weight(.semibold))
}
.padding(.bottom)
VStack {
Divider()
.padding(.horizontal, -16)
VStack(spacing: 8) {
HStack {
ForEach(bleManagerVal.weatherInformation.forecastIcon, id: \.self) { icon in
Image(systemName: getIcon(icon: Int(icon)))
.frame(maxWidth: .infinity, alignment: .center)
.padding(.bottom)
VStack {
Divider()
.padding(.horizontal, -16)
VStack(spacing: 8) {
HStack {
ForEach(bleManagerVal.weatherInformation.forecastIcon, id: \.self) { icon in
Image(systemName: getIcon(icon: Int(icon)))
.frame(maxWidth: .infinity, alignment: .center)
}
}
}
HStack {
ForEach(bleManagerVal.weatherInformation.forecastMaxTemperature, id: \.self) { temp in
Group {
if celsius {
Text(String(Int(round(temp))) + "°")
} else {
Text(String(Int(round(temp * 1.8 + 32))) + "°")
HStack {
ForEach(bleManagerVal.weatherInformation.forecastMaxTemperature, id: \.self) { temp in
Group {
if celsius {
Text(String(Int(round(temp))) + "°")
} else {
Text(String(Int(round(temp * 1.8 + 32))) + "°")
}
}
.frame(maxWidth: .infinity, alignment: .center)
}
.frame(maxWidth: .infinity, alignment: .center)
}
}
HStack {
ForEach(bleManagerVal.weatherInformation.forecastMinTemperature, id: \.self) { temp in
Group {
if celsius {
Text(String(Int(round(temp))) + "°")
} else {
Text(String(Int(round(temp * 1.8 + 32))) + "°")
HStack {
ForEach(bleManagerVal.weatherInformation.forecastMinTemperature, id: \.self) { temp in
Group {
if celsius {
Text(String(Int(round(temp))) + "°")
} else {
Text(String(Int(round(temp * 1.8 + 32))) + "°")
}
}
.frame(maxWidth: .infinity, alignment: .center)
}
.frame(maxWidth: .infinity, alignment: .center)
}
}
.padding(.vertical)
Divider()
.padding(.horizontal, -16)
}
.padding(.vertical)
Spacer()
Divider()
.padding(.horizontal, -16)
}
Spacer()
Divider()
.padding(.horizontal, -16)
Group {
if !WeatherController.shared.nwsapiFailed {
Text("Data from NWS")
} else if !WeatherController.shared.weatherapiFailed {
Text("Data from WeatherAPI")
Group {
if !WeatherController.shared.nwsapiFailed {
Text("Data from NWS")
} else if !WeatherController.shared.weatherapiFailed {
Text("Data from WeatherAPI")
}
}
.padding(8)
.font(.system(size: 14).weight(.medium))
.foregroundColor(.gray)
}
.padding(8)
.font(.system(size: 14).weight(.medium))
.foregroundColor(.gray)
}
.padding()
}
.onAppear {
// DEBUG
BLEManagerVal.shared.weatherInformation.shortDescription = "Light Rain"
BLEManagerVal.shared.weatherInformation.icon = 4
BLEManagerVal.shared.weatherInformation.temperature = 4
BLEManagerVal.shared.weatherInformation.maxTemperature = 3
BLEManagerVal.shared.weatherInformation.maxTemperature = 5
BLEManagerVal.shared.weatherInformation.forecastIcon = [4, 3, 0, 0, 4, 6, 2]
BLEManagerVal.shared.weatherInformation.forecastMaxTemperature = [35, 31, 39, 42, 53, 41, 37]
BLEManagerVal.shared.weatherInformation.forecastMinTemperature = [25, 22, 31, 32, 45, 36, 28]
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions InfiniLink/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<string>JetBrainsMono-Light.ttf</string>
<string>JetBrainsMono-Regular.ttf</string>
<string>open_sans_light.ttf</string>
<string>BebasNeue-Regular.ttf</string>
<string>Teko-Light.ttf</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
Expand Down
11 changes: 0 additions & 11 deletions InfiniLink/Launch Screen.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,13 @@
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
<rect key="frame" x="0.0" y="832" width="393" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="LaunchScreen" translatesAutoresizingMaskIntoConstraints="NO" id="QKM-0O-nLv">
<rect key="frame" x="-17" y="0.0" width="427" height="852"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" symbolic="YES" id="SfN-ll-jLj"/>
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
1 change: 1 addition & 0 deletions InfiniLink/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,4 @@
"use_current_location" = "Use Current Location";
"set_location" = "Location";
"always_allow_location_services" = "Always Allow Current Location";
"loading_weather" = "Loading Weather...";
1 change: 1 addition & 0 deletions InfiniLink/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,4 @@
"use_current_location" = "Use Current Location";
"set_location" = "Location";
"always_allow_location_services" = "Always Allow Current Location";
"loading_weather" = "Loading Weather...";
1 change: 1 addition & 0 deletions InfiniLink/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,4 @@
"use_current_location" = "Use Current Location";
"set_location" = "Location";
"always_allow_location_services" = "Always Allow Current Location";
"loading_weather" = "Loading Weather...";
Loading

0 comments on commit bdd3be1

Please sign in to comment.