mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix for scroll view flashing bug when new messages are received
This commit is contained in:
parent
f4c4df8182
commit
afbf626dd1
3 changed files with 18 additions and 24 deletions
|
|
@ -761,7 +761,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements;
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 10;
|
||||
CURRENT_PROJECT_VERSION = 15;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = GCH7VS5Y9R;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
|
@ -793,7 +793,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = MeshtasticClient/MeshtasticClient.entitlements;
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 10;
|
||||
CURRENT_PROJECT_VERSION = 15;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"MeshtasticClient/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = GCH7VS5Y9R;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
|
@ -809,7 +809,6 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "MeshtasticClient/Compression/MeshtasticClient-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ struct Connect: View {
|
|||
var body: some View {
|
||||
|
||||
let firmwareVersion = bleManager.lastConnnectionVersion
|
||||
let minimumVersion = "1.3.12"
|
||||
let minimumVersion = "1.3.15"
|
||||
let supportedVersion = firmwareVersion == "0.0.0" || minimumVersion.compare(firmwareVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(firmwareVersion, options: .numeric) == .orderedSame
|
||||
|
||||
NavigationView {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ struct UserMessageList: View {
|
|||
@State private var replyMessageId: Int64 = 0
|
||||
@State private var sendPositionWithMessage: Bool = false
|
||||
|
||||
@State var messageCount = 0
|
||||
@State private var messageCount = 0
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
|
@ -46,11 +46,7 @@ struct UserMessageList: View {
|
|||
ScrollView {
|
||||
|
||||
if user.messageList.count > 0 {
|
||||
|
||||
HStack{
|
||||
// Padding at the top of the message list
|
||||
}.padding(.bottom)
|
||||
|
||||
|
||||
ForEach( user.messageList ) { (message: MessageEntity) in
|
||||
|
||||
let currentUser: Bool = (bleManager.connectedPeripheral == nil) ? false : ((bleManager.connectedPeripheral != nil && bleManager.connectedPeripheral.num == message.fromUser?.num) ? true : false )
|
||||
|
|
@ -59,7 +55,7 @@ struct UserMessageList: View {
|
|||
|
||||
if message.replyID > 0 {
|
||||
|
||||
let messageReply = allMessages.first(where: { $0.messageId == message.replyID })
|
||||
let messageReply = user.messageList.first(where: { $0.messageId == message.replyID })
|
||||
|
||||
HStack {
|
||||
|
||||
|
|
@ -297,12 +293,13 @@ struct UserMessageList: View {
|
|||
|
||||
}
|
||||
.padding(.bottom)
|
||||
.id(allMessages.firstIndex(of: message))
|
||||
.id(user.messageList.firstIndex(of: message))
|
||||
|
||||
if !currentUser {
|
||||
Spacer(minLength:50)
|
||||
}
|
||||
}
|
||||
.id(message.messageId)
|
||||
.padding([.leading, .trailing])
|
||||
.frame(maxWidth: .infinity)
|
||||
.alert(isPresented: $showDeleteMessageAlert) {
|
||||
|
|
@ -311,7 +308,7 @@ struct UserMessageList: View {
|
|||
print("OK button tapped")
|
||||
if deleteMessageId > 0 {
|
||||
|
||||
let message = allMessages.first(where: { $0.messageId == deleteMessageId })
|
||||
let message = user.messageList.first(where: { $0.messageId == deleteMessageId })
|
||||
|
||||
context.delete(message!)
|
||||
do {
|
||||
|
|
@ -336,19 +333,17 @@ struct UserMessageList: View {
|
|||
|
||||
self.bleManager.context = context
|
||||
self.bleManager.userSettings = userSettings
|
||||
|
||||
if allMessages.count > 1 {
|
||||
|
||||
scrollView.scrollTo(allMessages.firstIndex(of: allMessages.last! ), anchor: .bottom)
|
||||
}
|
||||
|
||||
messageCount = user.messageList.count
|
||||
|
||||
})
|
||||
.onChange(of: allMessages.count, perform: { count in
|
||||
.onChange(of: messageCount, perform: { value in
|
||||
//scrollView.scrollTo(user.messageList.firstIndex(of: user.messageList.last! ), anchor: .bottom)
|
||||
scrollView.scrollTo(user.messageList.last!.messageId)
|
||||
})
|
||||
.onChange(of: user.messageList, perform: { messages in
|
||||
|
||||
if count > 1 {
|
||||
|
||||
scrollView.scrollTo(allMessages.firstIndex(of: allMessages.last! ), anchor: .bottom)
|
||||
|
||||
}
|
||||
messageCount = messages.count
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue