mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Various fixes
This commit is contained in:
parent
ef2d93c5a0
commit
9bb46769a3
@ -288,7 +288,7 @@ final class ComposePollScreenComponent: Component {
|
||||
self.reorderingItem = nil
|
||||
for (itemId, itemView) in self.pollOptionsSectionContainer.itemViews {
|
||||
if itemId == reorderingItem.id, let view = itemView.contents.view {
|
||||
let viewFrame = view.convert(view.bounds, to: self)
|
||||
let viewFrame = view.convert(view.bounds, to: self.scrollView)
|
||||
let transition = ComponentTransition.spring(duration: 0.3)
|
||||
transition.setPosition(view: reorderingItem.snapshotView, position: viewFrame.center)
|
||||
transition.setAlpha(view: reorderingItem.backgroundView, alpha: 0.0, completion: { _ in
|
||||
@ -311,13 +311,14 @@ final class ComposePollScreenComponent: Component {
|
||||
|
||||
snapshotView.center = targetPosition
|
||||
|
||||
let localPoint = self.pollOptionsSectionContainer.convert(targetPosition, from: self.scrollView)
|
||||
for (itemId, itemView) in self.pollOptionsSectionContainer.itemViews {
|
||||
if itemId == id {
|
||||
continue
|
||||
}
|
||||
if let view = itemView.contents.view {
|
||||
let viewFrame = view.convert(view.bounds, to: self)
|
||||
if viewFrame.contains(targetPosition) {
|
||||
let viewFrame = view.convert(view.bounds, to: self.pollOptionsSectionContainer)
|
||||
if viewFrame.contains(localPoint) {
|
||||
if let targetIndex = self.pollOptions.firstIndex(where: { AnyHashable($0.id) == itemId }), let reorderingItem = self.pollOptions.first(where: { AnyHashable($0.id) == id }) {
|
||||
self.reorderIfPossible(item: reorderingItem, toIndex: targetIndex)
|
||||
}
|
||||
|
@ -60,7 +60,8 @@ swift_library(
|
||||
"//submodules/TelegramUI/Components/AnimatedTextComponent",
|
||||
"//submodules/TelegramUI/Components/LottieComponent",
|
||||
"//submodules/Components/MultilineTextComponent",
|
||||
"//submodules/Components/BundleIconComponent",
|
||||
"//submodules/Components/MultilineTextWithEntitiesComponent",
|
||||
"//submodules/Components/BundleIconComponent",
|
||||
"//submodules/Components/BalancedTextComponent",
|
||||
"//submodules/Components/ComponentDisplayAdapters",
|
||||
"//submodules/ComponentFlow",
|
||||
|
@ -4,6 +4,7 @@ import Display
|
||||
import SwiftSignalKit
|
||||
import ComponentFlow
|
||||
import MultilineTextComponent
|
||||
import MultilineTextWithEntitiesComponent
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
@ -12,6 +13,7 @@ import PlainButtonComponent
|
||||
import AvatarNode
|
||||
import AccountContext
|
||||
import PhotoResources
|
||||
import TextFormat
|
||||
|
||||
final class VideoAdComponent: Component {
|
||||
let context: AccountContext
|
||||
@ -138,12 +140,23 @@ final class VideoAdComponent: Component {
|
||||
environment: {},
|
||||
containerSize: CGSize(width: availableSize.width - leftInset - rightInset, height: availableSize.height)
|
||||
)
|
||||
|
||||
let textColor = UIColor.white
|
||||
|
||||
var entities: [MessageTextEntity] = []
|
||||
if let attribute = component.message.attributes.first(where: { $0 is TextEntitiesMessageAttribute }) as? TextEntitiesMessageAttribute {
|
||||
entities = attribute.entities
|
||||
}
|
||||
let attributedText = stringWithAppliedEntities(component.message.text, entities: entities, baseColor: textColor, linkColor: textColor, baseFont: Font.regular(14.0), linkFont: Font.regular(14.0), boldFont: Font.semibold(14.0), italicFont: Font.italic(14.0), boldItalicFont: Font.semiboldItalic(14.0), fixedFont: Font.monospace(14.0), blockQuoteFont: Font.regular(14.0), message: nil)
|
||||
let textSize = self.text.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(
|
||||
MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(string: component.message.text, font: Font.regular(14.0), textColor: .white)),
|
||||
maximumNumberOfLines: 0
|
||||
MultilineTextWithEntitiesComponent(
|
||||
context: component.context,
|
||||
animationCache: component.context.animationCache,
|
||||
animationRenderer: component.context.animationRenderer,
|
||||
placeholderColor: UIColor.white.withAlphaComponent(0.2),
|
||||
text: .plain(attributedText)
|
||||
)
|
||||
),
|
||||
environment: {},
|
||||
|
@ -383,7 +383,7 @@ public final class ButtonComponent: Component {
|
||||
isEnabled: Bool,
|
||||
tintWhenDisabled: Bool = true,
|
||||
allowActionWhenDisabled: Bool = false,
|
||||
displaysProgress: Bool,
|
||||
displaysProgress: Bool = false,
|
||||
action: @escaping () -> Void
|
||||
) {
|
||||
self.background = background
|
||||
|
@ -413,7 +413,7 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
}
|
||||
|
||||
|
||||
if item.associatedData.isSuspiciousPeer, let entities = messageEntities {
|
||||
if incoming && item.associatedData.isSuspiciousPeer, let entities = messageEntities {
|
||||
messageEntities = entities.filter { entity in
|
||||
switch entity.type {
|
||||
case .Url, .TextUrl, .Mention, .TextMention, .Hashtag, .Email, .BankCard:
|
||||
|
@ -237,7 +237,7 @@ final class ComposeTodoScreenComponent: Component {
|
||||
self.reorderingItem = nil
|
||||
for (itemId, itemView) in self.todoItemsSectionContainer.itemViews {
|
||||
if itemId == reorderingItem.id, let view = itemView.contents.view {
|
||||
let viewFrame = view.convert(view.bounds, to: self)
|
||||
let viewFrame = view.convert(view.bounds, to: self.scrollView)
|
||||
let transition = ComponentTransition.spring(duration: 0.3)
|
||||
transition.setPosition(view: reorderingItem.snapshotView, position: viewFrame.center)
|
||||
transition.setAlpha(view: reorderingItem.backgroundView, alpha: 0.0, completion: { _ in
|
||||
@ -260,13 +260,14 @@ final class ComposeTodoScreenComponent: Component {
|
||||
|
||||
snapshotView.center = targetPosition
|
||||
|
||||
let localPoint = self.todoItemsSectionContainer.convert(targetPosition, from: self.scrollView)
|
||||
for (itemId, itemView) in self.todoItemsSectionContainer.itemViews {
|
||||
if itemId == id {
|
||||
continue
|
||||
}
|
||||
if let view = itemView.contents.view {
|
||||
let viewFrame = view.convert(view.bounds, to: self)
|
||||
if viewFrame.contains(targetPosition) {
|
||||
let viewFrame = view.convert(view.bounds, to: self.todoItemsSectionContainer)
|
||||
if viewFrame.contains(localPoint) {
|
||||
if let targetIndex = self.todoItems.firstIndex(where: { AnyHashable($0.id) == itemId }), let reorderingItem = self.todoItems.first(where: { AnyHashable($0.id) == id }) {
|
||||
self.reorderIfPossible(item: reorderingItem, toIndex: targetIndex)
|
||||
}
|
||||
@ -1662,7 +1663,7 @@ public class ComposeTodoScreen: ViewControllerComponentContainer, AttachmentCont
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
if !initialData.canEdit && initialData.existingTodo != nil {
|
||||
self.title = presentationData.strings.CreateTodo_Title
|
||||
self.title = presentationData.strings.CreateTodo_AddTitle
|
||||
} else {
|
||||
self.title = initialData.existingTodo != nil ? presentationData.strings.CreateTodo_EditTitle : presentationData.strings.CreateTodo_Title
|
||||
}
|
||||
|
@ -2368,7 +2368,7 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
transition: .immediate
|
||||
)
|
||||
context.add(descriptionButton
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: 207.0 + descriptionOffset + description.size.height / 2.0 - UIScreenPixel))
|
||||
.position(CGPoint(x: context.availableSize.width / 2.0, y: 207.0 + descriptionOffset + description.size.height / 2.0 - 1.0))
|
||||
.appear(.default(alpha: true))
|
||||
.disappear(.default(alpha: true))
|
||||
)
|
||||
|
@ -25,7 +25,7 @@ public final class PlainButtonComponent: Component {
|
||||
public init(
|
||||
content: AnyComponent<Empty>,
|
||||
background: AnyComponent<Empty>? = nil,
|
||||
effectAlignment: EffectAlignment,
|
||||
effectAlignment: EffectAlignment = .center,
|
||||
minSize: CGSize? = nil,
|
||||
contentInsets: UIEdgeInsets = UIEdgeInsets(),
|
||||
action: @escaping () -> Void,
|
||||
|
@ -1432,6 +1432,8 @@ private final class AmountFieldComponent: Component {
|
||||
private weak var state: EmptyComponentState?
|
||||
private var isUpdating: Bool = false
|
||||
|
||||
private var didSetValueOnce = false
|
||||
|
||||
override init(frame: CGRect) {
|
||||
self.placeholderView = ComponentView<Empty>()
|
||||
self.textField = TextFieldNodeView(frame: .zero)
|
||||
@ -1470,7 +1472,7 @@ private final class AmountFieldComponent: Component {
|
||||
}
|
||||
|
||||
self.textField.textColor = component.textColor
|
||||
if self.component?.currency != component.currency {
|
||||
if self.component?.currency != component.currency || ((self.textField.text ?? "").isEmpty && !self.didSetValueOnce) {
|
||||
if let value = component.value, value != .zero {
|
||||
var text = ""
|
||||
switch component.currency {
|
||||
@ -1480,6 +1482,7 @@ private final class AmountFieldComponent: Component {
|
||||
text = "\(formatTonAmountText(value, dateTimeFormat: PresentationDateTimeFormat(timeFormat: component.dateTimeFormat.timeFormat, dateFormat: component.dateTimeFormat.dateFormat, dateSeparator: "", dateSuffix: "", requiresFullYear: false, decimalSeparator: ".", groupingSeparator: "")))"
|
||||
}
|
||||
self.textField.text = text
|
||||
self.didSetValueOnce = true
|
||||
} else {
|
||||
self.textField.text = ""
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user