mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-21 02:31:10 +00:00
Various improvements
This commit is contained in:
parent
10c28d982e
commit
f79a244bf2
@ -1259,8 +1259,24 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
|||||||
messagePeer = EnginePeer(messagePeerValue)
|
messagePeer = EnginePeer(messagePeerValue)
|
||||||
} else if message.id.peerId.namespace == Namespaces.Peer.CloudChannel, let peer = message.peers[message.id.peerId] as? TelegramChannel, peer.isMonoForum {
|
} else if message.id.peerId.namespace == Namespaces.Peer.CloudChannel, let peer = message.peers[message.id.peerId] as? TelegramChannel, peer.isMonoForum {
|
||||||
if let author = message.author, let threadId = message.threadId, let threadPeer = message.peers[PeerId(threadId)], author.id != threadPeer.id {
|
if let author = message.author, let threadId = message.threadId, let threadPeer = message.peers[PeerId(threadId)], author.id != threadPeer.id {
|
||||||
isOutgoing = true
|
if case .channel = author {
|
||||||
messagePeer = EnginePeer(threadPeer)
|
var isUser = true
|
||||||
|
if let peer = message.peers[message.id.peerId] as? TelegramChannel {
|
||||||
|
if peer.isMonoForum, let linkedMonoforumId = peer.linkedMonoforumId, let mainChannel = message.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.manageDirect) {
|
||||||
|
isUser = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if isUser {
|
||||||
|
messagePeer = author
|
||||||
|
} else {
|
||||||
|
messagePeer = EnginePeer(threadPeer)
|
||||||
|
isOutgoing = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isOutgoing = true
|
||||||
|
messagePeer = EnginePeer(threadPeer)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1450,12 +1466,51 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
attributedString = NSAttributedString(string: string, font: titleFont, textColor: primaryTextColor)
|
attributedString = NSAttributedString(string: string, font: titleFont, textColor: primaryTextColor)
|
||||||
case .suggestedPostSuccess:
|
case let .suggestedPostSuccess(amount):
|
||||||
|
var isUser = true
|
||||||
|
var channelName: String = ""
|
||||||
|
if let peer = message.peers[message.id.peerId] as? TelegramChannel {
|
||||||
|
channelName = peer.title
|
||||||
|
if peer.isMonoForum, let linkedMonoforumId = peer.linkedMonoforumId, let mainChannel = message.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.manageDirect) {
|
||||||
|
isUser = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _ = isUser
|
||||||
|
|
||||||
//TODO:localize
|
//TODO:localize
|
||||||
attributedString = NSAttributedString(string: "Suggested post was posted", font: titleFont, textColor: primaryTextColor)
|
let amountString: String
|
||||||
case .suggestedPostRefund:
|
switch amount.currency {
|
||||||
|
case .stars:
|
||||||
|
if amount.amount.value == 1 {
|
||||||
|
amountString = "1 Star"
|
||||||
|
} else {
|
||||||
|
amountString = "\(amount.amount.value) Stars"
|
||||||
|
}
|
||||||
|
case .ton:
|
||||||
|
amountString = "\(formatTonAmountText(amount.amount.value, dateTimeFormat: dateTimeFormat)) TON"
|
||||||
|
}
|
||||||
|
attributedString = parseMarkdownIntoAttributedString("**\(channelName)** received **\(amountString)** for publishing this post", attributes: MarkdownAttributes(body: bodyAttributes, bold: boldAttributes, link: bodyAttributes, linkAttribute: { _ in return nil }))
|
||||||
|
case let .suggestedPostRefund(info):
|
||||||
|
var isUser = true
|
||||||
|
var channelName: String = ""
|
||||||
|
if let peer = message.peers[message.id.peerId] as? TelegramChannel {
|
||||||
|
channelName = peer.title
|
||||||
|
if peer.isMonoForum, let linkedMonoforumId = peer.linkedMonoforumId, let mainChannel = message.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.manageDirect) {
|
||||||
|
isUser = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _ = channelName
|
||||||
|
|
||||||
//TODO:localize
|
//TODO:localize
|
||||||
attributedString = NSAttributedString(string: "Suggested post was refunded", font: titleFont, textColor: primaryTextColor)
|
if info.isUserInitiated {
|
||||||
|
if isUser {
|
||||||
|
attributedString = NSAttributedString(string: "Suggested post was refunded because you didn't have enough funds", font: titleFont, textColor: primaryTextColor)
|
||||||
|
} else {
|
||||||
|
attributedString = NSAttributedString(string: "Suggested post was refunded because the user didn't have enough funds", font: titleFont, textColor: primaryTextColor)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
attributedString = NSAttributedString(string: "Suggested post was refunded because the message was deleted", font: titleFont, textColor: primaryTextColor)
|
||||||
|
}
|
||||||
case let .giftTon(currency, amount, _, _, _):
|
case let .giftTon(currency, amount, _, _, _):
|
||||||
attributedString = nil
|
attributedString = nil
|
||||||
if !forAdditionalServiceMessage {
|
if !forAdditionalServiceMessage {
|
||||||
|
@ -1408,7 +1408,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
layoutSize.height += additionalTopHeight
|
layoutSize.height += additionalTopHeight
|
||||||
imageFrame.origin.y += additionalTopHeight
|
imageFrame.origin.y += additionalTopHeight
|
||||||
|
|
||||||
var headersOffset: CGFloat = 0.0
|
var headersOffset: CGFloat = additionalTopHeight
|
||||||
if let (threadInfoSize, _) = threadInfoApply {
|
if let (threadInfoSize, _) = threadInfoApply {
|
||||||
headersOffset += threadInfoSize.height + 10.0
|
headersOffset += threadInfoSize.height + 10.0
|
||||||
}
|
}
|
||||||
@ -1625,7 +1625,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var headersOffset: CGFloat = 0.0
|
var headersOffset: CGFloat = additionalTopHeight
|
||||||
if let (threadInfoSize, threadInfoApply) = threadInfoApply {
|
if let (threadInfoSize, threadInfoApply) = threadInfoApply {
|
||||||
let threadInfoNode = threadInfoApply(synchronousLoads)
|
let threadInfoNode = threadInfoApply(synchronousLoads)
|
||||||
if strongSelf.threadInfoNode == nil {
|
if strongSelf.threadInfoNode == nil {
|
||||||
|
@ -991,7 +991,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView {
|
|||||||
baseShareButtonFrame.origin.x = dateAndStatusFrame.maxX + 8.0
|
baseShareButtonFrame.origin.x = dateAndStatusFrame.maxX + 8.0
|
||||||
}
|
}
|
||||||
|
|
||||||
var headersOffset: CGFloat = 0.0
|
var headersOffset: CGFloat = additionalTopHeight
|
||||||
if let (threadInfoSize, _) = threadInfoApply {
|
if let (threadInfoSize, _) = threadInfoApply {
|
||||||
headersOffset += threadInfoSize.height + 10.0
|
headersOffset += threadInfoSize.height + 10.0
|
||||||
}
|
}
|
||||||
@ -1149,7 +1149,7 @@ public class ChatMessageStickerItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var headersOffset: CGFloat = 0.0
|
var headersOffset: CGFloat = additionalTopHeight
|
||||||
if let (threadInfoSize, threadInfoApply) = threadInfoApply {
|
if let (threadInfoSize, threadInfoApply) = threadInfoApply {
|
||||||
let threadInfoNode = threadInfoApply(synchronousLoads)
|
let threadInfoNode = threadInfoApply(synchronousLoads)
|
||||||
if strongSelf.threadInfoNode == nil {
|
if strongSelf.threadInfoNode == nil {
|
||||||
|
@ -172,24 +172,27 @@ final class ForumSettingsScreenComponent: Component {
|
|||||||
if let controller = self.environment?.controller(), let navigationController = controller.navigationController as? NavigationController {
|
if let controller = self.environment?.controller(), let navigationController = controller.navigationController as? NavigationController {
|
||||||
var viewControllers = navigationController.viewControllers
|
var viewControllers = navigationController.viewControllers
|
||||||
|
|
||||||
if self.isOn && self.mode == .list {
|
if case .legacyGroup = peer {
|
||||||
for i in 0 ..< viewControllers.count {
|
|
||||||
if let chatController = viewControllers[i] as? ChatController, chatController.chatLocation.peerId == component.peerId {
|
|
||||||
let chatListController = component.context.sharedContext.makeChatListController(context: component.context, location: .forum(peerId: component.peerId), controlsHistoryPreload: false, hideNetworkActivityStatus: false, previewing: false, enableDebugActions: false)
|
|
||||||
viewControllers[i] = chatListController
|
|
||||||
}
|
|
||||||
}
|
|
||||||
navigationController.setViewControllers(viewControllers, animated: false)
|
|
||||||
} else {
|
} else {
|
||||||
for i in (0 ..< viewControllers.count).reversed() {
|
if self.isOn && self.mode == .list {
|
||||||
if let chatListController = viewControllers[i] as? ChatListController, chatListController.location == .forum(peerId: component.peerId) {
|
for i in 0 ..< viewControllers.count {
|
||||||
viewControllers.remove(at: i)
|
if let chatController = viewControllers[i] as? ChatController, chatController.chatLocation.peerId == component.peerId {
|
||||||
|
let chatListController = component.context.sharedContext.makeChatListController(context: component.context, location: .forum(peerId: component.peerId), controlsHistoryPreload: false, hideNetworkActivityStatus: false, previewing: false, enableDebugActions: false)
|
||||||
|
viewControllers[i] = chatListController
|
||||||
|
}
|
||||||
|
}
|
||||||
|
navigationController.setViewControllers(viewControllers, animated: false)
|
||||||
|
} else {
|
||||||
|
for i in (0 ..< viewControllers.count).reversed() {
|
||||||
|
if let chatListController = viewControllers[i] as? ChatListController, chatListController.location == .forum(peerId: component.peerId) {
|
||||||
|
viewControllers.remove(at: i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
navigationController.setViewControllers(viewControllers, animated: false)
|
||||||
|
|
||||||
|
if let baseController = navigationController as? TelegramRootControllerInterface, let chatListController = baseController.getChatsController() as? ChatListController {
|
||||||
|
chatListController.resetForumStackIfOpen()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
navigationController.setViewControllers(viewControllers, animated: false)
|
|
||||||
|
|
||||||
if let baseController = navigationController as? TelegramRootControllerInterface, let chatListController = baseController.getChatsController() as? ChatListController {
|
|
||||||
chatListController.resetForumStackIfOpen()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,6 +235,34 @@ final class ForumSettingsScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
if let resultPeerId {
|
if let resultPeerId {
|
||||||
self.peerIdPromise.set(resultPeerId)
|
self.peerIdPromise.set(resultPeerId)
|
||||||
|
|
||||||
|
let _ = component.context.engine.peers.setChannelForumMode(id: resultPeerId, isForum: true, displayForumAsTabs: self.mode == .tabs).startStandalone()
|
||||||
|
|
||||||
|
if let controller = self.environment?.controller(), let navigationController = controller.navigationController as? NavigationController {
|
||||||
|
var viewControllers = navigationController.viewControllers
|
||||||
|
if self.mode == .list {
|
||||||
|
for i in 0 ..< viewControllers.count {
|
||||||
|
if let chatController = viewControllers[i] as? ChatController, chatController.chatLocation.peerId == component.peerId {
|
||||||
|
let chatListController = component.context.sharedContext.makeChatListController(context: component.context, location: .forum(peerId: resultPeerId), controlsHistoryPreload: false, hideNetworkActivityStatus: false, previewing: false, enableDebugActions: false)
|
||||||
|
viewControllers[i] = chatListController
|
||||||
|
}
|
||||||
|
}
|
||||||
|
navigationController.setViewControllers(viewControllers, animated: false)
|
||||||
|
} else {
|
||||||
|
for i in (0 ..< viewControllers.count).reversed() {
|
||||||
|
if let chatListController = viewControllers[i] as? ChatListController, chatListController.location == .forum(peerId: component.peerId) {
|
||||||
|
viewControllers.remove(at: i)
|
||||||
|
} else if let peerInfoScreen = viewControllers[i] as? PeerInfoScreen, peerInfoScreen.peerId == component.peerId {
|
||||||
|
viewControllers.remove(at: i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
navigationController.setViewControllers(viewControllers, animated: false)
|
||||||
|
|
||||||
|
if let baseController = navigationController as? TelegramRootControllerInterface, let chatListController = baseController.getChatsController() as? ChatListController {
|
||||||
|
chatListController.resetForumStackIfOpen()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.isOn = false
|
self.isOn = false
|
||||||
self.state?.updated(transition: .easeInOut(duration: 0.2))
|
self.state?.updated(transition: .easeInOut(duration: 0.2))
|
||||||
|
@ -299,69 +299,86 @@ private final class SheetContent: CombinedComponent {
|
|||||||
if let tonBalance = state.tonBalance {
|
if let tonBalance = state.tonBalance {
|
||||||
tonBalanceValue = tonBalance
|
tonBalanceValue = tonBalance
|
||||||
}
|
}
|
||||||
if case let .suggestedPost(mode, _, _, _) = component.mode, (state.currency == .ton || tonBalanceValue > StarsAmount.zero) {
|
|
||||||
//TODO:localize
|
if case let .suggestedPost(mode, _, _, _) = component.mode {
|
||||||
let selectedId: AnyHashable = state.currency == .stars ? AnyHashable(0 as Int) : AnyHashable(1 as Int)
|
var displayCurrencySelector = false
|
||||||
let starsTitle: String
|
|
||||||
let tonTitle: String
|
|
||||||
switch mode {
|
switch mode {
|
||||||
case .sender:
|
case let .sender(_, isFromAdmin):
|
||||||
starsTitle = "Offer Stars"
|
if isFromAdmin {
|
||||||
tonTitle = "Offer TON"
|
displayCurrencySelector = true
|
||||||
|
} else {
|
||||||
|
if state.currency == .ton || tonBalanceValue > StarsAmount.zero {
|
||||||
|
displayCurrencySelector = true
|
||||||
|
}
|
||||||
|
}
|
||||||
case .admin:
|
case .admin:
|
||||||
starsTitle = "Request Stars"
|
displayCurrencySelector = true
|
||||||
tonTitle = "Request TON"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let currencyToggle = currencyToggle.update(
|
if displayCurrencySelector {
|
||||||
component: TabSelectorComponent(
|
//TODO:localize
|
||||||
colors: TabSelectorComponent.Colors(
|
let selectedId: AnyHashable = state.currency == .stars ? AnyHashable(0 as Int) : AnyHashable(1 as Int)
|
||||||
foreground: theme.list.itemSecondaryTextColor,
|
let starsTitle: String
|
||||||
selection: theme.list.itemSecondaryTextColor.withMultipliedAlpha(0.15),
|
let tonTitle: String
|
||||||
simple: true
|
switch mode {
|
||||||
),
|
case .sender:
|
||||||
customLayout: TabSelectorComponent.CustomLayout(
|
starsTitle = "Offer Stars"
|
||||||
font: Font.medium(14.0),
|
tonTitle = "Offer TON"
|
||||||
spacing: 10.0
|
case .admin:
|
||||||
),
|
starsTitle = "Request Stars"
|
||||||
items: [
|
tonTitle = "Request TON"
|
||||||
TabSelectorComponent.Item(
|
}
|
||||||
id: AnyHashable(0),
|
|
||||||
content: .component(AnyComponent(CurrencyTabItemComponent(icon: .stars, title: starsTitle, theme: theme)))
|
let currencyToggle = currencyToggle.update(
|
||||||
|
component: TabSelectorComponent(
|
||||||
|
colors: TabSelectorComponent.Colors(
|
||||||
|
foreground: theme.list.itemSecondaryTextColor,
|
||||||
|
selection: theme.list.itemSecondaryTextColor.withMultipliedAlpha(0.15),
|
||||||
|
simple: true
|
||||||
),
|
),
|
||||||
TabSelectorComponent.Item(
|
customLayout: TabSelectorComponent.CustomLayout(
|
||||||
id: AnyHashable(1),
|
font: Font.medium(14.0),
|
||||||
content: .component(AnyComponent(CurrencyTabItemComponent(icon: .ton, title: tonTitle, theme: theme)))
|
spacing: 10.0
|
||||||
)
|
),
|
||||||
],
|
items: [
|
||||||
selectedId: selectedId,
|
TabSelectorComponent.Item(
|
||||||
setSelectedId: { [weak state] id in
|
id: AnyHashable(0),
|
||||||
guard let state else {
|
content: .component(AnyComponent(CurrencyTabItemComponent(icon: .stars, title: starsTitle, theme: theme)))
|
||||||
return
|
),
|
||||||
|
TabSelectorComponent.Item(
|
||||||
|
id: AnyHashable(1),
|
||||||
|
content: .component(AnyComponent(CurrencyTabItemComponent(icon: .ton, title: tonTitle, theme: theme)))
|
||||||
|
)
|
||||||
|
],
|
||||||
|
selectedId: selectedId,
|
||||||
|
setSelectedId: { [weak state] id in
|
||||||
|
guard let state else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let currency: CurrencyAmount.Currency
|
||||||
|
if id == AnyHashable(0) {
|
||||||
|
currency = .stars
|
||||||
|
} else {
|
||||||
|
currency = .ton
|
||||||
|
}
|
||||||
|
if state.currency != currency {
|
||||||
|
state.currency = currency
|
||||||
|
state.amount = nil
|
||||||
|
}
|
||||||
|
state.updated(transition: .spring(duration: 0.4))
|
||||||
}
|
}
|
||||||
|
),
|
||||||
let currency: CurrencyAmount.Currency
|
availableSize: CGSize(width: context.availableSize.width - sideInset * 2.0, height: 100.0),
|
||||||
if id == AnyHashable(0) {
|
transition: context.transition
|
||||||
currency = .stars
|
)
|
||||||
} else {
|
contentSize.height -= 17.0
|
||||||
currency = .ton
|
let currencyToggleFrame = CGRect(origin: CGPoint(x: floor((context.availableSize.width - currencyToggle.size.width) * 0.5), y: contentSize.height), size: currencyToggle.size)
|
||||||
}
|
context.add(currencyToggle
|
||||||
if state.currency != currency {
|
.position(currencyToggle.size.centered(in: currencyToggleFrame).center))
|
||||||
state.currency = currency
|
|
||||||
state.amount = nil
|
contentSize.height += currencyToggle.size.height + 29.0
|
||||||
}
|
}
|
||||||
state.updated(transition: .spring(duration: 0.4))
|
|
||||||
}
|
|
||||||
),
|
|
||||||
availableSize: CGSize(width: context.availableSize.width - sideInset * 2.0, height: 100.0),
|
|
||||||
transition: context.transition
|
|
||||||
)
|
|
||||||
contentSize.height -= 17.0
|
|
||||||
let currencyToggleFrame = CGRect(origin: CGPoint(x: floor((context.availableSize.width - currencyToggle.size.width) * 0.5), y: contentSize.height), size: currencyToggle.size)
|
|
||||||
context.add(currencyToggle
|
|
||||||
.position(currencyToggle.size.centered(in: currencyToggleFrame).center))
|
|
||||||
|
|
||||||
contentSize.height += currencyToggle.size.height + 29.0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let amountFont = Font.regular(13.0)
|
let amountFont = Font.regular(13.0)
|
||||||
@ -506,7 +523,7 @@ private final class SheetContent: CombinedComponent {
|
|||||||
accentColor: theme.list.itemAccentColor,
|
accentColor: theme.list.itemAccentColor,
|
||||||
value: state.amount?.value,
|
value: state.amount?.value,
|
||||||
minValue: minAmount?.value,
|
minValue: minAmount?.value,
|
||||||
maxValue: state.currency == .ton ? nil : maxAmount?.value,
|
maxValue: maxAmount?.value,
|
||||||
placeholderText: amountPlaceholder,
|
placeholderText: amountPlaceholder,
|
||||||
labelText: amountLabel,
|
labelText: amountLabel,
|
||||||
currency: state.currency,
|
currency: state.currency,
|
||||||
@ -658,7 +675,7 @@ private final class SheetContent: CombinedComponent {
|
|||||||
//TODO:localize
|
//TODO:localize
|
||||||
switch mode {
|
switch mode {
|
||||||
case .sender:
|
case .sender:
|
||||||
if let amount = state.amount {
|
if let amount = state.amount, amount != .zero {
|
||||||
let currencySymbol: String
|
let currencySymbol: String
|
||||||
let currencyAmount: String
|
let currencyAmount: String
|
||||||
switch state.currency {
|
switch state.currency {
|
||||||
@ -1164,9 +1181,14 @@ private final class AmountFieldStarsFormatter: NSObject, UITextFieldDelegate {
|
|||||||
// Convert and combine
|
// Convert and combine
|
||||||
if let whole = Int64(wholeSlice),
|
if let whole = Int64(wholeSlice),
|
||||||
let frac = Int64(fractionStr) {
|
let frac = Int64(fractionStr) {
|
||||||
|
|
||||||
|
let whole = min(whole, Int64.max / scale)
|
||||||
|
|
||||||
amount = whole * scale + frac
|
amount = whole * scale + frac
|
||||||
}
|
}
|
||||||
} else if let whole = Int64(text) { // string had no dot at all
|
} else if let whole = Int64(text) { // string had no dot at all
|
||||||
|
let whole = min(whole, Int64.max / scale)
|
||||||
|
|
||||||
amount = whole * scale
|
amount = whole * scale
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1241,7 +1263,7 @@ private final class AmountFieldStarsFormatter: NSObject, UITextFieldDelegate {
|
|||||||
case .stars:
|
case .stars:
|
||||||
textField.text = "\(self.maxValue)"
|
textField.text = "\(self.maxValue)"
|
||||||
case .ton:
|
case .ton:
|
||||||
textField.text = "\(formatTonAmountText(self.maxValue, dateTimeFormat: self.dateTimeFormat))"
|
textField.text = "\(formatTonAmountText(self.maxValue, dateTimeFormat: PresentationDateTimeFormat(timeFormat: self.dateTimeFormat.timeFormat, dateFormat: self.dateTimeFormat.dateFormat, dateSeparator: "", dateSuffix: "", requiresFullYear: false, decimalSeparator: ".", groupingSeparator: "")))"
|
||||||
}
|
}
|
||||||
self.onTextChanged(text: self.textField.text ?? "")
|
self.onTextChanged(text: self.textField.text ?? "")
|
||||||
self.animateError()
|
self.animateError()
|
||||||
@ -1396,13 +1418,13 @@ private final class AmountFieldComponent: Component {
|
|||||||
|
|
||||||
self.textField.textColor = component.textColor
|
self.textField.textColor = component.textColor
|
||||||
if self.component?.currency != component.currency {
|
if self.component?.currency != component.currency {
|
||||||
if let value = component.value {
|
if let value = component.value, value != .zero {
|
||||||
var text = ""
|
var text = ""
|
||||||
switch component.currency {
|
switch component.currency {
|
||||||
case .stars:
|
case .stars:
|
||||||
text = "\(value)"
|
text = "\(value)"
|
||||||
case .ton:
|
case .ton:
|
||||||
text = "\(formatTonAmountText(value, dateTimeFormat: component.dateTimeFormat))"
|
text = "\(formatTonAmountText(value, dateTimeFormat: PresentationDateTimeFormat(timeFormat: component.dateTimeFormat.timeFormat, dateFormat: component.dateTimeFormat.dateFormat, dateSeparator: "", dateSuffix: "", requiresFullYear: false, decimalSeparator: ".", groupingSeparator: "")))"
|
||||||
}
|
}
|
||||||
self.textField.text = text
|
self.textField.text = text
|
||||||
} else {
|
} else {
|
||||||
@ -1461,7 +1483,7 @@ private final class AmountFieldComponent: Component {
|
|||||||
currency: component.currency,
|
currency: component.currency,
|
||||||
dateTimeFormat: component.dateTimeFormat,
|
dateTimeFormat: component.dateTimeFormat,
|
||||||
minValue: component.minValue ?? 0,
|
minValue: component.minValue ?? 0,
|
||||||
maxValue: component.maxValue ?? Int64.max,
|
maxValue: component.maxValue ?? 10000000,
|
||||||
updated: { [weak self] value in
|
updated: { [weak self] value in
|
||||||
guard let self, let component = self.component else {
|
guard let self, let component = self.component else {
|
||||||
return
|
return
|
||||||
|
@ -1523,6 +1523,13 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
|||||||
if case let .media(value) = editMessageState.content {
|
if case let .media(value) = editMessageState.content {
|
||||||
isEditingMedia = !value.isEmpty
|
isEditingMedia = !value.isEmpty
|
||||||
isMediaEnabled = !value.isEmpty
|
isMediaEnabled = !value.isEmpty
|
||||||
|
|
||||||
|
if interfaceState.interfaceState.postSuggestionState != nil {
|
||||||
|
if value.contains(.file) {
|
||||||
|
isEditingMedia = false
|
||||||
|
isMediaEnabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
isMediaEnabled = true
|
isMediaEnabled = true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user