Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin 2024-07-16 16:44:15 +04:00
commit 914c9934fd
2 changed files with 54 additions and 6 deletions

View File

@ -10792,8 +10792,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
return
}
let _ = pane
var items: [ContextMenuItem] = []
let strings = self.presentationData.strings
@ -10831,14 +10829,16 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
items.append(.action(ContextMenuActionItem(text: "Select", icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Select"), color: theme.contextMenu.primaryColor)
}, action: { [weak self] _, a in
}, action: { [weak pane] _, a in
if ignoreNextActions {
return
}
ignoreNextActions = true
a(.default)
let _ = self
if let pane {
pane.setIsSelectionModeActive(true)
}
})))
let contextController = ContextController(presentationData: self.presentationData, source: .reference(PeerInfoContextReferenceContentSource(controller: controller, sourceNode: source)), items: .single(ContextController.Items(content: .list(items))), gesture: gesture)

View File

@ -3132,7 +3132,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
parentController.cancelItemSelection()
}
let _ = self.context.engine.messages.deleteBotPreviews(peerId: peerId, ids: mappedItemIds)
let _ = self.context.engine.messages.deleteBotPreviews(peerId: peerId, ids: mappedItemIds).startStandalone()
})
]),
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, action: { dismissAction() })])
@ -3459,6 +3459,52 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr
}
))
let selectionPanelSize = selectionPanel.update(
transition: selectionPanelTransition,
component: AnyComponent(BottomActionsPanelComponent(
theme: presentationData.theme,
insets: UIEdgeInsets(top: 0.0, left: sideInset, bottom: bottomInset, right: sideInset),
items: selectionItems
)),
environment: {},
containerSize: size
)
let selectionPanelFrame = CGRect(origin: CGPoint(x: 0.0, y: size.height - selectionPanelSize.height), size: selectionPanelSize)
if let selectionPanelView = selectionPanel.view {
if selectionPanelView.superview == nil {
self.view.addSubview(selectionPanelView)
transition.animatePositionAdditive(layer: selectionPanelView.layer, offset: CGPoint(x: 0.0, y: selectionPanelFrame.height))
}
selectionPanelTransition.setFrame(view: selectionPanelView, frame: selectionPanelFrame)
}
bottomInset = selectionPanelSize.height
} else if self.isProfileEmbedded, let selectedIds = self.itemInteraction.selectedIds, self.canManageStories, case .botPreview = self.scope {
let selectionPanel: ComponentView<Empty>
var selectionPanelTransition = ComponentTransition(transition)
if let current = self.selectionPanel {
selectionPanel = current
} else {
selectionPanelTransition = selectionPanelTransition.withAnimation(.none)
selectionPanel = ComponentView()
self.selectionPanel = selectionPanel
}
var selectionItems: [BottomActionsPanelComponent.Item] = []
selectionItems.append(BottomActionsPanelComponent.Item(
id: "delete",
color: .destructive,
title: presentationData.strings.StoryList_ActionPanel_Delete,
isEnabled: !selectedIds.isEmpty,
action: { [weak self] in
guard let self, let selectedIds = self.itemInteraction.selectedIds else {
return
}
self.presentDeleteConfirmation(ids: selectedIds)
}
))
let selectionPanelSize = selectionPanel.update(
transition: selectionPanelTransition,
component: AnyComponent(BottomActionsPanelComponent(
@ -4054,7 +4100,9 @@ private final class BottomActionsPanelComponent: Component {
let itemCenterX: CGFloat = CGFloat(i) * (floor((availableSize.width - sideInset * 2.0) / CGFloat(itemsAndSizes.count - 1)))
let itemX: CGFloat
if i == 0 {
if itemsAndSizes.count == 1 {
itemX = floor((availableSize.width - itemSize.width) * 0.5)
} else if i == 0 {
itemX = sideInset
} else if i == itemsAndSizes.count - 1 {
itemX = availableSize.width - sideInset - itemSize.width