mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
bc8dbdbcb9
commit
87b14b171f
@ -684,6 +684,7 @@ private final class MonthComponent: CombinedComponent {
|
||||
let strings: PresentationStrings
|
||||
let theme: PresentationTheme
|
||||
let dayAction: (Int32) -> Void
|
||||
let monthAction: (ClosedRange<Int32>) -> Void
|
||||
let selectedDays: ClosedRange<Int32>?
|
||||
|
||||
init(
|
||||
@ -693,6 +694,7 @@ private final class MonthComponent: CombinedComponent {
|
||||
strings: PresentationStrings,
|
||||
theme: PresentationTheme,
|
||||
dayAction: @escaping (Int32) -> Void,
|
||||
monthAction: @escaping (ClosedRange<Int32>) -> Void,
|
||||
selectedDays: ClosedRange<Int32>?
|
||||
) {
|
||||
self.context = context
|
||||
@ -701,6 +703,7 @@ private final class MonthComponent: CombinedComponent {
|
||||
self.strings = strings
|
||||
self.theme = theme
|
||||
self.dayAction = dayAction
|
||||
self.monthAction = monthAction
|
||||
self.selectedDays = selectedDays
|
||||
}
|
||||
|
||||
@ -808,7 +811,9 @@ private final class MonthComponent: CombinedComponent {
|
||||
selection: daySelection,
|
||||
isSelecting: context.component.selectedDays != nil,
|
||||
action: {
|
||||
dayAction(dayTimestamp)
|
||||
if isEnabled {
|
||||
dayAction(dayTimestamp)
|
||||
}
|
||||
}
|
||||
)),
|
||||
environment: {
|
||||
@ -821,8 +826,15 @@ private final class MonthComponent: CombinedComponent {
|
||||
|
||||
let titleFrame = CGRect(origin: CGPoint(x: floor((context.availableSize.width - title.size.width) / 2.0), y: 0.0), size: title.size)
|
||||
|
||||
let monthAction = context.component.monthAction
|
||||
let firstDayStart = Int32(context.component.model.firstDay.timeIntervalSince1970)
|
||||
let lastDayStart = firstDayStart + 24 * 60 * 60 * Int32(context.component.model.numberOfDays)
|
||||
|
||||
context.add(title
|
||||
.position(CGPoint(x: titleFrame.midX, y: titleFrame.midY))
|
||||
.gesture(.tap {
|
||||
monthAction(firstDayStart ... lastDayStart)
|
||||
})
|
||||
)
|
||||
|
||||
let baseWeekdayTitleY = titleFrame.maxY + titleWeekdaysSpacing
|
||||
@ -918,7 +930,7 @@ private final class MonthComponent: CombinedComponent {
|
||||
completion()
|
||||
return
|
||||
}
|
||||
view.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { _ in
|
||||
view.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { _ in
|
||||
completion()
|
||||
})
|
||||
})
|
||||
@ -1622,6 +1634,8 @@ public final class CalendarMessageScreen: ViewController {
|
||||
theme: self.presentationData.theme,
|
||||
dayAction: { _ in
|
||||
},
|
||||
monthAction: { _ in
|
||||
},
|
||||
selectedDays: nil
|
||||
)),
|
||||
environment: {
|
||||
@ -1738,6 +1752,30 @@ public final class CalendarMessageScreen: ViewController {
|
||||
}
|
||||
}
|
||||
},
|
||||
monthAction: { [weak self] range in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
guard var selectionState = strongSelf.selectionState else {
|
||||
return
|
||||
}
|
||||
var transition = Transition(animation: .curve(duration: 0.2, curve: .spring))
|
||||
if let dayRange = selectionState.dayRange {
|
||||
if dayRange == range {
|
||||
selectionState.dayRange = nil
|
||||
transition = transition.withUserData(SelectionTransition.end)
|
||||
} else {
|
||||
selectionState.dayRange = range
|
||||
transition = transition.withUserData(SelectionTransition.change)
|
||||
}
|
||||
} else {
|
||||
selectionState.dayRange = range
|
||||
transition = transition.withUserData(SelectionTransition.begin)
|
||||
}
|
||||
strongSelf.selectionState = selectionState
|
||||
|
||||
strongSelf.updateSelectionState(transition: transition)
|
||||
},
|
||||
selectedDays: self.selectionState?.dayRange
|
||||
)),
|
||||
environment: {
|
||||
|
@ -1,12 +1,12 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
final class Button: CombinedComponent, Equatable {
|
||||
let content: AnyComponent<Empty>
|
||||
let insets: UIEdgeInsets
|
||||
let action: () -> Void
|
||||
public final class Button: CombinedComponent, Equatable {
|
||||
public let content: AnyComponent<Empty>
|
||||
public let insets: UIEdgeInsets
|
||||
public let action: () -> Void
|
||||
|
||||
init(
|
||||
public init(
|
||||
content: AnyComponent<Empty>,
|
||||
insets: UIEdgeInsets,
|
||||
action: @escaping () -> Void
|
||||
@ -16,7 +16,7 @@ final class Button: CombinedComponent, Equatable {
|
||||
self.action = action
|
||||
}
|
||||
|
||||
static func ==(lhs: Button, rhs: Button) -> Bool {
|
||||
public static func ==(lhs: Button, rhs: Button) -> Bool {
|
||||
if lhs.content != rhs.content {
|
||||
return false
|
||||
}
|
||||
@ -26,7 +26,7 @@ final class Button: CombinedComponent, Equatable {
|
||||
return true
|
||||
}
|
||||
|
||||
final class State: ComponentState {
|
||||
public final class State: ComponentState {
|
||||
var isHighlighted = false
|
||||
|
||||
override init() {
|
||||
@ -34,11 +34,11 @@ final class Button: CombinedComponent, Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
func makeState() -> State {
|
||||
public func makeState() -> State {
|
||||
return State()
|
||||
}
|
||||
|
||||
static var body: Body {
|
||||
public static var body: Body {
|
||||
let content = Child(environment: Empty.self)
|
||||
|
||||
return { context in
|
||||
|
@ -82,7 +82,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
|
||||
let backgroundNode: WallpaperBackgroundNode
|
||||
let historyNode: ChatHistoryListNode
|
||||
let historyScrollingArea: SparseDiscreteScrollingArea
|
||||
//let historyScrollingArea: SparseDiscreteScrollingArea
|
||||
var blurredHistoryNode: ASImageNode?
|
||||
let historyNodeContainer: ASDisplayNode
|
||||
let loadingNode: ChatLoadingNode
|
||||
@ -334,12 +334,12 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
})
|
||||
self.historyNode.rotated = true
|
||||
|
||||
self.historyScrollingArea = SparseDiscreteScrollingArea()
|
||||
self.historyNode.historyScrollingArea = self.historyScrollingArea
|
||||
//self.historyScrollingArea = SparseDiscreteScrollingArea()
|
||||
//self.historyNode.historyScrollingArea = self.historyScrollingArea
|
||||
|
||||
self.historyNodeContainer = ASDisplayNode()
|
||||
self.historyNodeContainer.addSubnode(self.historyNode)
|
||||
self.historyNodeContainer.addSubnode(self.historyScrollingArea)
|
||||
//self.historyNodeContainer.addSubnode(self.historyScrollingArea)
|
||||
|
||||
var getContentAreaInScreenSpaceImpl: (() -> CGRect)?
|
||||
var onTransitionEventImpl: ((ContainedViewLayoutTransition) -> Void)?
|
||||
@ -453,7 +453,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
}
|
||||
})
|
||||
|
||||
/*var backgroundColors: [UInt32] = []
|
||||
var backgroundColors: [UInt32] = []
|
||||
switch chatPresentationInterfaceState.chatWallpaper {
|
||||
case let .file(file):
|
||||
if file.isPattern {
|
||||
@ -476,8 +476,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
} else {
|
||||
self.historyNode.verticalScrollIndicatorColor = UIColor(white: 0.5, alpha: 0.8)
|
||||
}
|
||||
self.historyNode.enableExtractedBackgrounds = true*/
|
||||
self.historyNode.verticalScrollIndicatorColor = .clear
|
||||
self.historyNode.enableExtractedBackgrounds = true
|
||||
//self.historyNode.verticalScrollIndicatorColor = .clear
|
||||
|
||||
self.addSubnode(self.backgroundNode)
|
||||
self.addSubnode(self.historyNodeContainer)
|
||||
@ -1058,7 +1058,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
transition.updateFrame(node: blurredHistoryNode, frame: contentBounds)
|
||||
}
|
||||
|
||||
transition.updateFrame(node: self.historyScrollingArea, frame: contentBounds)
|
||||
//transition.updateFrame(node: self.historyScrollingArea, frame: contentBounds)
|
||||
|
||||
transition.updateFrame(node: self.loadingNode, frame: contentBounds)
|
||||
|
||||
|
@ -813,7 +813,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
||||
return true
|
||||
})
|
||||
|> mapToSignal { location, ignoreMessagesInTimestampRange in
|
||||
return chatHistoryViewForLocation(location, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, context: context, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, scheduled: isScheduledMessages, fixedCombinedReadStates: fixedCombinedReadStates.with { $0 }, tagMask: tagMask, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, additionalData: additionalData, orderStatistics: [.combinedLocation])
|
||||
return chatHistoryViewForLocation(location, ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, context: context, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, scheduled: isScheduledMessages, fixedCombinedReadStates: fixedCombinedReadStates.with { $0 }, tagMask: tagMask, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, additionalData: additionalData, orderStatistics: [])
|
||||
|> beforeNext { viewUpdate in
|
||||
switch viewUpdate {
|
||||
case let .HistoryView(view, _, _, _, _, _, _):
|
||||
|
Loading…
x
Reference in New Issue
Block a user