mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 20:39:24 +00:00
Update RoomScreen and UserSessionScreen UI tests (#1400)
* room tests * User session screen tests * regenerated keyboard ones * fixing some minor issues * code improvement * fixed the remaining tests * fixed last two
This commit is contained in:
@@ -33,43 +33,30 @@ struct TimelineView: View {
|
||||
|
||||
var body: some View {
|
||||
ScrollViewReader { scrollView in
|
||||
ScrollView {
|
||||
bottomPin
|
||||
|
||||
LazyVStack(spacing: 0) {
|
||||
ForEach(viewState.itemViewStates.reversed()) { viewState in
|
||||
RoomTimelineItemView(viewState: viewState)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(timelineStyle.rowInsets)
|
||||
.scaleEffect(x: 1, y: -1)
|
||||
timelineScrollView
|
||||
.introspect(.scrollView, on: .iOS(.v16)) { uiScrollView in
|
||||
guard uiScrollView != scrollViewAdapter.scrollView else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
topPin
|
||||
}
|
||||
.introspect(.scrollView, on: .iOS(.v16)) { uiScrollView in
|
||||
guard uiScrollView != scrollViewAdapter.scrollView else {
|
||||
return
|
||||
scrollViewAdapter.scrollView = uiScrollView
|
||||
scrollViewAdapter.shouldScrollToTopClosure = { _ in
|
||||
withElementAnimation {
|
||||
scrollView.scrollTo(topID)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Allows the scroll to top to work properly
|
||||
uiScrollView.contentOffset.y -= 1
|
||||
}
|
||||
|
||||
scrollViewAdapter.scrollView = uiScrollView
|
||||
scrollViewAdapter.shouldScrollToTopClosure = { _ in
|
||||
.scaleEffect(x: 1, y: -1)
|
||||
.onReceive(scrollToBottomPublisher) { _ in
|
||||
withElementAnimation {
|
||||
scrollView.scrollTo(topID)
|
||||
scrollView.scrollTo(bottomID)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Allows the scroll to top to work properly
|
||||
uiScrollView.contentOffset.y -= 1
|
||||
}
|
||||
.scaleEffect(x: 1, y: -1)
|
||||
.onReceive(scrollToBottomPublisher) { _ in
|
||||
withElementAnimation {
|
||||
scrollView.scrollTo(bottomID)
|
||||
}
|
||||
}
|
||||
.scrollDismissesKeyboard(.interactively)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
}
|
||||
.overlay(scrollToBottomButton, alignment: .bottomTrailing)
|
||||
.animation(.elementDefault, value: viewState.itemViewStates)
|
||||
@@ -78,16 +65,19 @@ struct TimelineView: View {
|
||||
return
|
||||
}
|
||||
let offset = scrollView.contentOffset.y + scrollView.contentInset.top
|
||||
let scrollToBottomButtonVisibleValue = offset > 0
|
||||
|
||||
// We give it a bit of tollerance which solves the issue when of it being displayed when the keyboard appears
|
||||
let scrollToBottomButtonVisibleValue = offset > 5
|
||||
if scrollToBottomButtonVisibleValue != scrollToBottomButtonVisible {
|
||||
scrollToBottomButtonVisible = scrollToBottomButtonVisibleValue
|
||||
}
|
||||
paginateBackwardsPublisher.send()
|
||||
|
||||
// Allows the scroll to top to work properly
|
||||
if offset == 0 {
|
||||
scrollView.contentOffset.y -= 1
|
||||
}
|
||||
|
||||
paginateBackwardsPublisher.send()
|
||||
}
|
||||
.onReceive(paginateBackwardsPublisher.collect(.byTime(DispatchQueue.main, 0.1))) { _ in
|
||||
paginateBackwardsIfNeeded()
|
||||
@@ -97,6 +87,21 @@ struct TimelineView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var timelineScrollView: some View {
|
||||
ScrollView {
|
||||
bottomPin
|
||||
LazyVStack(spacing: 0) {
|
||||
ForEach(viewState.itemViewStates.reversed()) { viewState in
|
||||
RoomTimelineItemView(viewState: viewState)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(timelineStyle.rowInsets)
|
||||
.scaleEffect(x: 1, y: -1)
|
||||
}
|
||||
}
|
||||
topPin
|
||||
}
|
||||
}
|
||||
|
||||
/// Used to mark the top of the scroll view and easily scroll to it
|
||||
private var topPin: some View {
|
||||
Divider()
|
||||
|
||||
Reference in New Issue
Block a user