mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Modernize color changed toast
This commit is contained in:
@@ -127,7 +127,7 @@ private func generateRingImage(nameColor: PeerNameColors.Colors) -> UIImage? {
|
||||
})
|
||||
}
|
||||
|
||||
func generatePeerNameColorImage(nameColor: PeerNameColors.Colors, isDark: Bool, bounds: CGSize = CGSize(width: 40.0, height: 40.0), size: CGSize = CGSize(width: 40.0, height: 40.0)) -> UIImage? {
|
||||
public func generatePeerNameColorImage(nameColor: PeerNameColors.Colors, isDark: Bool, bounds: CGSize = CGSize(width: 40.0, height: 40.0), size: CGSize = CGSize(width: 40.0, height: 40.0)) -> UIImage? {
|
||||
return generateImage(bounds, rotatedContext: { contextSize, context in
|
||||
let bounds = CGRect(origin: CGPoint(), size: contextSize)
|
||||
context.clear(bounds)
|
||||
@@ -179,6 +179,33 @@ func generatePeerNameColorImage(nameColor: PeerNameColors.Colors, isDark: Bool,
|
||||
})
|
||||
}
|
||||
|
||||
public func generateSettingsMenuPeerColorsLabelIcon(colors: [PeerNameColors.Colors]) -> UIImage {
|
||||
let iconWidth: CGFloat = 24.0
|
||||
let iconSpacing: CGFloat = 18.0
|
||||
let borderWidth: CGFloat = 2.0
|
||||
|
||||
return generateImage(CGSize(width: CGFloat(max(0, colors.count - 1)) * iconSpacing + CGFloat(colors.count == 0 ? 0 : 1) * iconWidth, height: 24.0), rotatedContext: { size, context in
|
||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
|
||||
for i in 0 ..< colors.count {
|
||||
let iconFrame = CGRect(origin: CGPoint(x: CGFloat(i) * iconSpacing, y: 0.0), size: CGSize(width: iconWidth, height: iconWidth))
|
||||
context.setBlendMode(.copy)
|
||||
context.setFillColor(UIColor.clear.cgColor)
|
||||
context.fillEllipse(in: iconFrame.insetBy(dx: -borderWidth, dy: -borderWidth))
|
||||
context.setBlendMode(.normal)
|
||||
|
||||
if let image = generatePeerNameColorImage(nameColor: colors[i], isDark: false, bounds: iconFrame.size, size: iconFrame.size)?.cgImage {
|
||||
context.saveGState()
|
||||
context.translateBy(x: iconFrame.midX, y: iconFrame.midY)
|
||||
context.scaleBy(x: 1.0, y: -1.0)
|
||||
context.translateBy(x: -iconFrame.midX, y: -iconFrame.midY)
|
||||
context.draw(image, in: iconFrame)
|
||||
context.restoreGState()
|
||||
}
|
||||
}
|
||||
})!
|
||||
}
|
||||
|
||||
private final class PeerNameColorIconItemNode : ListViewItemNode {
|
||||
private let containerNode: ContextControllerSourceNode
|
||||
private let fillNode: ASImageNode
|
||||
|
||||
@@ -835,7 +835,18 @@ public func PeerNameColorScreen(
|
||||
if let navigationController = controller?.navigationController as? NavigationController {
|
||||
Queue.mainQueue().after(0.25) {
|
||||
if let lastController = navigationController.viewControllers.last as? ViewController {
|
||||
let tipController = UndoOverlayController(presentationData: presentationData, content: .image(image: generatePeerNameColorImage(nameColor: colors, isDark: presentationData.theme.overallDarkAppearance, bounds: CGSize(width: 32.0, height: 32.0), size: CGSize(width: 22.0, height: 22.0))!, title: nil, text: presentationData.strings.NameColor_YourColorUpdated, round: false, undoText: nil), elevatedLayout: false, position: .bottom, animateInAsReplacement: false, action: { _ in return false })
|
||||
var colorList: [PeerNameColors.Colors] = []
|
||||
if let nameColor {
|
||||
colorList.append(context.peerNameColors.get(nameColor, dark: presentationData.theme.overallDarkAppearance))
|
||||
}
|
||||
if let profileColor {
|
||||
colorList.append(context.peerNameColors.getProfile(profileColor, dark: presentationData.theme.overallDarkAppearance, subject: .palette))
|
||||
}
|
||||
|
||||
let colorImage = generateSettingsMenuPeerColorsLabelIcon(colors: colorList)
|
||||
|
||||
//TODO:localize
|
||||
let tipController = UndoOverlayController(presentationData: presentationData, content: .image(image: colorImage, title: nil, text: "Your color has been updated.", round: false, undoText: nil), elevatedLayout: false, position: .bottom, animateInAsReplacement: false, action: { _ in return false })
|
||||
lastController.present(tipController, in: .window(.root))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user