Skip to content

Commit 0ac2bfb

Browse files
committed
- Made some changes to the side menu: The side menu is now wider and accommodates text size and zoom settings for accessibility on smaller screens. The "status" section was made redundant by the button above it, so it has been removed.
- Added dimming effect to main screen when side menu opens. - Added "rename" button over device name that does the same thing as the rename options in the settings menu.
1 parent f0a8e93 commit 0ac2bfb

9 files changed

Lines changed: 126 additions & 110 deletions

File tree

Infini-iOS.xcodeproj/project.pbxproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
26A40E912707C7A3007966F6 /* BLEDiscoveredCharacteristics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A40E902707C7A3007966F6 /* BLEDiscoveredCharacteristics.swift */; };
5353
26A40E932707D119007966F6 /* BLEUpdateHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A40E922707D119007966F6 /* BLEUpdateHandler.swift */; };
5454
26A40E952708C7F8007966F6 /* ScanningPopover.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A40E942708C7F8007966F6 /* ScanningPopover.swift */; };
55+
26A40EE8270A1F97007966F6 /* RenameDeviceHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A40EE7270A1F97007966F6 /* RenameDeviceHeader.swift */; };
5556
26A6314D26BEFD2C005AE404 /* MusicController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A6314C26BEFD2C005AE404 /* MusicController.swift */; };
5657
26A6315526C0297A005AE404 /* BLEWriteManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A6315426C0297A005AE404 /* BLEWriteManager.swift */; };
5758
26A6315B26C49841005AE404 /* DFU.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26A6315A26C49841005AE404 /* DFU.swift */; };
@@ -141,6 +142,7 @@
141142
26A40E902707C7A3007966F6 /* BLEDiscoveredCharacteristics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BLEDiscoveredCharacteristics.swift; sourceTree = "<group>"; };
142143
26A40E922707D119007966F6 /* BLEUpdateHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BLEUpdateHandler.swift; sourceTree = "<group>"; };
143144
26A40E942708C7F8007966F6 /* ScanningPopover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanningPopover.swift; sourceTree = "<group>"; };
145+
26A40EE7270A1F97007966F6 /* RenameDeviceHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RenameDeviceHeader.swift; sourceTree = "<group>"; };
144146
26A6314C26BEFD2C005AE404 /* MusicController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicController.swift; sourceTree = "<group>"; };
145147
26A6315426C0297A005AE404 /* BLEWriteManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BLEWriteManager.swift; sourceTree = "<group>"; };
146148
26A6315A26C49841005AE404 /* DFU.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DFU.swift; sourceTree = "<group>"; };
@@ -305,7 +307,7 @@
305307
isa = PBXGroup;
306308
children = (
307309
2632388B26F265B100D72B43 /* MainView.swift */,
308-
266F53E526FA7676007481A6 /* HomeScreen.swift */,
310+
26A40EE6270A1F78007966F6 /* Home View */,
309311
264DB80A26C62ED600E812C3 /* SideMenu.swift */,
310312
26F426EE26C72D7D00D0866B /* ChartView.swift */,
311313
26D7816F26CA004B00BBF555 /* SettingsView.swift */,
@@ -347,6 +349,15 @@
347349
path = "Debug View";
348350
sourceTree = "<group>";
349351
};
352+
26A40EE6270A1F78007966F6 /* Home View */ = {
353+
isa = PBXGroup;
354+
children = (
355+
266F53E526FA7676007481A6 /* HomeScreen.swift */,
356+
26A40EE7270A1F97007966F6 /* RenameDeviceHeader.swift */,
357+
);
358+
path = "Home View";
359+
sourceTree = "<group>";
360+
};
350361
26A6314E26BF0FA2005AE404 /* Music */ = {
351362
isa = PBXGroup;
352363
children = (
@@ -606,6 +617,7 @@
606617
26C5FAD526FBB76100921207 /* DeviceNameManager.swift in Sources */,
607618
26A6315B26C49841005AE404 /* DFU.swift in Sources */,
608619
26D7817A26CAD19F00BBF555 /* ColorPalette.swift in Sources */,
620+
26A40EE8270A1F97007966F6 /* RenameDeviceHeader.swift in Sources */,
609621
266F53EA26FA91F3007481A6 /* DeviceInfo.swift in Sources */,
610622
);
611623
runOnlyForDeploymentPostprocessing = 0;

Infini-iOS/ContentView.swift

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,19 @@ struct ContentView: View {
6868
.onChange(of: bleManager.batteryLevel) { bat in
6969
batteryNotifications.notify(bat: Int(bat), bleManager: bleManager)
7070
}
71-
.offset(x: pageSwitcher.showMenu ? geometry.size.width/2 : 0)
71+
//.offset(x: pageSwitcher.showMenu ? geometry.size.width * 0.6 : 0)
7272
.disabled(pageSwitcher.showMenu ? true : false)
7373
.overlay(Group {
7474
// this overlay lets you tap on the main screen to close the side menu. swiftUI requires a view that is not Color.clear and has any opacity level > 0 for tap interactions
7575
if pageSwitcher.showMenu {
76-
Color.white
77-
.opacity(pageSwitcher.showMenu ? 0.01 : 0)
76+
Color.black
77+
.opacity(pageSwitcher.showMenu ? 0.3 : 0)
7878
.onTapGesture {
7979
withAnimation {
8080
pageSwitcher.showMenu = false
8181
}
8282
}
83+
.ignoresSafeArea()
8384
}
8485
})
8586
// alert to handle errors thrown by SetTime
@@ -97,11 +98,21 @@ struct ContentView: View {
9798
})
9899
}
99100
if pageSwitcher.showMenu {
100-
SideMenu(isOpen: $pageSwitcher.showMenu)
101-
.frame(width: geometry.size.width/2)
102-
.transition(.move(edge: .leading))
103-
.ignoresSafeArea()
104-
.zIndex(10)
101+
if #available(iOS 15.0, *) {
102+
SideMenu(isOpen: $pageSwitcher.showMenu)
103+
.dynamicTypeSize(.large ... .accessibility5)
104+
.frame(width: geometry.size.width * 0.6)
105+
.transition(.move(edge: .leading))
106+
.ignoresSafeArea()
107+
.zIndex(10)
108+
} else {
109+
SideMenu(isOpen: $pageSwitcher.showMenu)
110+
.frame(width: geometry.size.width * 0.6)
111+
.minimumScaleFactor(1.5)
112+
.transition(.move(edge: .leading))
113+
.ignoresSafeArea()
114+
.zIndex(10)
115+
}
105116
}
106117
}
107118
.navigationBarItems(leading: (

Infini-iOS/View Components/DFU View/DFUWithBLE.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct DFUWithBLE: View {
4747
Section(header: Text("Current Firmware")) {
4848
Text(deviceInfo.firmware)
4949
}
50-
Section(header: ClearHeader()) {
50+
Section(header: ClearSelectedFirmwareHeader()) {
5151
if dfuUpdater.firmwareSelected {
5252
Text(dfuUpdater.firmwareFilename)
5353
} else {
@@ -93,7 +93,7 @@ struct DFUWithBLE: View {
9393
}
9494
}
9595

96-
struct ClearHeader: View {
96+
struct ClearSelectedFirmwareHeader: View {
9797
@ObservedObject var dfuUpdater = DFU_Updater.shared
9898
var body: some View {
9999
HStack{

Infini-iOS/View Components/HomeScreen.swift renamed to Infini-iOS/View Components/Home View/HomeScreen.swift

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ struct HomeScreen: View {
2323
@State var currentUptime: TimeInterval!
2424
@State var updateAvailable: Bool = false
2525

26+
@State var renamingDevice: Bool = false
27+
@State private var changedName: String = ""
28+
private var nameManager = DeviceNameManager()
29+
@State private var deviceName = ""
30+
2631
private var dateFormatter = DateComponentsFormatter()
2732

2833
var body: some View {
@@ -32,8 +37,17 @@ struct HomeScreen: View {
3237
.padding()
3338
.frame(maxWidth: .infinity, alignment: .leading)
3439
List{
35-
Section(header: Text("Device Name")) {
36-
Text(deviceInfo.deviceName)
40+
Section(header: RenameDeviceHeader(renamingDevice: $renamingDevice)) {
41+
if renamingDevice {
42+
TextField(deviceName, text: $changedName, onCommit: {
43+
_ = nameManager.updateName(deviceUUID: bleManager.infiniTime.identifier.uuidString, name: changedName)
44+
})
45+
.onAppear() {
46+
deviceName = String(DeviceNameManager().getName(deviceUUID: bleManager.infiniTime.identifier.uuidString).isEmpty ? "InfiniTime" : DeviceNameManager().getName(deviceUUID: bleManager.infiniTime.identifier.uuidString))
47+
}
48+
} else {
49+
Text(deviceInfo.deviceName)
50+
}
3751
}
3852
Section(header: Text("Device Information")) {
3953
if !bleManager.isConnectedToPinetime {
@@ -55,7 +69,7 @@ struct HomeScreen: View {
5569
Text("Last disconnect: ")
5670
} else {
5771
Text("Last disconnect: " + uptimeManager.dateFormatter.string(from: uptimeManager.lastDisconnect))
58-
72+
5973
}
6074
if currentUptime == nil {
6175
Text("Uptime: ")
@@ -99,32 +113,32 @@ struct HomeScreen: View {
99113

100114
// leaving this section here in case of negative feedback on removing the button.
101115

102-
// Spacer()
103-
// Button(action: {
104-
// // if pinetime is connected, button says disconnect, and disconnects on press
105-
// if bleManager.isConnectedToPinetime {
106-
// self.bleManager.disconnect()
107-
// } else {
108-
// // show connect sheet if pinetime is not connected and autoconnect is disabled,
109-
// // OR if pinetime is not connected and autoconnect is enabled, BUT there's no UUID saved for autoconnect
110-
// if !autoconnect || (autoconnect && autoconnectUUID.isEmpty) {
111-
// SheetManager.shared.showSheet = true
112-
// } else {
113-
// // if autoconnect is on and no pinetime is connected, start the scan which will autoconnect if that PT advertises
114-
// bleManager.startScanning()
115-
// }
116-
// }
117-
// }) {
118-
// Text(bleManager.isConnectedToPinetime ? "Disconnect from PineTime" : (bleManager.isScanning ? "Scanning" : "Connect to PineTime"))
119-
// .padding()
120-
// .padding(.vertical, 7)
121-
// .frame(maxWidth: .infinity, alignment: .center)
122-
// .background(colorScheme == .dark ? Color.darkGray : Color.blue)
123-
// .foregroundColor(Color.white)
124-
// .cornerRadius(10)
125-
// .padding(.horizontal, 20)
126-
// .padding(.bottom)
127-
// }.disabled(bleManager.isScanning && autoconnect) // this button should be disabled and read "Scanning" if autoconnect is enabled and a scan is started. Any other condition when not connected should show the sheet and cover the button
116+
// Spacer()
117+
// Button(action: {
118+
// // if pinetime is connected, button says disconnect, and disconnects on press
119+
// if bleManager.isConnectedToPinetime {
120+
// self.bleManager.disconnect()
121+
// } else {
122+
// // show connect sheet if pinetime is not connected and autoconnect is disabled,
123+
// // OR if pinetime is not connected and autoconnect is enabled, BUT there's no UUID saved for autoconnect
124+
// if !autoconnect || (autoconnect && autoconnectUUID.isEmpty) {
125+
// SheetManager.shared.showSheet = true
126+
// } else {
127+
// // if autoconnect is on and no pinetime is connected, start the scan which will autoconnect if that PT advertises
128+
// bleManager.startScanning()
129+
// }
130+
// }
131+
// }) {
132+
// Text(bleManager.isConnectedToPinetime ? "Disconnect from PineTime" : (bleManager.isScanning ? "Scanning" : "Connect to PineTime"))
133+
// .padding()
134+
// .padding(.vertical, 7)
135+
// .frame(maxWidth: .infinity, alignment: .center)
136+
// .background(colorScheme == .dark ? Color.darkGray : Color.blue)
137+
// .foregroundColor(Color.white)
138+
// .cornerRadius(10)
139+
// .padding(.horizontal, 20)
140+
// .padding(.bottom)
141+
// }.disabled(bleManager.isScanning && autoconnect) // this button should be disabled and read "Scanning" if autoconnect is enabled and a scan is started. Any other condition when not connected should show the sheet and cover the button
128142
}
129143
}
130144
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// RenameDeviceHeader.swift
3+
// Infini-iOS
4+
//
5+
// Created by Alex Emry on 10/3/21.
6+
//
7+
//
8+
9+
10+
import SwiftUI
11+
12+
struct RenameDeviceHeader: View {
13+
@ObservedObject var bleManager = BLEManager.shared
14+
@Binding var renamingDevice: Bool
15+
16+
var body: some View {
17+
HStack{
18+
Text("Device Name")
19+
Spacer()
20+
Button{
21+
renamingDevice = true
22+
} label: {
23+
Image(systemName: "square.and.pencil")
24+
Text("Rename")
25+
}
26+
.disabled(!bleManager.isConnectedToPinetime)
27+
}
28+
}
29+
}

Infini-iOS/View Components/MainView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct MainView: View {
3737
.zIndex(20)
3838
.transition(.move(edge: .bottom))
3939
.animation(.spring())
40+
.padding(.bottom, 20)
4041
}
4142
}
4243

Infini-iOS/View Components/ScanningPopover.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ struct ScanningPopover: View {
1919
VStack {
2020
Spacer()
2121
if bleManager.isConnectedToPinetime {
22-
Text("Connected to \(DeviceNameManager().getName(deviceUUID: bleManager.infiniTime.identifier.uuidString))")
22+
Text("Connected to \(DeviceNameManager().getName(deviceUUID: bleManager.infiniTime.identifier.uuidString).isEmpty ? "InfiniTime" : DeviceNameManager().getName(deviceUUID: bleManager.infiniTime.identifier.uuidString))")
2323
.padding()
24-
// .padding(.vertical, 7)
2524
.frame(maxWidth: .infinity, alignment: .center)
2625
.background(colorScheme == .dark ? Color.darkGray : Color.lightGray)
2726
.foregroundColor(Color.white)
@@ -37,7 +36,6 @@ struct ScanningPopover: View {
3736
} else if bleManager.isScanning {
3837
Text("Scanning")
3938
.padding()
40-
// .padding(.vertical, 7)
4139
.frame(maxWidth: .infinity, alignment: .center)
4240
.background(colorScheme == .dark ? Color.darkGray : Color.lightGray)
4341
.foregroundColor(Color.white)

0 commit comments

Comments
 (0)