Skip to content

Commit

Permalink
more tweaking
Browse files Browse the repository at this point in the history
  • Loading branch information
72A12F4E committed Jul 7, 2024
1 parent 98654f3 commit 1d1bc00
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 52 deletions.
6 changes: 0 additions & 6 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -10793,9 +10793,6 @@
},
"LED State" : {

},
"legacy" : {

},
"Licensed Operator" : {

Expand Down Expand Up @@ -17041,9 +17038,6 @@
},
"Recording route" : {

},
"redesign" : {

},
"Region" : {

Expand Down
125 changes: 101 additions & 24 deletions Meshtastic/Views/Nodes/Helpers/NodeDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,98 @@ struct NodeDetail: View {
}
.padding(.bottom, 2)
}

var modemPreset: ModemPresets = ModemPresets(
rawValue: UserDefaults.modemPreset
) ?? ModemPresets.longFast

var shortNameItem: some View {
CircleText(
text: node.user?.shortName ?? "?",
color: Color(UIColor(hex: UInt32(node.num))),
circleSize: 65
)
}

var hardwareItem: some View {
VStack {
if let user = node.user, user.hwModel != "UNSET" {
Image(user.hwModel ?? "unset".localized)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 75, height: 75)
.cornerRadius(5)
Text(String(user.hwModel ?? "unset".localized))
.font(.caption2)
.frame(maxWidth: 100)
} else {
Image(systemName: "person.crop.circle.badge.questionmark")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 75, height: 75)
.cornerRadius(5)
Text(String("incomplete".localized))
.font(.caption2)
.frame(maxWidth: 100)
}
}
}

var signalItem: some View {
VStack {
let signalStrength = getLoRaSignalStrength(
snr: node.snr,
rssi: node.rssi,
preset: modemPreset
)
LoRaSignalStrengthIndicator(signalStrength: signalStrength)
Text("Signal \(signalStrength.description)").font(.footnote)
Text("SNR \(String(format: "%.2f", node.snr))dB")
.foregroundColor(getSnrColor(snr: node.snr, preset: modemPreset))
.font(.caption2)
Text("RSSI \(node.rssi)dB")
.foregroundColor(getRssiColor(rssi: node.rssi))
.font(.caption2)
}
}

var listHeader: some View {
Grid {
GridRow {
shortNameItem
.padding()
.background(
RoundedRectangle(cornerRadius: 10)
.fill(.background)
)

hardwareItem
.padding()
.background(
RoundedRectangle(cornerRadius: 10)
.fill(.background)
)

if node.snr != 0 && !node.viaMqtt {
signalItem
.padding()
.background(
RoundedRectangle(cornerRadius: 10)
.fill(.background)
)
}

if node.telemetries?.count ?? 0 > 0 {
BatteryGauge(node: node)
.padding()
.background(
RoundedRectangle(cornerRadius: 10)
.fill(.background)
)
}
}
}
}

var redesignedNodeDetail: some View {
List {
Expand All @@ -234,10 +326,6 @@ struct NodeDetail: View {
context: context
)

Section {
NodeInfoItem(node: node)
}

Section {
HStack {
Label {
Expand Down Expand Up @@ -271,14 +359,14 @@ struct NodeDetail: View {
.symbolRenderingMode(.hierarchical)
}
Spacer()

let now = Date.now
let later = now + TimeInterval(dm.uptimeSeconds)
let uptime = (now..<later).formatted(.components(style: .narrow))
Text(uptime)
}
}

if let metadata = node.metadata {
HStack {
Label {
Expand All @@ -288,15 +376,14 @@ struct NodeDetail: View {
.symbolRenderingMode(.multicolor)
}
Spacer()

Text(metadata.firmwareVersion ?? "unknown".localized)
}

if let connectedNode,
connectedNode.myInfo?.hasAdmin ?? false,
let time = metadata.time,
!Calendar.current.isDateInToday(time)
{
!Calendar.current.isDateInToday(time) {
Button {
let adminMessageId = bleManager.requestDeviceMetadata(
fromUser: connectedNode.user!,
Expand All @@ -312,8 +399,10 @@ struct NodeDetail: View {
}
}
}
} header: {
listHeader
}

// TODO: section title
Section {
// Metrics
Expand Down Expand Up @@ -456,19 +545,7 @@ struct NodeDetail: View {

var body: some View {
NavigationStack {
List {
NavigationLink {
redesignedNodeDetail
} label: {
Text("redesign")
}

NavigationLink {
legacyNodeDetail
} label: {
Text("legacy")
}
}
redesignedNodeDetail
}
}
}
24 changes: 2 additions & 22 deletions Meshtastic/Views/Nodes/Helpers/NodeInfoItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,11 @@ struct NodeInfoItem: View {
var body: some View {
HStack {
VStack(alignment: .center) {
CircleText(text: node.user?.shortName ?? "?", color: Color(UIColor(hex: UInt32(node.num))), circleSize: 65)

}
if node.user != nil {
Divider()
VStack(alignment: .center) {
if node.user?.hwModel != "UNSET" {
Image(node.user!.hwModel ?? "unset".localized)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 75, height: 75)
.cornerRadius(5)
Text(String(node.user!.hwModel ?? "unset".localized))
.font(.caption2)
.frame(maxWidth: 100)
} else {
Image(systemName: "person.crop.circle.badge.questionmark")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 65, height: 65)
.cornerRadius(5)
Text(String("incomplete".localized))
.font(.caption)
.frame(maxWidth: 80)
}
}

}
if node.snr != 0 && !node.viaMqtt {
Divider()
Expand Down

0 comments on commit 1d1bc00

Please sign in to comment.