mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Merge branch 'master' into experimental-2
This commit is contained in:
@@ -407,13 +407,13 @@ public enum PresentationThemeBaseColor: Int32, CaseIterable {
|
||||
|
||||
public struct PresentationThemeAccentColor: PostboxCoding, Equatable {
|
||||
public static func == (lhs: PresentationThemeAccentColor, rhs: PresentationThemeAccentColor) -> Bool {
|
||||
return lhs.index == rhs.index && lhs.baseColor == rhs.baseColor && lhs.accentColor == rhs.accentColor && lhs.bubbleColors?.0 == rhs.bubbleColors?.0 && lhs.bubbleColors?.1 == rhs.bubbleColors?.1
|
||||
return lhs.index == rhs.index && lhs.baseColor == rhs.baseColor && lhs.accentColor == rhs.accentColor && lhs.bubbleColors == rhs.bubbleColors
|
||||
}
|
||||
|
||||
public var index: Int32
|
||||
public var baseColor: PresentationThemeBaseColor
|
||||
public var accentColor: UInt32?
|
||||
public var bubbleColors: (UInt32, UInt32?)?
|
||||
public var bubbleColors: [UInt32]
|
||||
public var wallpaper: TelegramWallpaper?
|
||||
public var themeIndex: Int64?
|
||||
|
||||
@@ -425,11 +425,11 @@ public struct PresentationThemeAccentColor: PostboxCoding, Equatable {
|
||||
}
|
||||
self.baseColor = baseColor
|
||||
self.accentColor = nil
|
||||
self.bubbleColors = nil
|
||||
self.bubbleColors = []
|
||||
self.wallpaper = nil
|
||||
}
|
||||
|
||||
public init(index: Int32, baseColor: PresentationThemeBaseColor, accentColor: UInt32? = nil, bubbleColors: (UInt32, UInt32?)? = nil, wallpaper: TelegramWallpaper? = nil) {
|
||||
public init(index: Int32, baseColor: PresentationThemeBaseColor, accentColor: UInt32? = nil, bubbleColors: [UInt32] = [], wallpaper: TelegramWallpaper? = nil) {
|
||||
self.index = index
|
||||
self.baseColor = baseColor
|
||||
self.accentColor = accentColor
|
||||
@@ -441,7 +441,7 @@ public struct PresentationThemeAccentColor: PostboxCoding, Equatable {
|
||||
self.index = -1
|
||||
self.baseColor = .theme
|
||||
self.accentColor = nil
|
||||
self.bubbleColors = nil
|
||||
self.bubbleColors = []
|
||||
self.wallpaper = nil
|
||||
self.themeIndex = themeIndex
|
||||
}
|
||||
@@ -450,15 +450,22 @@ public struct PresentationThemeAccentColor: PostboxCoding, Equatable {
|
||||
self.index = decoder.decodeInt32ForKey("i", orElse: -1)
|
||||
self.baseColor = PresentationThemeBaseColor(rawValue: decoder.decodeInt32ForKey("b", orElse: 0)) ?? .blue
|
||||
self.accentColor = decoder.decodeOptionalInt32ForKey("c").flatMap { UInt32(bitPattern: $0) }
|
||||
if let bubbleTopColor = decoder.decodeOptionalInt32ForKey("bt") {
|
||||
if let bubbleBottomColor = decoder.decodeOptionalInt32ForKey("bb") {
|
||||
self.bubbleColors = (UInt32(bitPattern: bubbleTopColor), UInt32(bitPattern: bubbleBottomColor))
|
||||
} else {
|
||||
self.bubbleColors = (UInt32(bitPattern: bubbleTopColor), nil)
|
||||
}
|
||||
|
||||
let bubbleColors = decoder.decodeInt32ArrayForKey("bubbleColors")
|
||||
if !bubbleColors.isEmpty {
|
||||
self.bubbleColors = bubbleColors.map(UInt32.init(bitPattern:))
|
||||
} else {
|
||||
self.bubbleColors = nil
|
||||
if let bubbleTopColor = decoder.decodeOptionalInt32ForKey("bt") {
|
||||
if let bubbleBottomColor = decoder.decodeOptionalInt32ForKey("bb") {
|
||||
self.bubbleColors = [UInt32(bitPattern: bubbleTopColor), UInt32(bitPattern: bubbleBottomColor)]
|
||||
} else {
|
||||
self.bubbleColors = [UInt32(bitPattern: bubbleTopColor)]
|
||||
}
|
||||
} else {
|
||||
self.bubbleColors = []
|
||||
}
|
||||
}
|
||||
|
||||
self.wallpaper = decoder.decodeObjectForKey("w", decoder: { TelegramWallpaper(decoder: $0) }) as? TelegramWallpaper
|
||||
self.themeIndex = decoder.decodeOptionalInt64ForKey("t")
|
||||
}
|
||||
@@ -471,17 +478,7 @@ public struct PresentationThemeAccentColor: PostboxCoding, Equatable {
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "c")
|
||||
}
|
||||
if let bubbleColors = self.bubbleColors {
|
||||
encoder.encodeInt32(Int32(bitPattern: bubbleColors.0), forKey: "bt")
|
||||
if let bubbleBottomColor = bubbleColors.1 {
|
||||
encoder.encodeInt32(Int32(bitPattern: bubbleBottomColor), forKey: "bb")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "bb")
|
||||
}
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "bt")
|
||||
encoder.encodeNil(forKey: "bb")
|
||||
}
|
||||
encoder.encodeInt32Array(self.bubbleColors.map(Int32.init(bitPattern:)), forKey: "bubbleColors")
|
||||
if let wallpaper = self.wallpaper {
|
||||
encoder.encodeObject(wallpaper, forKey: "w")
|
||||
} else {
|
||||
@@ -502,28 +499,12 @@ public struct PresentationThemeAccentColor: PostboxCoding, Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
public var customBubbleColors: (UIColor, UIColor?)? {
|
||||
if let bubbleColors = self.bubbleColors {
|
||||
if let bottomColor = bubbleColors.1 {
|
||||
return (UIColor(rgb: UInt32(bitPattern: bubbleColors.0)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
|
||||
} else {
|
||||
return (UIColor(rgb: UInt32(bitPattern: bubbleColors.0)), nil)
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
public var customBubbleColors: [UInt32] {
|
||||
return self.bubbleColors
|
||||
}
|
||||
|
||||
public var plainBubbleColors: (UIColor, UIColor)? {
|
||||
if let bubbleColors = self.bubbleColors {
|
||||
if let bottomColor = bubbleColors.1 {
|
||||
return (UIColor(rgb: UInt32(bitPattern: bubbleColors.0)), UIColor(rgb: UInt32(bitPattern: bottomColor)))
|
||||
} else {
|
||||
return (UIColor(rgb: UInt32(bitPattern: bubbleColors.0)), UIColor(rgb: UInt32(bitPattern: bubbleColors.0)))
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
public var plainBubbleColors: [UInt32] {
|
||||
return self.bubbleColors
|
||||
}
|
||||
|
||||
public func withUpdatedWallpaper(_ wallpaper: TelegramWallpaper?) -> PresentationThemeAccentColor {
|
||||
@@ -712,7 +693,7 @@ public struct PresentationThemeSettings: PreferencesEntry {
|
||||
}
|
||||
}
|
||||
|
||||
public func updatePresentationThemeSettingsInteractively(accountManager: AccountManager, _ f: @escaping (PresentationThemeSettings) -> PresentationThemeSettings) -> Signal<Void, NoError> {
|
||||
public func updatePresentationThemeSettingsInteractively(accountManager: AccountManager<TelegramAccountManagerTypes>, _ f: @escaping (PresentationThemeSettings) -> PresentationThemeSettings) -> Signal<Void, NoError> {
|
||||
return accountManager.transaction { transaction -> Void in
|
||||
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.presentationThemeSettings, { entry in
|
||||
let currentSettings: PresentationThemeSettings
|
||||
|
||||
Reference in New Issue
Block a user