mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix wallpapers
This commit is contained in:
parent
0ad74c49b7
commit
f71b103013
@ -239,10 +239,17 @@ final class ThemeGridController: ViewController {
|
|||||||
strongSelf.present(controller, in: .window(.root))
|
strongSelf.present(controller, in: .window(.root))
|
||||||
|
|
||||||
let _ = resetWallpapers(account: strongSelf.context.account).start(completed: { [weak self, weak controller] in
|
let _ = resetWallpapers(account: strongSelf.context.account).start(completed: { [weak self, weak controller] in
|
||||||
let presentationData = strongSelf.presentationData
|
|
||||||
let _ = updatePresentationThemeSettingsInteractively(accountManager: strongSelf.context.sharedContext.accountManager, { current in
|
let _ = updatePresentationThemeSettingsInteractively(accountManager: strongSelf.context.sharedContext.accountManager, { current in
|
||||||
return current.withUpdatedThemeSpecificChatWallpapers([:])
|
return current.withUpdatedThemeSpecificChatWallpapers([:])
|
||||||
}).start()
|
}).start()
|
||||||
|
|
||||||
|
let _ = (strongSelf.context.sharedContext.accountManager.transaction { transaction in
|
||||||
|
WallpapersState.update(transaction: transaction, { state in
|
||||||
|
var state = state
|
||||||
|
state.wallpapers.removeAll()
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
}).start()
|
||||||
|
|
||||||
let _ = (telegramWallpapers(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network)
|
let _ = (telegramWallpapers(postbox: strongSelf.context.account.postbox, network: strongSelf.context.account.network)
|
||||||
|> deliverOnMainQueue).start(completed: { [weak self, weak controller] in
|
|> deliverOnMainQueue).start(completed: { [weak self, weak controller] in
|
||||||
|
@ -363,20 +363,6 @@ final class ThemeGridControllerNode: ASDisplayNode {
|
|||||||
index += 1
|
index += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !entries.contains(where: { entry in
|
|
||||||
if case .gradient(defaultBuiltinWallpaperGradientColors.map(\.rgb), _) = entry.wallpaper {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}) {
|
|
||||||
let entry = ThemeGridControllerEntry(index: 1, wallpaper: .gradient(defaultBuiltinWallpaperGradientColors.map(\.rgb), WallpaperSettings()), isEditable: false, isSelected: false)
|
|
||||||
if !entries.contains(where: { $0.stableId == entry.stableId }) {
|
|
||||||
entries.insert(entry, at: index)
|
|
||||||
index += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var sortedWallpapers: [TelegramWallpaper] = []
|
var sortedWallpapers: [TelegramWallpaper] = []
|
||||||
if presentationData.theme.overallDarkAppearance {
|
if presentationData.theme.overallDarkAppearance {
|
||||||
|
@ -573,6 +573,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
if case let .file(_, patternColors, rotation, intensity, _, _) = wallpaper.content {
|
if case let .file(_, patternColors, rotation, intensity, _, _) = wallpaper.content {
|
||||||
var colors: [UIColor] = []
|
var colors: [UIColor] = []
|
||||||
var customPatternColor: UIColor? = nil
|
var customPatternColor: UIColor? = nil
|
||||||
|
var bakePatternAlpha: CGFloat = 1.0
|
||||||
if let intensity = intensity, intensity < 0 {
|
if let intensity = intensity, intensity < 0 {
|
||||||
if patternColors.isEmpty {
|
if patternColors.isEmpty {
|
||||||
colors.append(UIColor(rgb: 0xd6e2ee, alpha: 0.5))
|
colors.append(UIColor(rgb: 0xd6e2ee, alpha: 0.5))
|
||||||
@ -588,8 +589,9 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
}
|
}
|
||||||
let isLight = UIColor.average(of: patternColors.map(UIColor.init(rgb:))).hsb.b > 0.3
|
let isLight = UIColor.average(of: patternColors.map(UIColor.init(rgb:))).hsb.b > 0.3
|
||||||
customPatternColor = isLight ? .black : .white
|
customPatternColor = isLight ? .black : .white
|
||||||
|
bakePatternAlpha = CGFloat(intensity ?? 50) / 100.0
|
||||||
}
|
}
|
||||||
patternArguments = PatternWallpaperArguments(colors: colors, rotation: rotation, customPatternColor: customPatternColor)
|
patternArguments = PatternWallpaperArguments(colors: colors, rotation: rotation, customPatternColor: customPatternColor, bakePatternAlpha: bakePatternAlpha)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,12 +302,14 @@ public struct PatternWallpaperArguments: TransformImageCustomArguments {
|
|||||||
let rotation: Int32?
|
let rotation: Int32?
|
||||||
let preview: Bool
|
let preview: Bool
|
||||||
let customPatternColor: UIColor?
|
let customPatternColor: UIColor?
|
||||||
|
let bakePatternAlpha: CGFloat
|
||||||
|
|
||||||
public init(colors: [UIColor], rotation: Int32?, customPatternColor: UIColor? = nil, preview: Bool = false) {
|
public init(colors: [UIColor], rotation: Int32?, customPatternColor: UIColor? = nil, preview: Bool = false, bakePatternAlpha: CGFloat = 1.0) {
|
||||||
self.colors = colors
|
self.colors = colors
|
||||||
self.rotation = rotation
|
self.rotation = rotation
|
||||||
self.customPatternColor = customPatternColor
|
self.customPatternColor = customPatternColor
|
||||||
self.preview = preview
|
self.preview = preview
|
||||||
|
self.bakePatternAlpha = bakePatternAlpha
|
||||||
}
|
}
|
||||||
|
|
||||||
public func serialized() -> NSArray {
|
public func serialized() -> NSArray {
|
||||||
@ -318,6 +320,7 @@ public struct PatternWallpaperArguments: TransformImageCustomArguments {
|
|||||||
array.add(NSNumber(value: customPatternColor.argb))
|
array.add(NSNumber(value: customPatternColor.argb))
|
||||||
}
|
}
|
||||||
array.add(NSNumber(value: self.preview))
|
array.add(NSNumber(value: self.preview))
|
||||||
|
array.add(NSNumber(value: Double(self.bakePatternAlpha)))
|
||||||
return array
|
return array
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -552,6 +555,9 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da
|
|||||||
c.setBlendMode(.softLight)
|
c.setBlendMode(.softLight)
|
||||||
}
|
}
|
||||||
if let overlayImage = overlayImage {
|
if let overlayImage = overlayImage {
|
||||||
|
if customArguments.bakePatternAlpha != 1.0 {
|
||||||
|
c.setAlpha(customArguments.bakePatternAlpha)
|
||||||
|
}
|
||||||
c.translateBy(x: drawingRect.midX, y: drawingRect.midY)
|
c.translateBy(x: drawingRect.midX, y: drawingRect.midY)
|
||||||
c.scaleBy(x: 1.0, y: -1.0)
|
c.scaleBy(x: 1.0, y: -1.0)
|
||||||
c.translateBy(x: -drawingRect.midX, y: -drawingRect.midY)
|
c.translateBy(x: -drawingRect.midX, y: -drawingRect.midY)
|
||||||
@ -559,6 +565,7 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da
|
|||||||
c.translateBy(x: drawingRect.midX, y: drawingRect.midY)
|
c.translateBy(x: drawingRect.midX, y: drawingRect.midY)
|
||||||
c.scaleBy(x: 1.0, y: -1.0)
|
c.scaleBy(x: 1.0, y: -1.0)
|
||||||
c.translateBy(x: -drawingRect.midX, y: -drawingRect.midY)
|
c.translateBy(x: -drawingRect.midX, y: -drawingRect.midY)
|
||||||
|
c.setAlpha(1.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addCorners(context, arguments: arguments)
|
addCorners(context, arguments: arguments)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user