mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Improve charts theming
This commit is contained in:
parent
6266a29651
commit
13f7cdf401
@ -5474,3 +5474,5 @@ Any member of this group will be able to see messages in the channel.";
|
||||
"SetupUsername.ChangeLinkWarningGroup" = "Warning, if you change the short link to your group, it will loose its verified status. You will need to send a new application to @verification_bot";
|
||||
|
||||
"MuteFor.Forever" = "Mute Forever";
|
||||
|
||||
"Conversation.Dice" = "Send a 🎲 emoji to any chat to get a random number from Telegram.";
|
||||
|
@ -30,9 +30,7 @@ public protocol ChartThemeContainer {
|
||||
public class ChartTheme {
|
||||
public let chartTitleColor: GColor
|
||||
public let actionButtonColor: GColor
|
||||
public let tableBackgroundColor: GColor
|
||||
public let chartBackgroundColor: GColor
|
||||
public let tableSeparatorColor: GColor
|
||||
public let chartLabelsColor: GColor
|
||||
public let chartHelperLinesColor: GColor
|
||||
public let chartStrongLinesColor: GColor
|
||||
@ -40,17 +38,14 @@ public class ChartTheme {
|
||||
public let chartDetailsTextColor: GColor
|
||||
public let chartDetailsArrowColor: GColor
|
||||
public let chartDetailsViewColor: GColor
|
||||
public let descriptionActionColor: GColor
|
||||
public let rangeViewFrameColor: GColor
|
||||
public let rangeViewTintColor: GColor
|
||||
public let rangeViewFrameColor: GColor
|
||||
public let rangeViewMarkerColor: GColor
|
||||
|
||||
public init(chartTitleColor: GColor, actionButtonColor: GColor, tableBackgroundColor: GColor, chartBackgroundColor: GColor, tableSeparatorColor: GColor, chartLabelsColor: GColor, chartHelperLinesColor: GColor, chartStrongLinesColor: GColor, barChartStrongLinesColor: GColor, chartDetailsTextColor: GColor, chartDetailsArrowColor: GColor, chartDetailsViewColor: GColor, descriptionActionColor: GColor, rangeViewFrameColor: GColor, rangeViewTintColor: GColor, rangeViewMarkerColor: GColor) {
|
||||
public init(chartTitleColor: GColor, actionButtonColor: GColor, chartBackgroundColor: GColor, chartLabelsColor: GColor, chartHelperLinesColor: GColor, chartStrongLinesColor: GColor, barChartStrongLinesColor: GColor, chartDetailsTextColor: GColor, chartDetailsArrowColor: GColor, chartDetailsViewColor: GColor, rangeViewFrameColor: GColor, rangeViewTintColor: GColor, rangeViewMarkerColor: GColor) {
|
||||
self.chartTitleColor = chartTitleColor
|
||||
self.actionButtonColor = actionButtonColor
|
||||
self.tableBackgroundColor = tableBackgroundColor
|
||||
self.chartBackgroundColor = chartBackgroundColor
|
||||
self.tableSeparatorColor = tableSeparatorColor
|
||||
self.chartLabelsColor = chartLabelsColor
|
||||
self.chartHelperLinesColor = chartHelperLinesColor
|
||||
self.chartStrongLinesColor = chartStrongLinesColor
|
||||
@ -58,132 +53,15 @@ public class ChartTheme {
|
||||
self.chartDetailsTextColor = chartDetailsTextColor
|
||||
self.chartDetailsArrowColor = chartDetailsArrowColor
|
||||
self.chartDetailsViewColor = chartDetailsViewColor
|
||||
self.descriptionActionColor = descriptionActionColor
|
||||
self.rangeViewFrameColor = rangeViewFrameColor
|
||||
self.rangeViewTintColor = rangeViewTintColor
|
||||
self.rangeViewMarkerColor = rangeViewMarkerColor
|
||||
}
|
||||
|
||||
public static var defaultDayTheme = ChartTheme(chartTitleColor: GColor.black, actionButtonColor: GColor(red: 53/255.0, green: 120/255.0, blue: 246/255.0, alpha: 1.0), tableBackgroundColor: GColor(red: 239/255.0, green: 239/255.0, blue: 244/255.0, alpha: 1.0), chartBackgroundColor: GColor(red: 254/255.0, green: 254/255.0, blue: 254/255.0, alpha: 1.0), tableSeparatorColor: GColor(red: 200/255.0, green: 199/255.0, blue: 204/255.0, alpha: 1.0), chartLabelsColor: GColor(red: 37/255.0, green: 37/255.0, blue: 41/255.0, alpha: 0.5), chartHelperLinesColor: GColor(red: 24/255.0, green: 45/255.0, blue: 59/255.0, alpha: 0.1), chartStrongLinesColor: GColor(red: 24/255.0, green: 45/255.0, blue: 59/255.0, alpha: 0.35), barChartStrongLinesColor: GColor(red: 37/255.0, green: 37/255.0, blue: 41/255.0, alpha: 0.2), chartDetailsTextColor: GColor(red: 109/255.0, green: 109/255.0, blue: 114/255.0, alpha: 1.0), chartDetailsArrowColor: GColor(red: 197/255.0, green: 199/255.0, blue: 205/255.0, alpha: 1.0), chartDetailsViewColor: GColor(red: 245/255.0, green: 245/255.0, blue: 251/255.0, alpha: 1.0), descriptionActionColor: GColor(red: 1/255.0, green: 125/255.0, blue: 229/255.0, alpha: 1.0), rangeViewFrameColor: GColor(red: 202/255.0, green: 212/255.0, blue: 222/255.0, alpha: 1.0), rangeViewTintColor: GColor(red: 239/255.0, green: 239/255.0, blue: 244/255.0, alpha: 0.5), rangeViewMarkerColor: GColor.white)
|
||||
public static var defaultDayTheme = ChartTheme(chartTitleColor: GColor.black, actionButtonColor: GColor(red: 53/255.0, green: 120/255.0, blue: 246/255.0, alpha: 1.0), chartBackgroundColor: GColor(red: 254/255.0, green: 254/255.0, blue: 254/255.0, alpha: 1.0), chartLabelsColor: GColor(red: 37/255.0, green: 37/255.0, blue: 41/255.0, alpha: 0.5), chartHelperLinesColor: GColor(red: 24/255.0, green: 45/255.0, blue: 59/255.0, alpha: 0.1), chartStrongLinesColor: GColor(red: 24/255.0, green: 45/255.0, blue: 59/255.0, alpha: 0.35), barChartStrongLinesColor: GColor(red: 37/255.0, green: 37/255.0, blue: 41/255.0, alpha: 0.2), chartDetailsTextColor: GColor(red: 109/255.0, green: 109/255.0, blue: 114/255.0, alpha: 1.0), chartDetailsArrowColor: GColor(red: 197/255.0, green: 199/255.0, blue: 205/255.0, alpha: 1.0), chartDetailsViewColor: GColor(red: 245/255.0, green: 245/255.0, blue: 251/255.0, alpha: 1.0), rangeViewFrameColor: GColor(red: 202/255.0, green: 212/255.0, blue: 222/255.0, alpha: 1.0), rangeViewTintColor: GColor(red: 239/255.0, green: 239/255.0, blue: 244/255.0, alpha: 0.5), rangeViewMarkerColor: GColor.white)
|
||||
|
||||
|
||||
public static var defaultNightTheme = ChartTheme(chartTitleColor: GColor.white, actionButtonColor: GColor(red: 84/255.0, green: 164/255.0, blue: 247/255.0, alpha: 1.0), tableBackgroundColor: GColor(red: 24/255.0, green: 34/255.0, blue: 45/255.0, alpha: 1.0), chartBackgroundColor: GColor(red: 34/255.0, green: 47/255.0, blue: 63/255.0, alpha: 1.0), tableSeparatorColor: GColor(red: 18/255.0, green: 26/255.0, blue: 35/255.0, alpha: 1.0), chartLabelsColor: GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.6), chartHelperLinesColor: GColor(red: 133/255.0, green: 150/255.0, blue: 171/255.0, alpha: 0.20), chartStrongLinesColor: GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.45), barChartStrongLinesColor: GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.45), chartDetailsTextColor: GColor(red: 254/255.0, green: 254/255.0, blue: 254/255.0, alpha: 1.0), chartDetailsArrowColor: GColor(red: 76/255.0, green: 84/255.0, blue: 96/255.0, alpha: 1.0), chartDetailsViewColor: GColor(red: 25/255.0, green: 35/255.0, blue: 47/255.0, alpha: 1.0), descriptionActionColor: GColor(red: 24/255.0, green: 145/255.0, blue: 255/255.0, alpha: 1.0), rangeViewFrameColor: GColor(red: 53/255.0, green: 70/255.0, blue: 89/255.0, alpha: 1.0), rangeViewTintColor: GColor(red: 24/255.0, green: 34/255.0, blue: 45/255.0, alpha: 0.5), rangeViewMarkerColor: GColor.white)
|
||||
|
||||
|
||||
// public var actionButtonColor: GColor { // Кнопка Zoom Out/ Смена режима день/ночь
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 53/255.0, green: 120/255.0, blue: 246/255.0, alpha: 1.0)
|
||||
// case .night: return GColor(red: 84/255.0, green: 164/255.0, blue: 247/255.0, alpha: 1.0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var tableBackgroundColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 239/255.0, green: 239/255.0, blue: 244/255.0, alpha: 1.0)
|
||||
// case .night: return GColor(red: 24/255.0, green: 34/255.0, blue: 45/255.0, alpha: 1.0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var chartBackgroundColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 254/255.0, green: 254/255.0, blue: 254/255.0, alpha: 1.0)
|
||||
// case .night: return GColor(red: 34/255.0, green: 47/255.0, blue: 63/255.0, alpha: 1.0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var tableSeparatorColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 200/255.0, green: 199/255.0, blue: 204/255.0, alpha: 1.0)
|
||||
// case .night: return GColor(red: 18/255.0, green: 26/255.0, blue: 35/255.0, alpha: 1.0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var chartLabelsColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 37/255.0, green: 37/255.0, blue: 41/255.0, alpha: 0.5)
|
||||
// case .night: return GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.6)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var chartHelperLinesColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 24/255.0, green: 45/255.0, blue: 59/255.0, alpha: 0.1)
|
||||
// case .night: return GColor(red: 133/255.0, green: 150/255.0, blue: 171/255.0, alpha: 0.20)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var chartStrongLinesColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 24/255.0, green: 45/255.0, blue: 59/255.0, alpha: 0.35)
|
||||
// case .night: return GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.45)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var barChartStrongLinesColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 37/255.0, green: 37/255.0, blue: 41/255.0, alpha: 0.2)
|
||||
// case .night: return GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.45)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var chartDetailsTextColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 109/255.0, green: 109/255.0, blue: 114/255.0, alpha: 1.0)
|
||||
// case .night: return GColor(red: 254/255.0, green: 254/255.0, blue: 254/255.0, alpha: 1.0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var chartDetailsArrowColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 197/255.0, green: 199/255.0, blue: 205/255.0, alpha: 1.0)
|
||||
// case .night: return GColor(red: 76/255.0, green: 84/255.0, blue: 96/255.0, alpha: 1.0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var chartDetailsViewColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 245/255.0, green: 245/255.0, blue: 251/255.0, alpha: 1.0)
|
||||
// case .night: return GColor(red: 25/255.0, green: 35/255.0, blue: 47/255.0, alpha: 1.0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public var descriptionActionColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 1/255.0, green: 125/255.0, blue: 229/255.0, alpha: 1.0)
|
||||
// case .night: return GColor(red: 24/255.0, green: 145/255.0, blue: 255/255.0, alpha: 1.0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var rangeViewBackgroundColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 254/255.0, green: 254/255.0, blue: 254/255.0, alpha: 1.0)
|
||||
// case .night: return GColor(red: 34/255.0, green: 47/255.0, blue: 63/255.0, alpha: 1.0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var rangeViewFrameColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 202/255.0, green: 212/255.0, blue: 222/255.0, alpha: 1.0)
|
||||
// case .night: return GColor(red: 53/255.0, green: 70/255.0, blue: 89/255.0, alpha: 1.0)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var rangeViewTintColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor(red: 239/255.0, green: 239/255.0, blue: 244/255.0, alpha: 0.5)
|
||||
// case .night: return GColor(red: 24/255.0, green: 34/255.0, blue: 45/255.0, alpha: 0.5)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var rangeViewMarkerColor: GColor {
|
||||
// switch self {
|
||||
// case .day: return GColor.white
|
||||
// case .night: return GColor.white
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
public static var defaultNightTheme = ChartTheme(chartTitleColor: GColor.white, actionButtonColor: GColor(red: 84/255.0, green: 164/255.0, blue: 247/255.0, alpha: 1.0), chartBackgroundColor: GColor(red: 34/255.0, green: 47/255.0, blue: 63/255.0, alpha: 1.0), chartLabelsColor: GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.6), chartHelperLinesColor: GColor(red: 133/255.0, green: 150/255.0, blue: 171/255.0, alpha: 0.20), chartStrongLinesColor: GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.45), barChartStrongLinesColor: GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.45), chartDetailsTextColor: GColor(red: 254/255.0, green: 254/255.0, blue: 254/255.0, alpha: 1.0), chartDetailsArrowColor: GColor(red: 76/255.0, green: 84/255.0, blue: 96/255.0, alpha: 1.0), chartDetailsViewColor: GColor(red: 25/255.0, green: 35/255.0, blue: 47/255.0, alpha: 1.0), rangeViewFrameColor: GColor(red: 53/255.0, green: 70/255.0, blue: 89/255.0, alpha: 1.0), rangeViewTintColor: GColor(red: 24/255.0, green: 34/255.0, blue: 45/255.0, alpha: 0.5), rangeViewMarkerColor: GColor.white)
|
||||
|
||||
public var rangeCropImage: GImage? {
|
||||
// case .day:
|
||||
|
@ -19,10 +19,7 @@ public enum ChartType {
|
||||
|
||||
public extension ChartTheme {
|
||||
convenience init(presentationTheme: PresentationTheme) {
|
||||
let tableBackgroundColor = UIColor(rgb: 0xefeff4)
|
||||
let rangeViewTintColor = UIColor(rgb: 0xefeff4)
|
||||
|
||||
self.init(chartTitleColor: presentationTheme.list.itemPrimaryTextColor, actionButtonColor: presentationTheme.list.itemAccentColor, tableBackgroundColor: tableBackgroundColor, chartBackgroundColor: presentationTheme.list.itemBlocksBackgroundColor, tableSeparatorColor: presentationTheme.list.itemSecondaryTextColor, chartLabelsColor: presentationTheme.list.itemSecondaryTextColor, chartHelperLinesColor: presentationTheme.list.itemSecondaryTextColor, chartStrongLinesColor: presentationTheme.list.itemSecondaryTextColor, barChartStrongLinesColor: presentationTheme.list.itemSecondaryTextColor, chartDetailsTextColor: presentationTheme.list.itemSecondaryTextColor, chartDetailsArrowColor: presentationTheme.list.itemSecondaryTextColor, chartDetailsViewColor: presentationTheme.list.itemSecondaryTextColor, descriptionActionColor: presentationTheme.list.itemSecondaryTextColor, rangeViewFrameColor: presentationTheme.list.itemSecondaryTextColor, rangeViewTintColor: rangeViewTintColor, rangeViewMarkerColor: UIColor.white)
|
||||
self.init(chartTitleColor: presentationTheme.list.itemPrimaryTextColor, actionButtonColor: presentationTheme.list.itemAccentColor, chartBackgroundColor: presentationTheme.list.itemBlocksBackgroundColor, chartLabelsColor: presentationTheme.chart.labelsColor, chartHelperLinesColor: presentationTheme.chart.helperLinesColor, chartStrongLinesColor: presentationTheme.chart.strongLinesColor, barChartStrongLinesColor: presentationTheme.chart.barStrongLinesColor, chartDetailsTextColor: presentationTheme.chart.detailsTextColor, chartDetailsArrowColor: presentationTheme.chart.detailsArrowColor, chartDetailsViewColor: presentationTheme.chart.detailsViewColor, rangeViewFrameColor: presentationTheme.chart.rangeViewFrameColor, rangeViewTintColor: presentationTheme.list.blocksBackgroundColor.withAlphaComponent(0.5), rangeViewMarkerColor: presentationTheme.chart.rangeViewMarkerColor)
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +85,7 @@ public final class ChartNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
public func setupTheme(_ theme: ChartTheme) {
|
||||
self.chartView.apply(theme: ChartTheme.defaultDayTheme, animated: false)
|
||||
self.chartView.apply(theme: theme, animated: false)
|
||||
}
|
||||
|
||||
public func setup(controller: BaseChartController) {
|
||||
|
@ -27,7 +27,6 @@ class ChartStackSection: UIView, ChartThemeContainer {
|
||||
var rangeView: RangeChartView
|
||||
var visibilityView: ChartVisibilityView
|
||||
var sectionContainerView: UIView
|
||||
var separators: [UIView] = []
|
||||
|
||||
var titleLabel: UILabel!
|
||||
var backButton: UIButton!
|
||||
@ -87,19 +86,13 @@ class ChartStackSection: UIView, ChartThemeContainer {
|
||||
func apply(theme: ChartTheme, animated: Bool) {
|
||||
self.theme = theme
|
||||
|
||||
UIView.perform(animated: animated && self.isVisibleInWindow) {
|
||||
self.backgroundColor = theme.tableBackgroundColor
|
||||
|
||||
UIView.perform(animated: animated && self.isVisibleInWindow) {
|
||||
self.sectionContainerView.backgroundColor = theme.chartBackgroundColor
|
||||
self.rangeView.backgroundColor = theme.chartBackgroundColor
|
||||
self.visibilityView.backgroundColor = theme.chartBackgroundColor
|
||||
|
||||
self.backButton.tintColor = theme.actionButtonColor
|
||||
self.backButton.setTitleColor(theme.actionButtonColor, for: .normal)
|
||||
|
||||
for separator in self.separators {
|
||||
separator.backgroundColor = theme.tableSeparatorColor
|
||||
}
|
||||
}
|
||||
|
||||
if rangeView.isVisibleInWindow || chartView.isVisibleInWindow {
|
||||
|
@ -152,7 +152,6 @@ extension ChartVisibilityView: ChartThemeContainer {
|
||||
func apply(theme: ChartTheme, animated: Bool) {
|
||||
UIView.perform(animated: animated) {
|
||||
self.backgroundColor = theme.chartBackgroundColor
|
||||
self.tintColor = theme.descriptionActionColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ private extension RangeChartView {
|
||||
|
||||
extension RangeChartView: ChartThemeContainer {
|
||||
func apply(theme: ChartTheme, animated: Bool) {
|
||||
let colusre = {
|
||||
let closure = {
|
||||
self.lowerBoundTintView.backgroundColor = theme.rangeViewTintColor
|
||||
self.upperBoundTintView.backgroundColor = theme.rangeViewTintColor
|
||||
}
|
||||
@ -321,9 +321,9 @@ extension RangeChartView: ChartThemeContainer {
|
||||
self.cropFrameView.setImage(image, animated: animated)
|
||||
|
||||
if animated {
|
||||
UIView.animate(withDuration: .defaultDuration, animations: colusre)
|
||||
UIView.animate(withDuration: .defaultDuration, animations: closure)
|
||||
} else {
|
||||
colusre()
|
||||
closure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,11 +113,13 @@ public struct ManagedAnimationItem: Equatable {
|
||||
public let source: ManagedAnimationSource
|
||||
var frames: ManagedAnimationFrameRange
|
||||
var duration: Double
|
||||
var loop: Bool
|
||||
|
||||
public init(source: ManagedAnimationSource, frames: ManagedAnimationFrameRange, duration: Double) {
|
||||
public init(source: ManagedAnimationSource, frames: ManagedAnimationFrameRange, duration: Double, loop: Bool = false) {
|
||||
self.source = source
|
||||
self.frames = frames
|
||||
self.duration = duration
|
||||
self.loop = loop
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ final class StatsEmptyStateItemNode: ItemListControllerEmptyStateItemNode {
|
||||
|
||||
self.animationNode = AnimatedStickerNode()
|
||||
if let path = getAppBundle().path(forResource: "Charts", ofType: "tgs") {
|
||||
self.animationNode.setup(source: AnimatedStickerNodeLocalFileSource(path: path), width: 192, height: 192, playbackMode: .once, mode: .direct)
|
||||
self.animationNode.setup(source: AnimatedStickerNodeLocalFileSource(path: path), width: 192, height: 192, playbackMode: .loop, mode: .direct)
|
||||
self.animationNode.visibility = true
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ class StatsGraphItemNode: ListViewItemNode {
|
||||
}
|
||||
|
||||
if let updatedGraph = updatedGraph {
|
||||
if case let .Loaded(_, data) = updatedGraph, let updatedController = updatedController {
|
||||
if case .Loaded = updatedGraph, let updatedController = updatedController {
|
||||
strongSelf.chartNode.setup(controller: updatedController)
|
||||
strongSelf.activityIndicator.isHidden = true
|
||||
strongSelf.chartNode.isHidden = false
|
||||
|
@ -224,6 +224,7 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
|
||||
actionSheet: actionSheet,
|
||||
contextMenu: theme.contextMenu,
|
||||
inAppNotification: theme.inAppNotification,
|
||||
chart: theme.chart,
|
||||
preview: theme.preview
|
||||
)
|
||||
}
|
||||
@ -543,6 +544,17 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
|
||||
)
|
||||
)
|
||||
)
|
||||
let chart = PresentationThemeChart(
|
||||
labelsColor: UIColor(rgb: 0xbacce1, alpha: 0.6),
|
||||
helperLinesColor: UIColor(rgb: 0x8596ab, alpha: 0.2),
|
||||
strongLinesColor: UIColor(rgb: 0xbacce1, alpha: 0.6),
|
||||
barStrongLinesColor: UIColor(rgb: 0xbacce1, alpha: 0.45),
|
||||
detailsTextColor: UIColor(rgb: 0xffffff),
|
||||
detailsArrowColor: UIColor(rgb: 0x4c5460),
|
||||
detailsViewColor: UIColor(rgb: 0x19232f),
|
||||
rangeViewFrameColor: UIColor(rgb: 0x354659),
|
||||
rangeViewMarkerColor: UIColor(rgb: 0xffffff)
|
||||
)
|
||||
|
||||
return PresentationTheme(
|
||||
name: extendingThemeReference?.name ?? .builtin(.night),
|
||||
@ -558,6 +570,7 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
|
||||
actionSheet: actionSheet,
|
||||
contextMenu: contextMenu,
|
||||
inAppNotification: inAppNotification,
|
||||
chart: chart,
|
||||
preview: preview
|
||||
)
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
||||
var actionSheet = theme.actionSheet
|
||||
var contextMenu = theme.contextMenu
|
||||
var inAppNotification = theme.inAppNotification
|
||||
|
||||
var chart = theme.chart
|
||||
|
||||
var mainBackgroundColor: UIColor?
|
||||
var mainSelectionColor: UIColor?
|
||||
@ -234,7 +234,6 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
||||
|
||||
var outgoingBubbleFillColor: UIColor?
|
||||
var outgoingBubbleFillGradientColor: UIColor?
|
||||
var outgoingBubbleHighlightedFillColor: UIColor?
|
||||
var outgoingPrimaryTextColor: UIColor?
|
||||
var outgoingSecondaryTextColor: UIColor?
|
||||
var outgoingLinkTextColor: UIColor?
|
||||
@ -423,6 +422,16 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
||||
)
|
||||
)
|
||||
|
||||
chart = chart.withUpdated(
|
||||
labelsColor: accentColor?.withMultiplied(hue: 1.033, saturation: 0.211, brightness: 0.882).withAlphaComponent(0.6),
|
||||
helperLinesColor: accentColor?.withMultiplied(hue: 1.037, saturation: 0.271, brightness: 0.671).withAlphaComponent(0.2),
|
||||
strongLinesColor: accentColor?.withMultiplied(hue: 1.033, saturation: 0.211, brightness: 0.882).withAlphaComponent(0.6),
|
||||
barStrongLinesColor: accentColor?.withMultiplied(hue: 1.033, saturation: 0.211, brightness: 0.882).withAlphaComponent(0.45),
|
||||
detailsArrowColor: accentColor?.withMultiplied(hue: 1.051, saturation: 0.254, brightness: 0.376),
|
||||
detailsViewColor: accentColor?.withMultiplied(hue: 1.035, saturation: 0.571, brightness: 0.184),
|
||||
rangeViewFrameColor: accentColor?.withMultiplied(hue: 1.030, saturation: 0.494, brightness: 0.349)
|
||||
)
|
||||
|
||||
return PresentationTheme(
|
||||
name: title.flatMap { .custom($0) } ?? theme.name,
|
||||
index: theme.index,
|
||||
@ -437,6 +446,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
|
||||
actionSheet: actionSheet,
|
||||
contextMenu: contextMenu,
|
||||
inAppNotification: inAppNotification,
|
||||
chart: chart,
|
||||
preview: theme.preview
|
||||
)
|
||||
}
|
||||
@ -463,7 +473,6 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
|
||||
|
||||
let outgoingBubbleFillGradientColor = accentColor.withMultiplied(hue: 1.019, saturation: 0.731, brightness: 0.59)
|
||||
let outgoingBubbleFillColor = outgoingBubbleFillGradientColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98)
|
||||
let outgoingBubbleHighlightedFillColor: UIColor
|
||||
let outgoingScamColor = UIColor(rgb: 0xffffff)
|
||||
let outgoingPrimaryTextColor = UIColor(rgb: 0xffffff)
|
||||
let outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.5)
|
||||
@ -792,6 +801,18 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
let chart = PresentationThemeChart(
|
||||
labelsColor: UIColor(rgb: 0xbacce1, alpha: 0.6),
|
||||
helperLinesColor: UIColor(rgb: 0x8596ab, alpha: 0.2),
|
||||
strongLinesColor: UIColor(rgb: 0xbacce1, alpha: 0.6),
|
||||
barStrongLinesColor: UIColor(rgb: 0xbacce1, alpha: 0.45),
|
||||
detailsTextColor: UIColor(rgb: 0xffffff),
|
||||
detailsArrowColor: UIColor(rgb: 0x4c5460),
|
||||
detailsViewColor: UIColor(rgb: 0x19232f),
|
||||
rangeViewFrameColor: UIColor(rgb: 0x354659),
|
||||
rangeViewMarkerColor: UIColor(rgb: 0xffffff)
|
||||
)
|
||||
|
||||
return PresentationTheme(
|
||||
name: extendingThemeReference?.name ?? .builtin(.nightAccent),
|
||||
@ -807,6 +828,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
|
||||
actionSheet: actionSheet,
|
||||
contextMenu: contextMenu,
|
||||
inAppNotification: inAppNotification,
|
||||
chart: chart,
|
||||
preview: preview
|
||||
)
|
||||
}
|
||||
|
@ -312,6 +312,7 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, ti
|
||||
actionSheet: actionSheet,
|
||||
contextMenu: theme.contextMenu,
|
||||
inAppNotification: theme.inAppNotification,
|
||||
chart: theme.chart,
|
||||
preview: theme.preview
|
||||
)
|
||||
}
|
||||
@ -731,13 +732,13 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
|
||||
sectionSeparatorColor: UIColor(rgb: 0x8a8a8a, alpha: 0.2),
|
||||
itemBackgroundColor: UIColor(rgb: 0x000000, alpha: 0.0),
|
||||
itemHighlightedBackgroundColor: UIColor(rgb: 0x3c3c43, alpha: 0.2),
|
||||
primaryColor: UIColor(rgb: 0x000000, alpha: 1.0),
|
||||
primaryColor: UIColor(rgb: 0x000000),
|
||||
secondaryColor: UIColor(rgb: 0x000000, alpha: 0.8),
|
||||
destructiveColor: UIColor(rgb: 0xff3b30),
|
||||
badgeFillColor: UIColor(rgb: 0x007ee5),
|
||||
badgeForegroundColor: UIColor(rgb: 0xffffff, alpha: 1.0),
|
||||
badgeForegroundColor: UIColor(rgb: 0xffffff),
|
||||
badgeInactiveFillColor: UIColor(rgb: 0xb6b6bb),
|
||||
badgeInactiveForegroundColor: UIColor(rgb: 0xffffff, alpha: 1.0),
|
||||
badgeInactiveForegroundColor: UIColor(rgb: 0xffffff),
|
||||
extractedContentTintColor: .white
|
||||
)
|
||||
|
||||
@ -755,6 +756,18 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
|
||||
)
|
||||
)
|
||||
|
||||
let chart = PresentationThemeChart(
|
||||
labelsColor: UIColor(rgb: 0x252529, alpha: 0.5),
|
||||
helperLinesColor: UIColor(rgb: 0x182d3b, alpha: 0.1),
|
||||
strongLinesColor: UIColor(rgb: 0x182d3b, alpha: 0.35),
|
||||
barStrongLinesColor: UIColor(rgb: 0x252529, alpha: 0.2),
|
||||
detailsTextColor: UIColor(rgb: 0x6d6d72),
|
||||
detailsArrowColor: UIColor(rgb: 0xc5c7cd),
|
||||
detailsViewColor: UIColor(rgb: 0xf5f5fb),
|
||||
rangeViewFrameColor: UIColor(rgb: 0xcad4de),
|
||||
rangeViewMarkerColor: UIColor(rgb: 0xffffff)
|
||||
)
|
||||
|
||||
return PresentationTheme(
|
||||
name: extendingThemeReference?.name ?? .builtin(day ? .day : .dayClassic),
|
||||
index: extendingThemeReference?.index ?? PresentationThemeReference.builtin(day ? .day : .dayClassic).index,
|
||||
@ -769,6 +782,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
|
||||
actionSheet: actionSheet,
|
||||
contextMenu: contextMenu,
|
||||
inAppNotification: inAppNotification,
|
||||
chart: chart,
|
||||
preview: preview
|
||||
)
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1083,6 +1083,34 @@ public final class PresentationThemeInAppNotification {
|
||||
}
|
||||
}
|
||||
|
||||
public final class PresentationThemeChart {
|
||||
public let labelsColor: UIColor
|
||||
public let helperLinesColor: UIColor
|
||||
public let strongLinesColor: UIColor
|
||||
public let barStrongLinesColor: UIColor
|
||||
public let detailsTextColor: UIColor
|
||||
public let detailsArrowColor: UIColor
|
||||
public let detailsViewColor: UIColor
|
||||
public let rangeViewFrameColor: UIColor
|
||||
public let rangeViewMarkerColor: UIColor
|
||||
|
||||
public init(labelsColor: UIColor, helperLinesColor: UIColor, strongLinesColor: UIColor, barStrongLinesColor: UIColor, detailsTextColor: UIColor, detailsArrowColor: UIColor, detailsViewColor: UIColor, rangeViewFrameColor: UIColor, rangeViewMarkerColor: UIColor) {
|
||||
self.labelsColor = labelsColor
|
||||
self.helperLinesColor = helperLinesColor
|
||||
self.strongLinesColor = strongLinesColor
|
||||
self.barStrongLinesColor = barStrongLinesColor
|
||||
self.detailsTextColor = detailsTextColor
|
||||
self.detailsArrowColor = detailsArrowColor
|
||||
self.detailsViewColor = detailsViewColor
|
||||
self.rangeViewFrameColor = rangeViewFrameColor
|
||||
self.rangeViewMarkerColor = rangeViewMarkerColor
|
||||
}
|
||||
|
||||
public func withUpdated(labelsColor: UIColor? = nil, helperLinesColor: UIColor? = nil, strongLinesColor: UIColor? = nil, barStrongLinesColor: UIColor? = nil, detailsTextColor: UIColor? = nil, detailsArrowColor: UIColor? = nil, detailsViewColor: UIColor? = nil, rangeViewFrameColor: UIColor? = nil, rangeViewMarkerColor: UIColor? = nil) -> PresentationThemeChart {
|
||||
return PresentationThemeChart(labelsColor: labelsColor ?? self.labelsColor, helperLinesColor: helperLinesColor ?? self.helperLinesColor, strongLinesColor: strongLinesColor ?? self.strongLinesColor, barStrongLinesColor: barStrongLinesColor ?? self.barStrongLinesColor, detailsTextColor: detailsTextColor ?? self.detailsTextColor, detailsArrowColor: detailsArrowColor ?? self.detailsArrowColor, detailsViewColor: detailsViewColor ?? self.detailsViewColor, rangeViewFrameColor: rangeViewFrameColor ?? self.rangeViewFrameColor, rangeViewMarkerColor: rangeViewMarkerColor ?? self.rangeViewMarkerColor)
|
||||
}
|
||||
}
|
||||
|
||||
public enum PresentationThemeBuiltinName {
|
||||
case dayClassic
|
||||
case day
|
||||
@ -1144,7 +1172,7 @@ public enum PresentationThemeName: Equatable {
|
||||
}
|
||||
|
||||
public extension PresentationThemeReference {
|
||||
public var name: PresentationThemeName {
|
||||
var name: PresentationThemeName {
|
||||
switch self {
|
||||
case let .builtin(theme):
|
||||
switch theme {
|
||||
@ -1179,11 +1207,12 @@ public final class PresentationTheme: Equatable {
|
||||
public let actionSheet: PresentationThemeActionSheet
|
||||
public let contextMenu: PresentationThemeContextMenu
|
||||
public let inAppNotification: PresentationThemeInAppNotification
|
||||
public let chart: PresentationThemeChart
|
||||
public let preview: Bool
|
||||
|
||||
public let resourceCache: PresentationsResourceCache = PresentationsResourceCache()
|
||||
|
||||
public init(name: PresentationThemeName, index: Int64, referenceTheme: PresentationBuiltinThemeReference, overallDarkAppearance: Bool, intro: PresentationThemeIntro, passcode: PresentationThemePasscode, rootController: PresentationThemeRootController, list: PresentationThemeList, chatList: PresentationThemeChatList, chat: PresentationThemeChat, actionSheet: PresentationThemeActionSheet, contextMenu: PresentationThemeContextMenu, inAppNotification: PresentationThemeInAppNotification, preview: Bool = false) {
|
||||
public init(name: PresentationThemeName, index: Int64, referenceTheme: PresentationBuiltinThemeReference, overallDarkAppearance: Bool, intro: PresentationThemeIntro, passcode: PresentationThemePasscode, rootController: PresentationThemeRootController, list: PresentationThemeList, chatList: PresentationThemeChatList, chat: PresentationThemeChat, actionSheet: PresentationThemeActionSheet, contextMenu: PresentationThemeContextMenu, inAppNotification: PresentationThemeInAppNotification, chart: PresentationThemeChart, preview: Bool = false) {
|
||||
self.name = name
|
||||
self.index = index
|
||||
self.referenceTheme = referenceTheme
|
||||
@ -1197,6 +1226,7 @@ public final class PresentationTheme: Equatable {
|
||||
self.actionSheet = actionSheet
|
||||
self.contextMenu = contextMenu
|
||||
self.inAppNotification = inAppNotification
|
||||
self.chart = chart
|
||||
self.preview = preview
|
||||
}
|
||||
|
||||
@ -1230,10 +1260,10 @@ public final class PresentationTheme: Equatable {
|
||||
break
|
||||
}
|
||||
}
|
||||
return PresentationTheme(name: name.flatMap(PresentationThemeName.custom) ?? .custom(self.name.string), index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: self.list, chatList: self.chatList, chat: self.chat.withUpdated(defaultWallpaper: defaultWallpaper), actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification)
|
||||
return PresentationTheme(name: name.flatMap(PresentationThemeName.custom) ?? .custom(self.name.string), index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: self.list, chatList: self.chatList, chat: self.chat.withUpdated(defaultWallpaper: defaultWallpaper), actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification, chart: self.chart, preview: self.preview)
|
||||
}
|
||||
|
||||
public func withUpdated(preview: Bool) -> PresentationTheme {
|
||||
return PresentationTheme(name: self.name, index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: self.list, chatList: self.chatList, chat: self.chat, actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification, preview: preview)
|
||||
return PresentationTheme(name: self.name, index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: self.list, chatList: self.chatList, chat: self.chat, actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification, chart: self.chart, preview: preview)
|
||||
}
|
||||
}
|
||||
|
@ -1700,6 +1700,39 @@ extension PresentationThemeInAppNotification: Codable {
|
||||
}
|
||||
}
|
||||
|
||||
extension PresentationThemeChart: Codable {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case labels
|
||||
case helperLines
|
||||
case strongLines
|
||||
case barStrongLines
|
||||
case detailsText
|
||||
case detailsArrow
|
||||
case detailsView
|
||||
case rangeViewFrame
|
||||
case rangeViewMarker
|
||||
}
|
||||
|
||||
public convenience init(from decoder: Decoder) throws {
|
||||
let values = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.init(labelsColor: try decodeColor(values, .labels), helperLinesColor: try decodeColor(values, .helperLines), strongLinesColor: try decodeColor(values, .strongLines), barStrongLinesColor: try decodeColor(values, .barStrongLines), detailsTextColor: try decodeColor(values, .detailsText), detailsArrowColor: try decodeColor(values, .detailsArrow), detailsViewColor: try decodeColor(values, .detailsView), rangeViewFrameColor: try decodeColor(values, .rangeViewFrame), rangeViewMarkerColor: try decodeColor(values, .rangeViewMarker))
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var values = encoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
try encodeColor(&values, self.labelsColor, .labels)
|
||||
try encodeColor(&values, self.helperLinesColor, .helperLines)
|
||||
try encodeColor(&values, self.strongLinesColor, .strongLines)
|
||||
try encodeColor(&values, self.barStrongLinesColor, .barStrongLines)
|
||||
try encodeColor(&values, self.detailsTextColor, .detailsText)
|
||||
try encodeColor(&values, self.detailsArrowColor, .detailsArrow)
|
||||
try encodeColor(&values, self.detailsViewColor, .detailsView)
|
||||
try encodeColor(&values, self.rangeViewFrameColor, .rangeViewFrame)
|
||||
try encodeColor(&values, self.rangeViewMarkerColor, .rangeViewMarker)
|
||||
}
|
||||
}
|
||||
|
||||
extension PresentationThemeName: Codable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
let value = try decoder.singleValueContainer()
|
||||
@ -1776,6 +1809,7 @@ extension PresentationTheme: Codable {
|
||||
case actionSheet
|
||||
case contextMenu
|
||||
case notification
|
||||
case chart
|
||||
}
|
||||
|
||||
public convenience init(from decoder: Decoder) throws {
|
||||
@ -1808,7 +1842,8 @@ extension PresentationTheme: Codable {
|
||||
chat: try values.decode(PresentationThemeChat.self, forKey: .chat),
|
||||
actionSheet: try values.decode(PresentationThemeActionSheet.self, forKey: .actionSheet),
|
||||
contextMenu: try values.decode(PresentationThemeContextMenu.self, forKey: .contextMenu),
|
||||
inAppNotification: try values.decode(PresentationThemeInAppNotification.self, forKey: .notification)
|
||||
inAppNotification: try values.decode(PresentationThemeInAppNotification.self, forKey: .notification),
|
||||
chart: try values.decode(PresentationThemeChart.self, forKey: .chart)
|
||||
)
|
||||
}
|
||||
|
||||
@ -1826,5 +1861,6 @@ extension PresentationTheme: Codable {
|
||||
try container.encode(self.actionSheet, forKey: .actionSheet)
|
||||
try container.encode(self.contextMenu, forKey: .contextMenu)
|
||||
try container.encode(self.inAppNotification, forKey: .notification)
|
||||
try container.encode(self.chart, forKey: .chart)
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -256,6 +256,7 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState:
|
||||
var loadStickerSaveStatus: MediaId?
|
||||
var loadCopyMediaResource: MediaResource?
|
||||
var isAction = false
|
||||
var isDice = false
|
||||
if messages.count == 1 {
|
||||
for media in messages[0].media {
|
||||
if let file = media as? TelegramMediaFile {
|
||||
@ -270,6 +271,8 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState:
|
||||
if !messages[0].containsSecretMedia {
|
||||
loadCopyMediaResource = largestImageRepresentation(image.representations)?.resource
|
||||
}
|
||||
} else if let _ = media as? TelegramMediaDice {
|
||||
isDice = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -283,8 +286,7 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState:
|
||||
if Namespaces.Message.allScheduled.contains(message.id.namespace) {
|
||||
canReply = false
|
||||
canPin = false
|
||||
}
|
||||
else if messages[0].flags.intersection([.Failed, .Unsent]).isEmpty {
|
||||
} else if messages[0].flags.intersection([.Failed, .Unsent]).isEmpty {
|
||||
switch chatPresentationInterfaceState.chatLocation {
|
||||
case .peer:
|
||||
if let channel = messages[0].peers[messages[0].id.peerId] as? TelegramChannel {
|
||||
@ -411,7 +413,7 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState:
|
||||
resourceAvailable = false
|
||||
}
|
||||
|
||||
if !messages[0].text.isEmpty || resourceAvailable {
|
||||
if !messages[0].text.isEmpty || resourceAvailable || isDice {
|
||||
let message = messages[0]
|
||||
var isExpired = false
|
||||
for media in message.media {
|
||||
@ -423,40 +425,44 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState:
|
||||
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuCopy, icon: { theme in
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: theme.actionSheet.primaryTextColor)
|
||||
}, action: { _, f in
|
||||
let copyTextWithEntities = {
|
||||
var messageEntities: [MessageTextEntity]?
|
||||
for attribute in message.attributes {
|
||||
if let attribute = attribute as? TextEntitiesMessageAttribute {
|
||||
messageEntities = attribute.entities
|
||||
break
|
||||
if isDice {
|
||||
UIPasteboard.general.string = "🎲"
|
||||
} else {
|
||||
let copyTextWithEntities = {
|
||||
var messageEntities: [MessageTextEntity]?
|
||||
for attribute in message.attributes {
|
||||
if let attribute = attribute as? TextEntitiesMessageAttribute {
|
||||
messageEntities = attribute.entities
|
||||
break
|
||||
}
|
||||
}
|
||||
storeMessageTextInPasteboard(message.text, entities: messageEntities)
|
||||
}
|
||||
storeMessageTextInPasteboard(message.text, entities: messageEntities)
|
||||
}
|
||||
if resourceAvailable {
|
||||
for media in message.media {
|
||||
if let image = media as? TelegramMediaImage, let largest = largestImageRepresentation(image.representations) {
|
||||
let _ = (context.account.postbox.mediaBox.resourceData(largest.resource, option: .incremental(waitUntilFetchStatus: false))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { data in
|
||||
if data.complete, let imageData = try? Data(contentsOf: URL(fileURLWithPath: data.path)) {
|
||||
if let image = UIImage(data: imageData) {
|
||||
if !message.text.isEmpty {
|
||||
copyTextWithEntities()
|
||||
if resourceAvailable {
|
||||
for media in message.media {
|
||||
if let image = media as? TelegramMediaImage, let largest = largestImageRepresentation(image.representations) {
|
||||
let _ = (context.account.postbox.mediaBox.resourceData(largest.resource, option: .incremental(waitUntilFetchStatus: false))
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { data in
|
||||
if data.complete, let imageData = try? Data(contentsOf: URL(fileURLWithPath: data.path)) {
|
||||
if let image = UIImage(data: imageData) {
|
||||
if !message.text.isEmpty {
|
||||
copyTextWithEntities()
|
||||
} else {
|
||||
UIPasteboard.general.image = image
|
||||
}
|
||||
} else {
|
||||
UIPasteboard.general.image = image
|
||||
copyTextWithEntities()
|
||||
}
|
||||
} else {
|
||||
copyTextWithEntities()
|
||||
}
|
||||
} else {
|
||||
copyTextWithEntities()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
copyTextWithEntities()
|
||||
}
|
||||
} else {
|
||||
copyTextWithEntities()
|
||||
}
|
||||
f(.default)
|
||||
})))
|
||||
|
@ -148,8 +148,6 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
}
|
||||
|
||||
private func setupNode(item: ChatMessageItem) {
|
||||
var isDice = false
|
||||
|
||||
if let telegramDice = self.telegramDice, let diceEmojis = item.associatedData.animatedEmojiStickers["🎲"] {
|
||||
let animationNode = ManagedDiceAnimationNode(context: item.context, emojis: diceEmojis.map { $0.file })
|
||||
self.animationNode = animationNode
|
||||
@ -836,13 +834,12 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
}
|
||||
|
||||
if let item = self.item, self.imageNode.frame.contains(location) {
|
||||
if self.telegramFile != nil {
|
||||
if let _ = self.telegramFile {
|
||||
let _ = item.controllerInteraction.openMessage(item.message, .default)
|
||||
} else if let _ = self.telegramDice {
|
||||
item.controllerInteraction.displayMessageTooltip(item.content.firstMessage.id, item.presentationData.strings.Conversation_Dice, self, self.imageNode.frame)
|
||||
} else if let _ = self.emojiFile {
|
||||
let (emoji, fitz) = item.message.text.basicEmoji
|
||||
if emoji == "🎲" {
|
||||
|
||||
} else if let animationNode = self.animationNode as? AnimatedStickerNode {
|
||||
if let animationNode = self.animationNode as? AnimatedStickerNode {
|
||||
var startTime: Signal<Double, NoError>
|
||||
if animationNode.playIfNeeded() {
|
||||
startTime = .single(0.0)
|
||||
|
@ -73,7 +73,7 @@ final class ManagedDiceAnimationNode: ManagedAnimationNode, GenericAnimatedStick
|
||||
case let .value(currentValue):
|
||||
switch diceState {
|
||||
case .rolling:
|
||||
self.trackTo(item: ManagedAnimationItem(source: .local("DiceRolling"), frames: ManagedAnimationFrameRange(startFrame: 0, endFrame: 0), duration: 0.3))
|
||||
self.trackTo(item: ManagedAnimationItem(source: .local("DiceRolling"), frames: ManagedAnimationFrameRange(startFrame: 0, endFrame: 0), duration: 0.3, loop: true))
|
||||
case let .value(value):
|
||||
break
|
||||
}
|
||||
@ -107,7 +107,7 @@ final class ManagedDiceAnimationNode: ManagedAnimationNode, GenericAnimatedStick
|
||||
}
|
||||
}))
|
||||
case .rolling:
|
||||
self.trackTo(item: ManagedAnimationItem(source: .local("DiceRolling"), frames: ManagedAnimationFrameRange(startFrame: 0, endFrame: 0), duration: 0.3))
|
||||
self.trackTo(item: ManagedAnimationItem(source: .local("DiceRolling"), frames: ManagedAnimationFrameRange(startFrame: 0, endFrame: 0), duration: 0.3, loop: true))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user