Fix build

This commit is contained in:
Ilya Laktyushin
2019-09-02 22:19:31 +03:00
parent 058949fe4d
commit bf2e532d3f
3 changed files with 35 additions and 34 deletions

View File

@@ -29,6 +29,8 @@ public final class ThemePreviewController: ViewController {
return self.displayNode as! ThemePreviewControllerNode
}
private let titleView: CounterContollerTitleView
private var didPlayPresentationAnimation = false
private var presentationData: PresentationData
@@ -44,6 +46,8 @@ public final class ThemePreviewController: ViewController {
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
self.titleView = CounterContollerTitleView(theme: self.previewTheme)
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationTheme: self.previewTheme, presentationStrings: self.presentationData.strings))
let themeName: String
@@ -62,21 +66,21 @@ public final class ThemePreviewController: ViewController {
themeName = previewTheme.name.string
}
// if
// if let author = previewTheme.author {
// let titleView = CounterContollerTitleView(theme: self.previewTheme)
// titleView.title = CounterContollerTitle(title: themeName, counter: author)
// self.navigationItem.titleView = titleView
// } else {
self.title = themeName
// }
self.titleView.title = CounterContollerTitle(title: themeName, counter: " ")
self.navigationItem.titleView = titleView
self.statusBar.statusBarStyle = self.previewTheme.rootController.statusBarStyle.style
self.supportedOrientations = ViewControllerSupportedOrientations(regularSize: .all, compactSize: .portrait)
self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Accessory Panels/MessageSelectionAction"), color: self.previewTheme.rootController.navigationBar.accentTextColor), style: .plain, target: self, action: #selector(self.actionPressed))
//self.disposable
self.disposable = (self.theme.get()
|> deliverOnMainQueue).start(next: { [weak self] theme in
if let strongSelf = self, let theme = theme {
strongSelf.titleView.title = CounterContollerTitle(title: themeName, counter: strongSelf.presentationData.strings.Theme_UsersCount(max(1, theme.installCount)))
}
})
self.presentationDataDisposable = (context.sharedContext.presentationData
|> deliverOnMainQueue).start(next: { [weak self] presentationData in

View File

@@ -85,17 +85,18 @@ extension TelegramWallpaper: Codable {
components.append(file.slug)
if file.isPattern {
if let color = file.settings.color {
components.removeAll()
components.append(String(format: "%06x", color))
}
if let intensity = file.settings.intensity {
components.append("\(intensity)")
}
if file.settings.motion {
components.append("motion")
}
if file.settings.blur {
components.append("blur")
}
// if let intensity = file.settings.intensity {
// components.append("\(intensity)")
// }
// if file.settings.motion {
// components.append("motion")
// }
// if file.settings.blur {
// components.append("blur")
// }
}
try container.encode(components.joined(separator: " "))
default:

View File

@@ -944,23 +944,19 @@ public func themeIconImage(account: Account, accountManager: AccountManager, the
wallpaperSignal = cachedWallpaper(account: account, slug: file.slug)
|> mapToSignal { wallpaper in
if let wallpaper = wallpaper, case let .file(file) = wallpaper.wallpaper {
if file.isPattern {
var convertedRepresentations: [ImageRepresentationWithReference] = []
convertedRepresentations.append(ImageRepresentationWithReference(representation: TelegramMediaImageRepresentation(dimensions: CGSize(width: 100.0, height: 100.0), resource: file.file.resource), reference: .media(media: .standalone(media: file.file), resource: file.file.resource)))
return wallpaperDatas(account: account, accountManager: accountManager, fileReference: .standalone(media: file.file), representations: convertedRepresentations, alwaysShowThumbnailFirst: false, thumbnail: false, onlyFullSize: true, autoFetchFullSize: true, synchronousLoad: false)
|> mapToSignal { _, fullSizeData, complete -> Signal<(UIColor, UIColor, UIColor, UIImage?), NoError> in
guard complete, let fullSizeData = fullSizeData else {
return .complete()
}
accountManager.mediaBox.storeResourceData(file.file.resource.id, data: fullSizeData)
} else {
var convertedRepresentations: [ImageRepresentationWithReference] = []
convertedRepresentations.append(ImageRepresentationWithReference(representation: TelegramMediaImageRepresentation(dimensions: CGSize(width: 100.0, height: 100.0), resource: file.file.resource), reference: .media(media: .standalone(media: file.file), resource: file.file.resource)))
return wallpaperDatas(account: account, accountManager: accountManager, fileReference: .standalone(media: file.file), representations: convertedRepresentations, alwaysShowThumbnailFirst: false, thumbnail: false, onlyFullSize: true, autoFetchFullSize: true, synchronousLoad: false)
|> mapToSignal { _, fullSizeData, complete -> Signal<(UIColor, UIColor, UIColor, UIImage?), NoError> in
guard complete, let fullSizeData = fullSizeData else {
return .complete()
}
accountManager.mediaBox.storeResourceData(file.file.resource.id, data: fullSizeData)
if let image = UIImage(data: fullSizeData) {
return .single((backgroundColor, incomingColor, outgoingColor, image))
} else {
return .complete()
}
if let image = UIImage(data: fullSizeData) {
return .single((backgroundColor, incomingColor, outgoingColor, image))
} else {
return .complete()
}
}
} else {