mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-04 10:30:42 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
a305289f29
@ -32,6 +32,45 @@ private func interpolatePoints(_ point1: CGPoint, _ point2: CGPoint, at factor:
|
|||||||
return CGPoint(x: interpolateFloat(point1.x, point2.x, at: factor), y: interpolateFloat(point1.y, point2.y, at: factor))
|
return CGPoint(x: interpolateFloat(point1.x, point2.x, at: factor), y: interpolateFloat(point1.y, point2.y, at: factor))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func adjustSaturationInContext(context: DrawingContext, saturation: CGFloat) {
|
||||||
|
var buffer = vImage_Buffer()
|
||||||
|
buffer.data = context.bytes
|
||||||
|
buffer.width = UInt(context.size.width * context.scale)
|
||||||
|
buffer.height = UInt(context.size.height * context.scale)
|
||||||
|
buffer.rowBytes = context.bytesPerRow
|
||||||
|
|
||||||
|
let divisor: Int32 = 0x1000
|
||||||
|
|
||||||
|
let rwgt: CGFloat = 0.3086
|
||||||
|
let gwgt: CGFloat = 0.6094
|
||||||
|
let bwgt: CGFloat = 0.0820
|
||||||
|
|
||||||
|
let adjustSaturation = saturation
|
||||||
|
|
||||||
|
let a = (1.0 - adjustSaturation) * rwgt + adjustSaturation
|
||||||
|
let b = (1.0 - adjustSaturation) * rwgt
|
||||||
|
let c = (1.0 - adjustSaturation) * rwgt
|
||||||
|
let d = (1.0 - adjustSaturation) * gwgt
|
||||||
|
let e = (1.0 - adjustSaturation) * gwgt + adjustSaturation
|
||||||
|
let f = (1.0 - adjustSaturation) * gwgt
|
||||||
|
let g = (1.0 - adjustSaturation) * bwgt
|
||||||
|
let h = (1.0 - adjustSaturation) * bwgt
|
||||||
|
let i = (1.0 - adjustSaturation) * bwgt + adjustSaturation
|
||||||
|
|
||||||
|
let satMatrix: [CGFloat] = [
|
||||||
|
a, b, c, 0,
|
||||||
|
d, e, f, 0,
|
||||||
|
g, h, i, 0,
|
||||||
|
0, 0, 0, 1
|
||||||
|
]
|
||||||
|
|
||||||
|
var matrix: [Int16] = satMatrix.map { value in
|
||||||
|
return Int16(value * CGFloat(divisor))
|
||||||
|
}
|
||||||
|
|
||||||
|
vImageMatrixMultiply_ARGB8888(&buffer, &buffer, &matrix, divisor, nil, nil, vImage_Flags(kvImageDoNotTile))
|
||||||
|
}
|
||||||
|
|
||||||
private func generateGradient(size: CGSize, colors: [UIColor], positions: [CGPoint], adjustSaturation: CGFloat = 1.0) -> UIImage {
|
private func generateGradient(size: CGSize, colors: [UIColor], positions: [CGPoint], adjustSaturation: CGFloat = 1.0) -> UIImage {
|
||||||
let width = Int(size.width)
|
let width = Int(size.width)
|
||||||
let height = Int(size.height)
|
let height = Int(size.height)
|
||||||
@ -116,40 +155,7 @@ private func generateGradient(size: CGSize, colors: [UIColor], positions: [CGPoi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if abs(adjustSaturation - 1.0) > .ulpOfOne {
|
if abs(adjustSaturation - 1.0) > .ulpOfOne {
|
||||||
var buffer = vImage_Buffer()
|
adjustSaturationInContext(context: context, saturation: adjustSaturation)
|
||||||
buffer.data = context.bytes
|
|
||||||
buffer.width = UInt(width)
|
|
||||||
buffer.height = UInt(height)
|
|
||||||
buffer.rowBytes = context.bytesPerRow
|
|
||||||
|
|
||||||
let divisor: Int32 = 0x1000
|
|
||||||
|
|
||||||
let rwgt: CGFloat = 0.3086
|
|
||||||
let gwgt: CGFloat = 0.6094
|
|
||||||
let bwgt: CGFloat = 0.0820
|
|
||||||
|
|
||||||
let a = (1.0 - adjustSaturation) * rwgt + adjustSaturation
|
|
||||||
let b = (1.0 - adjustSaturation) * rwgt
|
|
||||||
let c = (1.0 - adjustSaturation) * rwgt
|
|
||||||
let d = (1.0 - adjustSaturation) * gwgt
|
|
||||||
let e = (1.0 - adjustSaturation) * gwgt + adjustSaturation
|
|
||||||
let f = (1.0 - adjustSaturation) * gwgt
|
|
||||||
let g = (1.0 - adjustSaturation) * bwgt
|
|
||||||
let h = (1.0 - adjustSaturation) * bwgt
|
|
||||||
let i = (1.0 - adjustSaturation) * bwgt + adjustSaturation
|
|
||||||
|
|
||||||
let satMatrix: [CGFloat] = [
|
|
||||||
a, b, c, 0,
|
|
||||||
d, e, f, 0,
|
|
||||||
g, h, i, 0,
|
|
||||||
0, 0, 0, 1
|
|
||||||
]
|
|
||||||
|
|
||||||
var matrix: [Int16] = satMatrix.map { value in
|
|
||||||
return Int16(value * CGFloat(divisor))
|
|
||||||
}
|
|
||||||
|
|
||||||
vImageMatrixMultiply_ARGB8888(&buffer, &buffer, &matrix, divisor, nil, nil, vImage_Flags(kvImageDoNotTile))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.generateImage()!
|
return context.generateImage()!
|
||||||
|
@ -247,7 +247,7 @@ final class ThemeAccentColorController: ViewController {
|
|||||||
baseTheme = .classic
|
baseTheme = .classic
|
||||||
}
|
}
|
||||||
|
|
||||||
let wallpaper = state.initialWallpaper ?? coloredWallpaper
|
let wallpaper = coloredWallpaper ?? state.initialWallpaper
|
||||||
|
|
||||||
let settings = TelegramThemeSettings(baseTheme: baseTheme, accentColor: state.accentColor, messageColors: state.messagesColors, wallpaper: wallpaper)
|
let settings = TelegramThemeSettings(baseTheme: baseTheme, accentColor: state.accentColor, messageColors: state.messagesColors, wallpaper: wallpaper)
|
||||||
let baseThemeReference = PresentationThemeReference.builtin(PresentationBuiltinThemeReference(baseTheme: baseTheme))
|
let baseThemeReference = PresentationThemeReference.builtin(PresentationBuiltinThemeReference(baseTheme: baseTheme))
|
||||||
|
@ -620,6 +620,12 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
|||||||
|
|
||||||
let colorPanelCollapsed = self.state.colorPanelCollapsed
|
let colorPanelCollapsed = self.state.colorPanelCollapsed
|
||||||
|
|
||||||
|
if colorPanelCollapsed != previousState.colorPanelCollapsed {
|
||||||
|
Queue.mainQueue().justDispatch {
|
||||||
|
self.colorPanelNode.view.endEditing(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (previousState.patternWallpaper != nil) != (self.state.patternWallpaper != nil) {
|
if (previousState.patternWallpaper != nil) != (self.state.patternWallpaper != nil) {
|
||||||
self.patternButtonNode.setSelected(self.state.patternWallpaper != nil, animated: animated)
|
self.patternButtonNode.setSelected(self.state.patternWallpaper != nil, animated: animated)
|
||||||
}
|
}
|
||||||
|
@ -250,14 +250,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
let signal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>
|
let signal: Signal<(TransformImageArguments) -> DrawingContext?, NoError>
|
||||||
let fileReference = FileMediaReference.standalone(media: file.file)
|
let fileReference = FileMediaReference.standalone(media: file.file)
|
||||||
if wallpaper.isPattern {
|
if wallpaper.isPattern {
|
||||||
signal = patternWallpaperImage(account: context.account, accountManager: context.sharedContext.accountManager, representations: convertedRepresentations, mode: .screen, autoFetchFullSize: false)
|
signal = .complete()
|
||||||
|> mapToSignal { value -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> in
|
|
||||||
if let value = value {
|
|
||||||
return .single(value)
|
|
||||||
} else {
|
|
||||||
return .complete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
signal = .complete()
|
signal = .complete()
|
||||||
}
|
}
|
||||||
|
@ -844,7 +844,14 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
|
|||||||
if let accentColor = accentColor, case let .theme(themeReference) = accentColor {
|
if let accentColor = accentColor, case let .theme(themeReference) = accentColor {
|
||||||
theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference)
|
theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference)
|
||||||
} else {
|
} else {
|
||||||
theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: generalThemeReference, accentColor: accentColor?.accentColor, bubbleColors: accentColor?.customBubbleColors, wallpaper: accentColor?.wallpaper)
|
var wallpaperGradientColors: [UInt32]?
|
||||||
|
switch accentColor {
|
||||||
|
case let .accentColor(value):
|
||||||
|
wallpaperGradientColors = value.baseColor.wallpaperGradientColors
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: generalThemeReference, accentColor: accentColor?.accentColor, bubbleColors: accentColor?.customBubbleColors, wallpaper: accentColor?.wallpaper, wallpaperGradientColors: wallpaperGradientColors)
|
||||||
}
|
}
|
||||||
effectiveWallpaper = theme?.chat.defaultWallpaper ?? .builtin(WallpaperSettings())
|
effectiveWallpaper = theme?.chat.defaultWallpaper ?? .builtin(WallpaperSettings())
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import TelegramPresentationData
|
|||||||
import LegacyComponents
|
import LegacyComponents
|
||||||
import AccountContext
|
import AccountContext
|
||||||
import MergeLists
|
import MergeLists
|
||||||
|
import Postbox
|
||||||
|
|
||||||
private let itemSize = CGSize(width: 88.0, height: 88.0)
|
private let itemSize = CGSize(width: 88.0, height: 88.0)
|
||||||
private let inset: CGFloat = 12.0
|
private let inset: CGFloat = 12.0
|
||||||
@ -267,12 +268,21 @@ final class WallpaperPatternPanelNode: ASDisplayNode {
|
|||||||
|
|
||||||
self.addSubnode(self.titleNode)
|
self.addSubnode(self.titleNode)
|
||||||
self.addSubnode(self.labelNode)
|
self.addSubnode(self.labelNode)
|
||||||
|
|
||||||
self.disposable = ((telegramWallpapers(postbox: context.account.postbox, network: context.account.network)
|
self.disposable = ((telegramWallpapers(postbox: context.account.postbox, network: context.account.network)
|
||||||
|> map { wallpapers in
|
|> map { wallpapers -> [TelegramWallpaper] in
|
||||||
|
var existingIds = Set<MediaId>()
|
||||||
|
|
||||||
return wallpapers.filter { wallpaper in
|
return wallpapers.filter { wallpaper in
|
||||||
if case let .file(file) = wallpaper, wallpaper.isPattern, file.file.mimeType != "image/webp" {
|
if case let .file(file) = wallpaper, wallpaper.isPattern, file.file.mimeType != "image/webp" {
|
||||||
|
if file.id == 0 {
|
||||||
return true
|
return true
|
||||||
|
}
|
||||||
|
if existingIds.contains(file.file.fileId) {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
existingIds.insert(file.file.fileId)
|
||||||
|
return true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -4930,7 +4930,7 @@ public final class VoiceChatController: ViewController {
|
|||||||
requestedVideoChannels.append(videoChannel)
|
requestedVideoChannels.append(videoChannel)
|
||||||
}
|
}
|
||||||
if member.peer.id != self.callState?.myPeerId {
|
if member.peer.id != self.callState?.myPeerId {
|
||||||
if var presentationChannel = member.requestedPresentationVideoChannel(minQuality: .thumbnail, maxQuality: .medium) {
|
if var presentationChannel = member.requestedPresentationVideoChannel(minQuality: .thumbnail, maxQuality: .thumbnail) {
|
||||||
if self.effectiveSpeaker?.1 == presentationChannel.endpointId {
|
if self.effectiveSpeaker?.1 == presentationChannel.endpointId {
|
||||||
presentationChannel.minQuality = .full
|
presentationChannel.minQuality = .full
|
||||||
presentationChannel.maxQuality = .full
|
presentationChannel.maxQuality = .full
|
||||||
|
@ -405,9 +405,11 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
|
|||||||
onlineDotColor: UIColor(rgb: 0x4cc91f)
|
onlineDotColor: UIColor(rgb: 0x4cc91f)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let incomingBubbleAlpha: CGFloat = 0.9
|
||||||
|
|
||||||
let message = PresentationThemeChatMessage(
|
let message = PresentationThemeChatMessage(
|
||||||
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1D1D1D, alpha: 0.9), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1D1D1D, alpha: 0.9), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628), shadow: nil)), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), accentControlDisabledColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.4), mediaControlInnerBackgroundColor: UIColor(rgb: 0x262628), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff, alpha: 0.12), separator: UIColor(rgb: 0x000000), bar: UIColor(rgb: 0xffffff), barIconForeground: .clear, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)),
|
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1D1D1D, alpha: incomingBubbleAlpha), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1D1D1D, alpha: incomingBubbleAlpha), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628), shadow: nil)), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), accentControlDisabledColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.4), mediaControlInnerBackgroundColor: UIColor(rgb: 0x262628), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff, alpha: 0.12), separator: UIColor(rgb: 0x000000), bar: UIColor(rgb: 0xffffff), barIconForeground: .clear, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)),
|
||||||
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x313131), gradientFill: UIColor(rgb: 0x313131), highlightedFill: UIColor(rgb: 0x464646), stroke: UIColor(rgb: 0x313131), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x313131), gradientFill: UIColor(rgb: 0x313131), highlightedFill: UIColor(rgb: 0x464646), stroke: UIColor(rgb: 0x313131), shadow: nil)), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), accentControlDisabledColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaControlInnerBackgroundColor: UIColor(rgb: 0x313131), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xffffff), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff).withAlphaComponent(0.12), separator: UIColor(rgb: 0xffffff, alpha: 0.5), bar: UIColor(rgb: 0xffffff), barIconForeground: .clear, barPositive: UIColor(rgb: 0xffffff), barNegative: UIColor(rgb: 0xffffff)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)),
|
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x61BCF9), gradientFill: UIColor(rgb: 0x007AFF), highlightedFill: UIColor(rgb: 0x61BCF9), stroke: .clear, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x61BCF9), gradientFill: UIColor(rgb: 0x007AFF), highlightedFill: UIColor(rgb: 0x61BCF9), stroke: .clear, shadow: nil)), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), accentControlDisabledColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaControlInnerBackgroundColor: UIColor(rgb: 0x313131), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xffffff), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff).withAlphaComponent(0.12), separator: UIColor(rgb: 0xffffff, alpha: 0.5), bar: UIColor(rgb: 0xffffff), barIconForeground: .clear, barPositive: UIColor(rgb: 0xffffff), barNegative: UIColor(rgb: 0xffffff)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)),
|
||||||
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f), shadow: nil)),
|
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f), shadow: nil)),
|
||||||
infoPrimaryTextColor: UIColor(rgb: 0xffffff),
|
infoPrimaryTextColor: UIColor(rgb: 0xffffff),
|
||||||
infoLinkTextColor: UIColor(rgb: 0xffffff),
|
infoLinkTextColor: UIColor(rgb: 0xffffff),
|
||||||
|
@ -92,7 +92,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
|||||||
passcode = passcode.withUpdated(backgroundColors: passcode.backgroundColors.withUpdated(topColor: accentColor?.withMultiplied(hue: 1.049, saturation: 0.573, brightness: 0.47), bottomColor: additionalBackgroundColor), buttonColor: mainBackgroundColor)
|
passcode = passcode.withUpdated(backgroundColors: passcode.backgroundColors.withUpdated(topColor: accentColor?.withMultiplied(hue: 1.049, saturation: 0.573, brightness: 0.47), bottomColor: additionalBackgroundColor), buttonColor: mainBackgroundColor)
|
||||||
rootController = rootController.withUpdated(
|
rootController = rootController.withUpdated(
|
||||||
tabBar: rootController.tabBar.withUpdated(
|
tabBar: rootController.tabBar.withUpdated(
|
||||||
backgroundColor: mainBackgroundColor,
|
backgroundColor: mainBackgroundColor?.withAlphaComponent(0.9),
|
||||||
separatorColor: mainSeparatorColor,
|
separatorColor: mainSeparatorColor,
|
||||||
iconColor: mainForegroundColor,
|
iconColor: mainForegroundColor,
|
||||||
selectedIconColor: accentColor,
|
selectedIconColor: accentColor,
|
||||||
@ -105,7 +105,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
|||||||
secondaryTextColor: mainSecondaryColor,
|
secondaryTextColor: mainSecondaryColor,
|
||||||
controlColor: mainSecondaryColor,
|
controlColor: mainSecondaryColor,
|
||||||
accentTextColor: accentColor,
|
accentTextColor: accentColor,
|
||||||
blurredBackgroundColor: mainBackgroundColor,
|
blurredBackgroundColor: mainBackgroundColor?.withAlphaComponent(0.9),
|
||||||
opaqueBackgroundColor: mainBackgroundColor,
|
opaqueBackgroundColor: mainBackgroundColor,
|
||||||
separatorColor: mainSeparatorColor,
|
separatorColor: mainSeparatorColor,
|
||||||
segmentedBackgroundColor: mainInputColor,
|
segmentedBackgroundColor: mainInputColor,
|
||||||
@ -271,20 +271,22 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
|||||||
highlightedOutgoingBubbleColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.019, saturation: 0.609, brightness: 0.63)
|
highlightedOutgoingBubbleColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.019, saturation: 0.609, brightness: 0.63)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let incomingFillColor = mainBackgroundColor?.withMultipliedAlpha(0.9)
|
||||||
|
|
||||||
chat = chat.withUpdated(
|
chat = chat.withUpdated(
|
||||||
defaultWallpaper: defaultWallpaper,
|
defaultWallpaper: defaultWallpaper,
|
||||||
message: chat.message.withUpdated(
|
message: chat.message.withUpdated(
|
||||||
incoming: chat.message.incoming.withUpdated(
|
incoming: chat.message.incoming.withUpdated(
|
||||||
bubble: chat.message.incoming.bubble.withUpdated(
|
bubble: chat.message.incoming.bubble.withUpdated(
|
||||||
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
|
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
|
||||||
fill: mainBackgroundColor,
|
fill: incomingFillColor,
|
||||||
gradientFill: mainBackgroundColor,
|
gradientFill: incomingFillColor,
|
||||||
highlightedFill: highlightedIncomingBubbleColor,
|
highlightedFill: highlightedIncomingBubbleColor,
|
||||||
stroke: mainBackgroundColor
|
stroke: mainBackgroundColor
|
||||||
),
|
),
|
||||||
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
|
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
|
||||||
fill: mainBackgroundColor,
|
fill: incomingFillColor,
|
||||||
gradientFill: mainBackgroundColor,
|
gradientFill: incomingFillColor,
|
||||||
highlightedFill: highlightedIncomingBubbleColor,
|
highlightedFill: highlightedIncomingBubbleColor,
|
||||||
stroke: mainBackgroundColor
|
stroke: mainBackgroundColor
|
||||||
)
|
)
|
||||||
@ -385,7 +387,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
|||||||
unreadBarStrokeColor: mainBackgroundColor
|
unreadBarStrokeColor: mainBackgroundColor
|
||||||
),
|
),
|
||||||
inputPanel: chat.inputPanel.withUpdated(
|
inputPanel: chat.inputPanel.withUpdated(
|
||||||
panelBackgroundColor: mainBackgroundColor,
|
panelBackgroundColor: mainBackgroundColor?.withAlphaComponent(0.9),
|
||||||
panelSeparatorColor: mainSeparatorColor,
|
panelSeparatorColor: mainSeparatorColor,
|
||||||
panelControlAccentColor: accentColor,
|
panelControlAccentColor: accentColor,
|
||||||
panelControlColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
|
panelControlColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
|
||||||
@ -420,7 +422,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
|||||||
buttonHighlightedStrokeColor: accentColor?.withMultiplied(hue: 1.019, saturation: 0.39, brightness: 0.07)
|
buttonHighlightedStrokeColor: accentColor?.withMultiplied(hue: 1.019, saturation: 0.39, brightness: 0.07)
|
||||||
),
|
),
|
||||||
historyNavigation: chat.historyNavigation.withUpdated(
|
historyNavigation: chat.historyNavigation.withUpdated(
|
||||||
fillColor: mainBackgroundColor,
|
fillColor: mainBackgroundColor?.withAlphaComponent(0.9),
|
||||||
strokeColor: mainSeparatorColor,
|
strokeColor: mainSeparatorColor,
|
||||||
foregroundColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
|
foregroundColor: mainSecondaryTextColor?.withAlphaComponent(0.5),
|
||||||
badgeBackgroundColor: accentColor,
|
badgeBackgroundColor: accentColor,
|
||||||
@ -509,7 +511,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
|
|||||||
secondaryTextColor: mainSecondaryColor,
|
secondaryTextColor: mainSecondaryColor,
|
||||||
controlColor: mainSecondaryColor,
|
controlColor: mainSecondaryColor,
|
||||||
accentTextColor: accentColor,
|
accentTextColor: accentColor,
|
||||||
blurredBackgroundColor: mainBackgroundColor,
|
blurredBackgroundColor: mainBackgroundColor.withAlphaComponent(0.9),
|
||||||
opaqueBackgroundColor: mainBackgroundColor,
|
opaqueBackgroundColor: mainBackgroundColor,
|
||||||
separatorColor: mainSeparatorColor,
|
separatorColor: mainSeparatorColor,
|
||||||
badgeBackgroundColor: UIColor(rgb: 0xef5b5b),
|
badgeBackgroundColor: UIColor(rgb: 0xef5b5b),
|
||||||
@ -665,9 +667,10 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
|
|||||||
)
|
)
|
||||||
|
|
||||||
let buttonStrokeColor = accentColor.withMultiplied(hue: 1.014, saturation: 0.56, brightness: 0.64).withAlphaComponent(0.15)
|
let buttonStrokeColor = accentColor.withMultiplied(hue: 1.014, saturation: 0.56, brightness: 0.64).withAlphaComponent(0.15)
|
||||||
|
let incomingFillColor = mainBackgroundColor.withMultipliedAlpha(0.9)
|
||||||
|
|
||||||
let message = PresentationThemeChatMessage(
|
let message = PresentationThemeChatMessage(
|
||||||
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil)), primaryTextColor: .white, secondaryTextColor: mainSecondaryTextColor.withAlphaComponent(0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: UIColor(rgb: 0xff6767), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: accentColor, accentControlColor: accentColor, accentControlDisabledColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.5), mediaControlInnerBackgroundColor: mainBackgroundColor, pendingActivityColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileTitleColor: accentColor, fileDescriptionColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileDurationColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23), polls: PresentationThemeChatBubblePolls(radioButton: accentColor.withMultiplied(hue: 0.995, saturation: 0.317, brightness: 0.51), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: mainSeparatorColor, bar: accentColor, barIconForeground: .white, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: accentColor.withAlphaComponent(0.2), textSelectionKnobColor: accentColor),
|
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: incomingFillColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: incomingFillColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil)), primaryTextColor: .white, secondaryTextColor: mainSecondaryTextColor.withAlphaComponent(0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: UIColor(rgb: 0xff6767), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: accentColor, accentControlColor: accentColor, accentControlDisabledColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.5), mediaControlInnerBackgroundColor: mainBackgroundColor, pendingActivityColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileTitleColor: accentColor, fileDescriptionColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileDurationColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23), polls: PresentationThemeChatBubblePolls(radioButton: accentColor.withMultiplied(hue: 0.995, saturation: 0.317, brightness: 0.51), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: mainSeparatorColor, bar: accentColor, barIconForeground: .white, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: accentColor.withAlphaComponent(0.2), textSelectionKnobColor: accentColor),
|
||||||
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: highlightedOutgoingBubbleColor, stroke: outgoingBubbleFillColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: highlightedOutgoingBubbleColor, stroke: outgoingBubbleFillColor, shadow: nil)), primaryTextColor: outgoingPrimaryTextColor, secondaryTextColor: outgoingSecondaryTextColor, linkTextColor: outgoingLinkTextColor, linkHighlightColor: UIColor.white.withAlphaComponent(0.5), scamColor: outgoingScamColor, textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: outgoingPrimaryTextColor, accentControlColor: outgoingPrimaryTextColor, accentControlDisabledColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaActiveControlColor: outgoingPrimaryTextColor, mediaInactiveControlColor: outgoingSecondaryTextColor, mediaControlInnerBackgroundColor: outgoingBubbleFillColor, pendingActivityColor: outgoingSecondaryTextColor, fileTitleColor: outgoingPrimaryTextColor, fileDescriptionColor: outgoingSecondaryTextColor, fileDurationColor: outgoingSecondaryTextColor, mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.804, brightness: 0.51), polls: PresentationThemeChatBubblePolls(radioButton: outgoingPrimaryTextColor, radioProgress: accentColor.withMultiplied(hue: 0.99, saturation: 0.56, brightness: 1.0), highlight: accentColor.withMultiplied(hue: 0.99, saturation: 0.56, brightness: 1.0).withAlphaComponent(0.12), separator: mainSeparatorColor, bar: outgoingPrimaryTextColor, barIconForeground: .clear, barPositive: outgoingPrimaryTextColor, barNegative: outgoingPrimaryTextColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: UIColor.white.withAlphaComponent(0.2), textSelectionKnobColor: UIColor.white),
|
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: highlightedOutgoingBubbleColor, stroke: outgoingBubbleFillColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: highlightedOutgoingBubbleColor, stroke: outgoingBubbleFillColor, shadow: nil)), primaryTextColor: outgoingPrimaryTextColor, secondaryTextColor: outgoingSecondaryTextColor, linkTextColor: outgoingLinkTextColor, linkHighlightColor: UIColor.white.withAlphaComponent(0.5), scamColor: outgoingScamColor, textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: outgoingPrimaryTextColor, accentControlColor: outgoingPrimaryTextColor, accentControlDisabledColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaActiveControlColor: outgoingPrimaryTextColor, mediaInactiveControlColor: outgoingSecondaryTextColor, mediaControlInnerBackgroundColor: outgoingBubbleFillColor, pendingActivityColor: outgoingSecondaryTextColor, fileTitleColor: outgoingPrimaryTextColor, fileDescriptionColor: outgoingSecondaryTextColor, fileDurationColor: outgoingSecondaryTextColor, mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.804, brightness: 0.51), polls: PresentationThemeChatBubblePolls(radioButton: outgoingPrimaryTextColor, radioProgress: accentColor.withMultiplied(hue: 0.99, saturation: 0.56, brightness: 1.0), highlight: accentColor.withMultiplied(hue: 0.99, saturation: 0.56, brightness: 1.0).withAlphaComponent(0.12), separator: mainSeparatorColor, bar: outgoingPrimaryTextColor, barIconForeground: .clear, barPositive: outgoingPrimaryTextColor, barNegative: outgoingPrimaryTextColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: UIColor.white.withAlphaComponent(0.2), textSelectionKnobColor: UIColor.white),
|
||||||
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil)),
|
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil)),
|
||||||
infoPrimaryTextColor: UIColor(rgb: 0xffffff),
|
infoPrimaryTextColor: UIColor(rgb: 0xffffff),
|
||||||
@ -754,7 +757,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
|
|||||||
)
|
)
|
||||||
|
|
||||||
let chat = PresentationThemeChat(
|
let chat = PresentationThemeChat(
|
||||||
defaultWallpaper: .color(accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18).argb),
|
defaultWallpaper: .file(id: 0, accessHash: 0, isCreator: false, isDefault: true, isPattern: true, isDark: false, slug: "fqv01SQemVIBAAAApND8LDRUhRU", file: TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: 36542425), partialReference: nil, resource: WallpaperDataResource(slug: "fqv01SQemVIBAAAApND8LDRUhRU"), previewRepresentations: [TelegramMediaImageRepresentation(dimensions: PixelDimensions(width: 600, height: 800), resource: WallpaperDataResource(slug: "fqv01SQemVIBAAAApND8LDRUhRU"), progressiveSizes: [], immediateThumbnailData: nil)], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "image/tgv", size: nil, attributes: []), settings: WallpaperSettings(colors: [0x1b2836, 0x121a22, 0x1b2836, 0x121a22], intensity: 50)),
|
||||||
message: message,
|
message: message,
|
||||||
serviceMessage: serviceMessage,
|
serviceMessage: serviceMessage,
|
||||||
inputPanel: inputPanel,
|
inputPanel: inputPanel,
|
||||||
|
@ -20,6 +20,12 @@ public func dateFillNeedsBlur(theme: PresentationTheme, wallpaper: TelegramWallp
|
|||||||
return false
|
return false
|
||||||
} else if case .color = wallpaper {
|
} else if case .color = wallpaper {
|
||||||
return false
|
return false
|
||||||
|
} else if case let .file(_, _, _, _, isPattern, _, _, _, settings) = wallpaper {
|
||||||
|
if isPattern, let intensity = settings.intensity, intensity < 0 {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -206,6 +206,7 @@ public final class PrincipalThemeEssentialGraphics {
|
|||||||
}
|
}
|
||||||
if let incomingGradientColors = incomingGradientColors {
|
if let incomingGradientColors = incomingGradientColors {
|
||||||
self.incomingBubbleGradientImage = generateImage(CGSize(width: 1.0, height: 512.0), opaque: true, scale: 1.0, rotatedContext: { size, context in
|
self.incomingBubbleGradientImage = generateImage(CGSize(width: 1.0, height: 512.0), opaque: true, scale: 1.0, rotatedContext: { size, context in
|
||||||
|
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||||
var locations: [CGFloat] = [0.0, 1.0]
|
var locations: [CGFloat] = [0.0, 1.0]
|
||||||
let colors = [incomingGradientColors.0.cgColor, incomingGradientColors.1.cgColor] as NSArray
|
let colors = [incomingGradientColors.0.cgColor, incomingGradientColors.1.cgColor] as NSArray
|
||||||
|
|
||||||
@ -224,6 +225,7 @@ public final class PrincipalThemeEssentialGraphics {
|
|||||||
}
|
}
|
||||||
if let outgoingGradientColors = outgoingGradientColors {
|
if let outgoingGradientColors = outgoingGradientColors {
|
||||||
self.outgoingBubbleGradientImage = generateImage(CGSize(width: 1.0, height: 512.0), opaque: true, scale: 1.0, rotatedContext: { size, context in
|
self.outgoingBubbleGradientImage = generateImage(CGSize(width: 1.0, height: 512.0), opaque: true, scale: 1.0, rotatedContext: { size, context in
|
||||||
|
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||||
var locations: [CGFloat] = [0.0, 1.0]
|
var locations: [CGFloat] = [0.0, 1.0]
|
||||||
let colors = [outgoingGradientColors.0.cgColor, outgoingGradientColors.1.cgColor] as NSArray
|
let colors = [outgoingGradientColors.0.cgColor, outgoingGradientColors.1.cgColor] as NSArray
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 10e208f6f35eaa4a8ef6bb95e58b704178e8affd
|
Subproject commit 4c98c768ca0969cfcebf6da3e585c6760960fe0b
|
@ -19,6 +19,7 @@ swift_library(
|
|||||||
"//submodules/AccountContext:AccountContext",
|
"//submodules/AccountContext:AccountContext",
|
||||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||||
"//submodules/WallpaperResources:WallpaperResources",
|
"//submodules/WallpaperResources:WallpaperResources",
|
||||||
|
"//submodules/FastBlur:FastBlur",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
@ -10,9 +10,25 @@ import AccountContext
|
|||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import WallpaperResources
|
import WallpaperResources
|
||||||
import Postbox
|
import Postbox
|
||||||
|
import FastBlur
|
||||||
|
|
||||||
private let motionAmount: CGFloat = 32.0
|
private let motionAmount: CGFloat = 32.0
|
||||||
|
|
||||||
|
private func generateBlurredContents(image: UIImage) -> UIImage? {
|
||||||
|
let size = image.size.aspectFitted(CGSize(width: 64.0, height: 64.0))
|
||||||
|
let context = DrawingContext(size: size, scale: 1.0, premultiplied: true, opaque: true, clear: false)
|
||||||
|
context.withFlippedContext { c in
|
||||||
|
c.draw(image.cgImage!, in: CGRect(origin: CGPoint(), size: size))
|
||||||
|
}
|
||||||
|
|
||||||
|
telegramFastBlurMore(Int32(context.size.width), Int32(context.size.height), Int32(context.bytesPerRow), context.bytes)
|
||||||
|
telegramFastBlurMore(Int32(context.size.width), Int32(context.size.height), Int32(context.bytesPerRow), context.bytes)
|
||||||
|
|
||||||
|
adjustSaturationInContext(context: context, saturation: 1.7)
|
||||||
|
|
||||||
|
return context.generateImage()
|
||||||
|
}
|
||||||
|
|
||||||
public final class WallpaperBackgroundNode: ASDisplayNode {
|
public final class WallpaperBackgroundNode: ASDisplayNode {
|
||||||
public final class BubbleBackgroundNode: ASDisplayNode {
|
public final class BubbleBackgroundNode: ASDisplayNode {
|
||||||
public enum BubbleType {
|
public enum BubbleType {
|
||||||
@ -96,12 +112,13 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
needsCleanBackground = true
|
needsCleanBackground = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isInvertedGradient = false
|
||||||
var hasComplexGradient = false
|
var hasComplexGradient = false
|
||||||
switch wallpaper {
|
switch wallpaper {
|
||||||
case let .file(_, _, _, _, isPattern, _, _, _, settings):
|
case let .file(_, _, _, _, _, _, _, _, settings):
|
||||||
hasComplexGradient = settings.colors.count >= 3
|
hasComplexGradient = settings.colors.count >= 3
|
||||||
if !isPattern {
|
if let intensity = settings.intensity, intensity < 0 {
|
||||||
needsCleanBackground = false
|
isInvertedGradient = true
|
||||||
}
|
}
|
||||||
case let .gradient(_, colors, _):
|
case let .gradient(_, colors, _):
|
||||||
hasComplexGradient = colors.count >= 3
|
hasComplexGradient = colors.count >= 3
|
||||||
@ -112,6 +129,15 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
var needsGradientBackground = false
|
var needsGradientBackground = false
|
||||||
var needsWallpaperBackground = false
|
var needsWallpaperBackground = false
|
||||||
|
|
||||||
|
if isInvertedGradient {
|
||||||
|
switch self.bubbleType {
|
||||||
|
case .free:
|
||||||
|
needsCleanBackground = false
|
||||||
|
case .incoming, .outgoing:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if needsCleanBackground {
|
if needsCleanBackground {
|
||||||
if hasComplexGradient {
|
if hasComplexGradient {
|
||||||
needsGradientBackground = backgroundNode.gradientBackgroundNode != nil
|
needsGradientBackground = backgroundNode.gradientBackgroundNode != nil
|
||||||
@ -127,8 +153,13 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
cleanWallpaperNode.frame = self.bounds
|
cleanWallpaperNode.frame = self.bounds
|
||||||
self.insertSubnode(cleanWallpaperNode, at: 0)
|
self.insertSubnode(cleanWallpaperNode, at: 0)
|
||||||
}
|
}
|
||||||
|
if let blurredBackgroundContents = backgroundNode.blurredBackgroundContents {
|
||||||
|
self.cleanWallpaperNode?.contents = blurredBackgroundContents.cgImage
|
||||||
|
self.cleanWallpaperNode?.backgroundColor = backgroundNode.contentNode.backgroundColor
|
||||||
|
} else {
|
||||||
self.cleanWallpaperNode?.contents = backgroundNode.contentNode.contents
|
self.cleanWallpaperNode?.contents = backgroundNode.contentNode.contents
|
||||||
self.cleanWallpaperNode?.backgroundColor = backgroundNode.contentNode.backgroundColor
|
self.cleanWallpaperNode?.backgroundColor = backgroundNode.contentNode.backgroundColor
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if let cleanWallpaperNode = self.cleanWallpaperNode {
|
if let cleanWallpaperNode = self.cleanWallpaperNode {
|
||||||
self.cleanWallpaperNode = nil
|
self.cleanWallpaperNode = nil
|
||||||
@ -242,6 +273,8 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
private let useSharedAnimationPhase: Bool
|
private let useSharedAnimationPhase: Bool
|
||||||
|
|
||||||
private let contentNode: ASDisplayNode
|
private let contentNode: ASDisplayNode
|
||||||
|
private var blurredBackgroundContents: UIImage?
|
||||||
|
|
||||||
private var gradientBackgroundNode: GradientBackgroundNode?
|
private var gradientBackgroundNode: GradientBackgroundNode?
|
||||||
private let patternImageNode: ASImageNode
|
private let patternImageNode: ASImageNode
|
||||||
|
|
||||||
@ -404,6 +437,7 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
|
|
||||||
self.contentNode.backgroundColor = nil
|
self.contentNode.backgroundColor = nil
|
||||||
self.contentNode.contents = nil
|
self.contentNode.contents = nil
|
||||||
|
self.blurredBackgroundContents = nil
|
||||||
self.motionEnabled = false
|
self.motionEnabled = false
|
||||||
self.wallpaperDisposable.set(nil)
|
self.wallpaperDisposable.set(nil)
|
||||||
} else {
|
} else {
|
||||||
@ -417,7 +451,7 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
|
|
||||||
if gradientColors.count >= 2 {
|
if gradientColors.count >= 2 {
|
||||||
self.contentNode.backgroundColor = nil
|
self.contentNode.backgroundColor = nil
|
||||||
self.contentNode.contents = generateImage(CGSize(width: 100.0, height: 200.0), rotatedContext: { size, context in
|
let image = generateImage(CGSize(width: 100.0, height: 200.0), rotatedContext: { size, context in
|
||||||
let gradientColors = [UIColor(rgb: gradientColors[0]).cgColor, UIColor(rgb: gradientColors[1]).cgColor] as CFArray
|
let gradientColors = [UIColor(rgb: gradientColors[0]).cgColor, UIColor(rgb: gradientColors[1]).cgColor] as CFArray
|
||||||
|
|
||||||
var locations: [CGFloat] = [0.0, 1.0]
|
var locations: [CGFloat] = [0.0, 1.0]
|
||||||
@ -429,22 +463,27 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||||
|
|
||||||
context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: size.height), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation])
|
context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: size.height), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation])
|
||||||
})?.cgImage
|
})
|
||||||
|
self.contentNode.contents = image?.cgImage
|
||||||
|
self.blurredBackgroundContents = image
|
||||||
self.wallpaperDisposable.set(nil)
|
self.wallpaperDisposable.set(nil)
|
||||||
} else if gradientColors.count >= 1 {
|
} else if gradientColors.count >= 1 {
|
||||||
self.contentNode.backgroundColor = UIColor(rgb: gradientColors[0])
|
self.contentNode.backgroundColor = UIColor(rgb: gradientColors[0])
|
||||||
self.contentNode.contents = nil
|
self.contentNode.contents = nil
|
||||||
|
self.blurredBackgroundContents = nil
|
||||||
self.wallpaperDisposable.set(nil)
|
self.wallpaperDisposable.set(nil)
|
||||||
} else {
|
} else {
|
||||||
self.contentNode.backgroundColor = .white
|
self.contentNode.backgroundColor = .white
|
||||||
if let image = chatControllerBackgroundImage(theme: nil, wallpaper: wallpaper, mediaBox: self.context.sharedContext.accountManager.mediaBox, knockoutMode: false) {
|
if let image = chatControllerBackgroundImage(theme: nil, wallpaper: wallpaper, mediaBox: self.context.sharedContext.accountManager.mediaBox, knockoutMode: false) {
|
||||||
self.contentNode.contents = image.cgImage
|
self.contentNode.contents = image.cgImage
|
||||||
|
self.blurredBackgroundContents = generateBlurredContents(image: image)
|
||||||
self.wallpaperDisposable.set(nil)
|
self.wallpaperDisposable.set(nil)
|
||||||
Queue.mainQueue().justDispatch {
|
Queue.mainQueue().justDispatch {
|
||||||
self._isReady.set(true)
|
self._isReady.set(true)
|
||||||
}
|
}
|
||||||
} else if let image = chatControllerBackgroundImage(theme: nil, wallpaper: wallpaper, mediaBox: self.context.account.postbox.mediaBox, knockoutMode: false) {
|
} else if let image = chatControllerBackgroundImage(theme: nil, wallpaper: wallpaper, mediaBox: self.context.account.postbox.mediaBox, knockoutMode: false) {
|
||||||
self.contentNode.contents = image.cgImage
|
self.contentNode.contents = image.cgImage
|
||||||
|
self.blurredBackgroundContents = generateBlurredContents(image: image)
|
||||||
self.wallpaperDisposable.set(nil)
|
self.wallpaperDisposable.set(nil)
|
||||||
Queue.mainQueue().justDispatch {
|
Queue.mainQueue().justDispatch {
|
||||||
self._isReady.set(true)
|
self._isReady.set(true)
|
||||||
@ -456,6 +495,11 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.contentNode.contents = image?.0?.cgImage
|
strongSelf.contentNode.contents = image?.0?.cgImage
|
||||||
|
if let image = image?.0 {
|
||||||
|
strongSelf.blurredBackgroundContents = generateBlurredContents(image: image)
|
||||||
|
} else {
|
||||||
|
strongSelf.blurredBackgroundContents = nil
|
||||||
|
}
|
||||||
strongSelf._isReady.set(true)
|
strongSelf._isReady.set(true)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -531,6 +575,8 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
|
|||||||
} else {
|
} else {
|
||||||
strongSelf._isReady.set(true)
|
strongSelf._isReady.set(true)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
strongSelf._isReady.set(true)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user