From df02b41fddd7d3138332dc65016ae32054d115cc Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 17 Nov 2022 22:49:27 -0800 Subject: [PATCH] Tighten up contacts view --- Meshtastic/Views/Bluetooth/Connect.swift | 2 - Meshtastic/Views/Messages/Contacts.swift | 114 ++++++++++++----------- 2 files changed, 62 insertions(+), 54 deletions(-) diff --git a/Meshtastic/Views/Bluetooth/Connect.swift b/Meshtastic/Views/Bluetooth/Connect.swift index 92c813d0..7582759d 100644 --- a/Meshtastic/Views/Bluetooth/Connect.swift +++ b/Meshtastic/Views/Bluetooth/Connect.swift @@ -29,9 +29,7 @@ struct Connect: View { List { if bleManager.isSwitchedOn { Section(header: Text("Connected Radio").font(.title)) { - if bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.peripheral.state == .connected { - HStack { Image(systemName: "antenna.radiowaves.left.and.right") .symbolRenderingMode(.hierarchical) diff --git a/Meshtastic/Views/Messages/Contacts.swift b/Meshtastic/Views/Messages/Contacts.swift index d85ac897..1e2bfed3 100644 --- a/Meshtastic/Views/Messages/Contacts.swift +++ b/Meshtastic/Views/Messages/Contacts.swift @@ -45,40 +45,45 @@ struct Contacts: View { CircleText(text: String(channel.index), color: .gray, circleSize: 52, fontSize: 40) .padding(.trailing, 5) VStack { - Text(String(channel.name ?? "Channel \(channel.index)").camelCaseToWords()).font(.headline) - } - .frame(maxWidth: .infinity, alignment: .leading) - - if channel.allPrivateMessages.count > 0 { - VStack (alignment: .trailing) { - if lastMessageDay == currentDay { - Text(lastMessageTime, style: .time ) - .font(.callout) - } else if lastMessageDay == (currentDay - 1) { - Text("Yesterday") - .font(.callout) - } else if lastMessageDay < (currentDay - 1) && lastMessageDay > (currentDay - 5) { - Text(lastMessageTime.formattedDate(format: "MM/dd/yy")) - .font(.callout) - } else if lastMessageDay < (currentDay - 1800) { - Text(lastMessageTime.formattedDate(format: "MM/dd/yy")) - .font(.callout) + HStack { + Text(String(channel.name ?? "Channel \(channel.index)").camelCaseToWords()).font(.headline) + Spacer() + if channel.allPrivateMessages.count > 0 { + VStack (alignment: .trailing) { + if lastMessageDay == currentDay { + Text(lastMessageTime, style: .time ) + .font(.subheadline) + } else if lastMessageDay == (currentDay - 1) { + Text("Yesterday") + .font(.subheadline) + } else if lastMessageDay < (currentDay - 1) && lastMessageDay > (currentDay - 5) { + Text(lastMessageTime.formattedDate(format: "MM/dd/yy")) + .font(.subheadline) + } else if lastMessageDay < (currentDay - 1800) { + Text(lastMessageTime.formattedDate(format: "MM/dd/yy")) + .font(.subheadline) + } + } + .brightness(-0.20) + } + } + if channel.allPrivateMessages.count > 0 { + HStack(alignment: .top) { + Text("\(mostRecent != nil ? mostRecent!.messagePayload! : " ")") + .truncationMode(.tail) + .frame(maxWidth: .infinity, alignment: .leading) + .brightness(-0.20) + .font(.body) } } } - } - if channel.allPrivateMessages.count > 0 { - HStack(alignment: .top) { - Text("\(mostRecent != nil ? mostRecent!.messagePayload! : " ")") - .truncationMode(.tail) - .frame(maxWidth: .infinity, alignment: .leading) - } + .frame(maxWidth: .infinity, alignment: .leading) } } } } } - .frame(maxWidth: .infinity, alignment: .leading) + .frame(maxWidth: .infinity, maxHeight: 80, alignment: .leading) } } .padding(.top, 10) @@ -94,39 +99,44 @@ struct Contacts: View { let lastMessageDay = Calendar.current.dateComponents([.day], from: lastMessageTime).day ?? 0 let currentDay = Calendar.current.dateComponents([.day], from: Date()).day ?? 0 HStack { - VStack(alignment: .leading) { + VStack { HStack { CircleText(text: user.shortName ?? "???", color: .gray, circleSize: 52, fontSize: 16) .padding(.trailing, 5) VStack { - Text(user.longName ?? "Unknown").font(.headline) - } - .frame(maxWidth: .infinity, alignment: .leading) - - if user.messageList.count > 0 { - VStack (alignment: .trailing) { - if lastMessageDay == currentDay { - Text(lastMessageTime, style: .time ) - .font(.callout) - } else if lastMessageDay == (currentDay - 1) { - Text("Yesterday") - .font(.callout) - } else if lastMessageDay < (currentDay - 1) && lastMessageDay > (currentDay - 5) { - Text(lastMessageTime.formattedDate(format: "MM/dd/yy")) - .font(.callout) - } else if lastMessageDay < (currentDay - 1800) { - Text(lastMessageTime.formattedDate(format: "MM/dd/yy")) - .font(.callout) + HStack { + Text(user.longName ?? "Unknown").font(.headline) + Spacer() + if user.messageList.count > 0 { + VStack (alignment: .trailing) { + if lastMessageDay == currentDay { + Text(lastMessageTime, style: .time ) + .font(.subheadline) + } else if lastMessageDay == (currentDay - 1) { + Text("Yesterday") + .font(.subheadline) + } else if lastMessageDay < (currentDay - 1) && lastMessageDay > (currentDay - 5) { + Text(lastMessageTime.formattedDate(format: "MM/dd/yy")) + .font(.subheadline) + } else if lastMessageDay < (currentDay - 1800) { + Text(lastMessageTime.formattedDate(format: "MM/dd/yy")) + .font(.subheadline) + } + } + .brightness(-0.2) + } + } + if user.messageList.count > 0 { + HStack(alignment: .top) { + Text("\(mostRecent != nil ? mostRecent!.messagePayload! : " ")") + .truncationMode(.tail) + .font(.body) + .frame(maxWidth: .infinity, alignment: .leading) + .brightness(-0.2) } } } - } - if user.messageList.count > 0 { - HStack(alignment: .top) { - Text("\(mostRecent != nil ? mostRecent!.messagePayload! : " ")") - .truncationMode(.tail) - .frame(maxWidth: .infinity, alignment: .leading) - } + .frame(maxWidth: .infinity, maxHeight: 80, alignment: .leading) } } }