mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Theme fixes
This commit is contained in:
parent
2cb6ebc410
commit
533257976b
@ -147,8 +147,8 @@ public final class CachedPatternWallpaperMaskRepresentation: CachedMediaResource
|
|||||||
public final class CachedPatternWallpaperRepresentation: CachedMediaResourceRepresentation {
|
public final class CachedPatternWallpaperRepresentation: CachedMediaResourceRepresentation {
|
||||||
public let keepDuration: CachedMediaRepresentationKeepDuration = .general
|
public let keepDuration: CachedMediaRepresentationKeepDuration = .general
|
||||||
|
|
||||||
public let color: Int32
|
public let color: UInt32
|
||||||
public let bottomColor: Int32?
|
public let bottomColor: UInt32?
|
||||||
public let intensity: Int32
|
public let intensity: Int32
|
||||||
public let rotation: Int32?
|
public let rotation: Int32?
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ public final class CachedPatternWallpaperRepresentation: CachedMediaResourceRepr
|
|||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(color: Int32, bottomColor: Int32?, intensity: Int32, rotation: Int32?) {
|
public init(color: UInt32, bottomColor: UInt32?, intensity: Int32, rotation: Int32?) {
|
||||||
self.color = color
|
self.color = color
|
||||||
self.bottomColor = bottomColor
|
self.bottomColor = bottomColor
|
||||||
self.intensity = intensity
|
self.intensity = intensity
|
||||||
|
@ -143,6 +143,16 @@ public final class SegmentedControlNode: ASDisplayNode, UIGestureRecognizerDeleg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func setSelectedIndex(_ index: Int, animated: Bool) {
|
||||||
|
guard index != self._selectedIndex else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self._selectedIndex = index
|
||||||
|
if let layout = self.validLayout {
|
||||||
|
let _ = self.updateLayout(layout, transition: .animated(duration: 0.2, curve: .easeInOut))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public var selectedIndexChanged: (Int) -> Void = { _ in }
|
public var selectedIndexChanged: (Int) -> Void = { _ in }
|
||||||
public var selectedIndexShouldChange: (Int, @escaping (Bool) -> Void) -> Void = { _, f in
|
public var selectedIndexShouldChange: (Int, @escaping (Bool) -> Void) -> Void = { _, f in
|
||||||
f(true)
|
f(true)
|
||||||
|
@ -290,7 +290,7 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll
|
|||||||
if let wallpaper = wallpaper {
|
if let wallpaper = wallpaper {
|
||||||
return theme.withUpdated(name: nil, defaultWallpaper: wallpaper.wallpaper)
|
return theme.withUpdated(name: nil, defaultWallpaper: wallpaper.wallpaper)
|
||||||
} else {
|
} else {
|
||||||
return theme.withUpdated(name: nil, defaultWallpaper: .color(Int32(bitPattern: theme.chatList.backgroundColor.argb)))
|
return theme.withUpdated(name: nil, defaultWallpaper: .color(theme.chatList.backgroundColor.argb))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
|
@ -91,7 +91,7 @@ final class SettingsThemeWallpaperNode: ASDisplayNode {
|
|||||||
apply()
|
apply()
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
let theme = context.sharedContext.currentPresentationData.with { $0 }.theme
|
let theme = context.sharedContext.currentPresentationData.with { $0 }.theme
|
||||||
let uiColor = UIColor(rgb: UInt32(bitPattern: color))
|
let uiColor = UIColor(rgb: color)
|
||||||
if uiColor.distance(to: theme.list.itemBlocksBackgroundColor) < 200 {
|
if uiColor.distance(to: theme.list.itemBlocksBackgroundColor) < 200 {
|
||||||
self.imageNode.isHidden = false
|
self.imageNode.isHidden = false
|
||||||
self.backgroundNode.isHidden = true
|
self.backgroundNode.isHidden = true
|
||||||
@ -101,12 +101,12 @@ final class SettingsThemeWallpaperNode: ASDisplayNode {
|
|||||||
} else {
|
} else {
|
||||||
self.imageNode.isHidden = true
|
self.imageNode.isHidden = true
|
||||||
self.backgroundNode.isHidden = false
|
self.backgroundNode.isHidden = false
|
||||||
self.backgroundNode.backgroundColor = UIColor(rgb: UInt32(bitPattern: color))
|
self.backgroundNode.backgroundColor = UIColor(rgb: color)
|
||||||
}
|
}
|
||||||
case let .gradient(topColor, bottomColor, _):
|
case let .gradient(topColor, bottomColor, _):
|
||||||
self.imageNode.isHidden = false
|
self.imageNode.isHidden = false
|
||||||
self.backgroundNode.isHidden = true
|
self.backgroundNode.isHidden = true
|
||||||
self.imageNode.setSignal(gradientImage([UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor))]))
|
self.imageNode.setSignal(gradientImage([UIColor(rgb: topColor), UIColor(rgb: bottomColor)]))
|
||||||
let apply = self.imageNode.asyncLayout()(TransformImageArguments(corners: corners, imageSize: CGSize(), boundingSize: size, intrinsicInsets: UIEdgeInsets()))
|
let apply = self.imageNode.asyncLayout()(TransformImageArguments(corners: corners, imageSize: CGSize(), boundingSize: size, intrinsicInsets: UIEdgeInsets()))
|
||||||
apply()
|
apply()
|
||||||
case let .image(representations, _):
|
case let .image(representations, _):
|
||||||
@ -136,11 +136,11 @@ final class SettingsThemeWallpaperNode: ASDisplayNode {
|
|||||||
if let intensity = file.settings.intensity {
|
if let intensity = file.settings.intensity {
|
||||||
patternIntensity = CGFloat(intensity) / 100.0
|
patternIntensity = CGFloat(intensity) / 100.0
|
||||||
}
|
}
|
||||||
patternColor = UIColor(rgb: UInt32(bitPattern: color), alpha: patternIntensity)
|
patternColor = UIColor(rgb: color, alpha: patternIntensity)
|
||||||
patternColors.append(patternColor)
|
patternColors.append(patternColor)
|
||||||
|
|
||||||
if let bottomColor = file.settings.bottomColor {
|
if let bottomColor = file.settings.bottomColor {
|
||||||
patternColors.append(UIColor(rgb: UInt32(bitPattern: bottomColor), alpha: patternIntensity))
|
patternColors.append(UIColor(rgb: bottomColor, alpha: patternIntensity))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,11 +149,12 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let context = strongSelf.context
|
let context = strongSelf.context
|
||||||
let initialAccentColor = strongSelf.initialAccentColor
|
let initialAccentColor = strongSelf.initialAccentColor
|
||||||
|
let autoNightModeTriggered = strongSelf.presentationData.autoNightModeTriggered
|
||||||
|
|
||||||
var coloredWallpaper: TelegramWallpaper?
|
var coloredWallpaper: TelegramWallpaper?
|
||||||
if let backgroundColors = state.backgroundColors {
|
if let backgroundColors = state.backgroundColors {
|
||||||
let color = Int32(bitPattern: backgroundColors.0.argb)
|
let color = backgroundColors.0.argb
|
||||||
let bottomColor = backgroundColors.1.flatMap { Int32(bitPattern: $0.argb) }
|
let bottomColor = backgroundColors.1.flatMap { $0.argb }
|
||||||
|
|
||||||
if let patternWallpaper = state.patternWallpaper {
|
if let patternWallpaper = state.patternWallpaper {
|
||||||
coloredWallpaper = patternWallpaper.withUpdatedSettings(WallpaperSettings(motion: state.motion, color: color, bottomColor: bottomColor, intensity: state.patternIntensity, rotation: state.rotation))
|
coloredWallpaper = patternWallpaper.withUpdatedSettings(WallpaperSettings(motion: state.motion, color: color, bottomColor: bottomColor, intensity: state.patternIntensity, rotation: state.rotation))
|
||||||
@ -167,7 +168,7 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
let prepare: Signal<CreateThemeResult, CreateThemeError>
|
let prepare: Signal<CreateThemeResult, CreateThemeError>
|
||||||
if let patternWallpaper = state.patternWallpaper, case let .file(file) = patternWallpaper, let backgroundColors = state.backgroundColors {
|
if let patternWallpaper = state.patternWallpaper, case let .file(file) = patternWallpaper, let backgroundColors = state.backgroundColors {
|
||||||
let resource = file.file.resource
|
let resource = file.file.resource
|
||||||
let representation = CachedPatternWallpaperRepresentation(color: Int32(bitPattern: backgroundColors.0.argb), bottomColor: backgroundColors.1.flatMap { Int32(bitPattern: $0.argb) }, intensity: state.patternIntensity, rotation: state.rotation)
|
let representation = CachedPatternWallpaperRepresentation(color: backgroundColors.0.argb, bottomColor: backgroundColors.1.flatMap { $0.argb }, intensity: state.patternIntensity, rotation: state.rotation)
|
||||||
|
|
||||||
var data: Data?
|
var data: Data?
|
||||||
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
if let path = strongSelf.context.account.postbox.mediaBox.completedResourcePath(resource), let maybeData = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead) {
|
||||||
@ -248,7 +249,44 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
|
|
||||||
let save: Signal<Void, NoError>
|
let save: Signal<Void, NoError>
|
||||||
|
|
||||||
if !create, let theme = telegramTheme {
|
if create {
|
||||||
|
let title = generateThemeName(accentColor: state.accentColor)
|
||||||
|
let _ = (prepare |> then(createTheme(account: context.account, title: title, resource: nil, thumbnailData: nil, settings: settings))
|
||||||
|
|> deliverOnMainQueue).start(next: { next in
|
||||||
|
if case let .result(resultTheme) = next {
|
||||||
|
let _ = applyTheme(accountManager: context.sharedContext.accountManager, account: context.account, theme: resultTheme).start()
|
||||||
|
let _ = (updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in
|
||||||
|
// if let resource = resultTheme.file?.resource, let data = themeData {
|
||||||
|
// context.sharedContext.accountManager.mediaBox.storeResourceData(resource.id, data: data, synchronous: true)
|
||||||
|
// }
|
||||||
|
|
||||||
|
let themeReference: PresentationThemeReference = .cloud(PresentationCloudTheme(theme: resultTheme, resolvedWallpaper: wallpaper))
|
||||||
|
|
||||||
|
var updatedTheme = current.theme
|
||||||
|
var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting
|
||||||
|
if autoNightModeTriggered {
|
||||||
|
updatedAutomaticThemeSwitchSetting.theme = themeReference
|
||||||
|
} else {
|
||||||
|
updatedTheme = themeReference
|
||||||
|
}
|
||||||
|
|
||||||
|
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
|
||||||
|
themeSpecificChatWallpapers[themeReference.index] = nil
|
||||||
|
|
||||||
|
var themeSpecificAccentColors = current.themeSpecificAccentColors
|
||||||
|
themeSpecificAccentColors[baseThemeReference.index] = PresentationThemeAccentColor(themeIndex: themeReference.index)
|
||||||
|
|
||||||
|
return PresentationThemeSettings(theme: updatedTheme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: updatedAutomaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
|
||||||
|
}) |> deliverOnMainQueue).start(completed: {
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.completion?()
|
||||||
|
strongSelf.dismiss()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, error: { error in
|
||||||
|
})
|
||||||
|
} else if let theme = telegramTheme {
|
||||||
let _ = (prepare |> then(updateTheme(account: context.account, accountManager: context.sharedContext.accountManager, theme: theme, title: theme.title, slug: theme.slug, resource: nil, settings: settings))
|
let _ = (prepare |> then(updateTheme(account: context.account, accountManager: context.sharedContext.accountManager, theme: theme, title: theme.title, slug: theme.slug, resource: nil, settings: settings))
|
||||||
|> deliverOnMainQueue).start(next: { next in
|
|> deliverOnMainQueue).start(next: { next in
|
||||||
if case let .result(resultTheme) = next {
|
if case let .result(resultTheme) = next {
|
||||||
@ -260,13 +298,21 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
|
|
||||||
let themeReference: PresentationThemeReference = .cloud(PresentationCloudTheme(theme: resultTheme, resolvedWallpaper: wallpaper))
|
let themeReference: PresentationThemeReference = .cloud(PresentationCloudTheme(theme: resultTheme, resolvedWallpaper: wallpaper))
|
||||||
|
|
||||||
|
var updatedTheme = current.theme
|
||||||
|
var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting
|
||||||
|
if autoNightModeTriggered {
|
||||||
|
updatedAutomaticThemeSwitchSetting.theme = themeReference
|
||||||
|
} else {
|
||||||
|
updatedTheme = themeReference
|
||||||
|
}
|
||||||
|
|
||||||
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
|
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
|
||||||
themeSpecificChatWallpapers[themeReference.index] = nil
|
themeSpecificChatWallpapers[themeReference.index] = nil
|
||||||
|
|
||||||
var themeSpecificAccentColors = current.themeSpecificAccentColors
|
var themeSpecificAccentColors = current.themeSpecificAccentColors
|
||||||
themeSpecificAccentColors[baseThemeReference.index] = PresentationThemeAccentColor(themeIndex: themeReference.index)
|
themeSpecificAccentColors[baseThemeReference.index] = PresentationThemeAccentColor(themeIndex: themeReference.index)
|
||||||
|
|
||||||
return PresentationThemeSettings(theme: themeReference, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
|
return PresentationThemeSettings(theme: updatedTheme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: updatedAutomaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
|
||||||
}) |> deliverOnMainQueue).start(completed: {
|
}) |> deliverOnMainQueue).start(completed: {
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.completion?()
|
strongSelf.completion?()
|
||||||
@ -274,37 +320,10 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, error: { error in
|
}, error: { _ in
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let title = generateThemeName(accentColor: state.accentColor)
|
|
||||||
let _ = (prepare |> then(createTheme(account: context.account, title: title, resource: nil, thumbnailData: nil, settings: settings))
|
|
||||||
|> deliverOnMainQueue).start(next: { next in
|
|
||||||
if case let .result(resultTheme) = next {
|
|
||||||
let _ = applyTheme(accountManager: context.sharedContext.accountManager, account: context.account, theme: resultTheme).start()
|
|
||||||
let _ = (updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in
|
|
||||||
// if let resource = resultTheme.file?.resource, let data = themeData {
|
|
||||||
// context.sharedContext.accountManager.mediaBox.storeResourceData(resource.id, data: data, synchronous: true)
|
|
||||||
// }
|
|
||||||
|
|
||||||
let themeReference: PresentationThemeReference = .cloud(PresentationCloudTheme(theme: resultTheme, resolvedWallpaper: wallpaper))
|
|
||||||
|
|
||||||
var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers
|
|
||||||
themeSpecificChatWallpapers[themeReference.index] = nil
|
|
||||||
|
|
||||||
var themeSpecificAccentColors = current.themeSpecificAccentColors
|
|
||||||
themeSpecificAccentColors[baseThemeReference.index] = PresentationThemeAccentColor(themeIndex: themeReference.index)
|
|
||||||
|
|
||||||
return PresentationThemeSettings(theme: themeReference, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)
|
|
||||||
}) |> deliverOnMainQueue).start(completed: {
|
|
||||||
if let strongSelf = self {
|
|
||||||
strongSelf.completion?()
|
|
||||||
strongSelf.dismiss()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}, error: { error in
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else if case .background = strongSelf.mode {
|
} else if case .background = strongSelf.mode {
|
||||||
let autoNightModeTriggered = strongSelf.presentationData.autoNightModeTriggered
|
let autoNightModeTriggered = strongSelf.presentationData.autoNightModeTriggered
|
||||||
@ -333,6 +352,11 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
strongSelf.segmentedTitleView.theme = theme
|
strongSelf.segmentedTitleView.theme = theme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.controllerNode.requestSectionUpdate = { [weak self] section in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.segmentedTitleView.setIndex(section.rawValue, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let _ = (combineLatest(
|
let _ = (combineLatest(
|
||||||
self.context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.presentationThemeSettings]) |> take(1),
|
self.context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.presentationThemeSettings]) |> take(1),
|
||||||
@ -367,9 +391,9 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
if let intensity = file.settings.intensity {
|
if let intensity = file.settings.intensity {
|
||||||
patternIntensity = intensity
|
patternIntensity = intensity
|
||||||
}
|
}
|
||||||
patternColor = UIColor(rgb: UInt32(bitPattern: color))
|
patternColor = UIColor(rgb: color)
|
||||||
if let bottomColorValue = file.settings.bottomColor {
|
if let bottomColorValue = file.settings.bottomColor {
|
||||||
bottomColor = UIColor(rgb: UInt32(bitPattern: bottomColorValue))
|
bottomColor = UIColor(rgb: bottomColorValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
patternWallpaper = wallpaper
|
patternWallpaper = wallpaper
|
||||||
@ -377,9 +401,9 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
motion = file.settings.motion
|
motion = file.settings.motion
|
||||||
rotation = file.settings.rotation ?? 0
|
rotation = file.settings.rotation ?? 0
|
||||||
} else if case let .color(color) = wallpaper {
|
} else if case let .color(color) = wallpaper {
|
||||||
backgroundColors = (UIColor(rgb: UInt32(bitPattern: color)), nil)
|
backgroundColors = (UIColor(rgb: color), nil)
|
||||||
} else if case let .gradient(topColor, bottomColor, settings) = wallpaper {
|
} else if case let .gradient(topColor, bottomColor, settings) = wallpaper {
|
||||||
backgroundColors = (UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
|
backgroundColors = (UIColor(rgb: topColor), UIColor(rgb: bottomColor))
|
||||||
motion = settings.motion
|
motion = settings.motion
|
||||||
rotation = settings.rotation ?? 0
|
rotation = settings.rotation ?? 0
|
||||||
} else {
|
} else {
|
||||||
|
@ -199,9 +199,8 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
private var patternArgumentsPromise = Promise<TransformImageArguments>()
|
private var patternArgumentsPromise = Promise<TransformImageArguments>()
|
||||||
private var patternArgumentsDisposable: Disposable?
|
private var patternArgumentsDisposable: Disposable?
|
||||||
|
|
||||||
private var tapGestureRecognizer: UITapGestureRecognizer?
|
|
||||||
|
|
||||||
var themeUpdated: ((PresentationTheme) -> Void)?
|
var themeUpdated: ((PresentationTheme) -> Void)?
|
||||||
|
var requestSectionUpdate: ((ThemeColorSection) -> Void)?
|
||||||
|
|
||||||
private var validLayout: (ContainerViewLayout, CGFloat, CGFloat)?
|
private var validLayout: (ContainerViewLayout, CGFloat, CGFloat)?
|
||||||
|
|
||||||
@ -423,8 +422,8 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
|
|
||||||
if let backgroundColors = backgroundColors {
|
if let backgroundColors = backgroundColors {
|
||||||
if let patternWallpaper = state.patternWallpaper, case let .file(file) = patternWallpaper {
|
if let patternWallpaper = state.patternWallpaper, case let .file(file) = patternWallpaper {
|
||||||
let color = Int32(bitPattern: backgroundColors.0.argb)
|
let color = backgroundColors.0.argb
|
||||||
let bottomColor = backgroundColors.1.flatMap { Int32(bitPattern: $0.argb) }
|
let bottomColor = backgroundColors.1.flatMap { $0.argb }
|
||||||
wallpaper = patternWallpaper.withUpdatedSettings(WallpaperSettings(motion: state.motion, color: color, bottomColor: bottomColor, intensity: state.patternIntensity, rotation: state.rotation))
|
wallpaper = patternWallpaper.withUpdatedSettings(WallpaperSettings(motion: state.motion, color: color, bottomColor: bottomColor, intensity: state.patternIntensity, rotation: state.rotation))
|
||||||
|
|
||||||
let dimensions = file.file.dimensions ?? PixelDimensions(width: 100, height: 100)
|
let dimensions = file.file.dimensions ?? PixelDimensions(width: 100, height: 100)
|
||||||
@ -436,10 +435,10 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
|
|
||||||
wallpaperSignal = patternWallpaperImage(account: context.account, accountManager: context.sharedContext.accountManager, representations: convertedRepresentations, mode: .screen, autoFetchFullSize: true)
|
wallpaperSignal = patternWallpaperImage(account: context.account, accountManager: context.sharedContext.accountManager, representations: convertedRepresentations, mode: .screen, autoFetchFullSize: true)
|
||||||
} else if let bottomColor = backgroundColors.1 {
|
} else if let bottomColor = backgroundColors.1 {
|
||||||
wallpaper = .gradient(Int32(bitPattern: backgroundColors.0.argb), Int32(bitPattern: bottomColor.argb), WallpaperSettings(rotation: state.rotation))
|
wallpaper = .gradient(backgroundColors.0.argb, bottomColor.argb, WallpaperSettings(rotation: state.rotation))
|
||||||
wallpaperSignal = gradientImage([backgroundColors.0, bottomColor], rotation: state.rotation)
|
wallpaperSignal = gradientImage([backgroundColors.0, bottomColor], rotation: state.rotation)
|
||||||
} else {
|
} else {
|
||||||
wallpaper = .color(Int32(bitPattern: backgroundColors.0.argb))
|
wallpaper = .color(backgroundColors.0.argb)
|
||||||
}
|
}
|
||||||
} else if let themeReference = mode.themeReference, case let .builtin(theme) = themeReference, state.initialWallpaper == nil {
|
} else if let themeReference = mode.themeReference, case let .builtin(theme) = themeReference, state.initialWallpaper == nil {
|
||||||
var suggestedWallpaper: TelegramWallpaper
|
var suggestedWallpaper: TelegramWallpaper
|
||||||
@ -447,12 +446,12 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
case .dayClassic:
|
case .dayClassic:
|
||||||
let topColor = accentColor.withMultiplied(hue: 1.010, saturation: 0.414, brightness: 0.957)
|
let topColor = accentColor.withMultiplied(hue: 1.010, saturation: 0.414, brightness: 0.957)
|
||||||
let bottomColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.867, brightness: 0.965)
|
let bottomColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.867, brightness: 0.965)
|
||||||
suggestedWallpaper = .gradient(Int32(bitPattern: topColor.argb), Int32(bitPattern: bottomColor.argb), WallpaperSettings())
|
suggestedWallpaper = .gradient(topColor.argb, bottomColor.argb, WallpaperSettings())
|
||||||
wallpaperSignal = gradientImage([topColor, bottomColor], rotation: state.rotation)
|
wallpaperSignal = gradientImage([topColor, bottomColor], rotation: state.rotation)
|
||||||
backgroundColors = (topColor, bottomColor)
|
backgroundColors = (topColor, bottomColor)
|
||||||
case .nightAccent:
|
case .nightAccent:
|
||||||
let color = accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18)
|
let color = accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18)
|
||||||
suggestedWallpaper = .color(Int32(bitPattern: color.argb))
|
suggestedWallpaper = .color(color.argb)
|
||||||
backgroundColors = (color, nil)
|
backgroundColors = (color, nil)
|
||||||
default:
|
default:
|
||||||
suggestedWallpaper = .builtin(WallpaperSettings())
|
suggestedWallpaper = .builtin(WallpaperSettings())
|
||||||
@ -510,8 +509,8 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
strongSelf.serviceBackgroundColorPromise.set(.single(serviceBackgroundColor))
|
strongSelf.serviceBackgroundColorPromise.set(.single(serviceBackgroundColor))
|
||||||
|
|
||||||
if case let .color(value) = wallpaper {
|
if case let .color(value) = wallpaper {
|
||||||
strongSelf.backgroundColor = UIColor(rgb: UInt32(bitPattern: value))
|
strongSelf.backgroundColor = UIColor(rgb: value)
|
||||||
strongSelf.immediateBackgroundNode.backgroundColor = UIColor(rgb: UInt32(bitPattern: value))
|
strongSelf.immediateBackgroundNode.backgroundColor = UIColor(rgb: value)
|
||||||
strongSelf.immediateBackgroundNode.image = nil
|
strongSelf.immediateBackgroundNode.image = nil
|
||||||
strongSelf.signalBackgroundNode.isHidden = true
|
strongSelf.signalBackgroundNode.isHidden = true
|
||||||
strongSelf.signalBackgroundNode.contentAnimations = []
|
strongSelf.signalBackgroundNode.contentAnimations = []
|
||||||
@ -588,10 +587,6 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
self.pageControlNode.setPage(0.0)
|
self.pageControlNode.setPage(0.0)
|
||||||
self.colorPanelNode.view.disablesInteractiveTransitionGestureRecognizer = true
|
self.colorPanelNode.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||||
self.patternPanelNode.view.disablesInteractiveTransitionGestureRecognizer = true
|
self.patternPanelNode.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||||
|
|
||||||
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.chatTapped(_:)))
|
|
||||||
// self.scrollNode.view.addGestureRecognizer(tapGestureRecognizer)
|
|
||||||
self.tapGestureRecognizer = tapGestureRecognizer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||||
@ -857,11 +852,14 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
let item = self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, message: message, theme: self.theme, strings: self.presentationData.strings, wallpaper: self.wallpaper, fontSize: self.presentationData.fontSize, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: !message.media.isEmpty ? FileMediaResourceStatus(mediaStatus: .playbackStatus(.paused), fetchStatus: .Local) : nil, tapMessage: { [weak self] message in
|
let item = self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, message: message, theme: self.theme, strings: self.presentationData.strings, wallpaper: self.wallpaper, fontSize: self.presentationData.fontSize, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: !message.media.isEmpty ? FileMediaResourceStatus(mediaStatus: .playbackStatus(.paused), fetchStatus: .Local) : nil, tapMessage: { [weak self] message in
|
||||||
if message.flags.contains(.Incoming) {
|
if message.flags.contains(.Incoming) {
|
||||||
self?.updateSection(.accent)
|
self?.updateSection(.accent)
|
||||||
|
self?.requestSectionUpdate?(.accent)
|
||||||
} else {
|
} else {
|
||||||
self?.updateSection(.messages)
|
self?.updateSection(.messages)
|
||||||
|
self?.requestSectionUpdate?(.messages)
|
||||||
}
|
}
|
||||||
}, clickThroughMessage: { [weak self] in
|
}, clickThroughMessage: { [weak self] in
|
||||||
self?.updateSection(.background)
|
self?.updateSection(.background)
|
||||||
|
self?.requestSectionUpdate?(.background)
|
||||||
})
|
})
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
@ -1038,19 +1036,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
self.setMotionEnabled(self.state.motion, animated: false)
|
self.setMotionEnabled(self.state.motion, animated: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func chatTapped(_ gestureRecognizer: UITapGestureRecognizer) {
|
|
||||||
// self.updateState({ current in
|
|
||||||
// var updated = current
|
|
||||||
// if updated.displayPatternPanel {
|
|
||||||
// updated.displayPatternPanel = false
|
|
||||||
// } else {
|
|
||||||
// updated.colorPanelCollapsed = !updated.colorPanelCollapsed
|
|
||||||
// }
|
|
||||||
// return updated
|
|
||||||
// }, animated: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc private func toggleMotion() {
|
@objc private func toggleMotion() {
|
||||||
self.updateState({ current in
|
self.updateState({ current in
|
||||||
var updated = current
|
var updated = current
|
||||||
|
@ -3,7 +3,7 @@ import Postbox
|
|||||||
import SyncCore
|
import SyncCore
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
|
|
||||||
private func patternWallpaper(slug: String, topColor: Int32, bottomColor: Int32?, intensity: Int32?, rotation: Int32?) -> TelegramWallpaper {
|
private func patternWallpaper(slug: String, topColor: UInt32, bottomColor: UInt32?, intensity: Int32?, rotation: Int32?) -> TelegramWallpaper {
|
||||||
return TelegramWallpaper.file(id: 0, accessHash: 0, isCreator: false, isDefault: true, isPattern: true, isDark: false, slug: slug, file: TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], immediateThumbnailData: nil, mimeType: "", size: nil, attributes: []), settings: WallpaperSettings(color: topColor, bottomColor: bottomColor, intensity: intensity ?? 50, rotation: rotation))
|
return TelegramWallpaper.file(id: 0, accessHash: 0, isCreator: false, isDefault: true, isPattern: true, isDark: false, slug: slug, file: TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], immediateThumbnailData: nil, mimeType: "", size: nil, attributes: []), settings: WallpaperSettings(color: topColor, bottomColor: bottomColor, intensity: intensity ?? 50, rotation: rotation))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,10 @@ final class ThemeColorSegmentedTitleView: UIView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setIndex(_ index: Int, animated: Bool) {
|
||||||
|
self.segmentedControlNode.setSelectedIndex(index, animated: animated)
|
||||||
|
}
|
||||||
|
|
||||||
var sectionUpdated: ((ThemeColorSection) -> Void)?
|
var sectionUpdated: ((ThemeColorSection) -> Void)?
|
||||||
var shouldUpdateSection: ((ThemeColorSection, @escaping (Bool) -> Void) -> Void)?
|
var shouldUpdateSection: ((ThemeColorSection, @escaping (Bool) -> Void) -> Void)?
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import TelegramPresentationData
|
|||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
import AccountContext
|
import AccountContext
|
||||||
|
|
||||||
private func availableColors() -> [Int32] {
|
private func availableColors() -> [UInt32] {
|
||||||
return [
|
return [
|
||||||
0xffffff,
|
0xffffff,
|
||||||
0xd4dfea,
|
0xd4dfea,
|
||||||
@ -49,7 +49,7 @@ private func availableColors() -> [Int32] {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
private func randomColor() -> Int32 {
|
private func randomColor() -> UInt32 {
|
||||||
let colors = availableColors()
|
let colors = availableColors()
|
||||||
return colors[1 ..< colors.count - 1].randomElement() ?? 0x000000
|
return colors[1 ..< colors.count - 1].randomElement() ?? 0x000000
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ final class ThemeColorsGridControllerNode: ASDisplayNode {
|
|||||||
|
|
||||||
private var disposable: Disposable?
|
private var disposable: Disposable?
|
||||||
|
|
||||||
init(context: AccountContext, presentationData: PresentationData, colors: [Int32], present: @escaping (ViewController, Any?) -> Void, pop: @escaping () -> Void, presentColorPicker: @escaping () -> Void) {
|
init(context: AccountContext, presentationData: PresentationData, colors: [UInt32], present: @escaping (ViewController, Any?) -> Void, pop: @escaping () -> Void, presentColorPicker: @escaping () -> Void) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.presentationData = presentationData
|
self.presentationData = presentationData
|
||||||
self.present = present
|
self.present = present
|
||||||
|
@ -300,7 +300,7 @@ final class ThemeGridController: ViewController {
|
|||||||
var options: [String] = []
|
var options: [String] = []
|
||||||
if isPattern {
|
if isPattern {
|
||||||
if let color = settings.color {
|
if let color = settings.color {
|
||||||
options.append("bg_color=\(UIColor(rgb: UInt32(bitPattern: color)).hexString)")
|
options.append("bg_color=\(UIColor(rgb: color).hexString)")
|
||||||
}
|
}
|
||||||
if let intensity = settings.intensity {
|
if let intensity = settings.intensity {
|
||||||
options.append("intensity=\(intensity)")
|
options.append("intensity=\(intensity)")
|
||||||
@ -313,7 +313,7 @@ final class ThemeGridController: ViewController {
|
|||||||
}
|
}
|
||||||
item = slug + optionsString
|
item = slug + optionsString
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
item = "\(UIColor(rgb: UInt32(bitPattern: color)).hexString)"
|
item = "\(UIColor(rgb: color).hexString)"
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -74,10 +74,10 @@ private struct ThemeGridControllerEntry: Comparable, Identifiable {
|
|||||||
case .builtin:
|
case .builtin:
|
||||||
return 0
|
return 0
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
return (Int64(1) << 32) | Int64(bitPattern: UInt64(UInt32(bitPattern: color)))
|
return (Int64(1) << 32) | Int64(bitPattern: UInt64(color))
|
||||||
case let .gradient(topColor, bottomColor, _):
|
case let .gradient(topColor, bottomColor, _):
|
||||||
var hash: UInt32 = UInt32(bitPattern: topColor)
|
var hash: UInt32 = topColor
|
||||||
hash = hash &* 31 &+ UInt32(bitPattern: bottomColor)
|
hash = hash &* 31 &+ bottomColor
|
||||||
return (Int64(2) << 32) | Int64(hash)
|
return (Int64(2) << 32) | Int64(hash)
|
||||||
case let .file(id, _, _, _, _, _, _, _, settings):
|
case let .file(id, _, _, _, _, _, _, _, settings):
|
||||||
var hash: Int = id.hashValue
|
var hash: Int = id.hashValue
|
||||||
|
@ -207,7 +207,7 @@ public final class ThemePreviewController: ViewController {
|
|||||||
} else if case let .file(file) = previewTheme.chat.defaultWallpaper, file.id == 0 {
|
} else if case let .file(file) = previewTheme.chat.defaultWallpaper, file.id == 0 {
|
||||||
self.controllerNode.wallpaperPromise.set(cachedWallpaper(account: self.context.account, slug: file.slug, settings: file.settings)
|
self.controllerNode.wallpaperPromise.set(cachedWallpaper(account: self.context.account, slug: file.slug, settings: file.settings)
|
||||||
|> mapToSignal { wallpaper in
|
|> mapToSignal { wallpaper in
|
||||||
return .single(wallpaper?.wallpaper ?? .color(Int32(bitPattern: previewTheme.chatList.backgroundColor.argb)))
|
return .single(wallpaper?.wallpaper ?? .color(previewTheme.chatList.backgroundColor.argb))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
self.controllerNode.wallpaperPromise.set(.single(previewTheme.chat.defaultWallpaper))
|
self.controllerNode.wallpaperPromise.set(.single(previewTheme.chat.defaultWallpaper))
|
||||||
|
@ -149,7 +149,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
self.maskNode.image = generateMaskImage(color: self.previewTheme.chatList.backgroundColor)
|
self.maskNode.image = generateMaskImage(color: self.previewTheme.chatList.backgroundColor)
|
||||||
|
|
||||||
if case let .color(value) = self.previewTheme.chat.defaultWallpaper {
|
if case let .color(value) = self.previewTheme.chat.defaultWallpaper {
|
||||||
self.instantChatBackgroundNode.backgroundColor = UIColor(rgb: UInt32(bitPattern: value))
|
self.instantChatBackgroundNode.backgroundColor = UIColor(rgb: value)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.pageControlNode.isUserInteractionEnabled = false
|
self.pageControlNode.isUserInteractionEnabled = false
|
||||||
@ -277,9 +277,9 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
if let intensity = file.settings.intensity {
|
if let intensity = file.settings.intensity {
|
||||||
patternIntensity = CGFloat(intensity) / 100.0
|
patternIntensity = CGFloat(intensity) / 100.0
|
||||||
}
|
}
|
||||||
var patternColors = [UIColor(rgb: UInt32(bitPattern: color), alpha: patternIntensity)]
|
var patternColors = [UIColor(rgb: color, alpha: patternIntensity)]
|
||||||
if let bottomColor = file.settings.bottomColor {
|
if let bottomColor = file.settings.bottomColor {
|
||||||
patternColors.append(UIColor(rgb: UInt32(bitPattern: bottomColor), alpha: patternIntensity))
|
patternColors.append(UIColor(rgb: bottomColor, alpha: patternIntensity))
|
||||||
}
|
}
|
||||||
patternArguments = PatternWallpaperArguments(colors: patternColors, rotation: file.settings.rotation)
|
patternArguments = PatternWallpaperArguments(colors: patternColors, rotation: file.settings.rotation)
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
self.chatListBackgroundNode.backgroundColor = self.previewTheme.chatList.backgroundColor
|
self.chatListBackgroundNode.backgroundColor = self.previewTheme.chatList.backgroundColor
|
||||||
self.maskNode.image = generateMaskImage(color: self.previewTheme.chatList.backgroundColor)
|
self.maskNode.image = generateMaskImage(color: self.previewTheme.chatList.backgroundColor)
|
||||||
if case let .color(value) = self.previewTheme.chat.defaultWallpaper {
|
if case let .color(value) = self.previewTheme.chat.defaultWallpaper {
|
||||||
self.instantChatBackgroundNode.backgroundColor = UIColor(rgb: UInt32(bitPattern: value))
|
self.instantChatBackgroundNode.backgroundColor = UIColor(rgb: value)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.toolbarNode.updateThemeAndStrings(theme: self.previewTheme, strings: self.presentationData.strings)
|
self.toolbarNode.updateThemeAndStrings(theme: self.previewTheme, strings: self.presentationData.strings)
|
||||||
|
@ -900,7 +900,6 @@ class ThemeSettingsAccentColorItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
}
|
}
|
||||||
entries.append(.theme(index, item.generalThemeReference, theme, selected))
|
entries.append(.theme(index, item.generalThemeReference, theme, selected))
|
||||||
}
|
}
|
||||||
|
|
||||||
index += 1
|
index += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,7 +934,7 @@ class ThemeSettingsAccentColorItemNode: ListViewItemNode, ItemListItemNode {
|
|||||||
item.openColorPicker(true)
|
item.openColorPicker(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let previousEntries = strongSelf.entries ?? []
|
let previousEntries = strongSelf.entries ?? []
|
||||||
let updatePosition = currentItem != nil && (previousEntries.count != entries.count || (currentItem?.generalThemeReference.index != item.generalThemeReference.index))
|
let updatePosition = currentItem != nil && (previousEntries.count != entries.count || (currentItem?.generalThemeReference.index != item.generalThemeReference.index))
|
||||||
let transition = preparedTransition(action: action, contextAction: contextAction, openColorPicker: openColorPicker, from: previousEntries, to: entries, updatePosition: updatePosition)
|
let transition = preparedTransition(action: action, contextAction: contextAction, openColorPicker: openColorPicker, from: previousEntries, to: entries, updatePosition: updatePosition)
|
||||||
|
@ -323,10 +323,6 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
|
|||||||
colorItems.append(.default)
|
colorItems.append(.default)
|
||||||
defaultColor = nil
|
defaultColor = nil
|
||||||
|
|
||||||
let patternWallpaper: (String, Int32, Int32?, Int32?, Int32?) -> TelegramWallpaper = { slug, topColor, bottomColor, intensity, rotation in
|
|
||||||
return TelegramWallpaper.file(id: 0, accessHash: 0, isCreator: false, isDefault: true, isPattern: true, isDark: false, slug: slug, file: TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: LocalFileMediaResource(fileId: 0), previewRepresentations: [], immediateThumbnailData: nil, mimeType: "", size: nil, attributes: []), settings: WallpaperSettings(color: topColor, bottomColor: bottomColor, intensity: intensity ?? 50, rotation: rotation))
|
|
||||||
}
|
|
||||||
|
|
||||||
for preset in dayClassicColorPresets {
|
for preset in dayClassicColorPresets {
|
||||||
colorItems.append(.preset(preset))
|
colorItems.append(.preset(preset))
|
||||||
}
|
}
|
||||||
@ -706,9 +702,19 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
|||||||
let _ = (cloudThemes.get()
|
let _ = (cloudThemes.get()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { themes in
|
|> deliverOnMainQueue).start(next: { themes in
|
||||||
|
removedThemeIndexesPromise.set(.single(removedThemeIndexes.modify({ value in
|
||||||
|
var updated = value
|
||||||
|
updated.insert(theme.theme.id)
|
||||||
|
return updated
|
||||||
|
})))
|
||||||
|
|
||||||
if isCurrent, let currentThemeIndex = themes.firstIndex(where: { $0.id == theme.theme.id }) {
|
if isCurrent, let currentThemeIndex = themes.firstIndex(where: { $0.id == theme.theme.id }) {
|
||||||
if let settings = theme.theme.settings {
|
if let settings = theme.theme.settings {
|
||||||
selectAccentColorImpl?(nil)
|
if settings.baseTheme == .night {
|
||||||
|
selectAccentColorImpl?(PresentationThemeAccentColor(baseColor: .blue))
|
||||||
|
} else {
|
||||||
|
selectAccentColorImpl?(nil)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let previousThemeIndex = themes.prefix(upTo: currentThemeIndex).reversed().firstIndex(where: { $0.file != nil })
|
let previousThemeIndex = themes.prefix(upTo: currentThemeIndex).reversed().firstIndex(where: { $0.file != nil })
|
||||||
let newTheme: PresentationThemeReference
|
let newTheme: PresentationThemeReference
|
||||||
@ -721,12 +727,6 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removedThemeIndexesPromise.set(.single(removedThemeIndexes.modify({ value in
|
|
||||||
var updated = value
|
|
||||||
updated.insert(theme.theme.id)
|
|
||||||
return updated
|
|
||||||
})))
|
|
||||||
|
|
||||||
let _ = deleteThemeInteractively(account: context.account, accountManager: context.sharedContext.accountManager, theme: theme.theme).start()
|
let _ = deleteThemeInteractively(account: context.account, accountManager: context.sharedContext.accountManager, theme: theme.theme).start()
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
@ -907,6 +907,12 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
|||||||
let _ = (cloudThemes.get()
|
let _ = (cloudThemes.get()
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { themes in
|
|> deliverOnMainQueue).start(next: { themes in
|
||||||
|
removedThemeIndexesPromise.set(.single(removedThemeIndexes.modify({ value in
|
||||||
|
var updated = value
|
||||||
|
updated.insert(cloudTheme.theme.id)
|
||||||
|
return updated
|
||||||
|
})))
|
||||||
|
|
||||||
if isCurrent, let settings = cloudTheme.theme.settings {
|
if isCurrent, let settings = cloudTheme.theme.settings {
|
||||||
let colorThemes = themes.filter { theme in
|
let colorThemes = themes.filter { theme in
|
||||||
if let settings = theme.settings {
|
if let settings = theme.settings {
|
||||||
@ -922,17 +928,15 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
|||||||
if let previousThemeIndex = previousThemeIndex {
|
if let previousThemeIndex = previousThemeIndex {
|
||||||
selectThemeImpl?(.cloud(PresentationCloudTheme(theme: themes[themes.index(before: previousThemeIndex.base)], resolvedWallpaper: nil)))
|
selectThemeImpl?(.cloud(PresentationCloudTheme(theme: themes[themes.index(before: previousThemeIndex.base)], resolvedWallpaper: nil)))
|
||||||
} else {
|
} else {
|
||||||
selectAccentColorImpl?(nil)
|
if settings.baseTheme == .night {
|
||||||
|
selectAccentColorImpl?(PresentationThemeAccentColor(baseColor: .blue))
|
||||||
|
} else {
|
||||||
|
selectAccentColorImpl?(nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removedThemeIndexesPromise.set(.single(removedThemeIndexes.modify({ value in
|
|
||||||
var updated = value
|
|
||||||
updated.insert(cloudTheme.theme.id)
|
|
||||||
return updated
|
|
||||||
})))
|
|
||||||
|
|
||||||
let _ = deleteThemeInteractively(account: context.account, accountManager: context.sharedContext.accountManager, theme: cloudTheme.theme).start()
|
let _ = deleteThemeInteractively(account: context.account, accountManager: context.sharedContext.accountManager, theme: cloudTheme.theme).start()
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
@ -1208,7 +1212,6 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
|||||||
var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting
|
var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting
|
||||||
|
|
||||||
if autoNightModeTriggered {
|
if autoNightModeTriggered {
|
||||||
var updatedAutomaticThemeSwitchSetting = current.automaticThemeSwitchSetting
|
|
||||||
updatedAutomaticThemeSwitchSetting.theme = generalThemeReference
|
updatedAutomaticThemeSwitchSetting.theme = generalThemeReference
|
||||||
} else {
|
} else {
|
||||||
updatedTheme = generalThemeReference
|
updatedTheme = generalThemeReference
|
||||||
|
@ -28,7 +28,7 @@ public enum WallpaperListSource {
|
|||||||
case slug(String, TelegramMediaFile?, WallpaperPresentationOptions?, UIColor?, UIColor?, Int32?, Int32?, Message?)
|
case slug(String, TelegramMediaFile?, WallpaperPresentationOptions?, UIColor?, UIColor?, Int32?, Int32?, Message?)
|
||||||
case asset(PHAsset)
|
case asset(PHAsset)
|
||||||
case contextResult(ChatContextResult)
|
case contextResult(ChatContextResult)
|
||||||
case customColor(Int32?)
|
case customColor(UInt32?)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func areMessagesEqual(_ lhsMessage: Message?, _ rhsMessage: Message?) -> Bool {
|
private func areMessagesEqual(_ lhsMessage: Message?, _ rhsMessage: Message?) -> Bool {
|
||||||
@ -107,18 +107,18 @@ private func updatedFileWallpaper(wallpaper: TelegramWallpaper, firstColor: UICo
|
|||||||
|
|
||||||
private func updatedFileWallpaper(id: Int64? = nil, accessHash: Int64? = nil, slug: String, file: TelegramMediaFile, firstColor: UIColor?, secondColor: UIColor?, intensity: Int32?, rotation: Int32?) -> TelegramWallpaper {
|
private func updatedFileWallpaper(id: Int64? = nil, accessHash: Int64? = nil, slug: String, file: TelegramMediaFile, firstColor: UIColor?, secondColor: UIColor?, intensity: Int32?, rotation: Int32?) -> TelegramWallpaper {
|
||||||
let isPattern = file.mimeType == "image/png"
|
let isPattern = file.mimeType == "image/png"
|
||||||
var firstColorValue: Int32?
|
var firstColorValue: UInt32?
|
||||||
var secondColorValue: Int32?
|
var secondColorValue: UInt32?
|
||||||
var intensityValue: Int32?
|
var intensityValue: Int32?
|
||||||
if let firstColor = firstColor {
|
if let firstColor = firstColor {
|
||||||
firstColorValue = Int32(bitPattern: firstColor.argb)
|
firstColorValue = firstColor.argb
|
||||||
intensityValue = intensity
|
intensityValue = intensity
|
||||||
} else if isPattern {
|
} else if isPattern {
|
||||||
firstColorValue = 0xd6e2ee
|
firstColorValue = 0xd6e2ee
|
||||||
intensityValue = 50
|
intensityValue = 50
|
||||||
}
|
}
|
||||||
if let secondColor = secondColor {
|
if let secondColor = secondColor {
|
||||||
secondColorValue = Int32(bitPattern: secondColor.argb)
|
secondColorValue = secondColor.argb
|
||||||
}
|
}
|
||||||
|
|
||||||
return .file(id: id ?? 0, accessHash: accessHash ?? 0, isCreator: false, isDefault: false, isPattern: isPattern, isDark: false, slug: slug, file: file, settings: WallpaperSettings(color: firstColorValue, bottomColor: secondColorValue, intensity: intensityValue, rotation: rotation))
|
return .file(id: id ?? 0, accessHash: accessHash ?? 0, isCreator: false, isDefault: false, isPattern: isPattern, isDark: false, slug: slug, file: file, settings: WallpaperSettings(color: firstColorValue, bottomColor: secondColorValue, intensity: intensityValue, rotation: rotation))
|
||||||
@ -206,7 +206,7 @@ public class WallpaperGalleryController: ViewController {
|
|||||||
entries = [.contextResult(result)]
|
entries = [.contextResult(result)]
|
||||||
centralEntryIndex = 0
|
centralEntryIndex = 0
|
||||||
case let .customColor(color):
|
case let .customColor(color):
|
||||||
let initialColor = color ?? 0x000000
|
let initialColor: UInt32 = color ?? 0x000000
|
||||||
entries = [.wallpaper(.color(initialColor), nil)]
|
entries = [.wallpaper(.color(initialColor), nil)]
|
||||||
centralEntryIndex = 0
|
centralEntryIndex = 0
|
||||||
}
|
}
|
||||||
@ -554,7 +554,7 @@ public class WallpaperGalleryController: ViewController {
|
|||||||
case let .wallpaper(wallpaper, _):
|
case let .wallpaper(wallpaper, _):
|
||||||
switch wallpaper {
|
switch wallpaper {
|
||||||
case .color:
|
case .color:
|
||||||
currentEntry = .wallpaper(.color(Int32(color.argb)), nil)
|
currentEntry = .wallpaper(.color(color.argb), nil)
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -570,7 +570,7 @@ public class WallpaperGalleryController: ViewController {
|
|||||||
private func updateEntries(pattern: TelegramWallpaper?, intensity: Int32? = nil, preview: Bool = false) {
|
private func updateEntries(pattern: TelegramWallpaper?, intensity: Int32? = nil, preview: Bool = false) {
|
||||||
var updatedEntries: [WallpaperGalleryEntry] = []
|
var updatedEntries: [WallpaperGalleryEntry] = []
|
||||||
for entry in self.entries {
|
for entry in self.entries {
|
||||||
var entryColor: Int32?
|
var entryColor: UInt32?
|
||||||
if case let .wallpaper(wallpaper, _) = entry {
|
if case let .wallpaper(wallpaper, _) = entry {
|
||||||
if case let .color(color) = wallpaper {
|
if case let .color(color) = wallpaper {
|
||||||
entryColor = color
|
entryColor = color
|
||||||
@ -781,9 +781,9 @@ public class WallpaperGalleryController: ViewController {
|
|||||||
if isPattern {
|
if isPattern {
|
||||||
if let color = settings.color {
|
if let color = settings.color {
|
||||||
if let bottomColor = settings.bottomColor {
|
if let bottomColor = settings.bottomColor {
|
||||||
options.append("bg_color=\(UIColor(rgb: UInt32(bitPattern: color)).hexString)-\(UIColor(rgb: UInt32(bitPattern: bottomColor)).hexString)")
|
options.append("bg_color=\(UIColor(rgb: color).hexString)-\(UIColor(rgb: bottomColor).hexString)")
|
||||||
} else {
|
} else {
|
||||||
options.append("bg_color=\(UIColor(rgb: UInt32(bitPattern: color)).hexString)")
|
options.append("bg_color=\(UIColor(rgb: color).hexString)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let intensity = settings.intensity {
|
if let intensity = settings.intensity {
|
||||||
@ -801,9 +801,9 @@ public class WallpaperGalleryController: ViewController {
|
|||||||
|
|
||||||
controller = ShareController(context: context, subject: .url("https://t.me/bg/\(slug)\(optionsString)"))
|
controller = ShareController(context: context, subject: .url("https://t.me/bg/\(slug)\(optionsString)"))
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
controller = ShareController(context: context, subject: .url("https://t.me/bg/\(UIColor(rgb: UInt32(bitPattern: color)).hexString)"))
|
controller = ShareController(context: context, subject: .url("https://t.me/bg/\(UIColor(rgb: color).hexString)"))
|
||||||
case let .gradient(topColor, bottomColor, _):
|
case let .gradient(topColor, bottomColor, _):
|
||||||
controller = ShareController(context: context, subject:. url("https://t.me/bg/\(UIColor(rgb: UInt32(bitPattern: topColor)).hexString)-\(UIColor(rgb: UInt32(bitPattern: bottomColor)).hexString)"))
|
controller = ShareController(context: context, subject:. url("https://t.me/bg/\(UIColor(rgb: topColor).hexString)-\(UIColor(rgb: bottomColor).hexString)"))
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
case let .color(color):
|
case let .color(color):
|
||||||
displaySize = CGSize(width: 1.0, height: 1.0)
|
displaySize = CGSize(width: 1.0, height: 1.0)
|
||||||
contentSize = displaySize
|
contentSize = displaySize
|
||||||
signal = solidColorImage(UIColor(rgb: UInt32(bitPattern: color)))
|
signal = solidColorImage(UIColor(rgb: color))
|
||||||
fetchSignal = .complete()
|
fetchSignal = .complete()
|
||||||
statusSignal = .single(.Local)
|
statusSignal = .single(.Local)
|
||||||
subtitleSignal = .single(nil)
|
subtitleSignal = .single(nil)
|
||||||
@ -236,7 +236,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
case let .gradient(topColor, bottomColor, settings):
|
case let .gradient(topColor, bottomColor, settings):
|
||||||
displaySize = CGSize(width: 1.0, height: 1.0)
|
displaySize = CGSize(width: 1.0, height: 1.0)
|
||||||
contentSize = displaySize
|
contentSize = displaySize
|
||||||
signal = gradientImage([UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor))], rotation: settings.rotation)
|
signal = gradientImage([UIColor(rgb: topColor), UIColor(rgb: bottomColor)], rotation: settings.rotation)
|
||||||
fetchSignal = .complete()
|
fetchSignal = .complete()
|
||||||
statusSignal = .single(.Local)
|
statusSignal = .single(.Local)
|
||||||
subtitleSignal = .single(nil)
|
subtitleSignal = .single(nil)
|
||||||
@ -263,11 +263,11 @@ final class WallpaperGalleryItemNode: GalleryItemNode {
|
|||||||
if let intensity = file.settings.intensity {
|
if let intensity = file.settings.intensity {
|
||||||
patternIntensity = CGFloat(intensity) / 100.0
|
patternIntensity = CGFloat(intensity) / 100.0
|
||||||
}
|
}
|
||||||
patternColor = UIColor(rgb: UInt32(bitPattern: color), alpha: patternIntensity)
|
patternColor = UIColor(rgb: color, alpha: patternIntensity)
|
||||||
patternColors.append(patternColor)
|
patternColors.append(patternColor)
|
||||||
|
|
||||||
if let bottomColor = file.settings.bottomColor {
|
if let bottomColor = file.settings.bottomColor {
|
||||||
patternColors.append(UIColor(rgb: UInt32(bitPattern: bottomColor), alpha: patternIntensity))
|
patternColors.append(UIColor(rgb: bottomColor, alpha: patternIntensity))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ final class WallpaperPatternPanelNode: ASDisplayNode {
|
|||||||
|
|
||||||
var updatedWallpaper = wallpaper
|
var updatedWallpaper = wallpaper
|
||||||
if case let .file(file) = updatedWallpaper {
|
if case let .file(file) = updatedWallpaper {
|
||||||
let settings = WallpaperSettings(color: Int32(bitPattern: backgroundColors.0.rgb), bottomColor: backgroundColors.1.flatMap { Int32(bitPattern: $0.rgb) }, intensity: 100)
|
let settings = WallpaperSettings(color: backgroundColors.0.rgb, bottomColor: backgroundColors.1.flatMap { $0.rgb }, intensity: 100)
|
||||||
updatedWallpaper = .file(id: file.id, accessHash: file.accessHash, isCreator: file.isCreator, isDefault: file.isDefault, isPattern: file.isPattern, isDark: file.isDark, slug: file.slug, file: file.file, settings: settings)
|
updatedWallpaper = .file(id: file.id, accessHash: file.accessHash, isCreator: file.isCreator, isDefault: file.isDefault, isPattern: file.isPattern, isDark: file.isDark, slug: file.slug, file: file.file, settings: settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@ import Postbox
|
|||||||
public struct WallpaperSettings: PostboxCoding, Equatable {
|
public struct WallpaperSettings: PostboxCoding, Equatable {
|
||||||
public let blur: Bool
|
public let blur: Bool
|
||||||
public let motion: Bool
|
public let motion: Bool
|
||||||
public let color: Int32?
|
public let color: UInt32?
|
||||||
public let bottomColor: Int32?
|
public let bottomColor: UInt32?
|
||||||
public let intensity: Int32?
|
public let intensity: Int32?
|
||||||
public let rotation: Int32?
|
public let rotation: Int32?
|
||||||
|
|
||||||
public init(blur: Bool = false, motion: Bool = false, color: Int32? = nil, bottomColor: Int32? = nil, intensity: Int32? = nil, rotation: Int32? = nil) {
|
public init(blur: Bool = false, motion: Bool = false, color: UInt32? = nil, bottomColor: UInt32? = nil, intensity: Int32? = nil, rotation: Int32? = nil) {
|
||||||
self.blur = blur
|
self.blur = blur
|
||||||
self.motion = motion
|
self.motion = motion
|
||||||
self.color = color
|
self.color = color
|
||||||
@ -20,8 +20,8 @@ public struct WallpaperSettings: PostboxCoding, Equatable {
|
|||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
self.blur = decoder.decodeInt32ForKey("b", orElse: 0) != 0
|
self.blur = decoder.decodeInt32ForKey("b", orElse: 0) != 0
|
||||||
self.motion = decoder.decodeInt32ForKey("m", orElse: 0) != 0
|
self.motion = decoder.decodeInt32ForKey("m", orElse: 0) != 0
|
||||||
self.color = decoder.decodeOptionalInt32ForKey("c")
|
self.color = decoder.decodeOptionalInt32ForKey("c").flatMap { UInt32(bitPattern: $0) }
|
||||||
self.bottomColor = decoder.decodeOptionalInt32ForKey("bc")
|
self.bottomColor = decoder.decodeOptionalInt32ForKey("bc").flatMap { UInt32(bitPattern: $0) }
|
||||||
self.intensity = decoder.decodeOptionalInt32ForKey("i")
|
self.intensity = decoder.decodeOptionalInt32ForKey("i")
|
||||||
self.rotation = decoder.decodeOptionalInt32ForKey("r")
|
self.rotation = decoder.decodeOptionalInt32ForKey("r")
|
||||||
}
|
}
|
||||||
@ -30,12 +30,12 @@ public struct WallpaperSettings: PostboxCoding, Equatable {
|
|||||||
encoder.encodeInt32(self.blur ? 1 : 0, forKey: "b")
|
encoder.encodeInt32(self.blur ? 1 : 0, forKey: "b")
|
||||||
encoder.encodeInt32(self.motion ? 1 : 0, forKey: "m")
|
encoder.encodeInt32(self.motion ? 1 : 0, forKey: "m")
|
||||||
if let color = self.color {
|
if let color = self.color {
|
||||||
encoder.encodeInt32(color, forKey: "c")
|
encoder.encodeInt32(Int32(bitPattern: color), forKey: "c")
|
||||||
} else {
|
} else {
|
||||||
encoder.encodeNil(forKey: "c")
|
encoder.encodeNil(forKey: "c")
|
||||||
}
|
}
|
||||||
if let bottomColor = self.bottomColor {
|
if let bottomColor = self.bottomColor {
|
||||||
encoder.encodeInt32(bottomColor, forKey: "bc")
|
encoder.encodeInt32(Int32(bitPattern: bottomColor), forKey: "bc")
|
||||||
} else {
|
} else {
|
||||||
encoder.encodeNil(forKey: "bc")
|
encoder.encodeNil(forKey: "bc")
|
||||||
}
|
}
|
||||||
@ -76,8 +76,8 @@ public struct WallpaperSettings: PostboxCoding, Equatable {
|
|||||||
|
|
||||||
public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
|
public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
|
||||||
case builtin(WallpaperSettings)
|
case builtin(WallpaperSettings)
|
||||||
case color(Int32)
|
case color(UInt32)
|
||||||
case gradient(Int32, Int32, WallpaperSettings)
|
case gradient(UInt32, UInt32, WallpaperSettings)
|
||||||
case image([TelegramMediaImageRepresentation], WallpaperSettings)
|
case image([TelegramMediaImageRepresentation], WallpaperSettings)
|
||||||
case file(id: Int64, accessHash: Int64, isCreator: Bool, isDefault: Bool, isPattern: Bool, isDark: Bool, slug: String, file: TelegramMediaFile, settings: WallpaperSettings)
|
case file(id: Int64, accessHash: Int64, isCreator: Bool, isDefault: Bool, isPattern: Bool, isDark: Bool, slug: String, file: TelegramMediaFile, settings: WallpaperSettings)
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
|
|||||||
let settings = decoder.decodeObjectForKey("settings", decoder: { WallpaperSettings(decoder: $0) }) as? WallpaperSettings ?? WallpaperSettings()
|
let settings = decoder.decodeObjectForKey("settings", decoder: { WallpaperSettings(decoder: $0) }) as? WallpaperSettings ?? WallpaperSettings()
|
||||||
self = .builtin(settings)
|
self = .builtin(settings)
|
||||||
case 1:
|
case 1:
|
||||||
self = .color(decoder.decodeInt32ForKey("c", orElse: 0))
|
self = .color(UInt32(bitPattern: decoder.decodeInt32ForKey("c", orElse: 0)))
|
||||||
case 2:
|
case 2:
|
||||||
let settings = decoder.decodeObjectForKey("settings", decoder: { WallpaperSettings(decoder: $0) }) as? WallpaperSettings ?? WallpaperSettings()
|
let settings = decoder.decodeObjectForKey("settings", decoder: { WallpaperSettings(decoder: $0) }) as? WallpaperSettings ?? WallpaperSettings()
|
||||||
self = .image(decoder.decodeObjectArrayWithDecoderForKey("i"), settings)
|
self = .image(decoder.decodeObjectArrayWithDecoderForKey("i"), settings)
|
||||||
@ -100,7 +100,7 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
|
|||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
let settings = decoder.decodeObjectForKey("settings", decoder: { WallpaperSettings(decoder: $0) }) as? WallpaperSettings ?? WallpaperSettings()
|
let settings = decoder.decodeObjectForKey("settings", decoder: { WallpaperSettings(decoder: $0) }) as? WallpaperSettings ?? WallpaperSettings()
|
||||||
self = .gradient(decoder.decodeInt32ForKey("c1", orElse: 0), decoder.decodeInt32ForKey("c2", orElse: 0), settings)
|
self = .gradient(UInt32(bitPattern: decoder.decodeInt32ForKey("c1", orElse: 0)), UInt32(bitPattern: decoder.decodeInt32ForKey("c2", orElse: 0)), settings)
|
||||||
default:
|
default:
|
||||||
assertionFailure()
|
assertionFailure()
|
||||||
self = .color(0xffffff)
|
self = .color(0xffffff)
|
||||||
@ -123,11 +123,11 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
|
|||||||
encoder.encodeObject(settings, forKey: "settings")
|
encoder.encodeObject(settings, forKey: "settings")
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
encoder.encodeInt32(1, forKey: "v")
|
encoder.encodeInt32(1, forKey: "v")
|
||||||
encoder.encodeInt32(color, forKey: "c")
|
encoder.encodeInt32(Int32(bitPattern: color), forKey: "c")
|
||||||
case let .gradient(topColor, bottomColor, settings):
|
case let .gradient(topColor, bottomColor, settings):
|
||||||
encoder.encodeInt32(4, forKey: "v")
|
encoder.encodeInt32(4, forKey: "v")
|
||||||
encoder.encodeInt32(topColor, forKey: "c1")
|
encoder.encodeInt32(Int32(bitPattern: topColor), forKey: "c1")
|
||||||
encoder.encodeInt32(bottomColor, forKey: "c2")
|
encoder.encodeInt32(Int32(bitPattern: bottomColor), forKey: "c2")
|
||||||
encoder.encodeObject(settings, forKey: "settings")
|
encoder.encodeObject(settings, forKey: "settings")
|
||||||
case let .image(representations, settings):
|
case let .image(representations, settings):
|
||||||
encoder.encodeInt32(2, forKey: "v")
|
encoder.encodeInt32(2, forKey: "v")
|
||||||
|
@ -116,7 +116,6 @@ public enum ThemeUpdatedResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func checkThemeUpdated(network: Network, theme: TelegramTheme) -> Signal<ThemeUpdatedResult, GetThemeError> {
|
private func checkThemeUpdated(network: Network, theme: TelegramTheme) -> Signal<ThemeUpdatedResult, GetThemeError> {
|
||||||
|
|
||||||
let id = theme.settings != nil ? 0 : theme.file?.id?.id
|
let id = theme.settings != nil ? 0 : theme.file?.id?.id
|
||||||
guard let documentId = id else {
|
guard let documentId = id else {
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
|
@ -9,7 +9,7 @@ extension WallpaperSettings {
|
|||||||
init(apiWallpaperSettings: Api.WallPaperSettings) {
|
init(apiWallpaperSettings: Api.WallPaperSettings) {
|
||||||
switch apiWallpaperSettings {
|
switch apiWallpaperSettings {
|
||||||
case let .wallPaperSettings(flags, backgroundColor, secondBackgroundColor, intensity, rotation):
|
case let .wallPaperSettings(flags, backgroundColor, secondBackgroundColor, intensity, rotation):
|
||||||
self = WallpaperSettings(blur: (flags & 1 << 1) != 0, motion: (flags & 1 << 2) != 0, color: backgroundColor, bottomColor: secondBackgroundColor, intensity: intensity, rotation: rotation)
|
self = WallpaperSettings(blur: (flags & 1 << 1) != 0, motion: (flags & 1 << 2) != 0, color: backgroundColor.flatMap { UInt32(bitPattern: $0) }, bottomColor: secondBackgroundColor.flatMap { UInt32(bitPattern: $0) }, intensity: intensity, rotation: rotation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ func apiWallpaperSettings(_ wallpaperSettings: WallpaperSettings) -> Api.WallPap
|
|||||||
if let _ = wallpaperSettings.bottomColor {
|
if let _ = wallpaperSettings.bottomColor {
|
||||||
flags |= (1 << 4)
|
flags |= (1 << 4)
|
||||||
}
|
}
|
||||||
return .wallPaperSettings(flags: flags, backgroundColor: wallpaperSettings.color, secondBackgroundColor: wallpaperSettings.bottomColor, intensity: wallpaperSettings.intensity, rotation: wallpaperSettings.rotation)
|
return .wallPaperSettings(flags: flags, backgroundColor: wallpaperSettings.color.flatMap { Int32(bitPattern: $0) }, secondBackgroundColor: wallpaperSettings.bottomColor.flatMap { Int32(bitPattern: $0) }, intensity: wallpaperSettings.intensity, rotation: wallpaperSettings.rotation)
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TelegramWallpaper {
|
extension TelegramWallpaper {
|
||||||
@ -53,9 +53,9 @@ extension TelegramWallpaper {
|
|||||||
case let .wallPaperNoFile(flags, settings):
|
case let .wallPaperNoFile(flags, settings):
|
||||||
if let settings = settings, case let .wallPaperSettings(flags, backgroundColor, secondBackgroundColor, intensity, rotation) = settings {
|
if let settings = settings, case let .wallPaperSettings(flags, backgroundColor, secondBackgroundColor, intensity, rotation) = settings {
|
||||||
if let color = backgroundColor, let bottomColor = secondBackgroundColor {
|
if let color = backgroundColor, let bottomColor = secondBackgroundColor {
|
||||||
self = .gradient(color, bottomColor, WallpaperSettings(rotation: rotation))
|
self = .gradient(UInt32(bitPattern: color), UInt32(bitPattern: bottomColor), WallpaperSettings(rotation: rotation))
|
||||||
} else if let color = backgroundColor {
|
} else if let color = backgroundColor {
|
||||||
self = .color(color)
|
self = .color(UInt32(bitPattern: color))
|
||||||
} else {
|
} else {
|
||||||
self = .color(0xffffff)
|
self = .color(0xffffff)
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ public func chatControllerBackgroundImage(theme: PresentationTheme?, wallpaper i
|
|||||||
}
|
}
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
backgroundImage = generateImage(CGSize(width: 1.0, height: 1.0), rotatedContext: { size, context in
|
backgroundImage = generateImage(CGSize(width: 1.0, height: 1.0), rotatedContext: { size, context in
|
||||||
context.setFillColor(UIColor(rgb: UInt32(bitPattern: color)).withAlphaComponent(1.0).cgColor)
|
context.setFillColor(UIColor(argb: color).withAlphaComponent(1.0).cgColor)
|
||||||
context.fill(CGRect(origin: CGPoint(), size: size))
|
context.fill(CGRect(origin: CGPoint(), size: size))
|
||||||
})
|
})
|
||||||
case let .gradient(topColor, bottomColor, settings):
|
case let .gradient(topColor, bottomColor, settings):
|
||||||
backgroundImage = generateImage(CGSize(width: 640.0, height: 1280.0), rotatedContext: { size, context in
|
backgroundImage = generateImage(CGSize(width: 640.0, height: 1280.0), rotatedContext: { size, context in
|
||||||
let gradientColors = [UIColor(rgb: UInt32(bitPattern: topColor)).cgColor, UIColor(rgb: UInt32(bitPattern: bottomColor)).cgColor] as CFArray
|
let gradientColors = [UIColor(argb: topColor).cgColor, UIColor(argb: bottomColor).cgColor] as CFArray
|
||||||
|
|
||||||
var locations: [CGFloat] = [0.0, 1.0]
|
var locations: [CGFloat] = [0.0, 1.0]
|
||||||
let colorSpace = CGColorSpaceCreateDeviceRGB()
|
let colorSpace = CGColorSpaceCreateDeviceRGB()
|
||||||
|
@ -83,9 +83,9 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
|
|||||||
defaultWallpaper = forcedWallpaper
|
defaultWallpaper = forcedWallpaper
|
||||||
} else if let backgroundColors = backgroundColors {
|
} else if let backgroundColors = backgroundColors {
|
||||||
if let secondColor = backgroundColors.1 {
|
if let secondColor = backgroundColors.1 {
|
||||||
defaultWallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: secondColor.rgb), WallpaperSettings())
|
defaultWallpaper = .gradient(backgroundColors.0.argb, secondColor.argb, WallpaperSettings())
|
||||||
} else {
|
} else {
|
||||||
defaultWallpaper = .color(Int32(bitPattern: backgroundColors.0.rgb))
|
defaultWallpaper = .color(backgroundColors.0.argb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
|||||||
if bubbleColors == nil, editing {
|
if bubbleColors == nil, editing {
|
||||||
if let accentColor = accentColor {
|
if let accentColor = accentColor {
|
||||||
let color = accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18)
|
let color = accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18)
|
||||||
suggestedWallpaper = .color(Int32(bitPattern: color.rgb))
|
suggestedWallpaper = .color(color.argb)
|
||||||
}
|
}
|
||||||
|
|
||||||
let accentColor = accentColor ?? defaultDarkTintedAccentColor
|
let accentColor = accentColor ?? defaultDarkTintedAccentColor
|
||||||
@ -224,9 +224,9 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
|||||||
defaultWallpaper = forcedWallpaper
|
defaultWallpaper = forcedWallpaper
|
||||||
} else if let backgroundColors = backgroundColors {
|
} else if let backgroundColors = backgroundColors {
|
||||||
if let secondColor = backgroundColors.1 {
|
if let secondColor = backgroundColors.1 {
|
||||||
defaultWallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: secondColor.rgb), WallpaperSettings())
|
defaultWallpaper = .gradient(backgroundColors.0.argb, secondColor.argb, WallpaperSettings())
|
||||||
} else {
|
} else {
|
||||||
defaultWallpaper = .color(Int32(bitPattern: backgroundColors.0.rgb))
|
defaultWallpaper = .color(backgroundColors.0.argb)
|
||||||
}
|
}
|
||||||
} else if let forcedWallpaper = suggestedWallpaper {
|
} else if let forcedWallpaper = suggestedWallpaper {
|
||||||
defaultWallpaper = forcedWallpaper
|
defaultWallpaper = forcedWallpaper
|
||||||
@ -728,7 +728,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
|
|||||||
)
|
)
|
||||||
|
|
||||||
let chat = PresentationThemeChat(
|
let chat = PresentationThemeChat(
|
||||||
defaultWallpaper: .color(Int32(bitPattern: accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18).rgb)),
|
defaultWallpaper: .color(accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18).argb),
|
||||||
message: message,
|
message: message,
|
||||||
serviceMessage: serviceMessage,
|
serviceMessage: serviceMessage,
|
||||||
inputPanel: inputPanel,
|
inputPanel: inputPanel,
|
||||||
|
@ -41,7 +41,7 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, ac
|
|||||||
|
|
||||||
let topColor = accentColor.withMultiplied(hue: 1.010, saturation: 0.414, brightness: 0.957)
|
let topColor = accentColor.withMultiplied(hue: 1.010, saturation: 0.414, brightness: 0.957)
|
||||||
let bottomColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.867, brightness: 0.965)
|
let bottomColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.867, brightness: 0.965)
|
||||||
suggestedWallpaper = .gradient(Int32(bitPattern: topColor.rgb), Int32(bitPattern: bottomColor.rgb), WallpaperSettings())
|
suggestedWallpaper = .gradient(topColor.argb, bottomColor.argb, WallpaperSettings())
|
||||||
} else {
|
} else {
|
||||||
bubbleColors = (UIColor(rgb: 0xe1ffc7), nil)
|
bubbleColors = (UIColor(rgb: 0xe1ffc7), nil)
|
||||||
suggestedWallpaper = .builtin(WallpaperSettings())
|
suggestedWallpaper = .builtin(WallpaperSettings())
|
||||||
@ -201,9 +201,9 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, ac
|
|||||||
defaultWallpaper = forcedWallpaper
|
defaultWallpaper = forcedWallpaper
|
||||||
} else if let backgroundColors = backgroundColors {
|
} else if let backgroundColors = backgroundColors {
|
||||||
if let secondColor = backgroundColors.1 {
|
if let secondColor = backgroundColors.1 {
|
||||||
defaultWallpaper = .gradient(Int32(bitPattern: backgroundColors.0.rgb), Int32(bitPattern: secondColor.rgb), WallpaperSettings())
|
defaultWallpaper = .gradient(backgroundColors.0.argb, secondColor.argb, WallpaperSettings())
|
||||||
} else {
|
} else {
|
||||||
defaultWallpaper = .color(Int32(bitPattern: backgroundColors.0.rgb))
|
defaultWallpaper = .color(backgroundColors.0.argb)
|
||||||
}
|
}
|
||||||
} else if let forcedWallpaper = suggestedWallpaper {
|
} else if let forcedWallpaper = suggestedWallpaper {
|
||||||
defaultWallpaper = forcedWallpaper
|
defaultWallpaper = forcedWallpaper
|
||||||
|
@ -395,9 +395,9 @@ public func serviceColor(for wallpaper: (TelegramWallpaper, UIImage?)) -> UIColo
|
|||||||
case .builtin:
|
case .builtin:
|
||||||
return UIColor(rgb: 0x748391, alpha: 0.45)
|
return UIColor(rgb: 0x748391, alpha: 0.45)
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
return serviceColor(with: UIColor(rgb: UInt32(bitPattern: color)))
|
return serviceColor(with: UIColor(argb: color))
|
||||||
case let .gradient(topColor, bottomColor, _):
|
case let .gradient(topColor, bottomColor, _):
|
||||||
let mixedColor = UIColor(rgb: UInt32(bitPattern: topColor)).mixedWith(UIColor(rgb: UInt32(bitPattern: bottomColor)), alpha: 0.5)
|
let mixedColor = UIColor(argb: topColor).mixedWith(UIColor(argb: bottomColor), alpha: 0.5)
|
||||||
return serviceColor(with: mixedColor)
|
return serviceColor(with: mixedColor)
|
||||||
case .image:
|
case .image:
|
||||||
if let image = wallpaper.1 {
|
if let image = wallpaper.1 {
|
||||||
@ -408,9 +408,9 @@ public func serviceColor(for wallpaper: (TelegramWallpaper, UIImage?)) -> UIColo
|
|||||||
case let .file(file):
|
case let .file(file):
|
||||||
if file.isPattern {
|
if file.isPattern {
|
||||||
if let color = file.settings.color {
|
if let color = file.settings.color {
|
||||||
var mixedColor = UIColor(rgb: UInt32(bitPattern: color))
|
var mixedColor = UIColor(argb: color)
|
||||||
if let bottomColor = file.settings.bottomColor {
|
if let bottomColor = file.settings.bottomColor {
|
||||||
mixedColor = mixedColor.mixedWith(UIColor(rgb: UInt32(bitPattern: bottomColor)), alpha: 0.5)
|
mixedColor = mixedColor.mixedWith(UIColor(argb: bottomColor), alpha: 0.5)
|
||||||
}
|
}
|
||||||
return serviceColor(with: mixedColor)
|
return serviceColor(with: mixedColor)
|
||||||
} else {
|
} else {
|
||||||
@ -450,9 +450,9 @@ public func chatServiceBackgroundColor(wallpaper: TelegramWallpaper, mediaBox: M
|
|||||||
case .builtin:
|
case .builtin:
|
||||||
return .single(UIColor(rgb: 0x748391, alpha: 0.45))
|
return .single(UIColor(rgb: 0x748391, alpha: 0.45))
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
return .single(serviceColor(with: UIColor(rgb: UInt32(bitPattern: color))))
|
return .single(serviceColor(with: UIColor(argb: color)))
|
||||||
case let .gradient(topColor, bottomColor, _):
|
case let .gradient(topColor, bottomColor, _):
|
||||||
let mixedColor = UIColor(rgb: UInt32(bitPattern: topColor)).mixedWith(UIColor(rgb: UInt32(bitPattern: bottomColor)), alpha: 0.5)
|
let mixedColor = UIColor(argb: topColor).mixedWith(UIColor(rgb: bottomColor), alpha: 0.5)
|
||||||
return .single(serviceColor(with: mixedColor))
|
return .single(serviceColor(with: mixedColor))
|
||||||
case let .image(representations, _):
|
case let .image(representations, _):
|
||||||
if let largest = largestImageRepresentation(representations) {
|
if let largest = largestImageRepresentation(representations) {
|
||||||
@ -477,9 +477,9 @@ public func chatServiceBackgroundColor(wallpaper: TelegramWallpaper, mediaBox: M
|
|||||||
case let .file(file):
|
case let .file(file):
|
||||||
if file.isPattern {
|
if file.isPattern {
|
||||||
if let color = file.settings.color {
|
if let color = file.settings.color {
|
||||||
var mixedColor = UIColor(rgb: UInt32(bitPattern: color))
|
var mixedColor = UIColor(argb: color)
|
||||||
if let bottomColor = file.settings.bottomColor {
|
if let bottomColor = file.settings.bottomColor {
|
||||||
mixedColor = mixedColor.mixedWith(UIColor(rgb: UInt32(bitPattern: bottomColor)), alpha: 0.5)
|
mixedColor = mixedColor.mixedWith(UIColor(rgb: bottomColor), alpha: 0.5)
|
||||||
}
|
}
|
||||||
return .single(serviceColor(with: mixedColor))
|
return .single(serviceColor(with: mixedColor))
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,7 +42,7 @@ extension TelegramWallpaper: Codable {
|
|||||||
let optionKeys = ["motion", "blur"]
|
let optionKeys = ["motion", "blur"]
|
||||||
|
|
||||||
if value.count == 6, let color = UIColor(hexString: value) {
|
if value.count == 6, let color = UIColor(hexString: value) {
|
||||||
self = .color(Int32(bitPattern: color.rgb))
|
self = .color(color.argb)
|
||||||
} else {
|
} else {
|
||||||
let components = value.components(separatedBy: " ")
|
let components = value.components(separatedBy: " ")
|
||||||
var blur = false
|
var blur = false
|
||||||
@ -63,11 +63,11 @@ extension TelegramWallpaper: Codable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self = .gradient(Int32(bitPattern: topColor.rgb), Int32(bitPattern: bottomColor.rgb), WallpaperSettings(blur: blur, motion: motion, rotation: rotation))
|
self = .gradient(topColor.argb, bottomColor.argb, WallpaperSettings(blur: blur, motion: motion, rotation: rotation))
|
||||||
} else {
|
} else {
|
||||||
var slug: String?
|
var slug: String?
|
||||||
var color: Int32?
|
var color: UInt32?
|
||||||
var bottomColor: Int32?
|
var bottomColor: UInt32?
|
||||||
var intensity: Int32?
|
var intensity: Int32?
|
||||||
var rotation: Int32?
|
var rotation: Int32?
|
||||||
|
|
||||||
@ -82,9 +82,9 @@ extension TelegramWallpaper: Codable {
|
|||||||
}
|
}
|
||||||
if component.count == 6, let value = UIColor(hexString: component) {
|
if component.count == 6, let value = UIColor(hexString: component) {
|
||||||
if color == nil {
|
if color == nil {
|
||||||
color = Int32(bitPattern: value.rgb)
|
color = value.argb
|
||||||
} else if bottomColor == nil {
|
} else if bottomColor == nil {
|
||||||
bottomColor = Int32(bitPattern: value.rgb)
|
bottomColor = value.argb
|
||||||
}
|
}
|
||||||
} else if component.count <= 3, let value = Int32(component) {
|
} else if component.count <= 3, let value = Int32(component) {
|
||||||
if intensity == nil {
|
if intensity == nil {
|
||||||
|
@ -337,6 +337,9 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
|
|||||||
let tapAction = contentNode.tapActionAtPoint(CGPoint(x: point.x - contentNode.frame.minX, y: point.y - contentNode.frame.minY), gesture: .tap)
|
let tapAction = contentNode.tapActionAtPoint(CGPoint(x: point.x - contentNode.frame.minX, y: point.y - contentNode.frame.minY), gesture: .tap)
|
||||||
switch tapAction {
|
switch tapAction {
|
||||||
case .none:
|
case .none:
|
||||||
|
if let _ = strongSelf.item?.controllerInteraction.tapMessage {
|
||||||
|
return .waitForSingleTap
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case .ignore:
|
case .ignore:
|
||||||
return .fail
|
return .fail
|
||||||
|
@ -454,9 +454,9 @@ private func fetchCachedPatternWallpaperRepresentation(resource: MediaResource,
|
|||||||
|
|
||||||
var colors: [UIColor] = []
|
var colors: [UIColor] = []
|
||||||
if let bottomColor = representation.bottomColor {
|
if let bottomColor = representation.bottomColor {
|
||||||
colors.append(UIColor(rgb: UInt32(bitPattern: bottomColor)))
|
colors.append(UIColor(rgb: bottomColor))
|
||||||
}
|
}
|
||||||
colors.append(UIColor(rgb: UInt32(bitPattern: representation.color)))
|
colors.append(UIColor(rgb: representation.color))
|
||||||
|
|
||||||
let intensity = CGFloat(representation.intensity) / 100.0
|
let intensity = CGFloat(representation.intensity) / 100.0
|
||||||
|
|
||||||
|
@ -514,9 +514,9 @@ func openChatWallpaper(context: AccountContext, message: Message, present: @esca
|
|||||||
case let .slug(slug, options, firstColor, secondColor, intensity, rotation):
|
case let .slug(slug, options, firstColor, secondColor, intensity, rotation):
|
||||||
source = .slug(slug, content.file, options, firstColor, secondColor, intensity, rotation, message)
|
source = .slug(slug, content.file, options, firstColor, secondColor, intensity, rotation, message)
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
source = .wallpaper(.color(Int32(color.argb)), nil, nil, nil, nil, nil, message)
|
source = .wallpaper(.color(color.argb), nil, nil, nil, nil, nil, message)
|
||||||
case let .gradient(topColor, bottomColor, rotation):
|
case let .gradient(topColor, bottomColor, rotation):
|
||||||
source = .wallpaper(.gradient(Int32(topColor.argb), Int32(bottomColor.argb), WallpaperSettings(rotation: rotation)), nil, nil, nil, nil, rotation, message)
|
source = .wallpaper(.gradient(topColor.argb, bottomColor.argb, WallpaperSettings(rotation: rotation)), nil, nil, nil, nil, rotation, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
let controller = WallpaperGalleryController(context: context, source: source)
|
let controller = WallpaperGalleryController(context: context, source: source)
|
||||||
|
@ -264,9 +264,9 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
|
|||||||
controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
|
controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
|
||||||
present(controller!, nil)
|
present(controller!, nil)
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
signal = .single(.color(Int32(color.argb)))
|
signal = .single(.color(color.argb))
|
||||||
case let .gradient(topColor, bottomColor, rotation):
|
case let .gradient(topColor, bottomColor, rotation):
|
||||||
signal = .single(.gradient(Int32(topColor.argb), Int32(bottomColor.argb), WallpaperSettings()))
|
signal = .single(.gradient(topColor.argb, bottomColor.argb, WallpaperSettings()))
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = (signal
|
let _ = (signal
|
||||||
|
@ -1122,7 +1122,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||||||
controllerInteraction = defaultChatControllerInteraction
|
controllerInteraction = defaultChatControllerInteraction
|
||||||
}
|
}
|
||||||
|
|
||||||
return ChatMessageItem(presentationData: ChatPresentationData(theme: ChatPresentationThemeData(theme: theme, wallpaper: wallpaper), fontSize: fontSize, strings: strings, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameOrder, disableAnimations: false, largeEmoji: false, animatedEmojiScale: 1.0, isPreview: true), context: context, chatLocation: .peer(message.id.peerId), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .contact, automaticDownloadNetworkType: .cellular, isRecentActions: false, isScheduledMessages: false, contactsPeerIds: Set(), animatedEmojiStickers: [:], forcedResourceStatus: forcedResourceStatus), controllerInteraction: defaultChatControllerInteraction, content: .message(message: message, read: true, selection: .none, attributes: ChatMessageEntryAttributes()), disableDate: true, additionalContent: nil)
|
return ChatMessageItem(presentationData: ChatPresentationData(theme: ChatPresentationThemeData(theme: theme, wallpaper: wallpaper), fontSize: fontSize, strings: strings, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameOrder, disableAnimations: false, largeEmoji: false, animatedEmojiScale: 1.0, isPreview: true), context: context, chatLocation: .peer(message.id.peerId), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .contact, automaticDownloadNetworkType: .cellular, isRecentActions: false, isScheduledMessages: false, contactsPeerIds: Set(), animatedEmojiStickers: [:], forcedResourceStatus: forcedResourceStatus), controllerInteraction: controllerInteraction, content: .message(message: message, read: true, selection: .none, attributes: ChatMessageEntryAttributes()), disableDate: true, additionalContent: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func makeChatMessageDateHeaderItem(context: AccountContext, timestamp: Int32, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, dateTimeFormat: PresentationDateTimeFormat, nameOrder: PresentationPersonNameOrder) -> ListViewItemHeader {
|
public func makeChatMessageDateHeaderItem(context: AccountContext, timestamp: Int32, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, dateTimeFormat: PresentationDateTimeFormat, nameOrder: PresentationPersonNameOrder) -> ListViewItemHeader {
|
||||||
|
@ -759,10 +759,10 @@ public func drawThemeImage(context c: CGContext, theme: PresentationTheme, wallp
|
|||||||
c.draw(cgImage, in: CGRect(origin: CGPoint(x: (drawingRect.size.width - size.width) / 2.0, y: (drawingRect.size.height - size.height) / 2.0), size: size))
|
c.draw(cgImage, in: CGRect(origin: CGPoint(x: (drawingRect.size.width - size.width) / 2.0, y: (drawingRect.size.height - size.height) / 2.0), size: size))
|
||||||
}
|
}
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
c.setFillColor(UIColor(rgb: UInt32(bitPattern: color)).cgColor)
|
c.setFillColor(UIColor(rgb: color).cgColor)
|
||||||
c.fill(drawingRect)
|
c.fill(drawingRect)
|
||||||
case let .gradient(topColor, bottomColor, _):
|
case let .gradient(topColor, bottomColor, _):
|
||||||
let gradientColors = [UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor))].map { $0.cgColor } as CFArray
|
let gradientColors = [UIColor(rgb: topColor), UIColor(rgb: bottomColor)].map { $0.cgColor } as CFArray
|
||||||
var locations: [CGFloat] = [0.0, 1.0]
|
var locations: [CGFloat] = [0.0, 1.0]
|
||||||
let colorSpace = CGColorSpaceCreateDeviceRGB()
|
let colorSpace = CGColorSpaceCreateDeviceRGB()
|
||||||
let gradient = CGGradient(colorsSpace: colorSpace, colors: gradientColors, locations: &locations)!
|
let gradient = CGGradient(colorsSpace: colorSpace, colors: gradientColors, locations: &locations)!
|
||||||
@ -1091,8 +1091,8 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
|||||||
incomingColor = UIColor(rgb: 0xffffff)
|
incomingColor = UIColor(rgb: 0xffffff)
|
||||||
if let accentColor = accentColor {
|
if let accentColor = accentColor {
|
||||||
if let wallpaper = wallpaper, case let .file(file) = wallpaper {
|
if let wallpaper = wallpaper, case let .file(file) = wallpaper {
|
||||||
topBackgroundColor = file.settings.color.flatMap { UIColor(rgb: UInt32(bitPattern: $0)) } ?? UIColor(rgb: 0xd6e2ee)
|
topBackgroundColor = file.settings.color.flatMap { UIColor(rgb: $0) } ?? UIColor(rgb: 0xd6e2ee)
|
||||||
bottomBackgroundColor = file.settings.bottomColor.flatMap { UIColor(rgb: UInt32(bitPattern: $0)) }
|
bottomBackgroundColor = file.settings.bottomColor.flatMap { UIColor(rgb: $0) }
|
||||||
} else {
|
} else {
|
||||||
if let bubbleColors = bubbleColors {
|
if let bubbleColors = bubbleColors {
|
||||||
topBackgroundColor = UIColor(rgb: 0xd6e2ee)
|
topBackgroundColor = UIColor(rgb: 0xd6e2ee)
|
||||||
@ -1139,15 +1139,15 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
|||||||
if let wallpaper = wallpaper {
|
if let wallpaper = wallpaper {
|
||||||
switch wallpaper {
|
switch wallpaper {
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
topBackgroundColor = UIColor(rgb: UInt32(bitPattern: color))
|
topBackgroundColor = UIColor(rgb: color)
|
||||||
case let .gradient(topColor, bottomColor, settings):
|
case let .gradient(topColor, bottomColor, settings):
|
||||||
topBackgroundColor = UIColor(rgb: UInt32(bitPattern: topColor))
|
topBackgroundColor = UIColor(rgb: topColor)
|
||||||
bottomBackgroundColor = UIColor(rgb: UInt32(bitPattern: bottomColor))
|
bottomBackgroundColor = UIColor(rgb: bottomColor)
|
||||||
rotation = settings.rotation
|
rotation = settings.rotation
|
||||||
case let .file(file):
|
case let .file(file):
|
||||||
if let color = file.settings.color {
|
if let color = file.settings.color {
|
||||||
topBackgroundColor = UIColor(rgb: UInt32(bitPattern: color))
|
topBackgroundColor = UIColor(rgb: color)
|
||||||
bottomBackgroundColor = file.settings.bottomColor.flatMap { UIColor(rgb: UInt32(bitPattern: $0)) }
|
bottomBackgroundColor = file.settings.bottomColor.flatMap { UIColor(rgb: $0) }
|
||||||
}
|
}
|
||||||
rotation = file.settings.rotation
|
rotation = file.settings.rotation
|
||||||
default:
|
default:
|
||||||
@ -1199,16 +1199,16 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
|
|||||||
case .builtin:
|
case .builtin:
|
||||||
backgroundColor = (UIColor(rgb: 0xd6e2ee), nil)
|
backgroundColor = (UIColor(rgb: 0xd6e2ee), nil)
|
||||||
case let .color(color):
|
case let .color(color):
|
||||||
backgroundColor = (UIColor(rgb: UInt32(bitPattern: color)), nil)
|
backgroundColor = (UIColor(rgb: color), nil)
|
||||||
case let .gradient(topColor, bottomColor, settings):
|
case let .gradient(topColor, bottomColor, settings):
|
||||||
backgroundColor = (UIColor(rgb: UInt32(bitPattern: topColor)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
|
backgroundColor = (UIColor(rgb: topColor), UIColor(rgb: bottomColor))
|
||||||
rotation = settings.rotation
|
rotation = settings.rotation
|
||||||
case .image:
|
case .image:
|
||||||
backgroundColor = (.black, nil)
|
backgroundColor = (.black, nil)
|
||||||
case let .file(file):
|
case let .file(file):
|
||||||
rotation = file.settings.rotation
|
rotation = file.settings.rotation
|
||||||
if file.isPattern, let color = file.settings.color {
|
if file.isPattern, let color = file.settings.color {
|
||||||
backgroundColor = (UIColor(rgb: UInt32(bitPattern: color)), file.settings.bottomColor.flatMap { UIColor(rgb: UInt32(bitPattern: $0)) })
|
backgroundColor = (UIColor(rgb: color), file.settings.bottomColor.flatMap { UIColor(rgb: $0) })
|
||||||
} else {
|
} else {
|
||||||
backgroundColor = (theme.chatList.backgroundColor, nil)
|
backgroundColor = (theme.chatList.backgroundColor, nil)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user