wip
This commit is contained in:
parent
c0ae9c8c4c
commit
58b69e7aa2
|
@ -29,7 +29,7 @@ struct ConversationMessageRow: View {
|
||||||
.background(Color.clearTappable)
|
.background(Color.clearTappable)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.gesture(
|
.gesture(
|
||||||
DragGesture(minimumDistance: 20, coordinateSpace: .local)
|
DragGesture(minimumDistance: 30, coordinateSpace: .local)
|
||||||
.onChanged { value in
|
.onChanged { value in
|
||||||
var width = value.translation.width
|
var width = value.translation.width
|
||||||
width = width > 0 ? 0 : width
|
width = width > 0 ? 0 : width
|
||||||
|
|
|
@ -7,6 +7,7 @@ struct ConversationScreen: View {
|
||||||
@EnvironmentObject var store: AppStore
|
@EnvironmentObject var store: AppStore
|
||||||
|
|
||||||
@State private var autoScroll = true
|
@State private var autoScroll = true
|
||||||
|
@State private var firstIsVisible = true
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
|
@ -29,11 +30,13 @@ struct ConversationScreen: View {
|
||||||
.id(message.id)
|
.id(message.id)
|
||||||
.onAppear {
|
.onAppear {
|
||||||
if message.id == messages.first?.id {
|
if message.id == messages.first?.id {
|
||||||
|
firstIsVisible = true
|
||||||
autoScroll = true
|
autoScroll = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
if message.id == messages.first?.id {
|
if message.id == messages.first?.id {
|
||||||
|
firstIsVisible = false
|
||||||
autoScroll = false
|
autoScroll = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +49,7 @@ struct ConversationScreen: View {
|
||||||
.scrollDismissesKeyboard(.immediately)
|
.scrollDismissesKeyboard(.immediately)
|
||||||
.scrollIndicators(.hidden)
|
.scrollIndicators(.hidden)
|
||||||
.onChange(of: autoScroll) { new in
|
.onChange(of: autoScroll) { new in
|
||||||
if new {
|
if new, !firstIsVisible {
|
||||||
withAnimation {
|
withAnimation {
|
||||||
proxy.scrollTo(messages.first?.id, anchor: .top)
|
proxy.scrollTo(messages.first?.id, anchor: .top)
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ struct ConversationTextInput: View {
|
||||||
private var composedMessage: String {
|
private var composedMessage: String {
|
||||||
var result = ""
|
var result = ""
|
||||||
if !replyText.isEmpty {
|
if !replyText.isEmpty {
|
||||||
result += replyText + "\n"
|
result += replyText + "\n\n"
|
||||||
}
|
}
|
||||||
result += messageStr
|
result += messageStr
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in a new issue