mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Stories
This commit is contained in:
parent
6d7f74ecc3
commit
e8b3615be6
@ -1246,6 +1246,8 @@ public final class ChatListNode: ListView {
|
||||
self.animationRenderer = animationRenderer
|
||||
self.autoSetReady = autoSetReady
|
||||
|
||||
let isMainTab = chatListFilter == nil && location == .chatList(groupId: .root)
|
||||
|
||||
var isSelecting = false
|
||||
if case .peers(_, true, _, _, _, _) = mode {
|
||||
isSelecting = true
|
||||
@ -1933,7 +1935,7 @@ public final class ChatListNode: ListView {
|
||||
notice = nil
|
||||
}
|
||||
|
||||
let (rawEntries, isLoading) = chatListNodeEntriesForView(view: update.list, state: state, savedMessagesPeer: savedMessagesPeer, foundPeers: state.foundPeers, hideArchivedFolderByDefault: hideArchivedFolderByDefault, displayArchiveIntro: displayArchiveIntro, notice: notice, mode: mode, chatListLocation: location, contacts: contacts, accountPeerId: accountPeerId)
|
||||
let (rawEntries, isLoading) = chatListNodeEntriesForView(view: update.list, state: state, savedMessagesPeer: savedMessagesPeer, foundPeers: state.foundPeers, hideArchivedFolderByDefault: hideArchivedFolderByDefault, displayArchiveIntro: displayArchiveIntro, notice: notice, mode: mode, chatListLocation: location, contacts: contacts, accountPeerId: accountPeerId, isMainTab: isMainTab)
|
||||
var isEmpty = true
|
||||
var entries = rawEntries.filter { entry in
|
||||
switch entry {
|
||||
|
@ -568,9 +568,9 @@ struct ChatListContactPeer {
|
||||
}
|
||||
}
|
||||
|
||||
func chatListNodeEntriesForView(view: EngineChatList, state: ChatListNodeState, savedMessagesPeer: EnginePeer?, foundPeers: [(EnginePeer, EnginePeer?)], hideArchivedFolderByDefault: Bool, displayArchiveIntro: Bool, notice: ChatListNotice?, mode: ChatListNodeMode, chatListLocation: ChatListControllerLocation, contacts: [ChatListContactPeer], accountPeerId: EnginePeer.Id) -> (entries: [ChatListNodeEntry], loading: Bool) {
|
||||
func chatListNodeEntriesForView(view: EngineChatList, state: ChatListNodeState, savedMessagesPeer: EnginePeer?, foundPeers: [(EnginePeer, EnginePeer?)], hideArchivedFolderByDefault: Bool, displayArchiveIntro: Bool, notice: ChatListNotice?, mode: ChatListNodeMode, chatListLocation: ChatListControllerLocation, contacts: [ChatListContactPeer], accountPeerId: EnginePeer.Id, isMainTab: Bool) -> (entries: [ChatListNodeEntry], loading: Bool) {
|
||||
var groupItems = view.groupItems
|
||||
if state.archiveStoryState != nil && groupItems.isEmpty {
|
||||
if isMainTab && state.archiveStoryState != nil && groupItems.isEmpty {
|
||||
groupItems.append(EngineChatList.GroupItem(
|
||||
id: .archive,
|
||||
topMessage: nil,
|
||||
|
@ -15,7 +15,7 @@ public extension StoryContainerScreen {
|
||||
|> mapToSignal { state -> Signal<Void, NoError> in
|
||||
if let slice = state.slice {
|
||||
return waitUntilStoryMediaPreloaded(context: context, peerId: slice.peer.id, storyItem: slice.item.storyItem)
|
||||
|> timeout(2.0, queue: .mainQueue(), alternate: .complete())
|
||||
|> timeout(4.0, queue: .mainQueue(), alternate: .complete())
|
||||
|> map { _ -> Void in
|
||||
}
|
||||
|> then(.single(Void()))
|
||||
@ -171,7 +171,7 @@ public extension StoryContainerScreen {
|
||||
|> mapToSignal { state -> Signal<StoryContentContextState, NoError> in
|
||||
if let slice = state.slice {
|
||||
return waitUntilStoryMediaPreloaded(context: context, peerId: slice.peer.id, storyItem: slice.item.storyItem)
|
||||
|> timeout(2.0, queue: .mainQueue(), alternate: .complete())
|
||||
|> timeout(4.0, queue: .mainQueue(), alternate: .complete())
|
||||
|> map { _ -> StoryContentContextState in
|
||||
}
|
||||
|> then(.single(state))
|
||||
|
@ -1022,14 +1022,13 @@ private final class StoryContainerScreenComponent: Component {
|
||||
)
|
||||
}
|
||||
|
||||
self.contentUpdatedDisposable?.dispose()
|
||||
var update = false
|
||||
self.contentUpdatedDisposable = (component.content.updated
|
||||
|> deliverOnMainQueue).start(next: { [weak self] _ in
|
||||
guard let self, let component = self.component else {
|
||||
|
||||
let contentUpdated: (StoryContainerScreenComponent) -> Void = { [weak self] component in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if update {
|
||||
|
||||
var focusedItemId: StoryId?
|
||||
var isVideo = false
|
||||
if let slice = component.content.stateValue?.slice {
|
||||
@ -1039,16 +1038,35 @@ private final class StoryContainerScreenComponent: Component {
|
||||
}
|
||||
}
|
||||
self.focusedItem.set(focusedItemId)
|
||||
|
||||
self.contentWantsVolumeButtonMonitoring.set(isVideo)
|
||||
|
||||
if update {
|
||||
if component.content.stateValue?.slice == nil {
|
||||
self.environment?.controller()?.dismiss()
|
||||
} else {
|
||||
self.state?.updated(transition: .immediate)
|
||||
}
|
||||
} else {
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.state?.updated(transition: .immediate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.contentUpdatedDisposable?.dispose()
|
||||
self.contentUpdatedDisposable = (component.content.updated
|
||||
|> deliverOnMainQueue).start(next: { [weak self] _ in
|
||||
guard let self, let component = self.component else {
|
||||
return
|
||||
}
|
||||
contentUpdated(component)
|
||||
})
|
||||
if component.content.stateValue?.slice != nil {
|
||||
contentUpdated(component)
|
||||
}
|
||||
update = true
|
||||
}
|
||||
|
||||
|
@ -148,12 +148,10 @@ private final class StoryProgressLayer: HierarchyTrackingLayer {
|
||||
|
||||
self.uploadProgressLayer.fillColor = nil
|
||||
self.uploadProgressLayer.strokeColor = UIColor.white.cgColor
|
||||
self.uploadProgressLayer.lineWidth = 2.0
|
||||
self.uploadProgressLayer.lineCap = .round
|
||||
|
||||
self.indefiniteDashLayer.fillColor = nil
|
||||
self.indefiniteDashLayer.strokeColor = UIColor.white.cgColor
|
||||
self.indefiniteDashLayer.lineWidth = 2.0
|
||||
self.indefiniteDashLayer.lineCap = .round
|
||||
self.indefiniteDashLayer.lineJoin = .round
|
||||
self.indefiniteDashLayer.strokeEnd = 0.0333
|
||||
@ -244,7 +242,7 @@ private final class StoryProgressLayer: HierarchyTrackingLayer {
|
||||
}
|
||||
}
|
||||
|
||||
func update(size: CGSize, lineWidth: CGFloat, value: Value, transition: Transition) {
|
||||
func update(size: CGSize, lineWidth: CGFloat, radius: CGFloat, value: Value, transition: Transition) {
|
||||
let params = Params(
|
||||
size: size,
|
||||
lineWidth: lineWidth,
|
||||
@ -255,18 +253,20 @@ private final class StoryProgressLayer: HierarchyTrackingLayer {
|
||||
}
|
||||
self.currentParams = params
|
||||
|
||||
let lineWidth: CGFloat = 2.0
|
||||
self.uploadProgressLayer.lineWidth = lineWidth
|
||||
self.indefiniteDashLayer.lineWidth = lineWidth
|
||||
|
||||
let bounds = CGRect(origin: .zero, size: size)
|
||||
if self.uploadProgressLayer.path == nil {
|
||||
let path = CGMutablePath()
|
||||
path.addEllipse(in: CGRect(origin: CGPoint(x: lineWidth * 0.5, y: lineWidth * 0.5), size: CGSize(width: size.width - lineWidth, height: size.height - lineWidth)))
|
||||
path.addEllipse(in: CGRect(origin: CGPoint(x: (size.width - radius * 2.0) * 0.5, y: (size.height - radius * 2.0) * 0.5), size: CGSize(width: radius * 2.0, height: radius * 2.0)))
|
||||
self.uploadProgressLayer.path = path
|
||||
self.uploadProgressLayer.frame = bounds
|
||||
}
|
||||
|
||||
if self.indefiniteDashLayer.path == nil {
|
||||
let path = CGMutablePath()
|
||||
path.addEllipse(in: CGRect(origin: CGPoint(x: lineWidth * 0.5, y: lineWidth * 0.5), size: CGSize(width: size.width - lineWidth, height: size.height - lineWidth)))
|
||||
path.addEllipse(in: CGRect(origin: CGPoint(x: (size.width - radius * 2.0) * 0.5, y: (size.height - radius * 2.0) * 0.5), size: CGSize(width: radius * 2.0, height: radius * 2.0)))
|
||||
self.indefiniteDashLayer.path = path
|
||||
self.indefiniteReplicatorLayer.frame = bounds
|
||||
self.indefiniteDashLayer.frame = bounds
|
||||
@ -861,9 +861,9 @@ public final class StoryPeerListItemComponent: Component {
|
||||
} else {
|
||||
progressTransition = .easeInOut(duration: 0.3)
|
||||
}
|
||||
progressLayer.update(size: progressFrame.size, lineWidth: indicatorLineUnseenWidth, value: .progress(progress), transition: progressTransition)
|
||||
progressLayer.update(size: progressFrame.size, lineWidth: indicatorLineUnseenWidth, radius: indicatorRadius - indicatorLineUnseenWidth * 0.5, value: .progress(progress), transition: progressTransition)
|
||||
case .loading:
|
||||
progressLayer.update(size: progressFrame.size, lineWidth: indicatorLineUnseenWidth, value: .indefinite, transition: transition)
|
||||
progressLayer.update(size: progressFrame.size, lineWidth: indicatorLineUnseenWidth, radius: indicatorRadius - indicatorLineUnseenWidth * 0.5, value: .indefinite, transition: transition)
|
||||
}
|
||||
self.indicatorShapeSeenLayer.opacity = 0.0
|
||||
self.indicatorShapeUnseenLayer.opacity = 0.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user