mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Colored location stickers
This commit is contained in:
parent
8e4da0cd18
commit
c45ea439c7
@ -171,6 +171,12 @@ public final class DrawingLocationEntityView: DrawingEntityView, UITextViewDeleg
|
|||||||
case .black:
|
case .black:
|
||||||
updatedStyle = .transparent
|
updatedStyle = .transparent
|
||||||
case .transparent:
|
case .transparent:
|
||||||
|
if self.locationEntity.hasCustomColor {
|
||||||
|
updatedStyle = .custom
|
||||||
|
} else {
|
||||||
|
updatedStyle = .white
|
||||||
|
}
|
||||||
|
case .custom:
|
||||||
updatedStyle = .white
|
updatedStyle = .white
|
||||||
case .blur:
|
case .blur:
|
||||||
updatedStyle = .white
|
updatedStyle = .white
|
||||||
@ -217,6 +223,8 @@ public final class DrawingLocationEntityView: DrawingEntityView, UITextViewDeleg
|
|||||||
textColor = .black
|
textColor = .black
|
||||||
case .black, .transparent, .blur:
|
case .black, .transparent, .blur:
|
||||||
textColor = .white
|
textColor = .white
|
||||||
|
case .custom:
|
||||||
|
textColor = .white
|
||||||
}
|
}
|
||||||
|
|
||||||
text.addAttribute(.foregroundColor, value: textColor, range: range)
|
text.addAttribute(.foregroundColor, value: textColor, range: range)
|
||||||
@ -247,6 +255,11 @@ public final class DrawingLocationEntityView: DrawingEntityView, UITextViewDeleg
|
|||||||
self.backgroundView.backgroundColor = UIColor(rgb: 0x000000, alpha: 0.2)
|
self.backgroundView.backgroundColor = UIColor(rgb: 0x000000, alpha: 0.2)
|
||||||
self.backgroundView.isHidden = false
|
self.backgroundView.isHidden = false
|
||||||
self.blurredBackgroundView.isHidden = true
|
self.blurredBackgroundView.isHidden = true
|
||||||
|
case .custom:
|
||||||
|
self.textView.textColor = .white
|
||||||
|
self.backgroundView.backgroundColor = self.locationEntity.color.toUIColor()
|
||||||
|
self.backgroundView.isHidden = false
|
||||||
|
self.blurredBackgroundView.isHidden = true
|
||||||
case .blur:
|
case .blur:
|
||||||
self.textView.textColor = .white
|
self.textView.textColor = .white
|
||||||
self.backgroundView.isHidden = true
|
self.backgroundView.isHidden = true
|
||||||
|
@ -11,6 +11,8 @@ public final class DrawingLocationEntity: DrawingEntity, Codable {
|
|||||||
case uuid
|
case uuid
|
||||||
case title
|
case title
|
||||||
case style
|
case style
|
||||||
|
case color
|
||||||
|
case hasCustomColor
|
||||||
case location
|
case location
|
||||||
case icon
|
case icon
|
||||||
case queryId
|
case queryId
|
||||||
@ -27,6 +29,7 @@ public final class DrawingLocationEntity: DrawingEntity, Codable {
|
|||||||
case white
|
case white
|
||||||
case black
|
case black
|
||||||
case transparent
|
case transparent
|
||||||
|
case custom
|
||||||
case blur
|
case blur
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +45,18 @@ public final class DrawingLocationEntity: DrawingEntity, Codable {
|
|||||||
public var icon: TelegramMediaFile?
|
public var icon: TelegramMediaFile?
|
||||||
public var queryId: Int64?
|
public var queryId: Int64?
|
||||||
public var resultId: String?
|
public var resultId: String?
|
||||||
public var color: DrawingColor = .clear
|
public var color: DrawingColor = DrawingColor(color: .white) {
|
||||||
|
didSet {
|
||||||
|
if self.color.toUIColor().argb == UIColor.white.argb {
|
||||||
|
self.style = .white
|
||||||
|
self.hasCustomColor = false
|
||||||
|
} else {
|
||||||
|
self.style = .custom
|
||||||
|
self.hasCustomColor = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var hasCustomColor = false
|
||||||
public var lineWidth: CGFloat = 0.0
|
public var lineWidth: CGFloat = 0.0
|
||||||
|
|
||||||
public var referenceDrawingSize: CGSize
|
public var referenceDrawingSize: CGSize
|
||||||
@ -88,6 +102,8 @@ public final class DrawingLocationEntity: DrawingEntity, Codable {
|
|||||||
self.uuid = try container.decode(UUID.self, forKey: .uuid)
|
self.uuid = try container.decode(UUID.self, forKey: .uuid)
|
||||||
self.title = try container.decode(String.self, forKey: .title)
|
self.title = try container.decode(String.self, forKey: .title)
|
||||||
self.style = try container.decode(Style.self, forKey: .style)
|
self.style = try container.decode(Style.self, forKey: .style)
|
||||||
|
self.color = try container.decodeIfPresent(DrawingColor.self, forKey: .color) ?? DrawingColor(color: .white)
|
||||||
|
self.hasCustomColor = try container.decodeIfPresent(Bool.self, forKey: .hasCustomColor) ?? false
|
||||||
|
|
||||||
if let locationData = try container.decodeIfPresent(Data.self, forKey: .location) {
|
if let locationData = try container.decodeIfPresent(Data.self, forKey: .location) {
|
||||||
self.location = PostboxDecoder(buffer: MemoryBuffer(data: locationData)).decodeRootObject() as! TelegramMediaMap
|
self.location = PostboxDecoder(buffer: MemoryBuffer(data: locationData)).decodeRootObject() as! TelegramMediaMap
|
||||||
@ -117,6 +133,8 @@ public final class DrawingLocationEntity: DrawingEntity, Codable {
|
|||||||
try container.encode(self.uuid, forKey: .uuid)
|
try container.encode(self.uuid, forKey: .uuid)
|
||||||
try container.encode(self.title, forKey: .title)
|
try container.encode(self.title, forKey: .title)
|
||||||
try container.encode(self.style, forKey: .style)
|
try container.encode(self.style, forKey: .style)
|
||||||
|
try container.encode(self.color, forKey: .color)
|
||||||
|
try container.encode(self.hasCustomColor, forKey: .hasCustomColor)
|
||||||
|
|
||||||
var encoder = PostboxEncoder()
|
var encoder = PostboxEncoder()
|
||||||
encoder.encodeRootObject(self.location)
|
encoder.encodeRootObject(self.location)
|
||||||
|
@ -116,16 +116,24 @@ public final class MediaEditorValues: Codable, Equatable {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if let lhsToolValue = lhsToolValue as? Float, let rhsToolValue = rhsToolValue as? Float {
|
if let lhsToolValue = lhsToolValue as? Float, let rhsToolValue = rhsToolValue as? Float {
|
||||||
return lhsToolValue != rhsToolValue
|
if lhsToolValue != rhsToolValue {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let lhsToolValue = lhsToolValue as? BlurValue, let rhsToolValue = rhsToolValue as? BlurValue {
|
if let lhsToolValue = lhsToolValue as? BlurValue, let rhsToolValue = rhsToolValue as? BlurValue {
|
||||||
return lhsToolValue != rhsToolValue
|
if lhsToolValue != rhsToolValue {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let lhsToolValue = lhsToolValue as? TintValue, let rhsToolValue = rhsToolValue as? TintValue {
|
if let lhsToolValue = lhsToolValue as? TintValue, let rhsToolValue = rhsToolValue as? TintValue {
|
||||||
return lhsToolValue != rhsToolValue
|
if lhsToolValue != rhsToolValue {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let lhsToolValue = lhsToolValue as? CurvesValue, let rhsToolValue = rhsToolValue as? CurvesValue {
|
if let lhsToolValue = lhsToolValue as? CurvesValue, let rhsToolValue = rhsToolValue as? CurvesValue {
|
||||||
return lhsToolValue != rhsToolValue
|
if lhsToolValue != rhsToolValue {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user