diff --git a/Meshtastic Client.xcodeproj/project.pbxproj b/Meshtastic Client.xcodeproj/project.pbxproj index ddfb97c7..bc566a69 100644 --- a/Meshtastic Client.xcodeproj/project.pbxproj +++ b/Meshtastic Client.xcodeproj/project.pbxproj @@ -718,7 +718,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; @@ -746,7 +746,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 4; DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\""; DEVELOPMENT_TEAM = GCH7VS5Y9R; ENABLE_PREVIEWS = YES; diff --git a/MeshtasticClient/Views/Helpers/CircleText.swift b/MeshtasticClient/Views/Helpers/CircleText.swift index de7c8548..021a0f02 100644 --- a/MeshtasticClient/Views/Helpers/CircleText.swift +++ b/MeshtasticClient/Views/Helpers/CircleText.swift @@ -8,14 +8,19 @@ import SwiftUI struct CircleText: View { var text: String var color: Color + var circleSize: CGFloat? = 40 + var fontSize: CGFloat? = 16 var body: some View { + + let font = Font.system(size: fontSize!) + ZStack { Circle() .fill(color) - .frame(width: 36, height: 36) - Text(text).textCase(.uppercase).font(.caption2).foregroundColor(.white) - .frame(width: 36, height: 36, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/).offset(x: 0, y: 0) + .frame(width: circleSize, height: circleSize) + Text(text).textCase(.uppercase).font(font).foregroundColor(.white) + .frame(width: circleSize, height: circleSize, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/).offset(x: 0, y: 0) } } } diff --git a/MeshtasticClient/Views/Messages/Contacts.swift b/MeshtasticClient/Views/Messages/Contacts.swift index 76932659..2081819f 100644 --- a/MeshtasticClient/Views/Messages/Contacts.swift +++ b/MeshtasticClient/Views/Messages/Contacts.swift @@ -28,7 +28,7 @@ struct Contacts: View { let allMessages = user.value(forKey: "allMessages") as! [MessageEntity] - NavigationLink(destination: UserMessageList(user: user).environment(\.managedObjectContext, self.context)) { + NavigationLink(destination: UserMessageList(user: user)) { if allMessages.count > 0 { diff --git a/MeshtasticClient/Views/Messages/UserMessageList.swift b/MeshtasticClient/Views/Messages/UserMessageList.swift index 0542d931..24da3a26 100644 --- a/MeshtasticClient/Views/Messages/UserMessageList.swift +++ b/MeshtasticClient/Views/Messages/UserMessageList.swift @@ -144,6 +144,17 @@ struct UserMessageList: View { } } + +// VStack (alignment: .trailing) { +// +// HStack { +// let image = "❤️".image(fontSize: 26) +// Image(uiImage: image!).font(.caption) +// CircleText(text: "AKA", color: .blue, circleSize: 28, fontSize: 11) +// } +// .padding(0) +// } + HStack(spacing: 4) { let time = Int32(message.messageTimestamp) @@ -158,11 +169,13 @@ struct UserMessageList: View { } .padding(.bottom, 10) } + .id(allMessages.firstIndex(of: message)) + if !currentUser { Spacer(minLength:50) } } - .padding(.trailing) + .padding([.leading, .trailing]) .frame(maxWidth: .infinity) .alert(isPresented: $showDeleteMessageAlert) { Alert(title: Text("Are you sure you want to delete this message?"), message: Text("This action is permanent."), @@ -189,30 +202,28 @@ struct UserMessageList: View { } } .listRowSeparator(.hidden) + } } .onAppear(perform: { self.bleManager.context = context + messageCount = ((user.sentMessages?.count ?? 0) + (user.receivedMessages?.count ?? 0)) if messageCount > 0 { - - //scrollView.scrollTo(allMessages[allMessages.count-1].id, anchor: .bottom) - //scrollView.scrollTo(allMessages[allMessages.endIndex - 1]) - //scrollView.scrollTo((allMessages[messageCount-1] as AnyObject).id, anchor: .bottom) - + scrollView.scrollTo(allMessages.firstIndex(of: allMessages.last! ), anchor: .bottom) } }) .onChange(of: user, perform: { newValue in - messageCount = ((user.sentMessages?.count ?? 0) + (user.receivedMessages?.count ?? 0)) - if messageCount > 0 { - - //scrollView.scrollTo((allMessages[messageCount-1] as AnyObject).id, anchor: .bottom) - } + messageCount = ((user.sentMessages?.count ?? 0) + (user.receivedMessages?.count ?? 0)) + + if messageCount > 0 { + + scrollView.scrollTo(allMessages.firstIndex(of: allMessages.last! ), anchor: .bottom) } - ) + }) }