mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Create & Join rooms UI/UX tweaks (#1005)
* Fix people icon size * Disable dismiss when loading in StartChatScreen * Reduce debounce on search * Add padding to invite button * Add show/hide bottom bar behaviour * Fix bg color in StartChatScreen form * Update localisations * Update search users results to 10 * Fix form background in InviteUsersScreen * Fix invites list bg color * Add mxid in InvitesScreenCell * Refactor InvitesScreenCell design * Fix separator spacing * Add more design fixes * Refine InvitesScreenCell layout * Refactor UserProfileCell design * Refactor FormRowAccessory * Update localisations * Fix camera size and security section padding * Change create button style * Refine InviteUsersScreenSelectedItem * Refine CreateRoomScreen * Refine UserProfileCell padding * Amend preview name * delete test code * Add separator in security section * Fix spacing in InviteUsersScreenSelectedItem * Revert confirmationAction in CreateRoomScreen * Refine HomeScreenInvitesButton * Add dismiss keyboard in InviteUsersScreen * Refactor FormRowAccessory * Remove isDisabled from FormButtonStyles * Update localisations * Cleanup RoomDetailsEditScreen * UI fixes on horizontal user carousel * Refactor InviteUsersScreenSelectedItem * Try fix flaky tests * Fix typo * Update snapshot tests * Fix flaky UTs * Fix HomeScreen ui tests * Fix scroll on selection * Refactor RoomFlowCoordinatorTests
This commit is contained in:
@@ -18,6 +18,11 @@ import Combine
|
||||
import UIKit
|
||||
|
||||
class ScrollViewAdapter: NSObject, UIScrollViewDelegate {
|
||||
enum ScrollDirection {
|
||||
case up
|
||||
case down
|
||||
}
|
||||
|
||||
var scrollView: UIScrollView? {
|
||||
didSet {
|
||||
oldValue?.delegate = nil
|
||||
@@ -25,13 +30,28 @@ class ScrollViewAdapter: NSObject, UIScrollViewDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
let didScroll = PassthroughSubject<Void, Never>()
|
||||
let isScrolling = CurrentValueSubject<Bool, Never>(false)
|
||||
private let didScrollSubject = PassthroughSubject<Void, Never>()
|
||||
var didScroll: AnyPublisher<Void, Never> {
|
||||
didScrollSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
private let isScrollingSubject = CurrentValueSubject<Bool, Never>(false)
|
||||
var isScrolling: CurrentValuePublisher<Bool, Never> {
|
||||
.init(isScrollingSubject)
|
||||
}
|
||||
|
||||
private let scrollDirectionSubject: PassthroughSubject<ScrollDirection, Never> = .init()
|
||||
var scrollDirection: AnyPublisher<ScrollDirection, Never> {
|
||||
scrollDirectionSubject
|
||||
.removeDuplicates()
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
// MARK: - UIScrollViewDelegate
|
||||
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
didScroll.send(())
|
||||
didScrollSubject.send(())
|
||||
updateScrollDirection(scrollView)
|
||||
}
|
||||
|
||||
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||
@@ -57,6 +77,20 @@ class ScrollViewAdapter: NSObject, UIScrollViewDelegate {
|
||||
// MARK: - Private
|
||||
|
||||
private func updateDidScroll(_ scrollView: UIScrollView) {
|
||||
isScrolling.send(scrollView.isDragging || scrollView.isDecelerating)
|
||||
isScrollingSubject.send(scrollView.isDragging || scrollView.isDecelerating)
|
||||
}
|
||||
|
||||
private func updateScrollDirection(_ scrollView: UIScrollView) {
|
||||
let velocity = scrollView.panGestureRecognizer.velocity(in: nil)
|
||||
|
||||
if velocity.y > Constant.scrollDirectionThreshold {
|
||||
scrollDirectionSubject.send(.down)
|
||||
} else if velocity.y < -Constant.scrollDirectionThreshold {
|
||||
scrollDirectionSubject.send(.up)
|
||||
}
|
||||
}
|
||||
|
||||
private enum Constant {
|
||||
static let scrollDirectionThreshold: CGFloat = 200
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user