Detail only button on node details view

This commit is contained in:
Garth Vander Houwen 2023-09-10 18:00:33 -07:00
parent e8d4a70857
commit b613d0427e
2 changed files with 28 additions and 26 deletions

View file

@ -22,7 +22,7 @@ struct NodeDetail: View {
var body: some View {
let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral?.num ?? -1, context: context)
NavigationStack {
// NavigationStack {
GeometryReader { bounds in
VStack {
ScrollView {
@ -145,18 +145,8 @@ struct NodeDetail: View {
self.bleManager.context = context
}
}
.edgesIgnoringSafeArea([.leading, .trailing])
.navigationBarTitle(String(node.user?.longName ?? "unknown".localized), displayMode: .inline)
.navigationBarItems(
trailing:
ZStack {
ConnectedDevice(
bluetoothOn: bleManager.isSwitchedOn,
deviceConnected: bleManager.connectedPeripheral != nil,
name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?", phoneOnly: true)
})
}
.padding(.bottom, 2)
}
// }
}
}

View file

@ -66,13 +66,25 @@ struct NodeList: View {
})
} content: {
if let node = selectedNode {
NodeDetail(node: node, columnVisibility: columnVisibility)
VStack {
Button {
columnVisibility = .detailOnly
} label: {
Image(systemName: "rectangle")
}
NavigationStack {
NodeDetail(node: node, columnVisibility: columnVisibility)
.edgesIgnoringSafeArea([.leading, .trailing])
.navigationBarTitle(String(node.user?.longName ?? "unknown".localized), displayMode: .inline)
.navigationBarItems(
trailing:
ZStack {
if (UIDevice.current.userInterfaceIdiom != .phone) {
Button {
columnVisibility = .detailOnly
} label: {
Image(systemName: "rectangle")
}
}
ConnectedDevice(
bluetoothOn: bleManager.isSwitchedOn,
deviceConnected: bleManager.connectedPeripheral != nil,
name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?", phoneOnly: true)
})
}
.padding(.bottom, 5)
} else {
@ -82,13 +94,13 @@ struct NodeList: View {
Text("Select something to view")
}
.navigationSplitViewStyle(.balanced)
.onChange(of: selectedNode) { _ in
if selectedNode == nil {
columnVisibility = .all
} else {
columnVisibility = .doubleColumn
}
}
// .onChange(of: selectedNode) { _ in
// if selectedNode == nil {
// columnVisibility = .all
// } else {
// columnVisibility = .doubleColumn
// }
// }
.onAppear {
if self.bleManager.context == nil {
self.bleManager.context = context