mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
4e46697a66
commit
31ba87fb0f
@ -12582,3 +12582,5 @@ Sorry for the inconvenience.";
|
|||||||
"WebBrowser.Exceptions.Create.Placeholder" = "Enter URL";
|
"WebBrowser.Exceptions.Create.Placeholder" = "Enter URL";
|
||||||
|
|
||||||
"WebBrowser.Done" = "Done";
|
"WebBrowser.Done" = "Done";
|
||||||
|
|
||||||
|
"AccessDenied.LocationWeather" = "Telegram needs access to your location so that you can add the weather widget to your stories.\n\nPlease go to Settings > Privacy > Location Services and set Telegram to ON.";
|
||||||
|
@ -36,6 +36,7 @@ public enum DeviceAccessLocationSubject {
|
|||||||
case send
|
case send
|
||||||
case live
|
case live
|
||||||
case tracking
|
case tracking
|
||||||
|
case weather
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DeviceAccessSubject {
|
public enum DeviceAccessSubject {
|
||||||
@ -474,7 +475,7 @@ public final class DeviceAccess {
|
|||||||
}
|
}
|
||||||
case .authorizedWhenInUse:
|
case .authorizedWhenInUse:
|
||||||
switch locationSubject {
|
switch locationSubject {
|
||||||
case .send, .tracking:
|
case .send, .tracking, .weather:
|
||||||
completion(true)
|
completion(true)
|
||||||
case .live:
|
case .live:
|
||||||
completion(false)
|
completion(false)
|
||||||
@ -495,6 +496,8 @@ public final class DeviceAccess {
|
|||||||
text = presentationData.strings.AccessDenied_LocationDenied
|
text = presentationData.strings.AccessDenied_LocationDenied
|
||||||
case .tracking:
|
case .tracking:
|
||||||
text = presentationData.strings.AccessDenied_LocationTracking
|
text = presentationData.strings.AccessDenied_LocationTracking
|
||||||
|
case .weather:
|
||||||
|
text = presentationData.strings.AccessDenied_LocationWeather
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
text = presentationData.strings.AccessDenied_LocationDisabled
|
text = presentationData.strings.AccessDenied_LocationDisabled
|
||||||
@ -505,7 +508,7 @@ public final class DeviceAccess {
|
|||||||
}
|
}
|
||||||
case .notDetermined:
|
case .notDetermined:
|
||||||
switch locationSubject {
|
switch locationSubject {
|
||||||
case .send, .tracking:
|
case .send, .tracking, .weather:
|
||||||
locationManager?.requestWhenInUseAuthorization(completion: { status in
|
locationManager?.requestWhenInUseAuthorization(completion: { status in
|
||||||
completion(status == .authorizedWhenInUse || status == .authorizedAlways)
|
completion(status == .authorizedWhenInUse || status == .authorizedAlways)
|
||||||
})
|
})
|
||||||
|
@ -159,6 +159,14 @@ public final class DrawingWeatherEntityView: DrawingEntityView, UITextViewDelega
|
|||||||
case .white:
|
case .white:
|
||||||
updatedStyle = .black
|
updatedStyle = .black
|
||||||
case .black:
|
case .black:
|
||||||
|
updatedStyle = .transparent
|
||||||
|
case .transparent:
|
||||||
|
if self.weatherEntity.hasCustomColor {
|
||||||
|
updatedStyle = .custom
|
||||||
|
} else {
|
||||||
|
updatedStyle = .white
|
||||||
|
}
|
||||||
|
case .custom:
|
||||||
updatedStyle = .white
|
updatedStyle = .white
|
||||||
}
|
}
|
||||||
self.weatherEntity.style = updatedStyle
|
self.weatherEntity.style = updatedStyle
|
||||||
@ -201,8 +209,15 @@ public final class DrawingWeatherEntityView: DrawingEntityView, UITextViewDelega
|
|||||||
switch self.weatherEntity.style {
|
switch self.weatherEntity.style {
|
||||||
case .white:
|
case .white:
|
||||||
textColor = .black
|
textColor = .black
|
||||||
case .black:
|
case .black, .transparent:
|
||||||
textColor = .white
|
textColor = .white
|
||||||
|
case .custom:
|
||||||
|
let color = self.weatherEntity.color.toUIColor()
|
||||||
|
if color.lightness > 0.705 {
|
||||||
|
textColor = .black
|
||||||
|
} else {
|
||||||
|
textColor = .white
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text.addAttribute(.foregroundColor, value: textColor, range: range)
|
text.addAttribute(.foregroundColor, value: textColor, range: range)
|
||||||
@ -226,6 +241,21 @@ public final class DrawingWeatherEntityView: DrawingEntityView, UITextViewDelega
|
|||||||
self.textView.textColor = .white
|
self.textView.textColor = .white
|
||||||
self.backgroundView.backgroundColor = .black
|
self.backgroundView.backgroundColor = .black
|
||||||
self.backgroundView.isHidden = false
|
self.backgroundView.isHidden = false
|
||||||
|
case .transparent:
|
||||||
|
self.textView.textColor = .white
|
||||||
|
self.backgroundView.backgroundColor = UIColor(rgb: 0x000000, alpha: 0.2)
|
||||||
|
self.backgroundView.isHidden = false
|
||||||
|
case .custom:
|
||||||
|
let color = self.weatherEntity.color.toUIColor()
|
||||||
|
let textColor: UIColor
|
||||||
|
if color.lightness > 0.705 {
|
||||||
|
textColor = .black
|
||||||
|
} else {
|
||||||
|
textColor = .white
|
||||||
|
}
|
||||||
|
self.textView.textColor = textColor
|
||||||
|
self.backgroundView.backgroundColor = color
|
||||||
|
self.backgroundView.isHidden = false
|
||||||
}
|
}
|
||||||
self.textView.textAlignment = .left
|
self.textView.textAlignment = .left
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[340088945] = { return Api.MediaArea.parse_mediaAreaSuggestedReaction($0) }
|
dict[340088945] = { return Api.MediaArea.parse_mediaAreaSuggestedReaction($0) }
|
||||||
dict[926421125] = { return Api.MediaArea.parse_mediaAreaUrl($0) }
|
dict[926421125] = { return Api.MediaArea.parse_mediaAreaUrl($0) }
|
||||||
dict[-1098720356] = { return Api.MediaArea.parse_mediaAreaVenue($0) }
|
dict[-1098720356] = { return Api.MediaArea.parse_mediaAreaVenue($0) }
|
||||||
dict[1132918857] = { return Api.MediaArea.parse_mediaAreaWeather($0) }
|
dict[1235637404] = { return Api.MediaArea.parse_mediaAreaWeather($0) }
|
||||||
dict[-808853502] = { return Api.MediaAreaCoordinates.parse_mediaAreaCoordinates($0) }
|
dict[-808853502] = { return Api.MediaAreaCoordinates.parse_mediaAreaCoordinates($0) }
|
||||||
dict[-1808510398] = { return Api.Message.parse_message($0) }
|
dict[-1808510398] = { return Api.Message.parse_message($0) }
|
||||||
dict[-1868117372] = { return Api.Message.parse_messageEmpty($0) }
|
dict[-1868117372] = { return Api.Message.parse_messageEmpty($0) }
|
||||||
@ -1170,6 +1170,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[-1542017919] = { return Api.auth.SentCodeType.parse_sentCodeTypeSmsWord($0) }
|
dict[-1542017919] = { return Api.auth.SentCodeType.parse_sentCodeTypeSmsWord($0) }
|
||||||
dict[-391678544] = { return Api.bots.BotInfo.parse_botInfo($0) }
|
dict[-391678544] = { return Api.bots.BotInfo.parse_botInfo($0) }
|
||||||
dict[428978491] = { return Api.bots.PopularAppBots.parse_popularAppBots($0) }
|
dict[428978491] = { return Api.bots.PopularAppBots.parse_popularAppBots($0) }
|
||||||
|
dict[1357069389] = { return Api.bots.PreviewInfo.parse_previewInfo($0) }
|
||||||
dict[-309659827] = { return Api.channels.AdminLogResults.parse_adminLogResults($0) }
|
dict[-309659827] = { return Api.channels.AdminLogResults.parse_adminLogResults($0) }
|
||||||
dict[-541588713] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) }
|
dict[-541588713] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) }
|
||||||
dict[-1699676497] = { return Api.channels.ChannelParticipants.parse_channelParticipants($0) }
|
dict[-1699676497] = { return Api.channels.ChannelParticipants.parse_channelParticipants($0) }
|
||||||
@ -1399,7 +1400,7 @@ public extension Api {
|
|||||||
return parser(reader)
|
return parser(reader)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
telegramApiLog("Type constructor \(String(UInt32(bitPattern: signature), radix: 16, uppercase: false)) not found")
|
telegramApiLog("Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2151,6 +2152,8 @@ public extension Api {
|
|||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.bots.PopularAppBots:
|
case let _1 as Api.bots.PopularAppBots:
|
||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
|
case let _1 as Api.bots.PreviewInfo:
|
||||||
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.channels.AdminLogResults:
|
case let _1 as Api.channels.AdminLogResults:
|
||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.channels.ChannelParticipant:
|
case let _1 as Api.channels.ChannelParticipant:
|
||||||
|
@ -231,7 +231,7 @@ public extension Api {
|
|||||||
case mediaAreaSuggestedReaction(flags: Int32, coordinates: Api.MediaAreaCoordinates, reaction: Api.Reaction)
|
case mediaAreaSuggestedReaction(flags: Int32, coordinates: Api.MediaAreaCoordinates, reaction: Api.Reaction)
|
||||||
case mediaAreaUrl(coordinates: Api.MediaAreaCoordinates, url: String)
|
case mediaAreaUrl(coordinates: Api.MediaAreaCoordinates, url: String)
|
||||||
case mediaAreaVenue(coordinates: Api.MediaAreaCoordinates, geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String)
|
case mediaAreaVenue(coordinates: Api.MediaAreaCoordinates, geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String)
|
||||||
case mediaAreaWeather(flags: Int32, coordinates: Api.MediaAreaCoordinates, emoji: String, temperatureC: Double)
|
case mediaAreaWeather(coordinates: Api.MediaAreaCoordinates, emoji: String, temperatureC: Double, color: Int32)
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
@ -295,14 +295,14 @@ public extension Api {
|
|||||||
serializeString(venueId, buffer: buffer, boxed: false)
|
serializeString(venueId, buffer: buffer, boxed: false)
|
||||||
serializeString(venueType, buffer: buffer, boxed: false)
|
serializeString(venueType, buffer: buffer, boxed: false)
|
||||||
break
|
break
|
||||||
case .mediaAreaWeather(let flags, let coordinates, let emoji, let temperatureC):
|
case .mediaAreaWeather(let coordinates, let emoji, let temperatureC, let color):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(1132918857)
|
buffer.appendInt32(1235637404)
|
||||||
}
|
}
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
|
||||||
coordinates.serialize(buffer, true)
|
coordinates.serialize(buffer, true)
|
||||||
serializeString(emoji, buffer: buffer, boxed: false)
|
serializeString(emoji, buffer: buffer, boxed: false)
|
||||||
serializeDouble(temperatureC, buffer: buffer, boxed: false)
|
serializeDouble(temperatureC, buffer: buffer, boxed: false)
|
||||||
|
serializeInt32(color, buffer: buffer, boxed: false)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,8 +323,8 @@ public extension Api {
|
|||||||
return ("mediaAreaUrl", [("coordinates", coordinates as Any), ("url", url as Any)])
|
return ("mediaAreaUrl", [("coordinates", coordinates as Any), ("url", url as Any)])
|
||||||
case .mediaAreaVenue(let coordinates, let geo, let title, let address, let provider, let venueId, let venueType):
|
case .mediaAreaVenue(let coordinates, let geo, let title, let address, let provider, let venueId, let venueType):
|
||||||
return ("mediaAreaVenue", [("coordinates", coordinates as Any), ("geo", geo as Any), ("title", title as Any), ("address", address as Any), ("provider", provider as Any), ("venueId", venueId as Any), ("venueType", venueType as Any)])
|
return ("mediaAreaVenue", [("coordinates", coordinates as Any), ("geo", geo as Any), ("title", title as Any), ("address", address as Any), ("provider", provider as Any), ("venueId", venueId as Any), ("venueType", venueType as Any)])
|
||||||
case .mediaAreaWeather(let flags, let coordinates, let emoji, let temperatureC):
|
case .mediaAreaWeather(let coordinates, let emoji, let temperatureC, let color):
|
||||||
return ("mediaAreaWeather", [("flags", flags as Any), ("coordinates", coordinates as Any), ("emoji", emoji as Any), ("temperatureC", temperatureC as Any)])
|
return ("mediaAreaWeather", [("coordinates", coordinates as Any), ("emoji", emoji as Any), ("temperatureC", temperatureC as Any), ("color", color as Any)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,22 +484,22 @@ public extension Api {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static func parse_mediaAreaWeather(_ reader: BufferReader) -> MediaArea? {
|
public static func parse_mediaAreaWeather(_ reader: BufferReader) -> MediaArea? {
|
||||||
var _1: Int32?
|
var _1: Api.MediaAreaCoordinates?
|
||||||
_1 = reader.readInt32()
|
|
||||||
var _2: Api.MediaAreaCoordinates?
|
|
||||||
if let signature = reader.readInt32() {
|
if let signature = reader.readInt32() {
|
||||||
_2 = Api.parse(reader, signature: signature) as? Api.MediaAreaCoordinates
|
_1 = Api.parse(reader, signature: signature) as? Api.MediaAreaCoordinates
|
||||||
}
|
}
|
||||||
var _3: String?
|
var _2: String?
|
||||||
_3 = parseString(reader)
|
_2 = parseString(reader)
|
||||||
var _4: Double?
|
var _3: Double?
|
||||||
_4 = reader.readDouble()
|
_3 = reader.readDouble()
|
||||||
|
var _4: Int32?
|
||||||
|
_4 = reader.readInt32()
|
||||||
let _c1 = _1 != nil
|
let _c1 = _1 != nil
|
||||||
let _c2 = _2 != nil
|
let _c2 = _2 != nil
|
||||||
let _c3 = _3 != nil
|
let _c3 = _3 != nil
|
||||||
let _c4 = _4 != nil
|
let _c4 = _4 != nil
|
||||||
if _c1 && _c2 && _c3 && _c4 {
|
if _c1 && _c2 && _c3 && _c4 {
|
||||||
return Api.MediaArea.mediaAreaWeather(flags: _1!, coordinates: _2!, emoji: _3!, temperatureC: _4!)
|
return Api.MediaArea.mediaAreaWeather(coordinates: _1!, emoji: _2!, temperatureC: _3!, color: _4!)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -1,3 +1,55 @@
|
|||||||
|
public extension Api.bots {
|
||||||
|
enum PreviewInfo: TypeConstructorDescription {
|
||||||
|
case previewInfo(media: [Api.MessageMedia], langCodes: [String])
|
||||||
|
|
||||||
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
|
switch self {
|
||||||
|
case .previewInfo(let media, let langCodes):
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(1357069389)
|
||||||
|
}
|
||||||
|
buffer.appendInt32(481674261)
|
||||||
|
buffer.appendInt32(Int32(media.count))
|
||||||
|
for item in media {
|
||||||
|
item.serialize(buffer, true)
|
||||||
|
}
|
||||||
|
buffer.appendInt32(481674261)
|
||||||
|
buffer.appendInt32(Int32(langCodes.count))
|
||||||
|
for item in langCodes {
|
||||||
|
serializeString(item, buffer: buffer, boxed: false)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||||
|
switch self {
|
||||||
|
case .previewInfo(let media, let langCodes):
|
||||||
|
return ("previewInfo", [("media", media as Any), ("langCodes", langCodes as Any)])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func parse_previewInfo(_ reader: BufferReader) -> PreviewInfo? {
|
||||||
|
var _1: [Api.MessageMedia]?
|
||||||
|
if let _ = reader.readInt32() {
|
||||||
|
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageMedia.self)
|
||||||
|
}
|
||||||
|
var _2: [String]?
|
||||||
|
if let _ = reader.readInt32() {
|
||||||
|
_2 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self)
|
||||||
|
}
|
||||||
|
let _c1 = _1 != nil
|
||||||
|
let _c2 = _2 != nil
|
||||||
|
if _c1 && _c2 {
|
||||||
|
return Api.bots.PreviewInfo.previewInfo(media: _1!, langCodes: _2!)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
public extension Api.channels {
|
public extension Api.channels {
|
||||||
enum AdminLogResults: TypeConstructorDescription {
|
enum AdminLogResults: TypeConstructorDescription {
|
||||||
case adminLogResults(events: [Api.ChannelAdminLogEvent], chats: [Api.Chat], users: [Api.User])
|
case adminLogResults(events: [Api.ChannelAdminLogEvent], chats: [Api.Chat], users: [Api.User])
|
||||||
@ -1404,61 +1456,3 @@ public extension Api.help {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public extension Api.help {
|
|
||||||
enum Country: TypeConstructorDescription {
|
|
||||||
case country(flags: Int32, iso2: String, defaultName: String, name: String?, countryCodes: [Api.help.CountryCode])
|
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
|
||||||
switch self {
|
|
||||||
case .country(let flags, let iso2, let defaultName, let name, let countryCodes):
|
|
||||||
if boxed {
|
|
||||||
buffer.appendInt32(-1014526429)
|
|
||||||
}
|
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
|
||||||
serializeString(iso2, buffer: buffer, boxed: false)
|
|
||||||
serializeString(defaultName, buffer: buffer, boxed: false)
|
|
||||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(name!, buffer: buffer, boxed: false)}
|
|
||||||
buffer.appendInt32(481674261)
|
|
||||||
buffer.appendInt32(Int32(countryCodes.count))
|
|
||||||
for item in countryCodes {
|
|
||||||
item.serialize(buffer, true)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
|
||||||
switch self {
|
|
||||||
case .country(let flags, let iso2, let defaultName, let name, let countryCodes):
|
|
||||||
return ("country", [("flags", flags as Any), ("iso2", iso2 as Any), ("defaultName", defaultName as Any), ("name", name as Any), ("countryCodes", countryCodes as Any)])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func parse_country(_ reader: BufferReader) -> Country? {
|
|
||||||
var _1: Int32?
|
|
||||||
_1 = reader.readInt32()
|
|
||||||
var _2: String?
|
|
||||||
_2 = parseString(reader)
|
|
||||||
var _3: String?
|
|
||||||
_3 = parseString(reader)
|
|
||||||
var _4: String?
|
|
||||||
if Int(_1!) & Int(1 << 1) != 0 {_4 = parseString(reader) }
|
|
||||||
var _5: [Api.help.CountryCode]?
|
|
||||||
if let _ = reader.readInt32() {
|
|
||||||
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.help.CountryCode.self)
|
|
||||||
}
|
|
||||||
let _c1 = _1 != nil
|
|
||||||
let _c2 = _2 != nil
|
|
||||||
let _c3 = _3 != nil
|
|
||||||
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
|
|
||||||
let _c5 = _5 != nil
|
|
||||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
|
||||||
return Api.help.Country.country(flags: _1!, iso2: _2!, defaultName: _3!, name: _4, countryCodes: _5!)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,3 +1,61 @@
|
|||||||
|
public extension Api.help {
|
||||||
|
enum Country: TypeConstructorDescription {
|
||||||
|
case country(flags: Int32, iso2: String, defaultName: String, name: String?, countryCodes: [Api.help.CountryCode])
|
||||||
|
|
||||||
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
|
switch self {
|
||||||
|
case .country(let flags, let iso2, let defaultName, let name, let countryCodes):
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(-1014526429)
|
||||||
|
}
|
||||||
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
|
serializeString(iso2, buffer: buffer, boxed: false)
|
||||||
|
serializeString(defaultName, buffer: buffer, boxed: false)
|
||||||
|
if Int(flags) & Int(1 << 1) != 0 {serializeString(name!, buffer: buffer, boxed: false)}
|
||||||
|
buffer.appendInt32(481674261)
|
||||||
|
buffer.appendInt32(Int32(countryCodes.count))
|
||||||
|
for item in countryCodes {
|
||||||
|
item.serialize(buffer, true)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||||
|
switch self {
|
||||||
|
case .country(let flags, let iso2, let defaultName, let name, let countryCodes):
|
||||||
|
return ("country", [("flags", flags as Any), ("iso2", iso2 as Any), ("defaultName", defaultName as Any), ("name", name as Any), ("countryCodes", countryCodes as Any)])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func parse_country(_ reader: BufferReader) -> Country? {
|
||||||
|
var _1: Int32?
|
||||||
|
_1 = reader.readInt32()
|
||||||
|
var _2: String?
|
||||||
|
_2 = parseString(reader)
|
||||||
|
var _3: String?
|
||||||
|
_3 = parseString(reader)
|
||||||
|
var _4: String?
|
||||||
|
if Int(_1!) & Int(1 << 1) != 0 {_4 = parseString(reader) }
|
||||||
|
var _5: [Api.help.CountryCode]?
|
||||||
|
if let _ = reader.readInt32() {
|
||||||
|
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.help.CountryCode.self)
|
||||||
|
}
|
||||||
|
let _c1 = _1 != nil
|
||||||
|
let _c2 = _2 != nil
|
||||||
|
let _c3 = _3 != nil
|
||||||
|
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
|
||||||
|
let _c5 = _5 != nil
|
||||||
|
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
||||||
|
return Api.help.Country.country(flags: _1!, iso2: _2!, defaultName: _3!, name: _4, countryCodes: _5!)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
public extension Api.help {
|
public extension Api.help {
|
||||||
enum CountryCode: TypeConstructorDescription {
|
enum CountryCode: TypeConstructorDescription {
|
||||||
case countryCode(flags: Int32, countryCode: String, prefixes: [String]?, patterns: [String]?)
|
case countryCode(flags: Int32, countryCode: String, prefixes: [String]?, patterns: [String]?)
|
||||||
|
@ -2201,12 +2201,13 @@ public extension Api.functions.auth {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public extension Api.functions.bots {
|
public extension Api.functions.bots {
|
||||||
static func addPreviewMedia(bot: Api.InputUser, media: Api.InputMedia) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.MessageMedia>) {
|
static func addPreviewMedia(bot: Api.InputUser, langCode: String, media: Api.InputMedia) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.MessageMedia>) {
|
||||||
let buffer = Buffer()
|
let buffer = Buffer()
|
||||||
buffer.appendInt32(1633332331)
|
buffer.appendInt32(911238190)
|
||||||
bot.serialize(buffer, true)
|
bot.serialize(buffer, true)
|
||||||
|
serializeString(langCode, buffer: buffer, boxed: false)
|
||||||
media.serialize(buffer, true)
|
media.serialize(buffer, true)
|
||||||
return (FunctionDescription(name: "bots.addPreviewMedia", parameters: [("bot", String(describing: bot)), ("media", String(describing: media))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.MessageMedia? in
|
return (FunctionDescription(name: "bots.addPreviewMedia", parameters: [("bot", String(describing: bot)), ("langCode", String(describing: langCode)), ("media", String(describing: media))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.MessageMedia? in
|
||||||
let reader = BufferReader(buffer)
|
let reader = BufferReader(buffer)
|
||||||
var result: Api.MessageMedia?
|
var result: Api.MessageMedia?
|
||||||
if let signature = reader.readInt32() {
|
if let signature = reader.readInt32() {
|
||||||
@ -2263,16 +2264,17 @@ public extension Api.functions.bots {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public extension Api.functions.bots {
|
public extension Api.functions.bots {
|
||||||
static func deletePreviewMedia(bot: Api.InputUser, media: [Api.InputMedia]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
static func deletePreviewMedia(bot: Api.InputUser, langCode: String, media: [Api.InputMedia]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||||
let buffer = Buffer()
|
let buffer = Buffer()
|
||||||
buffer.appendInt32(481471475)
|
buffer.appendInt32(755054003)
|
||||||
bot.serialize(buffer, true)
|
bot.serialize(buffer, true)
|
||||||
|
serializeString(langCode, buffer: buffer, boxed: false)
|
||||||
buffer.appendInt32(481674261)
|
buffer.appendInt32(481674261)
|
||||||
buffer.appendInt32(Int32(media.count))
|
buffer.appendInt32(Int32(media.count))
|
||||||
for item in media {
|
for item in media {
|
||||||
item.serialize(buffer, true)
|
item.serialize(buffer, true)
|
||||||
}
|
}
|
||||||
return (FunctionDescription(name: "bots.deletePreviewMedia", parameters: [("bot", String(describing: bot)), ("media", String(describing: media))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
return (FunctionDescription(name: "bots.deletePreviewMedia", parameters: [("bot", String(describing: bot)), ("langCode", String(describing: langCode)), ("media", String(describing: media))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||||
let reader = BufferReader(buffer)
|
let reader = BufferReader(buffer)
|
||||||
var result: Api.Bool?
|
var result: Api.Bool?
|
||||||
if let signature = reader.readInt32() {
|
if let signature = reader.readInt32() {
|
||||||
@ -2283,13 +2285,14 @@ public extension Api.functions.bots {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public extension Api.functions.bots {
|
public extension Api.functions.bots {
|
||||||
static func editPreviewMedia(bot: Api.InputUser, media: Api.InputMedia, newMedia: Api.InputMedia) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.MessageMedia>) {
|
static func editPreviewMedia(bot: Api.InputUser, langCode: String, media: Api.InputMedia, newMedia: Api.InputMedia) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.MessageMedia>) {
|
||||||
let buffer = Buffer()
|
let buffer = Buffer()
|
||||||
buffer.appendInt32(-1436441263)
|
buffer.appendInt32(1892426154)
|
||||||
bot.serialize(buffer, true)
|
bot.serialize(buffer, true)
|
||||||
|
serializeString(langCode, buffer: buffer, boxed: false)
|
||||||
media.serialize(buffer, true)
|
media.serialize(buffer, true)
|
||||||
newMedia.serialize(buffer, true)
|
newMedia.serialize(buffer, true)
|
||||||
return (FunctionDescription(name: "bots.editPreviewMedia", parameters: [("bot", String(describing: bot)), ("media", String(describing: media)), ("newMedia", String(describing: newMedia))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.MessageMedia? in
|
return (FunctionDescription(name: "bots.editPreviewMedia", parameters: [("bot", String(describing: bot)), ("langCode", String(describing: langCode)), ("media", String(describing: media)), ("newMedia", String(describing: newMedia))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.MessageMedia? in
|
||||||
let reader = BufferReader(buffer)
|
let reader = BufferReader(buffer)
|
||||||
var result: Api.MessageMedia?
|
var result: Api.MessageMedia?
|
||||||
if let signature = reader.readInt32() {
|
if let signature = reader.readInt32() {
|
||||||
@ -2363,6 +2366,22 @@ public extension Api.functions.bots {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public extension Api.functions.bots {
|
||||||
|
static func getPreviewInfo(bot: Api.InputUser, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.bots.PreviewInfo>) {
|
||||||
|
let buffer = Buffer()
|
||||||
|
buffer.appendInt32(1111143341)
|
||||||
|
bot.serialize(buffer, true)
|
||||||
|
serializeString(langCode, buffer: buffer, boxed: false)
|
||||||
|
return (FunctionDescription(name: "bots.getPreviewInfo", parameters: [("bot", String(describing: bot)), ("langCode", String(describing: langCode))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.bots.PreviewInfo? in
|
||||||
|
let reader = BufferReader(buffer)
|
||||||
|
var result: Api.bots.PreviewInfo?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
result = Api.parse(reader, signature: signature) as? Api.bots.PreviewInfo
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
public extension Api.functions.bots {
|
public extension Api.functions.bots {
|
||||||
static func getPreviewMedias(bot: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.MessageMedia]>) {
|
static func getPreviewMedias(bot: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.MessageMedia]>) {
|
||||||
let buffer = Buffer()
|
let buffer = Buffer()
|
||||||
@ -2396,16 +2415,17 @@ public extension Api.functions.bots {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public extension Api.functions.bots {
|
public extension Api.functions.bots {
|
||||||
static func reorderPreviewMedias(bot: Api.InputUser, order: [Api.InputMedia]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
static func reorderPreviewMedias(bot: Api.InputUser, langCode: String, order: [Api.InputMedia]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||||
let buffer = Buffer()
|
let buffer = Buffer()
|
||||||
buffer.appendInt32(-1472444656)
|
buffer.appendInt32(-1238895702)
|
||||||
bot.serialize(buffer, true)
|
bot.serialize(buffer, true)
|
||||||
|
serializeString(langCode, buffer: buffer, boxed: false)
|
||||||
buffer.appendInt32(481674261)
|
buffer.appendInt32(481674261)
|
||||||
buffer.appendInt32(Int32(order.count))
|
buffer.appendInt32(Int32(order.count))
|
||||||
for item in order {
|
for item in order {
|
||||||
item.serialize(buffer, true)
|
item.serialize(buffer, true)
|
||||||
}
|
}
|
||||||
return (FunctionDescription(name: "bots.reorderPreviewMedias", parameters: [("bot", String(describing: bot)), ("order", String(describing: order))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
return (FunctionDescription(name: "bots.reorderPreviewMedias", parameters: [("bot", String(describing: bot)), ("langCode", String(describing: langCode)), ("order", String(describing: order))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||||
let reader = BufferReader(buffer)
|
let reader = BufferReader(buffer)
|
||||||
var result: Api.Bool?
|
var result: Api.Bool?
|
||||||
if let signature = reader.readInt32() {
|
if let signature = reader.readInt32() {
|
||||||
|
@ -522,12 +522,8 @@ func mediaAreaFromApiMediaArea(_ mediaArea: Api.MediaArea) -> MediaArea? {
|
|||||||
return .link(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), url: url)
|
return .link(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), url: url)
|
||||||
case let .mediaAreaChannelPost(coordinates, channelId, messageId):
|
case let .mediaAreaChannelPost(coordinates, channelId, messageId):
|
||||||
return .channelMessage(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), messageId: EngineMessage.Id(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: messageId))
|
return .channelMessage(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), messageId: EngineMessage.Id(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: messageId))
|
||||||
case let .mediaAreaWeather(flags, coordinates, emoji, temperatureC):
|
case let .mediaAreaWeather(coordinates, emoji, temperatureC, color):
|
||||||
var parsedFlags = MediaArea.WeatherFlags()
|
return .weather(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), emoji: emoji, temperature: temperatureC, color: color)
|
||||||
if (flags & (1 << 0)) != 0 {
|
|
||||||
parsedFlags.insert(.isDark)
|
|
||||||
}
|
|
||||||
return .weather(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), emoji: emoji, temperature: temperatureC, flags: parsedFlags)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,12 +576,8 @@ func apiMediaAreasFromMediaAreas(_ mediaAreas: [MediaArea], transaction: Transac
|
|||||||
}
|
}
|
||||||
case let .link(_, url):
|
case let .link(_, url):
|
||||||
apiMediaAreas.append(.mediaAreaUrl(coordinates: inputCoordinates, url: url))
|
apiMediaAreas.append(.mediaAreaUrl(coordinates: inputCoordinates, url: url))
|
||||||
case let .weather(_, emoji, temperature, flags):
|
case let .weather(_, emoji, temperature, color):
|
||||||
var apiFlags: Int32 = 0
|
apiMediaAreas.append(.mediaAreaWeather(coordinates: inputCoordinates, emoji: emoji, temperatureC: temperature, color: color))
|
||||||
if flags.contains(.isDark) {
|
|
||||||
apiFlags |= (1 << 0)
|
|
||||||
}
|
|
||||||
apiMediaAreas.append(.mediaAreaWeather(flags: apiFlags, coordinates: inputCoordinates, emoji: emoji, temperatureC: temperature))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return apiMediaAreas
|
return apiMediaAreas
|
||||||
|
@ -8,6 +8,7 @@ public enum MediaArea: Codable, Equatable {
|
|||||||
case value
|
case value
|
||||||
case flags
|
case flags
|
||||||
case temperature
|
case temperature
|
||||||
|
case color
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct Coordinates: Codable, Equatable {
|
public struct Coordinates: Codable, Equatable {
|
||||||
@ -150,7 +151,7 @@ public enum MediaArea: Codable, Equatable {
|
|||||||
case reaction(coordinates: Coordinates, reaction: MessageReaction.Reaction, flags: ReactionFlags)
|
case reaction(coordinates: Coordinates, reaction: MessageReaction.Reaction, flags: ReactionFlags)
|
||||||
case channelMessage(coordinates: Coordinates, messageId: EngineMessage.Id)
|
case channelMessage(coordinates: Coordinates, messageId: EngineMessage.Id)
|
||||||
case link(coordinates: Coordinates, url: String)
|
case link(coordinates: Coordinates, url: String)
|
||||||
case weather(coordinates: Coordinates, emoji: String, temperature: Double, flags: WeatherFlags)
|
case weather(coordinates: Coordinates, emoji: String, temperature: Double, color: Int32)
|
||||||
|
|
||||||
public struct ReactionFlags: OptionSet {
|
public struct ReactionFlags: OptionSet {
|
||||||
public var rawValue: Int32
|
public var rawValue: Int32
|
||||||
@ -167,21 +168,6 @@ public enum MediaArea: Codable, Equatable {
|
|||||||
public static let isFlipped = ReactionFlags(rawValue: 1 << 1)
|
public static let isFlipped = ReactionFlags(rawValue: 1 << 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct WeatherFlags: OptionSet {
|
|
||||||
public var rawValue: Int32
|
|
||||||
|
|
||||||
public init(rawValue: Int32) {
|
|
||||||
self.rawValue = rawValue
|
|
||||||
}
|
|
||||||
|
|
||||||
public init() {
|
|
||||||
self.rawValue = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
public static let isDark = WeatherFlags(rawValue: 1 << 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private enum MediaAreaType: Int32 {
|
private enum MediaAreaType: Int32 {
|
||||||
case venue
|
case venue
|
||||||
case reaction
|
case reaction
|
||||||
@ -222,8 +208,8 @@ public enum MediaArea: Codable, Equatable {
|
|||||||
let coordinates = try container.decode(MediaArea.Coordinates.self, forKey: .coordinates)
|
let coordinates = try container.decode(MediaArea.Coordinates.self, forKey: .coordinates)
|
||||||
let emoji = try container.decode(String.self, forKey: .value)
|
let emoji = try container.decode(String.self, forKey: .value)
|
||||||
let temperature = try container.decode(Double.self, forKey: .temperature)
|
let temperature = try container.decode(Double.self, forKey: .temperature)
|
||||||
let flags = WeatherFlags(rawValue: try container.decodeIfPresent(Int32.self, forKey: .flags) ?? 0)
|
let color = try container.decodeIfPresent(Int32.self, forKey: .color) ?? 0
|
||||||
self = .weather(coordinates: coordinates, emoji: emoji, temperature: temperature, flags: flags)
|
self = .weather(coordinates: coordinates, emoji: emoji, temperature: temperature, color: color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,12 +234,12 @@ public enum MediaArea: Codable, Equatable {
|
|||||||
try container.encode(MediaAreaType.link.rawValue, forKey: .type)
|
try container.encode(MediaAreaType.link.rawValue, forKey: .type)
|
||||||
try container.encode(coordinates, forKey: .coordinates)
|
try container.encode(coordinates, forKey: .coordinates)
|
||||||
try container.encode(url, forKey: .value)
|
try container.encode(url, forKey: .value)
|
||||||
case let .weather(coordinates, emoji, temperature, flags):
|
case let .weather(coordinates, emoji, temperature, color):
|
||||||
try container.encode(MediaAreaType.weather.rawValue, forKey: .type)
|
try container.encode(MediaAreaType.weather.rawValue, forKey: .type)
|
||||||
try container.encode(coordinates, forKey: .coordinates)
|
try container.encode(coordinates, forKey: .coordinates)
|
||||||
try container.encode(emoji, forKey: .value)
|
try container.encode(emoji, forKey: .value)
|
||||||
try container.encode(temperature, forKey: .temperature)
|
try container.encode(temperature, forKey: .temperature)
|
||||||
try container.encode(flags.rawValue, forKey: .flags)
|
try container.encode(color, forKey: .color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1300,7 +1300,7 @@ func _internal_uploadBotPreviewImpl(
|
|||||||
return postbox.transaction { transaction -> Signal<StoryUploadResult, NoError> in
|
return postbox.transaction { transaction -> Signal<StoryUploadResult, NoError> in
|
||||||
switch content.content {
|
switch content.content {
|
||||||
case let .media(inputMedia, _):
|
case let .media(inputMedia, _):
|
||||||
return network.request(Api.functions.bots.addPreviewMedia(bot: inputUser, media: inputMedia))
|
return network.request(Api.functions.bots.addPreviewMedia(bot: inputUser, langCode: "", media: inputMedia))
|
||||||
|> map(Optional.init)
|
|> map(Optional.init)
|
||||||
|> `catch` { _ -> Signal<Api.MessageMedia?, NoError> in
|
|> `catch` { _ -> Signal<Api.MessageMedia?, NoError> in
|
||||||
return .single(nil)
|
return .single(nil)
|
||||||
@ -1402,7 +1402,7 @@ func _internal_deleteBotPreviews(account: Account, peerId: PeerId, ids: [MediaId
|
|||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
|
|
||||||
return account.network.request(Api.functions.bots.deletePreviewMedia(bot: inputPeer, media: inputMedia))
|
return account.network.request(Api.functions.bots.deletePreviewMedia(bot: inputPeer, langCode: "", media: inputMedia))
|
||||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||||
return .single(.boolFalse)
|
return .single(.boolFalse)
|
||||||
}
|
}
|
||||||
|
@ -2307,7 +2307,7 @@ public final class BotPreviewStoryListContext: StoryListContext {
|
|||||||
guard let self, let inputUser else {
|
guard let self, let inputUser else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let signal = self.account.network.request(Api.functions.bots.reorderPreviewMedias(bot: inputUser, order: inputMedia))
|
let signal = self.account.network.request(Api.functions.bots.reorderPreviewMedias(bot: inputUser, langCode: "", order: inputMedia))
|
||||||
self.reorderDisposable.set(signal.startStrict())
|
self.reorderDisposable.set(signal.startStrict())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -192,15 +192,12 @@ public enum CodableDrawingEntity: Equatable {
|
|||||||
url: url
|
url: url
|
||||||
)
|
)
|
||||||
case let .weather(entity):
|
case let .weather(entity):
|
||||||
var flags: MediaArea.WeatherFlags = []
|
let color: UInt32 = 0xffffffff
|
||||||
if entity.style == .black {
|
|
||||||
flags.insert(.isDark)
|
|
||||||
}
|
|
||||||
return .weather(
|
return .weather(
|
||||||
coordinates: coordinates,
|
coordinates: coordinates,
|
||||||
emoji: entity.emoji,
|
emoji: entity.emoji,
|
||||||
temperature: entity.temperature,
|
temperature: entity.temperature,
|
||||||
flags: flags
|
color: Int32(bitPattern: color)
|
||||||
)
|
)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
|
@ -11,6 +11,7 @@ public final class DrawingWeatherEntity: DrawingEntity, Codable {
|
|||||||
case uuid
|
case uuid
|
||||||
case style
|
case style
|
||||||
case color
|
case color
|
||||||
|
case hasCustomColor
|
||||||
case emoji
|
case emoji
|
||||||
case temperature
|
case temperature
|
||||||
case icon
|
case icon
|
||||||
@ -25,6 +26,8 @@ public final class DrawingWeatherEntity: DrawingEntity, Codable {
|
|||||||
public enum Style: Codable, Equatable {
|
public enum Style: Codable, Equatable {
|
||||||
case white
|
case white
|
||||||
case black
|
case black
|
||||||
|
case transparent
|
||||||
|
case custom
|
||||||
}
|
}
|
||||||
|
|
||||||
public var uuid: UUID
|
public var uuid: UUID
|
||||||
@ -38,7 +41,18 @@ public final class DrawingWeatherEntity: DrawingEntity, Codable {
|
|||||||
public var emoji: String
|
public var emoji: String
|
||||||
public var temperature: Double
|
public var temperature: Double
|
||||||
|
|
||||||
public var color: DrawingColor = 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
|
||||||
@ -83,6 +97,8 @@ public final class DrawingWeatherEntity: DrawingEntity, Codable {
|
|||||||
self.emoji = try container.decode(String.self, forKey: .emoji)
|
self.emoji = try container.decode(String.self, forKey: .emoji)
|
||||||
self.temperature = try container.decode(Double.self, forKey: .temperature)
|
self.temperature = try container.decode(Double.self, forKey: .temperature)
|
||||||
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 iconData = try container.decodeIfPresent(Data.self, forKey: .icon) {
|
if let iconData = try container.decodeIfPresent(Data.self, forKey: .icon) {
|
||||||
self.icon = PostboxDecoder(buffer: MemoryBuffer(data: iconData)).decodeRootObject() as? TelegramMediaFile
|
self.icon = PostboxDecoder(buffer: MemoryBuffer(data: iconData)).decodeRootObject() as? TelegramMediaFile
|
||||||
@ -104,6 +120,8 @@ public final class DrawingWeatherEntity: DrawingEntity, Codable {
|
|||||||
try container.encode(self.emoji, forKey: .emoji)
|
try container.encode(self.emoji, forKey: .emoji)
|
||||||
try container.encode(self.temperature, forKey: .temperature)
|
try container.encode(self.temperature, forKey: .temperature)
|
||||||
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()
|
||||||
if let icon = self.icon {
|
if let icon = self.icon {
|
||||||
@ -152,6 +170,9 @@ public final class DrawingWeatherEntity: DrawingEntity, Codable {
|
|||||||
if self.style != other.style {
|
if self.style != other.style {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if self.color != other.color {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if self.referenceDrawingSize != other.referenceDrawingSize {
|
if self.referenceDrawingSize != other.referenceDrawingSize {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,6 @@ import StickerPackEditTitleController
|
|||||||
import StickerPickerScreen
|
import StickerPickerScreen
|
||||||
import UIKitRuntimeUtils
|
import UIKitRuntimeUtils
|
||||||
import ImageObjectSeparation
|
import ImageObjectSeparation
|
||||||
import DeviceAccess
|
|
||||||
|
|
||||||
private let playbackButtonTag = GenericComponentViewTag()
|
private let playbackButtonTag = GenericComponentViewTag()
|
||||||
private let muteButtonTag = GenericComponentViewTag()
|
private let muteButtonTag = GenericComponentViewTag()
|
||||||
@ -4592,7 +4591,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
|||||||
}
|
}
|
||||||
|
|
||||||
func presentLocationAccessAlert() {
|
func presentLocationAccessAlert() {
|
||||||
DeviceAccess.authorizeAccess(to: .location(.send), locationManager: self.locationManager, presentationData: self.presentationData, present: { [weak self] c, a in
|
DeviceAccess.authorizeAccess(to: .location(.weather), locationManager: self.locationManager, presentationData: self.presentationData, present: { [weak self] c, a in
|
||||||
self?.controller?.present(c, in: .window(.root), with: a)
|
self?.controller?.present(c, in: .window(.root), with: a)
|
||||||
}, openSettings: { [weak self] in
|
}, openSettings: { [weak self] in
|
||||||
self?.context.sharedContext.applicationBindings.openSettings()
|
self?.context.sharedContext.applicationBindings.openSettings()
|
||||||
|
@ -562,7 +562,7 @@ final class StoryItemOverlaysView: UIView {
|
|||||||
emoji: String,
|
emoji: String,
|
||||||
emojiFile: TelegramMediaFile?,
|
emojiFile: TelegramMediaFile?,
|
||||||
temperature: Double,
|
temperature: Double,
|
||||||
flags: MediaArea.WeatherFlags,
|
color: Int32,
|
||||||
synchronous: Bool,
|
synchronous: Bool,
|
||||||
size: CGSize,
|
size: CGSize,
|
||||||
cornerRadius: CGFloat,
|
cornerRadius: CGFloat,
|
||||||
@ -570,13 +570,21 @@ final class StoryItemOverlaysView: UIView {
|
|||||||
) -> CGSize {
|
) -> CGSize {
|
||||||
let itemSize = CGSize(width: floor(size.height * 0.71), height: floor(size.height * 0.71))
|
let itemSize = CGSize(width: floor(size.height * 0.71), height: floor(size.height * 0.71))
|
||||||
|
|
||||||
|
let backgroundColor = UIColor(argb: UInt32(bitPattern: color))
|
||||||
|
let textColor: UIColor
|
||||||
|
if backgroundColor.lightness > 0.705 {
|
||||||
|
textColor = .black
|
||||||
|
} else {
|
||||||
|
textColor = .white
|
||||||
|
}
|
||||||
|
let placeholderColor = textColor.withAlphaComponent(0.1)
|
||||||
|
|
||||||
if self.file?.fileId != emojiFile?.fileId, let file = emojiFile {
|
if self.file?.fileId != emojiFile?.fileId, let file = emojiFile {
|
||||||
self.file = file
|
self.file = file
|
||||||
|
|
||||||
self.customEmojiLoadDisposable?.dispose()
|
self.customEmojiLoadDisposable?.dispose()
|
||||||
self.customEmojiLoadDisposable = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, userLocation: .other, userContentType: .sticker, reference: .standalone(resource: file.resource)).start()
|
self.customEmojiLoadDisposable = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, userLocation: .other, userContentType: .sticker, reference: .standalone(resource: file.resource)).start()
|
||||||
|
|
||||||
let placeholderColor = flags.contains(.isDark) ? UIColor(white: 1.0, alpha: 0.1) : UIColor(white: 0.0, alpha: 0.1)
|
|
||||||
let _ = self.directStickerView.update(
|
let _ = self.directStickerView.update(
|
||||||
transition: .immediate,
|
transition: .immediate,
|
||||||
component: AnyComponent(LottieComponent(
|
component: AnyComponent(LottieComponent(
|
||||||
@ -601,7 +609,7 @@ final class StoryItemOverlaysView: UIView {
|
|||||||
let string = NSMutableAttributedString(
|
let string = NSMutableAttributedString(
|
||||||
string: stringForTemperature(temperature),
|
string: stringForTemperature(temperature),
|
||||||
font: textFont,
|
font: textFont,
|
||||||
textColor: flags.contains(.isDark) ? UIColor(rgb: 0xffffff) : UIColor(rgb: 0x000000)
|
textColor: textColor
|
||||||
)
|
)
|
||||||
string.addAttribute(.kern, value: -(size.height / 38.0) as NSNumber, range: NSMakeRange(0, string.length))
|
string.addAttribute(.kern, value: -(size.height / 38.0) as NSNumber, range: NSMakeRange(0, string.length))
|
||||||
|
|
||||||
@ -644,7 +652,7 @@ final class StoryItemOverlaysView: UIView {
|
|||||||
|
|
||||||
let contentSize = CGSize(width: contentWidth, height: size.height)
|
let contentSize = CGSize(width: contentWidth, height: size.height)
|
||||||
|
|
||||||
self.backgroundView.backgroundColor = flags.contains(.isDark) ? UIColor(rgb: 0x000000) : UIColor(rgb: 0xffffff)
|
self.backgroundView.backgroundColor = backgroundColor
|
||||||
self.backgroundView.frame = CGRect(origin: .zero, size: contentSize)
|
self.backgroundView.frame = CGRect(origin: .zero, size: contentSize)
|
||||||
self.backgroundView.layer.cornerRadius = cornerRadius
|
self.backgroundView.layer.cornerRadius = cornerRadius
|
||||||
|
|
||||||
@ -752,7 +760,7 @@ final class StoryItemOverlaysView: UIView {
|
|||||||
)
|
)
|
||||||
|
|
||||||
nextId += 1
|
nextId += 1
|
||||||
case let .weather(coordinates, emoji, temperature, flags):
|
case let .weather(coordinates, emoji, temperature, color):
|
||||||
guard let (itemFrame, itemRotation, cornerRadius) = getFrameAndRotation(coordinates: coordinates) else {
|
guard let (itemFrame, itemRotation, cornerRadius) = getFrameAndRotation(coordinates: coordinates) else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -773,7 +781,7 @@ final class StoryItemOverlaysView: UIView {
|
|||||||
emoji: emoji,
|
emoji: emoji,
|
||||||
emojiFile: context.animatedEmojiStickersValue[emoji]?.first?.file,
|
emojiFile: context.animatedEmojiStickersValue[emoji]?.first?.file,
|
||||||
temperature: temperature,
|
temperature: temperature,
|
||||||
flags: flags,
|
color: color,
|
||||||
synchronous: attemptSynchronous,
|
synchronous: attemptSynchronous,
|
||||||
size: itemFrame.size,
|
size: itemFrame.size,
|
||||||
cornerRadius: cornerRadius,
|
cornerRadius: cornerRadius,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user