mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update tag layout
This commit is contained in:
parent
fc21b289a7
commit
53ba8afced
@ -423,7 +423,7 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView {
|
||||
|
||||
let textOrigin: CGFloat
|
||||
if layout.isTag {
|
||||
textOrigin = 30.0
|
||||
textOrigin = 32.0
|
||||
} else {
|
||||
textOrigin = 36.0
|
||||
}
|
||||
@ -684,7 +684,7 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView {
|
||||
size.width -= 2.0
|
||||
}
|
||||
} else if spec.component.isTag && !hasTitle {
|
||||
size.width += 2.0
|
||||
size.width += 1.0
|
||||
} else {
|
||||
let counterSpec = CounterLayout.Spec(
|
||||
stringComponents: counterComponents
|
||||
@ -700,6 +700,9 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView {
|
||||
}
|
||||
counterLayout = counterValue
|
||||
size.width += spacing + counterValue.size.width
|
||||
if spec.component.isTag {
|
||||
size.width += 5.0
|
||||
}
|
||||
}
|
||||
|
||||
let backgroundColors = ReactionButtonAsyncNode.ContainerButtonNode.Colors(
|
||||
|
@ -624,8 +624,6 @@ private class AdMessagesHistoryContextImpl {
|
||||
let image = telegramMediaImageFromApiPhoto(photo)
|
||||
let flags: ExternalJoiningChatState.Invite.Flags = .init(isChannel: (flags & (1 << 0)) != 0, isBroadcast: (flags & (1 << 1)) != 0, isPublic: (flags & (1 << 2)) != 0, isMegagroup: (flags & (1 << 3)) != 0, requestNeeded: (flags & (1 << 6)) != 0, isVerified: (flags & (1 << 7)) != 0, isScam: (flags & (1 << 8)) != 0, isFake: (flags & (1 << 9)) != 0)
|
||||
|
||||
displayAvatar = false
|
||||
|
||||
let _ = flags
|
||||
let _ = participantsCount
|
||||
let _ = participants
|
||||
@ -634,9 +632,11 @@ private class AdMessagesHistoryContextImpl {
|
||||
title: title,
|
||||
joinHash: chatInviteHash,
|
||||
nameColor: PeerNameColor(rawValue: nameColor),
|
||||
image: image,
|
||||
image: displayAvatar ? image : nil,
|
||||
peer: nil
|
||||
))
|
||||
|
||||
displayAvatar = false
|
||||
case let .chatInvitePeek(chat, _):
|
||||
if let peer = parseTelegramGroupOrChannel(chat: chat) {
|
||||
target = .invite(CachedMessage.Target.Invite(
|
||||
@ -649,16 +649,16 @@ private class AdMessagesHistoryContextImpl {
|
||||
}
|
||||
case let .chatInviteAlready(chat):
|
||||
if let peer = parseTelegramGroupOrChannel(chat: chat) {
|
||||
displayAvatar = false
|
||||
|
||||
target = .invite(CachedMessage.Target.Invite(
|
||||
title: peer.debugDisplayTitle,
|
||||
joinHash: chatInviteHash,
|
||||
nameColor: peer.nameColor,
|
||||
image: nil,
|
||||
peer: peer
|
||||
peer: displayAvatar ? peer : nil
|
||||
))
|
||||
}
|
||||
|
||||
displayAvatar = false
|
||||
}
|
||||
}
|
||||
// else if let botApp = app.flatMap({ BotApp(apiBotApp: $0) }) {
|
||||
|
@ -637,9 +637,9 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
|
||||
highlightedFill: UIColor(rgb: 0xbaff93),
|
||||
stroke: bubbleStrokeColor,
|
||||
shadow: nil,
|
||||
reactionInactiveBackground: UIColor(rgb: 0x2DA32F).withMultipliedAlpha(0.12),
|
||||
reactionInactiveForeground: UIColor(rgb: 0x2DA32F),
|
||||
reactionActiveBackground: UIColor(rgb: 0x2DA32F),
|
||||
reactionInactiveBackground: UIColor(rgb: 0x3fc33b).withMultipliedAlpha(0.12),
|
||||
reactionInactiveForeground: UIColor(rgb: 0x3fc33b),
|
||||
reactionActiveBackground: UIColor(rgb: 0x3fc33b),
|
||||
reactionActiveForeground: .clear,
|
||||
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
|
||||
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
|
||||
@ -649,9 +649,9 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
|
||||
highlightedFill: UIColor(rgb: 0xbaff93),
|
||||
stroke: bubbleStrokeColor,
|
||||
shadow: nil,
|
||||
reactionInactiveBackground: UIColor(rgb: 0x2DA32F).withMultipliedAlpha(0.12),
|
||||
reactionInactiveForeground: UIColor(rgb: 0x2DA32F),
|
||||
reactionActiveBackground: UIColor(rgb: 0x2DA32F),
|
||||
reactionInactiveBackground: UIColor(rgb: 0x3fc33b).withMultipliedAlpha(0.12),
|
||||
reactionInactiveForeground: UIColor(rgb: 0x3fc33b),
|
||||
reactionActiveBackground: UIColor(rgb: 0x3fc33b),
|
||||
reactionActiveForeground: .clear,
|
||||
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
|
||||
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
|
||||
|
@ -1,3 +0,0 @@
|
||||
<svg width="30" height="26" viewBox="0 0 30 26" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0 6C0 2.68629 2.68629 0 6 0H15.155C17.5853 0 19.8838 1.10472 21.402 3.00244L29.001 10.5036C30.1697 11.9645 30.1697 14.0403 29.001 15.5012L21.402 23C19.8838 24.8977 17.5853 26.0024 15.155 26.0024H6C2.68629 26.0024 0 23.3161 0 20.0024V6Z" fill="white"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 365 B |
@ -1,7 +1,7 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ChatSearchPanelTag.svg",
|
||||
"filename" : "tag.pdf",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
|
88
submodules/TelegramUI/Images.xcassets/Chat/Title Panels/SearchTagTab.imageset/tag.pdf
vendored
Normal file
88
submodules/TelegramUI/Images.xcassets/Chat/Title Panels/SearchTagTab.imageset/tag.pdf
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
%PDF-1.7
|
||||
|
||||
1 0 obj
|
||||
<< >>
|
||||
endobj
|
||||
|
||||
2 0 obj
|
||||
<< /Length 3 0 R >>
|
||||
stream
|
||||
/DeviceRGB CS
|
||||
/DeviceRGB cs
|
||||
q
|
||||
1.000000 0.000000 -0.000000 1.000000 0.000000 0.000000 cm
|
||||
0.000000 0.000000 0.000000 scn
|
||||
30.847454 17.553677 m
|
||||
28.817463 20.485888 l
|
||||
28.817451 20.485901 l
|
||||
27.420450 22.503792 26.721949 23.512739 25.811777 24.242273 c
|
||||
25.005890 24.888220 24.082550 25.372007 23.092739 25.666922 c
|
||||
21.974840 26.000000 20.747694 26.000000 18.293402 26.000000 c
|
||||
9.600000 26.000000 l
|
||||
6.239685 26.000000 4.559527 26.000000 3.276057 25.346039 c
|
||||
2.147084 24.770800 1.229201 23.852915 0.653961 22.723944 c
|
||||
0.000000 21.440472 0.000000 19.760315 0.000000 16.399998 c
|
||||
0.000000 9.600000 l
|
||||
0.000000 6.239685 0.000000 4.559526 0.653961 3.276056 c
|
||||
1.229201 2.147085 2.147084 1.229200 3.276057 0.653961 c
|
||||
4.559527 0.000000 6.239685 0.000000 9.600000 0.000000 c
|
||||
18.293402 0.000000 l
|
||||
20.747694 0.000000 21.974840 0.000000 23.092739 0.333078 c
|
||||
24.082550 0.627993 25.005890 1.111780 25.811777 1.757727 c
|
||||
26.721951 2.487263 27.420454 3.496210 28.817459 5.514109 c
|
||||
30.847452 8.446320 l
|
||||
31.984114 10.088164 32.552444 10.909086 32.772739 11.800718 c
|
||||
32.967350 12.588397 32.967350 13.411603 32.772739 14.199282 c
|
||||
32.552444 15.090914 31.984114 15.911835 30.847454 17.553677 c
|
||||
h
|
||||
f
|
||||
n
|
||||
Q
|
||||
|
||||
endstream
|
||||
endobj
|
||||
|
||||
3 0 obj
|
||||
1170
|
||||
endobj
|
||||
|
||||
4 0 obj
|
||||
<< /Annots []
|
||||
/Type /Page
|
||||
/MediaBox [ 0.000000 0.000000 32.918701 26.000000 ]
|
||||
/Resources 1 0 R
|
||||
/Contents 2 0 R
|
||||
/Parent 5 0 R
|
||||
>>
|
||||
endobj
|
||||
|
||||
5 0 obj
|
||||
<< /Kids [ 4 0 R ]
|
||||
/Count 1
|
||||
/Type /Pages
|
||||
>>
|
||||
endobj
|
||||
|
||||
6 0 obj
|
||||
<< /Pages 5 0 R
|
||||
/Type /Catalog
|
||||
>>
|
||||
endobj
|
||||
|
||||
xref
|
||||
0 7
|
||||
0000000000 65535 f
|
||||
0000000010 00000 n
|
||||
0000000034 00000 n
|
||||
0000001260 00000 n
|
||||
0000001283 00000 n
|
||||
0000001456 00000 n
|
||||
0000001530 00000 n
|
||||
trailer
|
||||
<< /ID [ (some) (id) ]
|
||||
/Root 6 0 R
|
||||
/Size 7
|
||||
>>
|
||||
startxref
|
||||
1589
|
||||
%%EOF
|
@ -17,6 +17,14 @@ import PromptUI
|
||||
import BundleIconComponent
|
||||
import SavedTagNameAlertController
|
||||
|
||||
private let backgroundTagImage: UIImage? = {
|
||||
if let image = UIImage(bundleImageName: "Chat/Title Panels/SearchTagTab") {
|
||||
return image.stretchableImage(withLeftCapWidth: 8, topCapHeight: 0).withRenderingMode(.alwaysTemplate)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
|
||||
final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, UIScrollViewDelegate {
|
||||
private struct Params: Equatable {
|
||||
var width: CGFloat
|
||||
@ -78,9 +86,7 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, UISc
|
||||
self.containerButton = HighlightTrackingButton()
|
||||
|
||||
self.background = UIImageView()
|
||||
if let image = UIImage(bundleImageName: "Chat/Title Panels/SearchTagTab") {
|
||||
self.background.image = image.stretchableImage(withLeftCapWidth: 8, topCapHeight: 0).withRenderingMode(.alwaysTemplate)
|
||||
}
|
||||
self.background.image = backgroundTagImage
|
||||
|
||||
super.init(frame: CGRect())
|
||||
|
||||
@ -203,6 +209,7 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, UISc
|
||||
|
||||
private let background: UIImageView
|
||||
private let icon = ComponentView<Empty>()
|
||||
private let title = ComponentView<Empty>()
|
||||
private let counter = ComponentView<Empty>()
|
||||
|
||||
init(context: AccountContext, action: @escaping (() -> Void), contextGesture: @escaping (ContextGesture, ContextExtractedContentContainingNode) -> Void) {
|
||||
@ -215,9 +222,7 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, UISc
|
||||
self.containerButton = HighlightTrackingButton()
|
||||
|
||||
self.background = UIImageView()
|
||||
if let image = UIImage(bundleImageName: "Chat/Title Panels/SearchTagTab") {
|
||||
self.background.image = image.stretchableImage(withLeftCapWidth: 8, topCapHeight: 0).withRenderingMode(.alwaysTemplate)
|
||||
}
|
||||
self.background.image = backgroundTagImage
|
||||
|
||||
super.init(frame: CGRect())
|
||||
|
||||
@ -280,9 +285,9 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, UISc
|
||||
}
|
||||
|
||||
func update(item: Item, isSelected: Bool, theme: PresentationTheme, height: CGFloat, transition: Transition) -> CGSize {
|
||||
let spacing: CGFloat = 4.0
|
||||
let spacing: CGFloat = 3.0
|
||||
|
||||
let reactionSize = CGSize(width: 16.0, height: 16.0)
|
||||
let reactionSize = CGSize(width: 20.0, height: 20.0)
|
||||
var reactionDisplaySize = reactionSize
|
||||
if case .builtin = item.reaction {
|
||||
reactionDisplaySize = CGSize(width: reactionDisplaySize.width * 2.0, height: reactionDisplaySize.height * 2.0)
|
||||
@ -310,25 +315,40 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, UISc
|
||||
containerSize: reactionDisplaySize
|
||||
)
|
||||
|
||||
let title: String
|
||||
if let value = item.title, !value.isEmpty {
|
||||
title = "\(value) \(item.count)"
|
||||
} else {
|
||||
title = "\(item.count)"
|
||||
}
|
||||
let counterSize = self.counter.update(
|
||||
let titleText: String = item.title ?? ""
|
||||
let titleSize = self.title.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(string: title, font: Font.regular(11.0), textColor: isSelected ? theme.list.itemCheckColors.foregroundColor : theme.list.itemPrimaryTextColor.withMultipliedAlpha(0.6)))
|
||||
text: .plain(NSAttributedString(string: titleText, font: Font.regular(11.0), textColor: isSelected ? theme.list.itemCheckColors.foregroundColor : theme.list.itemPrimaryTextColor.withMultipliedAlpha(0.6)))
|
||||
)),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: 100.0, height: 100.0)
|
||||
)
|
||||
|
||||
let size = CGSize(width: reactionSize.width + spacing + counterSize.width, height: height)
|
||||
let counterText: String = "\(item.count)"
|
||||
let counterSize = self.counter.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(string: counterText, font: Font.regular(11.0), textColor: isSelected ? theme.list.itemCheckColors.foregroundColor : theme.list.itemPrimaryTextColor.withMultipliedAlpha(0.6)))
|
||||
)),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: 100.0, height: 100.0)
|
||||
)
|
||||
|
||||
let iconFrame = CGRect(origin: CGPoint(x: 0.0, y: floor((size.height - reactionSize.height) * 0.5)), size: reactionSize)
|
||||
let counterFrame = CGRect(origin: CGPoint(x: iconFrame.maxX + spacing, y: floor((size.height - counterSize.height) * 0.5)), size: counterSize)
|
||||
let titleCounterSpacing: CGFloat = 3.0
|
||||
|
||||
var titleAndCounterSize: CGFloat = titleSize.width
|
||||
if titleSize.width != 0.0 {
|
||||
titleAndCounterSize += titleCounterSpacing
|
||||
}
|
||||
titleAndCounterSize += counterSize.width
|
||||
|
||||
let size = CGSize(width: reactionSize.width + spacing + titleAndCounterSize - 2.0, height: height)
|
||||
|
||||
let iconFrame = CGRect(origin: CGPoint(x: -1.0, y: floor((size.height - reactionSize.height) * 0.5)), size: reactionSize)
|
||||
|
||||
let titleFrame = CGRect(origin: CGPoint(x: iconFrame.maxX + spacing, y: floor((size.height - titleSize.height) * 0.5)), size: titleSize)
|
||||
let counterFrame = CGRect(origin: CGPoint(x: titleFrame.maxX + (titleSize.width.isZero ? 0.0 : titleCounterSpacing), y: floor((size.height - counterSize.height) * 0.5)), size: counterSize)
|
||||
|
||||
if let iconView = self.icon.view {
|
||||
if iconView.superview == nil {
|
||||
@ -338,6 +358,13 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, UISc
|
||||
iconView.frame = reactionDisplaySize.centered(around: iconFrame.center)
|
||||
}
|
||||
|
||||
if let titleView = self.title.view {
|
||||
if titleView.superview == nil {
|
||||
titleView.isUserInteractionEnabled = false
|
||||
self.containerButton.addSubview(titleView)
|
||||
}
|
||||
titleView.frame = titleFrame
|
||||
}
|
||||
if let counterView = self.counter.view {
|
||||
if counterView.superview == nil {
|
||||
counterView.isUserInteractionEnabled = false
|
||||
@ -506,7 +533,7 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, UISc
|
||||
let panelHeight: CGFloat = 39.0
|
||||
|
||||
let containerInsets = UIEdgeInsets(top: 0.0, left: params.leftInset + 16.0, bottom: 0.0, right: params.rightInset + 16.0)
|
||||
let itemSpacing: CGFloat = 26.0
|
||||
let itemSpacing: CGFloat = 24.0
|
||||
|
||||
var contentSize = CGSize(width: 0.0, height: panelHeight)
|
||||
contentSize.width += containerInsets.left
|
||||
@ -642,13 +669,13 @@ final class ChatSearchTitleAccessoryPanelNode: ChatTitleAccessoryPanelNode, UISc
|
||||
let itemFrame = CGRect(origin: CGPoint(x: contentSize.width, y: -5.0), size: itemSize)
|
||||
|
||||
itemTransition.updatePosition(layer: itemView.layer, position: itemFrame.center)
|
||||
itemTransition.updateBounds(layer: itemView.layer, bounds: CGRect(origin: CGPoint(), size: itemFrame.size))
|
||||
|
||||
if animateIn && transition.isAnimated {
|
||||
itemView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15)
|
||||
transition.animateTransformScale(view: itemView, from: 0.001)
|
||||
}
|
||||
|
||||
itemView.bounds = CGRect(origin: CGPoint(), size: itemFrame.size)
|
||||
|
||||
contentSize.width += itemSize.width
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user