Merge commit '6fa3948d22a25f47dea9ac827f1b4f6d7c60e8d8' into beta

This commit is contained in:
Ilya Laktyushin 2023-03-03 14:39:12 +04:00
commit b9fa124740
7 changed files with 84 additions and 12 deletions

View File

@ -254,17 +254,17 @@ public final class AuthorizationSequencePhoneEntryController: ViewController, MF
@objc func nextPressed() {
let (_, _, number) = self.controllerNode.codeAndNumber
if !number.isEmpty {
let logInNumber = formatPhoneNumber(self.controllerNode.currentNumber)
let logInNumber = cleanPhoneNumber(self.controllerNode.currentNumber, removePlus: true)
var existing: (String, AccountRecordId)?
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)
}
}
if let (_, id) = existing {
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
self?.sharedContext.switchToAccount(id: id, fromSettingsController: nil, withChatListController: nil)
self?.back()

View File

@ -218,12 +218,13 @@ public class ChatMessageBackground: ASDisplayNode {
}
let outlineImage: UIImage?
var isIncoming = false
if hasWallpaper {
switch type {
case .none:
outlineImage = nil
case let .incoming(mergeType):
isIncoming = true
switch mergeType {
case .None:
outlineImage = graphics.chatMessageBackgroundIncomingOutlineImage
@ -305,9 +306,9 @@ public class ChatMessageBackground: ASDisplayNode {
}
}
}
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.alpha = 1.0

View File

@ -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 {
var hue: CGFloat = 0.0
var saturation: CGFloat = 0.0
@ -202,6 +220,26 @@ public extension UIColor {
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 {
let alpha = min(1.0, max(0.0, alpha))

View File

@ -5,6 +5,20 @@ import TelegramCore
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 {
do {
let number = try phoneNumberUtil.parse("+" + string, defaultRegion: nil)

View File

@ -2726,7 +2726,7 @@ public final class PremiumIntroScreen: ViewControllerComponentContainer {
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
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.navigationPresentation = .modal
} else {

View File

@ -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(
defaultWallpaper: defaultWallpaper,
animateMessageColors: animateBubbleColors,
@ -223,7 +233,7 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
bubble: chat.message.outgoing.bubble.withUpdated(
withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated(
fill: outgoingBubbleFillColors,
highlightedFill: outgoingBubbleFillColors?.first?.withMultipliedBrightnessBy(1.421),
highlightedFill: highlightedBubbleFillColor,
stroke: .clear,
reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.12),
reactionInactiveForeground: UIColor(rgb: 0xffffff),
@ -234,7 +244,7 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
),
withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated(
fill: outgoingBubbleFillColors,
highlightedFill: outgoingBubbleFillColors?.first?.withMultipliedBrightnessBy(1.421),
highlightedFill: highlightedBubbleFillColor,
stroke: .clear,
reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.12),
reactionInactiveForeground: UIColor(rgb: 0xffffff),

View File

@ -168,7 +168,16 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, ti
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:)))
if lightnessColor.lightness > 0.705 {
@ -622,7 +631,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
bubble: PresentationThemeBubbleColor(
withWallpaper: PresentationThemeBubbleColorComponents(
fill: [UIColor(rgb: 0xe1ffc7)],
highlightedFill: UIColor(rgb: 0xc8ffa6),
highlightedFill: UIColor(rgb: 0xbaff93),
stroke: bubbleStrokeColor,
shadow: nil,
reactionInactiveBackground: UIColor(rgb: 0x2DA32F).withMultipliedAlpha(0.12),
@ -634,7 +643,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
),
withoutWallpaper: PresentationThemeBubbleColorComponents(
fill: [UIColor(rgb: 0xe1ffc7)],
highlightedFill: UIColor(rgb: 0xc8ffa6),
highlightedFill: UIColor(rgb: 0xbaff93),
stroke: bubbleStrokeColor,
shadow: nil,
reactionInactiveBackground: UIColor(rgb: 0x2DA32F).withMultipliedAlpha(0.12),