diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index b9b1d45a9f..5242db897b 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -1967,17 +1967,29 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController self.rawStoryArchiveSubscriptions = rawStoryArchiveSubscriptions - let hasUnseenArchive: Bool? + let archiveStoryState: ChatListNodeState.StoryState? if rawStoryArchiveSubscriptions.items.isEmpty { - hasUnseenArchive = nil + archiveStoryState = nil } else { - hasUnseenArchive = rawStoryArchiveSubscriptions.items.contains(where: { $0.hasUnseen }) + var unseenCount = 0 + for item in rawStoryArchiveSubscriptions.items { + if item.hasUnseen { + unseenCount += 1 + } + } + archiveStoryState = ChatListNodeState.StoryState( + stats: EngineChatList.StoryStats( + totalCount: rawStoryArchiveSubscriptions.items.count, + unseenCount: unseenCount + ), + hasUnseenCloseFriends: rawStoryArchiveSubscriptions.items.contains(where: { $0.hasUnseenCloseFriends }) + ) } self.chatListDisplayNode.mainContainerNode.currentItemNode.updateState { chatListState in var chatListState = chatListState - chatListState.hasUnseenArchiveStories = hasUnseenArchive + chatListState.archiveStoryState = archiveStoryState return chatListState } diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index 1d7337e6c6..834a1d8bbf 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -251,7 +251,7 @@ public struct ChatListNodeState: Equatable { public var foundPeers: [(EnginePeer, EnginePeer?)] public var selectedPeerMap: [EnginePeer.Id: EnginePeer] public var selectedThreadIds: Set - public var hasUnseenArchiveStories: Bool? + public var archiveStoryState: StoryState? public init( presentationData: ChatListPresentationData, @@ -267,7 +267,7 @@ public struct ChatListNodeState: Equatable { hiddenItemShouldBeTemporaryRevealed: Bool, hiddenPsaPeerId: EnginePeer.Id?, selectedThreadIds: Set, - hasUnseenArchiveStories: Bool? + archiveStoryState: StoryState? ) { self.presentationData = presentationData self.editing = editing @@ -282,7 +282,7 @@ public struct ChatListNodeState: Equatable { self.hiddenItemShouldBeTemporaryRevealed = hiddenItemShouldBeTemporaryRevealed self.hiddenPsaPeerId = hiddenPsaPeerId self.selectedThreadIds = selectedThreadIds - self.hasUnseenArchiveStories = hasUnseenArchiveStories + self.archiveStoryState = archiveStoryState } public static func ==(lhs: ChatListNodeState, rhs: ChatListNodeState) -> Bool { @@ -325,7 +325,7 @@ public struct ChatListNodeState: Equatable { if lhs.selectedThreadIds != rhs.selectedThreadIds { return false } - if lhs.hasUnseenArchiveStories != rhs.hasUnseenArchiveStories { + if lhs.archiveStoryState != rhs.archiveStoryState { return false } return true @@ -1251,7 +1251,7 @@ public final class ChatListNode: ListView { isSelecting = true } - self.currentState = ChatListNodeState(presentationData: ChatListPresentationData(theme: theme, fontSize: fontSize, strings: strings, dateTimeFormat: dateTimeFormat, nameSortOrder: nameSortOrder, nameDisplayOrder: nameDisplayOrder, disableAnimations: disableAnimations), editing: isSelecting, peerIdWithRevealedOptions: nil, selectedPeerIds: Set(), foundPeers: [], selectedPeerMap: [:], selectedAdditionalCategoryIds: Set(), peerInputActivities: nil, pendingRemovalItemIds: Set(), pendingClearHistoryPeerIds: Set(), hiddenItemShouldBeTemporaryRevealed: false, hiddenPsaPeerId: nil, selectedThreadIds: Set(), hasUnseenArchiveStories: nil) + self.currentState = ChatListNodeState(presentationData: ChatListPresentationData(theme: theme, fontSize: fontSize, strings: strings, dateTimeFormat: dateTimeFormat, nameSortOrder: nameSortOrder, nameDisplayOrder: nameDisplayOrder, disableAnimations: disableAnimations), editing: isSelecting, peerIdWithRevealedOptions: nil, selectedPeerIds: Set(), foundPeers: [], selectedPeerMap: [:], selectedAdditionalCategoryIds: Set(), peerInputActivities: nil, pendingRemovalItemIds: Set(), pendingClearHistoryPeerIds: Set(), hiddenItemShouldBeTemporaryRevealed: false, hiddenPsaPeerId: nil, selectedThreadIds: Set(), archiveStoryState: nil) self.statePromise = ValuePromise(self.currentState, ignoreRepeated: true) self.theme = theme diff --git a/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift b/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift index 12b7dab724..16140b6b2e 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift @@ -834,13 +834,8 @@ func chatListNodeEntriesForView(view: EngineChatList, state: ChatListNodeState, for groupReference in view.groupItems { let messageIndex = EngineMessage.Index(id: EngineMessage.Id(peerId: EnginePeer.Id(0), namespace: 0, id: 0), timestamp: 1) var mappedStoryState: ChatListNodeState.StoryState? - if let hasUnseenArchiveStories = state.hasUnseenArchiveStories { - mappedStoryState = ChatListNodeState.StoryState( - stats: EngineChatList.StoryStats( - totalCount: 1, unseenCount: hasUnseenArchiveStories ? 1 : 0 - ), - hasUnseenCloseFriends: false - ) + if let archiveStoryState = state.archiveStoryState { + mappedStoryState = archiveStoryState } result.append(.GroupReferenceEntry(ChatListNodeEntry.GroupReferenceEntryData( index: .chatList(EngineChatList.Item.Index.ChatList(pinningIndex: pinningIndex, messageIndex: messageIndex)), diff --git a/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListNavigationBar.swift b/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListNavigationBar.swift index 82925bfecd..c737f53630 100644 --- a/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListNavigationBar.swift +++ b/submodules/TelegramUI/Components/ChatListHeaderComponent/Sources/ChatListNavigationBar.swift @@ -414,6 +414,18 @@ public final class ChatListNavigationBar: Component { self.addSubview(headerContentView) } transition.setFrameWithAdditivePosition(view: headerContentView, frame: headerContentFrame) + + if component.isSearchActive != (headerContentView.alpha == 0.0) { + headerContentView.alpha = component.isSearchActive ? 0.0 : 1.0 + + if !transition.animation.isImmediate { + if component.isSearchActive { + headerContentView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.14) + } else { + headerContentView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3) + } + } + } } if component.tabsNode !== self.tabsNode { diff --git a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift index 51840617ed..059185058a 100644 --- a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListComponent.swift @@ -889,7 +889,7 @@ public final class StoryPeerListComponent: Component { rightItemFrame = calculateItem(i + 1).itemFrame } - itemAlpha = collapsedState.sideAlphaFraction * 1.0 + (1.0 - collapsedState.sideAlphaFraction) * (1.0 - collapsedState.activityFraction) + itemAlpha = (collapsedState.sideAlphaFraction * 1.0 + (1.0 - collapsedState.sideAlphaFraction) * (1.0 - collapsedState.activityFraction)) * collapsedState.sideAlphaFraction } else { if itemLayout.itemCount == 1 { itemAlpha = min(1.0, (collapsedState.minFraction + collapsedState.maxFraction) * 4.0) diff --git a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift index 9b295d53aa..25b1731eab 100644 --- a/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryPeerListComponent/Sources/StoryPeerListItemComponent.swift @@ -62,6 +62,20 @@ private func calculateMergingCircleShape(center: CGPoint, leftCenter: CGPoint?, let path = CGMutablePath() + let segmentCount = max(totalCount, 1) + + if isSeen { + if unseenCount < totalCount { + } else { + return path + } + } else { + if unseenCount != 0 { + } else { + return path + } + } + if let leftAngles, let rightAngles { path.addArc(center: center, radius: radius, startAngle: leftAngles.point1Angle, endAngle: rightAngles.point2Angle, clockwise: true) @@ -70,14 +84,13 @@ private func calculateMergingCircleShape(center: CGPoint, leftCenter: CGPoint?, } else if let angles = leftAngles ?? rightAngles { path.addArc(center: center, radius: radius, startAngle: angles.point1Angle, endAngle: angles.point2Angle, clockwise: true) } else { - let segmentCount = max(totalCount, 1) if segmentCount == 1 { - if unseenCount != 0 { - if !isSeen { + if isSeen { + if unseenCount == 0 { path.addEllipse(in: CGRect(origin: CGPoint(x: center.x - radius, y: center.y - radius), size: CGSize(width: radius * 2.0, height: radius * 2.0))) } } else { - if isSeen { + if unseenCount != 0 { path.addEllipse(in: CGRect(origin: CGPoint(x: center.x - radius, y: center.y - radius), size: CGSize(width: radius * 2.0, height: radius * 2.0))) } } @@ -610,12 +623,12 @@ public final class StoryPeerListItemComponent: Component { transition.setFrame(view: avatarNode.view, frame: CGRect(origin: CGPoint(), size: avatarFrame.size)) transition.setFrame(view: self.avatarBackgroundView, frame: CGRect(origin: CGPoint(), size: avatarFrame.size).insetBy(dx: -3.0 - UIScreenPixel * 2.0, dy: -3.0 - UIScreenPixel * 2.0)) - let indicatorFrame = avatarFrame.insetBy(dx: -6.0, dy: -6.0) + let indicatorFrame = avatarFrame.insetBy(dx: -8.0, dy: -8.0) let baseLineUnseenWidth: CGFloat = 2.0 let baseLineSeenWidth: CGFloat = 1.0 + UIScreenPixel - let minimizedLineWidth: CGFloat = 3.0 + let minimizedLineWidth: CGFloat = 4.3 let indicatorLineSeenWidth: CGFloat = baseLineSeenWidth * component.scale + minimizedLineWidth * (1.0 - component.scale) let indicatorLineUnseenWidth: CGFloat = baseLineUnseenWidth * component.scale + minimizedLineWidth * (1.0 - component.scale) @@ -691,7 +704,7 @@ public final class StoryPeerListItemComponent: Component { self.avatarBackgroundView.isHidden = component.ringAnimation != nil || self.indicatorColorSeenLayer.isHidden let baseRadius: CGFloat = 30.0 - let collapsedRadius: CGFloat = 32.0 + let collapsedRadius: CGFloat = 35.0 let indicatorRadius: CGFloat = baseRadius * component.scale + collapsedRadius * (1.0 - component.scale) self.indicatorShapeSeenLayer.lineWidth = indicatorLineSeenWidth @@ -748,7 +761,7 @@ public final class StoryPeerListItemComponent: Component { let cutoutSize: CGFloat = 18.0 + UIScreenPixel * 2.0 avatarPath.addEllipse(in: CGRect(origin: CGPoint(x: avatarSize.width - cutoutSize + UIScreenPixel, y: avatarSize.height - 1.0 - cutoutSize + UIScreenPixel), size: CGSize(width: cutoutSize, height: cutoutSize))) } else if let mappedLeftCenter { - avatarPath.addEllipse(in: CGRect(origin: CGPoint(), size: avatarSize).insetBy(dx: -indicatorLineSeenWidth, dy: -indicatorLineSeenWidth).offsetBy(dx: -abs(indicatorCenter.x - mappedLeftCenter.x), dy: -abs(indicatorCenter.y - mappedLeftCenter.y))) + avatarPath.addEllipse(in: CGRect(origin: CGPoint(), size: avatarSize).insetBy(dx: -indicatorLineSeenWidth * 1.4, dy: -indicatorLineSeenWidth * 1.4).offsetBy(dx: -abs(indicatorCenter.x - mappedLeftCenter.x), dy: -abs(indicatorCenter.y - mappedLeftCenter.y))) } Transition.immediate.setShapeLayerPath(layer: self.avatarShapeLayer, path: avatarPath)