Compare commits

...

1 Commits

Author SHA1 Message Date
fda6c37e22 Fix height of DM input 2023-01-30 11:59:20 -05:00

View File

@@ -63,6 +63,8 @@ struct DMChatView: View {
) )
.padding(16) .padding(16)
.foregroundColor(Color.primary) .foregroundColor(Color.primary)
.frame(minHeight: 70, maxHeight: 150, alignment: .bottom)
.fixedSize(horizontal: false, vertical: true)
} }
@Environment(\.colorScheme) var colorScheme @Environment(\.colorScheme) var colorScheme
@@ -97,22 +99,15 @@ struct DMChatView: View {
} }
} }
} }
} .fixedSize(horizontal: false, vertical: true)
.frame(height: 50 + 20 * CGFloat(text_lines)) .frame(minHeight: 70, maxHeight: 150, alignment: .bottom)
}
var text_lines: Int { Text(message).opacity(0).padding(.all, 8)
var lines = 1 .fixedSize(horizontal: false, vertical: true)
for c in message { .frame(minHeight: 70, maxHeight: 150, alignment: .bottom)
if lines > 4 {
return lines
}
if c.isNewline {
lines += 1
}
} }
.fixedSize(horizontal: false, vertical: true)
return lines .frame(minHeight: 70, maxHeight: 150, alignment: .bottom)
} }
func send_message() { func send_message() {
@@ -142,12 +137,13 @@ struct DMChatView: View {
Footer Footer
} }
Text("Send a message to start the conversation...", comment: "Text prompt for user to send a message to the other user.") Text("Send a message to start the conversation...", comment: "Text prompt for user to send a message to the other user.")
.lineLimit(nil) .lineLimit(nil)
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
.padding(.horizontal, 40) .padding(.horizontal, 40)
.opacity(((dms.events.count == 0) ? 1.0 : 0.0)) .opacity(((dms.events.count == 0) ? 1.0 : 0.0))
.foregroundColor(.gray) .foregroundColor(.gray)
} }
.navigationTitle(NSLocalizedString("DMs", comment: "Navigation title for DMs view, where DM is the English abbreviation for Direct Message.")) .navigationTitle(NSLocalizedString("DMs", comment: "Navigation title for DMs view, where DM is the English abbreviation for Direct Message."))
.toolbar { Header } .toolbar { Header }