mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Update menu
This commit is contained in:
@@ -13,7 +13,8 @@ public protocol ContextControllerActionsStackItemNode: ASDisplayNode {
|
|||||||
func update(
|
func update(
|
||||||
presentationData: PresentationData,
|
presentationData: PresentationData,
|
||||||
constrainedSize: CGSize,
|
constrainedSize: CGSize,
|
||||||
standardWidth: CGFloat,
|
standardMinWidth: CGFloat,
|
||||||
|
standardMaxWidth: CGFloat,
|
||||||
transition: ContainedViewLayoutTransition
|
transition: ContainedViewLayoutTransition
|
||||||
) -> (size: CGSize, apparentHeight: CGFloat)
|
) -> (size: CGSize, apparentHeight: CGFloat)
|
||||||
|
|
||||||
@@ -476,7 +477,8 @@ final class ContextControllerActionsListStackItem: ContextControllerActionsStack
|
|||||||
func update(
|
func update(
|
||||||
presentationData: PresentationData,
|
presentationData: PresentationData,
|
||||||
constrainedSize: CGSize,
|
constrainedSize: CGSize,
|
||||||
standardWidth: CGFloat,
|
standardMinWidth: CGFloat,
|
||||||
|
standardMaxWidth: CGFloat,
|
||||||
transition: ContainedViewLayoutTransition
|
transition: ContainedViewLayoutTransition
|
||||||
) -> (size: CGSize, apparentHeight: CGFloat) {
|
) -> (size: CGSize, apparentHeight: CGFloat) {
|
||||||
var itemNodeLayouts: [(minSize: CGSize, apply: (_ size: CGSize, _ transition: ContainedViewLayoutTransition) -> Void)] = []
|
var itemNodeLayouts: [(minSize: CGSize, apply: (_ size: CGSize, _ transition: ContainedViewLayoutTransition) -> Void)] = []
|
||||||
@@ -486,13 +488,13 @@ final class ContextControllerActionsListStackItem: ContextControllerActionsStack
|
|||||||
|
|
||||||
let itemNodeLayout = item.node.update(
|
let itemNodeLayout = item.node.update(
|
||||||
presentationData: presentationData,
|
presentationData: presentationData,
|
||||||
constrainedSize: CGSize(width: standardWidth, height: constrainedSize.height)
|
constrainedSize: CGSize(width: standardMaxWidth, height: constrainedSize.height)
|
||||||
)
|
)
|
||||||
itemNodeLayouts.append(itemNodeLayout)
|
itemNodeLayouts.append(itemNodeLayout)
|
||||||
combinedSize.width = max(combinedSize.width, itemNodeLayout.minSize.width)
|
combinedSize.width = max(combinedSize.width, itemNodeLayout.minSize.width)
|
||||||
combinedSize.height += itemNodeLayout.minSize.height
|
combinedSize.height += itemNodeLayout.minSize.height
|
||||||
}
|
}
|
||||||
combinedSize.width = max(combinedSize.width, standardWidth)
|
combinedSize.width = max(combinedSize.width, standardMinWidth)
|
||||||
|
|
||||||
var nextItemOrigin = CGPoint()
|
var nextItemOrigin = CGPoint()
|
||||||
for i in 0 ..< self.itemNodes.count {
|
for i in 0 ..< self.itemNodes.count {
|
||||||
@@ -619,7 +621,8 @@ final class ContextControllerActionsCustomStackItem: ContextControllerActionsSta
|
|||||||
func update(
|
func update(
|
||||||
presentationData: PresentationData,
|
presentationData: PresentationData,
|
||||||
constrainedSize: CGSize,
|
constrainedSize: CGSize,
|
||||||
standardWidth: CGFloat,
|
standardMinWidth: CGFloat,
|
||||||
|
standardMaxWidth: CGFloat,
|
||||||
transition: ContainedViewLayoutTransition
|
transition: ContainedViewLayoutTransition
|
||||||
) -> (size: CGSize, apparentHeight: CGFloat) {
|
) -> (size: CGSize, apparentHeight: CGFloat) {
|
||||||
let contentLayout = self.contentNode.update(
|
let contentLayout = self.contentNode.update(
|
||||||
@@ -830,14 +833,16 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
|
|||||||
func update(
|
func update(
|
||||||
presentationData: PresentationData,
|
presentationData: PresentationData,
|
||||||
constrainedSize: CGSize,
|
constrainedSize: CGSize,
|
||||||
standardWidth: CGFloat,
|
standardMinWidth: CGFloat,
|
||||||
|
standardMaxWidth: CGFloat,
|
||||||
transitionFraction: CGFloat,
|
transitionFraction: CGFloat,
|
||||||
transition: ContainedViewLayoutTransition
|
transition: ContainedViewLayoutTransition
|
||||||
) -> (size: CGSize, apparentHeight: CGFloat) {
|
) -> (size: CGSize, apparentHeight: CGFloat) {
|
||||||
let (size, apparentHeight) = self.node.update(
|
let (size, apparentHeight) = self.node.update(
|
||||||
presentationData: presentationData,
|
presentationData: presentationData,
|
||||||
constrainedSize: constrainedSize,
|
constrainedSize: constrainedSize,
|
||||||
standardWidth: standardWidth,
|
standardMinWidth: standardMinWidth,
|
||||||
|
standardMaxWidth: standardMaxWidth,
|
||||||
transition: transition
|
transition: transition
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1076,7 +1081,8 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
|
|||||||
let itemSize = itemContainer.update(
|
let itemSize = itemContainer.update(
|
||||||
presentationData: presentationData,
|
presentationData: presentationData,
|
||||||
constrainedSize: CGSize(width: constrainedSize.width, height: itemConstrainedHeight),
|
constrainedSize: CGSize(width: constrainedSize.width, height: itemConstrainedHeight),
|
||||||
standardWidth: 250.0,
|
standardMinWidth: 220.0,
|
||||||
|
standardMaxWidth: 240.0,
|
||||||
transitionFraction: alphaTransitionFraction,
|
transitionFraction: alphaTransitionFraction,
|
||||||
transition: itemContainerTransition
|
transition: itemContainerTransition
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3542,40 +3542,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
|
|
||||||
var items: [ContextMenuItem] = []
|
var items: [ContextMenuItem] = []
|
||||||
|
|
||||||
var isSoundEnabled = true
|
|
||||||
if let notificationSettings = self.data?.notificationSettings {
|
|
||||||
switch notificationSettings.messageSound {
|
|
||||||
case .none:
|
|
||||||
isSoundEnabled = false
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !isSoundEnabled {
|
|
||||||
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_EnableSound, icon: { theme in
|
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Unmute"), color: theme.contextMenu.primaryColor)
|
|
||||||
}, action: { [weak self] _, f in
|
|
||||||
f(.default)
|
|
||||||
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let _ = strongSelf.context.engine.peers.updatePeerNotificationSoundInteractive(peerId: strongSelf.peerId, sound: .default).start()
|
|
||||||
})))
|
|
||||||
} else {
|
|
||||||
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_DisableSound, icon: { theme in
|
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Muted"), color: theme.contextMenu.primaryColor)
|
|
||||||
}, action: { [weak self] _, f in
|
|
||||||
f(.default)
|
|
||||||
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let _ = strongSelf.context.engine.peers.updatePeerNotificationSoundInteractive(peerId: strongSelf.peerId, sound: .none).start()
|
|
||||||
})))
|
|
||||||
}
|
|
||||||
|
|
||||||
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_MuteFor, icon: { theme in
|
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_MuteFor, icon: { theme in
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Mute2d"), color: theme.contextMenu.primaryColor)
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Mute2d"), color: theme.contextMenu.primaryColor)
|
||||||
}, action: { [weak self] c, _ in
|
}, action: { [weak self] c, _ in
|
||||||
@@ -3622,6 +3588,42 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
c.pushItems(items: .single(ContextController.Items(content: .list(subItems))))
|
c.pushItems(items: .single(ContextController.Items(content: .list(subItems))))
|
||||||
})))
|
})))
|
||||||
|
|
||||||
|
items.append(.separator)
|
||||||
|
|
||||||
|
var isSoundEnabled = true
|
||||||
|
if let notificationSettings = self.data?.notificationSettings {
|
||||||
|
switch notificationSettings.messageSound {
|
||||||
|
case .none:
|
||||||
|
isSoundEnabled = false
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isSoundEnabled {
|
||||||
|
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_EnableSound, icon: { theme in
|
||||||
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Unmute"), color: theme.contextMenu.primaryColor)
|
||||||
|
}, action: { [weak self] _, f in
|
||||||
|
f(.default)
|
||||||
|
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let _ = strongSelf.context.engine.peers.updatePeerNotificationSoundInteractive(peerId: strongSelf.peerId, sound: .default).start()
|
||||||
|
})))
|
||||||
|
} else {
|
||||||
|
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_DisableSound, icon: { theme in
|
||||||
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Muted"), color: theme.contextMenu.primaryColor)
|
||||||
|
}, action: { [weak self] _, f in
|
||||||
|
f(.default)
|
||||||
|
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let _ = strongSelf.context.engine.peers.updatePeerNotificationSoundInteractive(peerId: strongSelf.peerId, sound: .none).start()
|
||||||
|
})))
|
||||||
|
}
|
||||||
|
|
||||||
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_NotificationsCustomize, icon: { theme in
|
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.PeerInfo_NotificationsCustomize, icon: { theme in
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Customize"), color: theme.contextMenu.primaryColor)
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Customize"), color: theme.contextMenu.primaryColor)
|
||||||
}, action: { [weak self] _, f in
|
}, action: { [weak self] _, f in
|
||||||
@@ -3795,8 +3797,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
subItems.append(.separator)
|
subItems.append(.separator)
|
||||||
|
|
||||||
let presetValues: [Int32] = [
|
let presetValues: [Int32] = [
|
||||||
60 * 60,
|
1 * 24 * 60 * 60,
|
||||||
24 * 60 * 60,
|
|
||||||
7 * 24 * 60 * 60,
|
7 * 24 * 60 * 60,
|
||||||
31 * 24 * 60 * 60
|
31 * 24 * 60 * 60
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user