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

This commit is contained in:
Ilya Laktyushin 2022-11-27 21:48:55 +04:00
commit a5455b7e1a
7 changed files with 48 additions and 12 deletions

View File

@ -985,9 +985,18 @@ public final class AvatarBadgeView: UIImageView {
context.setFillColor(UIColor(white: 0.0, alpha: 0.05).cgColor)
context.fillEllipse(in: CGRect(origin: CGPoint(), size: size))*/
let string = NSAttributedString(string: parameters.text, font: Font.bold(floor(parameters.size.height * 0.48)), textColor: .white)
var fontSize: CGFloat = floor(parameters.size.height * 0.48)
while true {
let string = NSAttributedString(string: parameters.text, font: Font.bold(fontSize), textColor: .white)
let stringBounds = string.boundingRect(with: CGSize(width: 100.0, height: 100.0), options: .usesLineFragmentOrigin, context: nil)
if stringBounds.width <= size.width - 5.0 * 2.0 || fontSize <= 2.0 {
string.draw(at: CGPoint(x: stringBounds.minX + floorToScreenPixels((size.width - stringBounds.width) / 2.0), y: stringBounds.minY + floorToScreenPixels((size.height - stringBounds.height) / 2.0)))
break
} else {
fontSize -= 1.0
}
}
let lineWidth: CGFloat = 1.5
let lineInset: CGFloat = 2.0

View File

@ -226,6 +226,7 @@ public func globalAutoremoveScreen(context: AccountContext, initialValue: Int32,
var state = state
state.updatedValue = timeout
if timeout != 0 {
state.additionalValues.removeAll()
state.additionalValues.insert(timeout)
}
return state
@ -321,6 +322,9 @@ public func globalAutoremoveScreen(context: AccountContext, initialValue: Int32,
if user.botInfo == nil {
canManage = true
}
if user.id.isRepliesOrSavedMessages(accountPeerId: context.account.peerId) {
return false
}
} else if case .secretChat = peer {
canManage = true
} else if case let .legacyGroup(group) = peer {
@ -356,6 +360,21 @@ public func globalAutoremoveScreen(context: AccountContext, initialValue: Int32,
let _ = (context.engine.peers.setChatMessageAutoremoveTimeouts(peerIds: peerIds, timeout: value)
|> deliverOnMainQueue).start(completed: {
selectionController?.dismiss()
let isOn: Bool = true
//TODO:localize
let text = "You applied the \(timeIntervalString(strings: presentationData.strings, value: value)) self-destruct timer to \(peerIds.count) \(peerIds.count == 1 ? "chat" : "chats")."
var animateAsReplacement = false
if let window = getController?()?.window {
window.forEachController { other in
if let other = other as? UndoOverlayController {
animateAsReplacement = true
other.dismiss()
}
}
}
presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .autoDelete(isOn: isOn, title: nil, text: text), elevatedLayout: false, animateInAsReplacement: animateAsReplacement, action: { _ in return false }), nil)
})
}
})

View File

@ -1,5 +0,0 @@
<svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.5953 11.5986C4.12087 11.4918 2.82405 10.6403 2.17149 8.85384C1.77098 7.7574 2.07201 6.26373 3.0746 4.37282C3.16459 4.20303 3.68939 4.39974 3.71944 4.44691L4.50543 5.68903C4.55963 5.77404 4.79721 5.69973 4.8111 5.67179C5.03783 5.21551 5.22636 4.6273 5.37671 3.90715C5.52201 3.21113 5.59278 2.56825 5.5953 1.81662C5.59594 1.62274 5.95245 1.32054 6 1.34613C7.14662 1.96317 8.0944 2.72803 8.66171 3.48285C9.63301 4.7752 9.88777 5.77431 9.96174 6.98816C10.1296 8.28857 9.7451 9.42338 8.80824 10.3926C7.87138 11.3618 6.8004 11.7638 5.5953 11.5986Z" fill="#8E8E93"/>
<path d="M3 11L11 3" stroke="white" stroke-width="1.66" stroke-linecap="round"/>
<path d="M2 11L10 3" stroke="#8E8E93" stroke-width="1.33" stroke-linecap="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 879 B

View File

@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "AutoremoveIconOff.svg",
"filename" : "Frame 4.svg",
"idiom" : "universal"
}
],

View File

@ -0,0 +1,4 @@
<svg width="12" height="13" viewBox="0 0 12 13" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.02539 11.1484C4.50657 11.4116 5.03826 11.5582 5.5953 11.5986C6.8004 11.7638 7.87138 11.3618 8.80824 10.3926C9.7451 9.42338 10.1296 8.28857 9.96174 6.98816C9.92908 6.45213 9.86116 5.95798 9.71184 5.46195L4.02539 11.1484ZM2.7871 10.0391C2.54531 9.70246 2.33754 9.30842 2.17149 8.85384C1.77098 7.7574 2.07201 6.26373 3.0746 4.37282C3.16459 4.20303 3.68939 4.39974 3.71944 4.44691L4.50543 5.68903C4.55963 5.77404 4.79721 5.69973 4.8111 5.67179C5.03783 5.21551 5.22636 4.6273 5.37671 3.90715C5.52201 3.21113 5.59278 2.56825 5.5953 1.81662C5.59594 1.62274 5.95245 1.32054 6 1.34613C7.14662 1.96317 8.0944 2.72803 8.66171 3.48285C8.76382 3.61871 8.85801 3.75133 8.9449 3.8813L2.7871 10.0391Z" fill="#8E8E93"/>
<path d="M2 11L10 3" stroke="#8E8E93" stroke-width="1.33" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 941 B

View File

@ -208,7 +208,7 @@ class ChatMessageActionBubbleContentNode: ChatMessageBubbleContentNode {
if let (currentOffset, currentImage, currentRects) = cachedMaskBackgroundImage, currentRects == labelRects {
backgroundMaskImage = (currentOffset, currentImage)
} else {
backgroundMaskImage = LinkHighlightingNode.generateImage(color: .black, inset: 0.0, innerRadius: 10.0, outerRadius: 10.0, rects: labelRects, useModernPathCalculation: false)
backgroundMaskImage = LinkHighlightingNode.generateImage(color: .black, inset: 0.0, innerRadius: 10.0, outerRadius: 10.0, rects: labelRects, useModernPathCalculation: true)
backgroundMaskUpdated = true
}
@ -449,6 +449,7 @@ class ChatMessageActionBubbleContentNode: ChatMessageBubbleContentNode {
} else {
let serviceColor = serviceMessageColorComponents(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper)
linkHighlightingNode = LinkHighlightingNode(color: serviceColor.linkHighlight)
linkHighlightingNode.useModernPathCalculation = true
linkHighlightingNode.inset = 2.5
self.linkHighlightingNode = linkHighlightingNode
self.insertSubnode(linkHighlightingNode, belowSubnode: self.labelNode.textNode)

View File

@ -169,8 +169,10 @@ private final class AccessoryItemIconButtonNode: HighlightTrackingButtonNode {
let previousItem = self.item
self.item = item
let (updatedImage, text, _, _, _) = AccessoryItemIconButtonNode.imageAndInsets(item: item, theme: self.theme, strings: self.strings)
if let image = self.iconImageNode.image {
self.iconImageNode.image = AccessoryItemIconButtonNode.imageAndInsets(item: item, theme: self.theme, strings: self.strings).0
self.iconImageNode.image = updatedImage
let bottomInset: CGFloat = 0.0
let imageFrame = CGRect(origin: CGPoint(x: floor((size.width - image.size.width) / 2.0), y: floor((size.height - image.size.height) / 2.0) - bottomInset), size: image.size)
@ -307,6 +309,12 @@ private final class AccessoryItemIconButtonNode: HighlightTrackingButtonNode {
}
}
}
if let text = text {
self.setAttributedTitle(NSAttributedString(string: text, font: accessoryButtonFont, textColor: self.theme.chat.inputPanel.inputControlColor), for: .normal)
} else {
self.setAttributedTitle(NSAttributedString(), for: .normal)
}
}
var buttonWidth: CGFloat {