mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
90f0bcbc8a
commit
5473a8d25d
@ -1370,15 +1370,21 @@ final class AvatarEditorScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func presentPremiumToast() {
|
private func presentPremiumToast() {
|
||||||
guard let environment = self.environment, let component = self.component, let parentController = environment.controller() else {
|
guard let environment = self.environment, let component = self.component, let state = self.state, let parentController = environment.controller() else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
HapticFeedback().impact(.light)
|
HapticFeedback().impact(.light)
|
||||||
|
|
||||||
|
var text: String = environment.strings.AvatarEditor_PremiumNeeded_Background
|
||||||
|
if let selectedFile = state.selectedFile {
|
||||||
|
if selectedFile.isSticker {
|
||||||
|
text = environment.strings.AvatarEditor_PremiumNeeded_Sticker
|
||||||
|
}
|
||||||
|
}
|
||||||
let controller = premiumAlertController(
|
let controller = premiumAlertController(
|
||||||
context: component.context,
|
context: component.context,
|
||||||
parentController: parentController,
|
parentController: parentController,
|
||||||
text: environment.strings.AvatarEditor_PremiumNeeded_Background
|
text: text
|
||||||
)
|
)
|
||||||
parentController.present(controller, in: .window(.root))
|
parentController.present(controller, in: .window(.root))
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ final class BackgroundColorComponent: Component {
|
|||||||
background: values[i].0,
|
background: values[i].0,
|
||||||
isCustom: values[i].1,
|
isCustom: values[i].1,
|
||||||
isSelected: component.selectedValue == values[i].0,
|
isSelected: component.selectedValue == values[i].0,
|
||||||
isLocked: i >= 7 && !values[i].1,
|
isLocked: i >= 7 && !values[i].1 && !component.isPremium,
|
||||||
action: {
|
action: {
|
||||||
if let value = values[i].0, component.selectedValue != value {
|
if let value = values[i].0, component.selectedValue != value {
|
||||||
component.updateValue(value)
|
component.updateValue(value)
|
||||||
|
@ -68,6 +68,9 @@ public final class ChatMessageNotificationItem: NotificationItem {
|
|||||||
private let compactAvatarFont = avatarPlaceholderFont(size: 20.0)
|
private let compactAvatarFont = avatarPlaceholderFont(size: 20.0)
|
||||||
private let avatarFont = avatarPlaceholderFont(size: 24.0)
|
private let avatarFont = avatarPlaceholderFont(size: 24.0)
|
||||||
|
|
||||||
|
private let telegramCodeRegex = try? NSRegularExpression(pattern: "(?<=: )\\b\\d{5,8}\\b(?=\\.)", options: [])
|
||||||
|
private let loginCodeRegex = try? NSRegularExpression(pattern: "\\b\\d{5,8}\\b", options: [])
|
||||||
|
|
||||||
final class ChatMessageNotificationItemNode: NotificationItemNode {
|
final class ChatMessageNotificationItemNode: NotificationItemNode {
|
||||||
private var item: ChatMessageNotificationItem?
|
private var item: ChatMessageNotificationItem?
|
||||||
|
|
||||||
@ -327,6 +330,30 @@ final class ChatMessageNotificationItemNode: NotificationItemNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var customEntities: [MessageTextEntity] = []
|
||||||
|
if item.messages[0].id.peerId.isTelegramNotifications || item.messages[0].id.peerId.isVerificationCodes {
|
||||||
|
let regex: NSRegularExpression?
|
||||||
|
if item.messages[0].id.peerId.isTelegramNotifications {
|
||||||
|
regex = telegramCodeRegex
|
||||||
|
} else {
|
||||||
|
regex = loginCodeRegex
|
||||||
|
}
|
||||||
|
if let matches = regex?.matches(in: item.messages[0].text, options: [], range: NSMakeRange(0, (item.messages[0].text as NSString).length)) {
|
||||||
|
if let first = matches.first {
|
||||||
|
customEntities.append(MessageTextEntity(range: first.range.location ..< first.range.location + first.range.length, type: .Spoiler))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !customEntities.isEmpty {
|
||||||
|
if messageEntities == nil {
|
||||||
|
messageEntities = customEntities
|
||||||
|
} else if var currentEntities = messageEntities {
|
||||||
|
currentEntities.append(contentsOf: customEntities)
|
||||||
|
messageEntities = customEntities
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let textFont = compact ? Font.regular(15.0) : Font.regular(16.0)
|
let textFont = compact ? Font.regular(15.0) : Font.regular(16.0)
|
||||||
let textColor = presentationData.theme.inAppNotification.primaryTextColor
|
let textColor = presentationData.theme.inAppNotification.primaryTextColor
|
||||||
var attributedMessageText: NSAttributedString
|
var attributedMessageText: NSAttributedString
|
||||||
@ -406,7 +433,7 @@ final class ChatMessageNotificationItemNode: NotificationItemNode {
|
|||||||
let _ = titleApply()
|
let _ = titleApply()
|
||||||
|
|
||||||
let makeTextLayout = TextNodeWithEntities.asyncLayout(self.textNode)
|
let makeTextLayout = TextNodeWithEntities.asyncLayout(self.textNode)
|
||||||
let (textLayout, textApply) = makeTextLayout(TextNodeLayoutArguments(attributedString: self.textAttributedText, backgroundColor: nil, maximumNumberOfLines: 2, truncationType: .end, constrainedSize: CGSize(width: width - leftInset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .left, lineSpacing: 0.0, cutout: nil, insets: UIEdgeInsets()))
|
let (textLayout, textApply) = makeTextLayout(TextNodeLayoutArguments(attributedString: self.textAttributedText, backgroundColor: nil, maximumNumberOfLines: 2, truncationType: .end, constrainedSize: CGSize(width: width - leftInset - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .left, lineSpacing: 0.0, cutout: nil, insets: UIEdgeInsets(), displaySpoilers: false))
|
||||||
let _ = titleApply()
|
let _ = titleApply()
|
||||||
|
|
||||||
if let item = self.item {
|
if let item = self.item {
|
||||||
|
@ -1316,10 +1316,13 @@ private final class GiftViewSheetContent: CombinedComponent {
|
|||||||
exported = true
|
exported = true
|
||||||
|
|
||||||
func formatAddress(_ str: String) -> String {
|
func formatAddress(_ str: String) -> String {
|
||||||
var result = str
|
guard str.count == 48 && !str.hasSuffix(".ton") else {
|
||||||
let middleIndex = result.index(result.startIndex, offsetBy: str.count / 2)
|
return str
|
||||||
result.insert("\n", at: middleIndex)
|
}
|
||||||
return result
|
var result = str
|
||||||
|
let middleIndex = result.index(result.startIndex, offsetBy: str.count / 2)
|
||||||
|
result.insert("\n", at: middleIndex)
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
tableItems.append(.init(
|
tableItems.append(.init(
|
||||||
@ -1910,7 +1913,7 @@ private final class GiftViewSheetContent: CombinedComponent {
|
|||||||
}
|
}
|
||||||
var addressToOpen: String?
|
var addressToOpen: String?
|
||||||
var descriptionText: String
|
var descriptionText: String
|
||||||
if let uniqueGift, let address = uniqueGift.giftAddress {
|
if let uniqueGift, let address = uniqueGift.giftAddress, case .address = uniqueGift.owner {
|
||||||
addressToOpen = address
|
addressToOpen = address
|
||||||
descriptionText = strings.Gift_View_TonGiftAddressInfo
|
descriptionText = strings.Gift_View_TonGiftAddressInfo
|
||||||
} else if savedToProfile {
|
} else if savedToProfile {
|
||||||
|
@ -218,7 +218,7 @@ extension ChatControllerImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let peer = self.presentationInterfaceState.renderedPeer?.peer, showPremiumGift, let user = peer as? TelegramUser, !user.isPremium && !user.isDeleted && user.botInfo == nil && !user.flags.contains(.isSupport) {
|
if let peer = self.presentationInterfaceState.renderedPeer?.peer, showPremiumGift, let user = peer as? TelegramUser, !user.isDeleted && user.botInfo == nil && !user.flags.contains(.isSupport) {
|
||||||
premiumGiftOptions = self.presentationInterfaceState.premiumGiftOptions
|
premiumGiftOptions = self.presentationInterfaceState.premiumGiftOptions
|
||||||
} else {
|
} else {
|
||||||
premiumGiftOptions = []
|
premiumGiftOptions = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user