mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-12 09:19:52 +00:00
Merge commit '6fa3948d22a25f47dea9ac827f1b4f6d7c60e8d8' into beta
This commit is contained in:
commit
b9fa124740
@ -254,17 +254,17 @@ public final class AuthorizationSequencePhoneEntryController: ViewController, MF
|
|||||||
@objc func nextPressed() {
|
@objc func nextPressed() {
|
||||||
let (_, _, number) = self.controllerNode.codeAndNumber
|
let (_, _, number) = self.controllerNode.codeAndNumber
|
||||||
if !number.isEmpty {
|
if !number.isEmpty {
|
||||||
let logInNumber = formatPhoneNumber(self.controllerNode.currentNumber)
|
let logInNumber = cleanPhoneNumber(self.controllerNode.currentNumber, removePlus: true)
|
||||||
var existing: (String, AccountRecordId)?
|
var existing: (String, AccountRecordId)?
|
||||||
for (number, id, isTestingEnvironment) in self.otherAccountPhoneNumbers.1 {
|
for (number, id, isTestingEnvironment) in self.otherAccountPhoneNumbers.1 {
|
||||||
if isTestingEnvironment == self.isTestingEnvironment && formatPhoneNumber(number) == logInNumber {
|
if isTestingEnvironment == self.isTestingEnvironment && cleanPhoneNumber(number, removePlus: true) == logInNumber {
|
||||||
existing = (number, id)
|
existing = (number, id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let (_, id) = existing {
|
if let (_, id) = existing {
|
||||||
var actions: [TextAlertAction] = []
|
var actions: [TextAlertAction] = []
|
||||||
if let (current, _, _) = self.otherAccountPhoneNumbers.0, logInNumber != formatPhoneNumber(current) {
|
if let (current, _, _) = self.otherAccountPhoneNumbers.0, logInNumber != cleanPhoneNumber(current, removePlus: true) {
|
||||||
actions.append(TextAlertAction(type: .genericAction, title: self.presentationData.strings.Login_PhoneNumberAlreadyAuthorizedSwitch, action: { [weak self] in
|
actions.append(TextAlertAction(type: .genericAction, title: self.presentationData.strings.Login_PhoneNumberAlreadyAuthorizedSwitch, action: { [weak self] in
|
||||||
self?.sharedContext.switchToAccount(id: id, fromSettingsController: nil, withChatListController: nil)
|
self?.sharedContext.switchToAccount(id: id, fromSettingsController: nil, withChatListController: nil)
|
||||||
self?.back()
|
self?.back()
|
||||||
|
|||||||
@ -218,12 +218,13 @@ public class ChatMessageBackground: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let outlineImage: UIImage?
|
let outlineImage: UIImage?
|
||||||
|
var isIncoming = false
|
||||||
if hasWallpaper {
|
if hasWallpaper {
|
||||||
switch type {
|
switch type {
|
||||||
case .none:
|
case .none:
|
||||||
outlineImage = nil
|
outlineImage = nil
|
||||||
case let .incoming(mergeType):
|
case let .incoming(mergeType):
|
||||||
|
isIncoming = true
|
||||||
switch mergeType {
|
switch mergeType {
|
||||||
case .None:
|
case .None:
|
||||||
outlineImage = graphics.chatMessageBackgroundIncomingOutlineImage
|
outlineImage = graphics.chatMessageBackgroundIncomingOutlineImage
|
||||||
@ -307,7 +308,7 @@ public class ChatMessageBackground: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.imageNode.image = image
|
self.imageNode.image = image
|
||||||
if highlighted && maskMode, let backdropNode = self.backdropNode, backdropNode.hasImage {
|
if highlighted && maskMode, let backdropNode = self.backdropNode, backdropNode.hasImage && isIncoming {
|
||||||
self.imageNode.layer.compositingFilter = "overlayBlendMode"
|
self.imageNode.layer.compositingFilter = "overlayBlendMode"
|
||||||
self.imageNode.alpha = 1.0
|
self.imageNode.alpha = 1.0
|
||||||
|
|
||||||
|
|||||||
@ -158,6 +158,24 @@ public extension UIColor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var brightness: CGFloat {
|
||||||
|
var hue: CGFloat = 0.0
|
||||||
|
var saturation: CGFloat = 0.0
|
||||||
|
var brightness: CGFloat = 0.0
|
||||||
|
var alpha: CGFloat = 0.0
|
||||||
|
self.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha)
|
||||||
|
return brightness
|
||||||
|
}
|
||||||
|
|
||||||
|
var saturation: CGFloat {
|
||||||
|
var hue: CGFloat = 0.0
|
||||||
|
var saturation: CGFloat = 0.0
|
||||||
|
var brightness: CGFloat = 0.0
|
||||||
|
var alpha: CGFloat = 0.0
|
||||||
|
self.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha)
|
||||||
|
return saturation
|
||||||
|
}
|
||||||
|
|
||||||
func withMultipliedBrightnessBy(_ factor: CGFloat) -> UIColor {
|
func withMultipliedBrightnessBy(_ factor: CGFloat) -> UIColor {
|
||||||
var hue: CGFloat = 0.0
|
var hue: CGFloat = 0.0
|
||||||
var saturation: CGFloat = 0.0
|
var saturation: CGFloat = 0.0
|
||||||
@ -202,6 +220,26 @@ public extension UIColor {
|
|||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func multipliedWith(_ other: UIColor) -> UIColor {
|
||||||
|
var r1: CGFloat = 0.0
|
||||||
|
var r2: CGFloat = 0.0
|
||||||
|
var g1: CGFloat = 0.0
|
||||||
|
var g2: CGFloat = 0.0
|
||||||
|
var b1: CGFloat = 0.0
|
||||||
|
var b2: CGFloat = 0.0
|
||||||
|
var a1: CGFloat = 0.0
|
||||||
|
var a2: CGFloat = 0.0
|
||||||
|
if self.getRed(&r1, green: &g1, blue: &b1, alpha: &a1) &&
|
||||||
|
other.getRed(&r2, green: &g2, blue: &b2, alpha: &a2)
|
||||||
|
{
|
||||||
|
let r = r1 * r2
|
||||||
|
let g = g1 * g2
|
||||||
|
let b = b1 * b2
|
||||||
|
return UIColor(red: r, green: g, blue: b, alpha: 1.0)
|
||||||
|
}
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
func blitOver(_ other: UIColor, alpha: CGFloat) -> UIColor {
|
func blitOver(_ other: UIColor, alpha: CGFloat) -> UIColor {
|
||||||
let alpha = min(1.0, max(0.0, alpha))
|
let alpha = min(1.0, max(0.0, alpha))
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,20 @@ import TelegramCore
|
|||||||
|
|
||||||
private let phoneNumberUtil = NBPhoneNumberUtil()
|
private let phoneNumberUtil = NBPhoneNumberUtil()
|
||||||
|
|
||||||
|
public func cleanPhoneNumber(_ text: String, removePlus: Bool = false) -> String {
|
||||||
|
var result = ""
|
||||||
|
for c in text {
|
||||||
|
if c == "+" && !removePlus {
|
||||||
|
if result.isEmpty {
|
||||||
|
result += String(c)
|
||||||
|
}
|
||||||
|
} else if c >= "0" && c <= "9" {
|
||||||
|
result += String(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
public func formatPhoneNumber(_ string: String) -> String {
|
public func formatPhoneNumber(_ string: String) -> String {
|
||||||
do {
|
do {
|
||||||
let number = try phoneNumberUtil.parse("+" + string, defaultRegion: nil)
|
let number = try phoneNumberUtil.parse("+" + string, defaultRegion: nil)
|
||||||
|
|||||||
@ -2726,7 +2726,7 @@ public final class PremiumIntroScreen: ViewControllerComponentContainer {
|
|||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
|
||||||
if modal {
|
if modal {
|
||||||
let cancelItem = UIBarButtonItem(title: presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
|
let cancelItem = UIBarButtonItem(title: presentationData.strings.Common_Close, style: .plain, target: self, action: #selector(self.cancelPressed))
|
||||||
self.navigationItem.setLeftBarButton(cancelItem, animated: false)
|
self.navigationItem.setLeftBarButton(cancelItem, animated: false)
|
||||||
self.navigationPresentation = .modal
|
self.navigationPresentation = .modal
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -174,6 +174,16 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var highlightedBubbleFillColor: UIColor?
|
||||||
|
if let outgoingBubbleFillColors {
|
||||||
|
let middleBubbleFillColor = outgoingBubbleFillColors[Int(floor(Float(outgoingBubbleFillColors.count) / 2))]
|
||||||
|
if middleBubbleFillColor.brightness > 0.98 {
|
||||||
|
highlightedBubbleFillColor = middleBubbleFillColor.withMultiplied(hue: 1.0, saturation: 0.87, brightness: 1.0)
|
||||||
|
} else {
|
||||||
|
highlightedBubbleFillColor = middleBubbleFillColor.withMultiplied(hue: 1.0, saturation: 1.1, brightness: 1.121)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
chat = chat.withUpdated(
|
chat = chat.withUpdated(
|
||||||
defaultWallpaper: defaultWallpaper,
|
defaultWallpaper: defaultWallpaper,
|
||||||
animateMessageColors: animateBubbleColors,
|
animateMessageColors: animateBubbleColors,
|
||||||
@ -223,7 +233,7 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
|
|||||||
bubble: chat.message.outgoing.bubble.withUpdated(
|
bubble: chat.message.outgoing.bubble.withUpdated(
|
||||||
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
|
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
|
||||||
fill: outgoingBubbleFillColors,
|
fill: outgoingBubbleFillColors,
|
||||||
highlightedFill: outgoingBubbleFillColors?.first?.withMultipliedBrightnessBy(1.421),
|
highlightedFill: highlightedBubbleFillColor,
|
||||||
stroke: .clear,
|
stroke: .clear,
|
||||||
reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.12),
|
reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.12),
|
||||||
reactionInactiveForeground: UIColor(rgb: 0xffffff),
|
reactionInactiveForeground: UIColor(rgb: 0xffffff),
|
||||||
@ -234,7 +244,7 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
|
|||||||
),
|
),
|
||||||
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
|
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
|
||||||
fill: outgoingBubbleFillColors,
|
fill: outgoingBubbleFillColors,
|
||||||
highlightedFill: outgoingBubbleFillColors?.first?.withMultipliedBrightnessBy(1.421),
|
highlightedFill: highlightedBubbleFillColor,
|
||||||
stroke: .clear,
|
stroke: .clear,
|
||||||
reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.12),
|
reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.12),
|
||||||
reactionInactiveForeground: UIColor(rgb: 0xffffff),
|
reactionInactiveForeground: UIColor(rgb: 0xffffff),
|
||||||
|
|||||||
@ -168,7 +168,16 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, ti
|
|||||||
outgoingBubbleStrokeColor = .clear
|
outgoingBubbleStrokeColor = .clear
|
||||||
}
|
}
|
||||||
|
|
||||||
outgoingBubbleHighlightedFill = outgoingBubbleFillColors?.first?.withMultiplied(hue: 1.00, saturation: 1.589, brightness: 0.96)
|
if let outgoingBubbleFillColors {
|
||||||
|
let middleBubbleFillColor = outgoingBubbleFillColors[Int(floor(Float(outgoingBubbleFillColors.count - 1) / 2))]
|
||||||
|
if middleBubbleFillColor.lightness < 0.85 {
|
||||||
|
outgoingBubbleHighlightedFill = middleBubbleFillColor.multipliedWith(middleBubbleFillColor).withMultiplied(hue: 1.0, saturation: 0.6, brightness: 1.0)
|
||||||
|
} else if middleBubbleFillColor.lightness > 0.97 {
|
||||||
|
outgoingBubbleHighlightedFill = middleBubbleFillColor.withMultiplied(hue: 1.00, saturation: 2.359, brightness: 0.99)
|
||||||
|
} else {
|
||||||
|
outgoingBubbleHighlightedFill = middleBubbleFillColor.withMultiplied(hue: 1.00, saturation: 1.589, brightness: 0.99)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let lightnessColor = UIColor.average(of: bubbleColors.map(UIColor.init(rgb:)))
|
let lightnessColor = UIColor.average(of: bubbleColors.map(UIColor.init(rgb:)))
|
||||||
if lightnessColor.lightness > 0.705 {
|
if lightnessColor.lightness > 0.705 {
|
||||||
@ -622,7 +631,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
|
|||||||
bubble: PresentationThemeBubbleColor(
|
bubble: PresentationThemeBubbleColor(
|
||||||
withWallpaper: PresentationThemeBubbleColorComponents(
|
withWallpaper: PresentationThemeBubbleColorComponents(
|
||||||
fill: [UIColor(rgb: 0xe1ffc7)],
|
fill: [UIColor(rgb: 0xe1ffc7)],
|
||||||
highlightedFill: UIColor(rgb: 0xc8ffa6),
|
highlightedFill: UIColor(rgb: 0xbaff93),
|
||||||
stroke: bubbleStrokeColor,
|
stroke: bubbleStrokeColor,
|
||||||
shadow: nil,
|
shadow: nil,
|
||||||
reactionInactiveBackground: UIColor(rgb: 0x2DA32F).withMultipliedAlpha(0.12),
|
reactionInactiveBackground: UIColor(rgb: 0x2DA32F).withMultipliedAlpha(0.12),
|
||||||
@ -634,7 +643,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
|
|||||||
),
|
),
|
||||||
withoutWallpaper: PresentationThemeBubbleColorComponents(
|
withoutWallpaper: PresentationThemeBubbleColorComponents(
|
||||||
fill: [UIColor(rgb: 0xe1ffc7)],
|
fill: [UIColor(rgb: 0xe1ffc7)],
|
||||||
highlightedFill: UIColor(rgb: 0xc8ffa6),
|
highlightedFill: UIColor(rgb: 0xbaff93),
|
||||||
stroke: bubbleStrokeColor,
|
stroke: bubbleStrokeColor,
|
||||||
shadow: nil,
|
shadow: nil,
|
||||||
reactionInactiveBackground: UIColor(rgb: 0x2DA32F).withMultipliedAlpha(0.12),
|
reactionInactiveBackground: UIColor(rgb: 0x2DA32F).withMultipliedAlpha(0.12),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user