Disable scroll in blocked users & recent sessions screens when there's nothing to show

This commit is contained in:
Ilya Laktyushin 2019-07-11 02:44:16 +02:00
parent 1f84fce32c
commit 01057a495f
4 changed files with 14 additions and 8 deletions

View File

@ -149,6 +149,12 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
public final var rotated = false
public final var experimentalSnapScrollToItem = false
public final var scrollEnabled: Bool = true {
didSet {
self.scroller.isScrollEnabled = self.scrollEnabled
}
}
private final var invisibleInset: CGFloat = 500.0
public var preloadPages: Bool = true {
didSet {

View File

@ -288,7 +288,7 @@ public func blockedPeersController(context: AccountContext, blockedPeersContext:
previousState = blockedPeersState
let controllerState = ItemListControllerState(theme: presentationData.theme, title: .text(presentationData.strings.BlockedUsers_Title), leftNavigationButton: nil, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: true)
let listState = ItemListNodeState(entries: blockedPeersControllerEntries(presentationData: presentationData, state: state, blockedPeersState: blockedPeersState), style: .blocks, emptyStateItem: emptyStateItem, animateChanges: previousStateValue != nil && previousStateValue!.peers.count >= blockedPeersState.peers.count)
let listState = ItemListNodeState(entries: blockedPeersControllerEntries(presentationData: presentationData, state: state, blockedPeersState: blockedPeersState), style: .blocks, emptyStateItem: emptyStateItem, animateChanges: previousStateValue != nil && previousStateValue!.peers.count >= blockedPeersState.peers.count, scrollEnabled: emptyStateItem == nil)
return (controllerState, (listState, arguments))
}

View File

@ -56,7 +56,7 @@ private struct ItemListNodeTransition<Entry: ItemListNodeEntry> {
let animateAlpha: Bool
let crossfade: Bool
let mergedEntries: [Entry]
let userInteractionEnabled: Bool
let scrollEnabled: Bool
}
struct ItemListNodeState<Entry: ItemListNodeEntry> {
@ -66,12 +66,12 @@ struct ItemListNodeState<Entry: ItemListNodeEntry> {
let searchItem: ItemListControllerSearch?
let animateChanges: Bool
let crossfadeState: Bool
let userInteractionEnabled: Bool
let scrollEnabled: Bool
let focusItemTag: ItemListItemTag?
let ensureVisibleItemTag: ItemListItemTag?
let initialScrollToItem: ListViewScrollToItem?
init(entries: [Entry], style: ItemListStyle, focusItemTag: ItemListItemTag? = nil, ensureVisibleItemTag: ItemListItemTag? = nil, emptyStateItem: ItemListControllerEmptyStateItem? = nil, searchItem: ItemListControllerSearch? = nil, initialScrollToItem: ListViewScrollToItem? = nil, crossfadeState: Bool = false, animateChanges: Bool = true, userInteractionEnabled: Bool = true) {
init(entries: [Entry], style: ItemListStyle, focusItemTag: ItemListItemTag? = nil, ensureVisibleItemTag: ItemListItemTag? = nil, emptyStateItem: ItemListControllerEmptyStateItem? = nil, searchItem: ItemListControllerSearch? = nil, initialScrollToItem: ListViewScrollToItem? = nil, crossfadeState: Bool = false, animateChanges: Bool = true, scrollEnabled: Bool = true) {
self.entries = entries
self.style = style
self.emptyStateItem = emptyStateItem
@ -81,7 +81,7 @@ struct ItemListNodeState<Entry: ItemListNodeEntry> {
self.focusItemTag = focusItemTag
self.ensureVisibleItemTag = ensureVisibleItemTag
self.initialScrollToItem = initialScrollToItem
self.userInteractionEnabled = userInteractionEnabled
self.scrollEnabled = scrollEnabled
}
}
@ -275,7 +275,7 @@ class ItemListControllerNode<Entry: ItemListNodeEntry>: ASDisplayNode, UIScrollV
scrollToItem = state.initialScrollToItem
}
return ItemListNodeTransition(theme: theme, entries: transition, updateStyle: updatedStyle, emptyStateItem: state.emptyStateItem, searchItem: state.searchItem, focusItemTag: state.focusItemTag, ensureVisibleItemTag: state.ensureVisibleItemTag, scrollToItem: scrollToItem, firstTime: previous == nil, animated: previous != nil && state.animateChanges, animateAlpha: previous != nil && state.animateChanges, crossfade: state.crossfadeState, mergedEntries: state.entries, userInteractionEnabled: state.userInteractionEnabled)
return ItemListNodeTransition(theme: theme, entries: transition, updateStyle: updatedStyle, emptyStateItem: state.emptyStateItem, searchItem: state.searchItem, focusItemTag: state.focusItemTag, ensureVisibleItemTag: state.ensureVisibleItemTag, scrollToItem: scrollToItem, firstTime: previous == nil, animated: previous != nil && state.animateChanges, animateAlpha: previous != nil && state.animateChanges, crossfade: state.crossfadeState, mergedEntries: state.entries, scrollEnabled: state.scrollEnabled)
}) |> deliverOnMainQueue).start(next: { [weak self] transition in
if let strongSelf = self {
strongSelf.enqueueTransition(transition)
@ -593,7 +593,7 @@ class ItemListControllerNode<Entry: ItemListNodeEntry>: ASDisplayNode, UIScrollV
self.emptyStateNode = nil
}
}
self.listNode.isUserInteractionEnabled = transition.userInteractionEnabled
self.listNode.scrollEnabled = transition.scrollEnabled
if updateSearchItem {
self.requestLayout?(.animated(duration: 0.3, curve: .spring))

View File

@ -634,7 +634,7 @@ public func recentSessionsController(context: AccountContext, activeSessionsCont
}
let controllerState = ItemListControllerState(theme: presentationData.theme, title: title, leftNavigationButton: nil, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: true)
let listState = ItemListNodeState(entries: entries, style: .blocks, emptyStateItem: emptyStateItem, crossfadeState: crossfadeState, animateChanges: animateChanges, userInteractionEnabled: emptyStateItem == nil)
let listState = ItemListNodeState(entries: entries, style: .blocks, emptyStateItem: emptyStateItem, crossfadeState: crossfadeState, animateChanges: animateChanges, scrollEnabled: emptyStateItem == nil)
return (controllerState, (listState, arguments))
} |> afterDisposed {