Updated circle text helper

This commit is contained in:
Garth Vander Houwen 2022-01-02 10:05:13 -08:00
parent 2925d3e22c
commit 7741d63e0c
4 changed files with 34 additions and 18 deletions

View file

@ -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;

View file

@ -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)
}
}
}

View file

@ -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 {

View file

@ -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)
}
)
})
}