This commit is contained in:
Ilya Laktyushin 2020-01-14 19:09:40 +03:00
parent a85da95943
commit aeb0ded0cd
5 changed files with 24 additions and 18 deletions

View File

@ -482,12 +482,19 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
let updateHasTwoStepAuth: () -> Void = {
let signal = twoStepVerificationConfiguration(account: context.account)
|> map { value -> TwoStepVerificationAccessConfiguration? in
return TwoStepVerificationAccessConfiguration(configuration: value, password: nil)
return TwoStepVerificationAccessConfiguration(configuration: value, password: nil)
}
|> deliverOnMainQueue
updateTwoStepAuthDisposable.set(
signal.start(next: { value in
twoStepAuthDataValue.set(.single(value))
if let value = value {
if case .set = value {
updatedHasTwoStepAuth?(true)
} else {
updatedHasTwoStepAuth?(false)
}
}
})
)
}

View File

@ -945,7 +945,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM
blockedPeers.set(.single(blockedPeersContext))
}, updatedHasTwoStepAuth: { hasTwoStepAuthValue in
hasTwoStepAuthPromise.set(.single(hasTwoStepAuthValue))
}, activeSessionsContext: activeSessionsContext, webSessionsContext: webSessionsContext, blockedPeersContext: blockedPeersContext))
}, activeSessionsContext: activeSessionsContext, webSessionsContext: webSessionsContext, blockedPeersContext: blockedPeersContext, hasTwoStepAuth: hasTwoStepAuth))
})
})
}, openDataAndStorage: {

View File

@ -443,8 +443,7 @@ final class ThemeAccentColorController: ViewController {
var defaultPatternWallpaper: TelegramWallpaper?
for wallpaper in wallpapers {
//JqSUrO0-mFIBAAAAWwTvLzoWGQI, 25
if case let .file(file) = wallpaper, file.slug == "-Xc-np9y2VMCAAAARKr0yNNPYW0" {
if case let .file(file) = wallpaper, file.slug == "JqSUrO0-mFIBAAAAWwTvLzoWGQI" {
defaultPatternWallpaper = wallpaper
break
}

View File

@ -55,7 +55,6 @@ extension TelegramWallpaper: Codable {
}
if components.count >= 2 && components.count <= 5 && [6, 8].contains(components[0].count) && !optionKeys.contains(components[0]) && [6, 8].contains(components[1].count) && !optionKeys.contains(components[1]), let topColor = UIColor(hexString: components[0]), let bottomColor = UIColor(hexString: components[1]) {
var rotation: Int32?
if components.count > 2, components[2].count <= 3, let value = Int32(components[2]) {
if value >= 0 && value < 360 {

View File

@ -429,17 +429,7 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da
var scale = scale
let drawingRect = arguments.drawingRect
var fittedSize = arguments.imageSize
if abs(fittedSize.width - arguments.boundingSize.width).isLessThanOrEqualTo(CGFloat(1.0)) {
fittedSize.width = arguments.boundingSize.width
}
if abs(fittedSize.height - arguments.boundingSize.height).isLessThanOrEqualTo(CGFloat(1.0)) {
fittedSize.height = arguments.boundingSize.height
}
fittedSize = fittedSize.aspectFilled(arguments.drawingRect.size)
let fittedRect = CGRect(origin: CGPoint(x: drawingRect.origin.x + (drawingRect.size.width - fittedSize.width) / 2.0, y: drawingRect.origin.y + (drawingRect.size.height - fittedSize.height) / 2.0), size: fittedSize)
if let customArguments = arguments.custom as? PatternWallpaperArguments, let combinedColor = customArguments.colors.first {
if customArguments.preview {
scale = max(1.0, UIScreenScale - 1.0)
@ -479,6 +469,17 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da
let image = customArguments.preview ? (scaledSizeImage ?? fullSizeImage) : fullSizeImage
if let image = image {
var fittedSize = CGSize(width: image.width, height: image.height)
if abs(fittedSize.width - arguments.boundingSize.width).isLessThanOrEqualTo(CGFloat(1.0)) {
fittedSize.width = arguments.boundingSize.width
}
if abs(fittedSize.height - arguments.boundingSize.height).isLessThanOrEqualTo(CGFloat(1.0)) {
fittedSize.height = arguments.boundingSize.height
}
fittedSize = fittedSize.aspectFilled(arguments.drawingRect.size)
let fittedRect = CGRect(origin: CGPoint(x: drawingRect.origin.x + (drawingRect.size.width - fittedSize.width) / 2.0, y: drawingRect.origin.y + (drawingRect.size.height - fittedSize.height) / 2.0), size: fittedSize)
c.setBlendMode(.normal)
c.interpolationQuality = customArguments.preview ? .low : .medium
c.clip(to: fittedRect, mask: image)
@ -538,7 +539,7 @@ public func solidColorImage(_ color: UIColor) -> Signal<(TransformImageArguments
let context = DrawingContext(size: arguments.drawingSize, clear: true)
context.withFlippedContext { c in
c.setFillColor(color.cgColor)
c.setFillColor(color.withAlphaComponent(1.0).cgColor)
c.fill(arguments.drawingRect)
}
@ -563,7 +564,7 @@ public func gradientImage(_ colors: [UIColor], rotation: Int32? = nil) -> Signal
let context = DrawingContext(size: arguments.drawingSize, clear: !arguments.corners.isEmpty)
context.withContext { c in
let gradientColors = colors.map { $0.cgColor } as CFArray
let gradientColors = colors.map { $0.withAlphaComponent(1.0).cgColor } as CFArray
let delta: CGFloat = 1.0 / (CGFloat(colors.count) - 1.0)
var locations: [CGFloat] = []