mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix up weather widget
This commit is contained in:
parent
b80b9e65b3
commit
e8d4a70857
3 changed files with 42 additions and 34 deletions
|
|
@ -17,6 +17,7 @@ struct NodeDetail: View {
|
|||
@State private var showingRebootConfirm: Bool = false
|
||||
|
||||
@ObservedObject var node: NodeInfoEntity
|
||||
var columnVisibility = NavigationSplitViewVisibility.all
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
|
@ -146,12 +147,13 @@ struct NodeDetail: View {
|
|||
}
|
||||
.edgesIgnoringSafeArea([.leading, .trailing])
|
||||
.navigationBarTitle(String(node.user?.longName ?? "unknown".localized), displayMode: .inline)
|
||||
.navigationBarItems(trailing:
|
||||
.navigationBarItems(
|
||||
trailing:
|
||||
ZStack {
|
||||
ConnectedDevice(
|
||||
bluetoothOn: bleManager.isSwitchedOn,
|
||||
deviceConnected: bleManager.connectedPeripheral != nil,
|
||||
name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?", phoneOnly: true)
|
||||
ConnectedDevice(
|
||||
bluetoothOn: bleManager.isSwitchedOn,
|
||||
deviceConnected: bleManager.connectedPeripheral != nil,
|
||||
name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?", phoneOnly: true)
|
||||
})
|
||||
}
|
||||
.padding(.bottom, 2)
|
||||
|
|
|
|||
|
|
@ -87,30 +87,31 @@ struct NodeMapControl: View {
|
|||
.pickerStyle(.menu)
|
||||
.padding(5)
|
||||
VStack {
|
||||
Label(temperature?.formatted(.measurement(width: .narrow)) ?? "??", systemImage: symbolName)
|
||||
.font(.caption)
|
||||
VStack {
|
||||
Label(temperature?.formatted(.measurement(width: .narrow)) ?? "??", systemImage: symbolName)
|
||||
.font(.caption)
|
||||
|
||||
Label("\(humidity ?? 0)%", systemImage: "humidity")
|
||||
.font(.caption2)
|
||||
|
||||
Label("\(humidity ?? 0)%", systemImage: "humidity")
|
||||
.font(.caption2)
|
||||
AsyncImage(url: attributionLogo) { image in
|
||||
image
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
} placeholder: {
|
||||
ProgressView()
|
||||
.controlSize(.mini)
|
||||
}
|
||||
.frame(height: 10)
|
||||
|
||||
Link("Other data sources", destination: attributionLink ?? URL(string: "https://weather-data.apple.com/legal-attribution.html")!)
|
||||
.font(.caption2)
|
||||
}
|
||||
.padding(5)
|
||||
|
||||
}
|
||||
.padding(10)
|
||||
.background(.thinMaterial, in: RoundedRectangle(cornerRadius: 12, style: .continuous))
|
||||
.padding(5)
|
||||
VStack {
|
||||
AsyncImage(url: attributionLogo) { image in
|
||||
image
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
} placeholder: {
|
||||
ProgressView()
|
||||
.controlSize(.mini)
|
||||
}
|
||||
.frame(height: 15)
|
||||
|
||||
Link("Other data sources", destination: attributionLink ?? URL(string: "https://weather-data.apple.com/legal-attribution.html")!)
|
||||
}
|
||||
.font(.footnote)
|
||||
.padding(.bottom, 5)
|
||||
.task {
|
||||
do {
|
||||
if node.hasPositions {
|
||||
|
|
|
|||
|
|
@ -21,10 +21,6 @@ struct NodeList: View {
|
|||
|
||||
@State private var columnVisibility = NavigationSplitViewVisibility.all
|
||||
@State private var selectedNode: NodeInfoEntity?
|
||||
@State private var selectedDetail: SelectedDetail?
|
||||
|
||||
@SceneStorage("selectedDetailView") var selectedDetailView: String?
|
||||
|
||||
@State private var searchText = ""
|
||||
var nodesQuery: Binding<String> {
|
||||
Binding {
|
||||
|
|
@ -69,20 +65,29 @@ struct NodeList: View {
|
|||
name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?", phoneOnly: true)
|
||||
})
|
||||
} content: {
|
||||
|
||||
if let node = selectedNode {
|
||||
NodeDetail(node: node)
|
||||
|
||||
NodeDetail(node: node, columnVisibility: columnVisibility)
|
||||
VStack {
|
||||
Button {
|
||||
columnVisibility = .detailOnly
|
||||
} label: {
|
||||
Image(systemName: "rectangle")
|
||||
}
|
||||
}
|
||||
.padding(.bottom, 5)
|
||||
} else {
|
||||
Text("select.node")
|
||||
}
|
||||
|
||||
} detail: {
|
||||
Text("Select something to view")
|
||||
}
|
||||
.navigationSplitViewStyle(.balanced)
|
||||
.onChange(of: selectedNode) { _ in
|
||||
selectedDetail = nil
|
||||
if selectedNode == nil {
|
||||
columnVisibility = .all
|
||||
} else {
|
||||
columnVisibility = .doubleColumn
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
if self.bleManager.context == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue