Skip to content

Commit 948a99a

Browse files
author
Isaac
committed
Input field
1 parent 5efc685 commit 948a99a

File tree

9 files changed

+114
-113
lines changed

9 files changed

+114
-113
lines changed

submodules/ChatSendMessageActionUI/Sources/SendButton.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class SendButton: HighlightTrackingButton {
2828
private let kind: Kind
2929

3030
private let containerView: UIView
31-
private let backgroundView: GlassBackgroundView
31+
private let backgroundView: UIImageView
3232
private let iconView: UIImageView
3333
private var activityIndicator: RadialStatusNode?
3434

@@ -41,7 +41,8 @@ final class SendButton: HighlightTrackingButton {
4141
self.containerView = UIView()
4242
self.containerView.isUserInteractionEnabled = false
4343

44-
self.backgroundView = GlassBackgroundView()
44+
self.backgroundView = UIImageView()
45+
self.backgroundView.image = generateStretchableFilledCircleImage(diameter: 34.0, color: .white)?.withRenderingMode(.alwaysTemplate)
4546

4647
self.iconView = UIImageView()
4748
self.iconView.isUserInteractionEnabled = false
@@ -69,12 +70,12 @@ final class SendButton: HighlightTrackingButton {
6970
size: CGSize,
7071
transition: ComponentTransition
7172
) {
72-
let innerSize = CGSize(width: size.width, height: size.height)
73+
let innerSize = CGSize(width: size.width - 3.0 * 2.0, height: size.height - 3.0 * 2.0)
7374
let containerFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - innerSize.width) * 0.5), y: floorToScreenPixels((size.height - innerSize.height) * 0.5)), size: innerSize)
7475
transition.setFrame(view: self.containerView, frame: containerFrame)
7576
transition.setCornerRadius(layer: self.containerView.layer, cornerRadius: innerSize.height * 0.5)
7677

77-
self.backgroundView.update(size: innerSize, cornerRadius: innerSize.height * 0.5, isDark: presentationData.theme.overallDarkAppearance, tintColor: .init(kind: .custom, color: presentationData.theme.chat.inputPanel.actionControlFillColor), transition: .immediate)
78+
self.backgroundView.tintColor = presentationData.theme.chat.inputPanel.actionControlFillColor
7879
transition.setFrame(view: self.backgroundView, frame: CGRect(origin: CGPoint(), size: innerSize))
7980

8081
if self.previousIsAnimatedIn != isAnimatedIn {

submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,21 +382,23 @@ public struct PresentationResourcesChat {
382382

383383
public static func chatInputPanelSendIconImage(_ theme: PresentationTheme) -> UIImage? {
384384
return theme.image(PresentationResourceKey.chatInputPanelSendIconImage.rawValue, { theme in
385-
return generateImage(CGSize(width: 33.0, height: 33.0), rotatedContext: { size, context in
385+
return generateImage(CGSize(width: 34.0, height: 34.0), rotatedContext: { size, context in
386+
UIGraphicsPushContext(context)
387+
defer {
388+
UIGraphicsPopContext()
389+
}
390+
386391
context.clear(CGRect(origin: CGPoint(), size: size))
387392
let color: UIColor
388393
if [.day, .night].contains(theme.referenceTheme.baseTheme) && !theme.chat.message.outgoing.bubble.withWallpaper.hasSingleFillColor {
389394
color = .white
390395
} else {
391396
color = theme.chat.inputPanel.actionControlForegroundColor
392397
}
393-
context.setStrokeColor(color.cgColor)
394-
context.setFillColor(color.cgColor)
395-
context.setLineWidth(2.0)
396-
context.setLineCap(.round)
397-
context.setLineJoin(.round)
398-
let _ = try? drawSvgPath(context, path: "M11,14.6666667 L16.4310816,9.40016333 L16.4310816,9.40016333 C16.4694824,9.36292619 16.5305176,9.36292619 16.5689184,9.40016333 L22,14.6666667 S ")
399-
let _ = try? drawSvgPath(context, path: "M16.5,9.33333333 C17.0522847,9.33333333 17.5,9.78104858 17.5,10.3333333 L17.5,24 C17.5,24.5522847 17.0522847,25 16.5,25 C15.9477153,25 15.5,24.5522847 15.5,24 L15.5,10.3333333 C15.5,9.78104858 15.9477153,9.33333333 16.5,9.33333333 Z ")
398+
399+
if let image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Text/SendIcon"), color: color) {
400+
image.draw(in: CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - image.size.width) * 0.5), y: floorToScreenPixels((size.height - image.size.height) * 0.5)), size: image.size))
401+
}
400402
})
401403
})
402404
}

submodules/TelegramUI/Components/Chat/ChatRecordingPreviewInputPanelNode/Sources/ChatRecordingPreviewInputPanelNode.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ public final class ChatRecordingPreviewInputPanelNodeImpl: ChatInputPanelNode {
388388
}
389389

390390
override public func updateLayout(width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, additionalSideInsets: UIEdgeInsets, maxHeight: CGFloat, maxOverlayHeight: CGFloat, isSecondary: Bool, transition: ContainedViewLayoutTransition, interfaceState: ChatPresentationInterfaceState, metrics: LayoutMetrics, isMediaInputExpanded: Bool) -> CGFloat {
391-
let waveformBackgroundFrame = CGRect(origin: CGPoint(x: 2.0, y: 2.0), size: CGSize(width: width - 2.0 * 2.0, height: 40.0 - 2.0 * 2.0))
391+
let waveformBackgroundFrame = CGRect(origin: CGPoint(x: 3.0, y: 3.0), size: CGSize(width: width - 3.0 * 2.0, height: 40.0 - 3.0 * 2.0))
392392

393393
if self.presentationInterfaceState != interfaceState {
394394
var updateWaveform = false
@@ -479,7 +479,7 @@ public final class ChatRecordingPreviewInputPanelNodeImpl: ChatInputPanelNode {
479479
transition: .immediate
480480
)
481481

482-
let waveformForegroundFrame = CGRect(origin: CGPoint(x: 2.0 + leftHandleFrame.minX, y: 2.0), size: CGSize(width: rightHandleFrame.maxX - leftHandleFrame.minX, height: 40.0 - 2.0 * 2.0))
482+
let waveformForegroundFrame = CGRect(origin: CGPoint(x: 3.0 + leftHandleFrame.minX, y: 3.0), size: CGSize(width: rightHandleFrame.maxX - leftHandleFrame.minX, height: 40.0 - 3.0 * 2.0))
483483
transition.updateFrame(node: self.waveformBackgroundNodeImpl, frame: waveformForegroundFrame)
484484

485485
self.waveformNode.updateClipping(minX: leftHandleFrame.minX - 19.0, maxX: rightHandleFrame.maxX - 19.0, transition: transition)
@@ -563,7 +563,7 @@ public final class ChatRecordingPreviewInputPanelNodeImpl: ChatInputPanelNode {
563563
if view.superview == nil {
564564
self.view.addSubview(view)
565565
}
566-
view.frame = CGRect(origin: CGPoint(x: 2.0, y: 2.0), size: scrubberSize)
566+
view.frame = CGRect(origin: CGPoint(x: 3.0, y: 3.0), size: scrubberSize)
567567
}
568568
}
569569
}

submodules/TelegramUI/Components/Chat/ChatRecordingViewOnceButtonNode/Sources/ChatRecordingViewOnceButtonNode.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public final class ChatRecordingViewOnceButtonNode: HighlightTrackingButtonNode
8888
case .recordMore:
8989
self.iconView.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Text/IconMicrophone"), color: .white)?.withRenderingMode(.alwaysTemplate)
9090
}
91+
92+
self.iconView.tintColor = theme.chat.inputPanel.panelControlColor
9193
}
9294

9395
let backgroundFrame = CGRect(origin: CGPoint(x: floorToScreenPixels(size.width / 2.0 - innerSize.width / 2.0), y: floorToScreenPixels(size.height / 2.0 - innerSize.height / 2.0)), size: innerSize)

submodules/TelegramUI/Components/Chat/ChatTextInputActionButtonsNode/Sources/ChatTextInputActionButtonsNode.swift

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,11 @@ public final class ChatTextInputActionButtonsNode: ASDisplayNode, ChatSendMessag
133133
private let presentationContext: ChatPresentationContext?
134134
private let strings: PresentationStrings
135135

136-
public let micButtonBackgroundView: GlassBackgroundView
137136
public let micButtonTintMaskView: UIImageView
138137
public let micButton: ChatTextInputMediaRecordingButton
139138

140139
public let sendContainerNode: ASDisplayNode
141-
public let sendButtonBackgroundView: GlassBackgroundView
140+
public let sendButtonBackgroundView: UIImageView
142141
public let sendButton: HighlightTrackingButtonNode
143142
public var sendButtonRadialStatusNode: ChatSendButtonRadialStatusNode?
144143
public var sendButtonHasApplyIcon = false
@@ -147,7 +146,6 @@ public final class ChatTextInputActionButtonsNode: ASDisplayNode, ChatSendMessag
147146
public let textNode: ImmediateAnimatedCountLabelNode
148147

149148
public let expandMediaInputButton: HighlightTrackingButton
150-
private let expandMediaInputButtonBackgroundView: GlassBackgroundView
151149
private let expandMediaInputButtonIcon: GlassBackgroundView.ContentImageView
152150

153151
private var effectBadgeView: EffectBadgeView?
@@ -164,6 +162,8 @@ public final class ChatTextInputActionButtonsNode: ASDisplayNode, ChatSendMessag
164162
private var micButtonPointerInteraction: PointerInteraction?
165163
private var sendButtonPointerInteraction: PointerInteraction?
166164

165+
let maskContentView: UIView
166+
167167
private var validLayout: CGSize?
168168

169169
public init(context: AccountContext, presentationInterfaceState: ChatPresentationInterfaceState, presentationContext: ChatPresentationContext?, presentController: @escaping (ViewController) -> Void) {
@@ -173,31 +173,31 @@ public final class ChatTextInputActionButtonsNode: ASDisplayNode, ChatSendMessag
173173
let strings = presentationInterfaceState.strings
174174
self.strings = strings
175175

176-
self.micButtonBackgroundView = GlassBackgroundView()
176+
self.maskContentView = UIView()
177+
177178
self.micButtonTintMaskView = UIImageView()
178179
self.micButtonTintMaskView.tintColor = .black
179180
self.micButton = ChatTextInputMediaRecordingButton(context: context, theme: theme, pause: true, strings: strings, presentController: presentController)
180181
self.micButton.animationOutput = self.micButtonTintMaskView
181-
self.micButtonBackgroundView.maskContentView.addSubview(self.micButtonTintMaskView)
182+
self.maskContentView.addSubview(self.micButtonTintMaskView)
182183

183184
self.sendContainerNode = ASDisplayNode()
184185
self.sendContainerNode.layer.allowsGroupOpacity = true
185186

186-
self.sendButtonBackgroundView = GlassBackgroundView()
187+
self.sendButtonBackgroundView = UIImageView()
188+
self.sendButtonBackgroundView.image = generateStretchableFilledCircleImage(diameter: 34.0, color: .white)?.withRenderingMode(.alwaysTemplate)
187189
self.sendButton = HighlightTrackingButtonNode(pointerStyle: nil)
188190

189191
self.textNode = ImmediateAnimatedCountLabelNode()
190192
self.textNode.isUserInteractionEnabled = false
191193

192194
self.expandMediaInputButton = HighlightTrackingButton()
193-
self.expandMediaInputButtonBackgroundView = GlassBackgroundView()
194-
self.expandMediaInputButtonBackgroundView.isUserInteractionEnabled = false
195-
self.expandMediaInputButton.addSubview(self.expandMediaInputButtonBackgroundView)
196195
self.expandMediaInputButtonIcon = GlassBackgroundView.ContentImageView()
197-
self.expandMediaInputButtonBackgroundView.contentView.addSubview(self.expandMediaInputButtonIcon)
196+
self.maskContentView.addSubview(self.expandMediaInputButtonIcon.tintMask)
198197
self.expandMediaInputButtonIcon.image = PresentationResourcesChat.chatInputPanelExpandButtonImage(presentationInterfaceState.theme)
199-
self.expandMediaInputButtonIcon.tintColor = theme.chat.inputPanel.panelControlColor
200-
self.expandMediaInputButtonIcon.setMonochromaticEffect(tintColor: theme.chat.inputPanel.panelControlColor)
198+
self.expandMediaInputButtonIcon.tintColor = theme.chat.inputPanel.inputControlColor.withAlphaComponent(1.0)
199+
self.expandMediaInputButtonIcon.setMonochromaticEffect(tintColor: theme.chat.inputPanel.panelControlColor.withAlphaComponent(1.0))
200+
self.expandMediaInputButtonIcon.alpha = theme.chat.inputPanel.panelControlColor.alpha
201201

202202
super.init()
203203

@@ -225,14 +225,14 @@ public final class ChatTextInputActionButtonsNode: ASDisplayNode, ChatSendMessag
225225
}
226226

227227
self.micButton.layer.allowsGroupOpacity = true
228-
self.view.addSubview(self.micButtonBackgroundView)
229228
self.view.addSubview(self.micButton)
230229

231230
self.addSubnode(self.sendContainerNode)
232231
self.sendContainerNode.view.addSubview(self.sendButtonBackgroundView)
233232
self.sendContainerNode.addSubnode(self.sendButton)
234233
self.sendContainerNode.addSubnode(self.textNode)
235234
self.view.addSubview(self.expandMediaInputButton)
235+
self.expandMediaInputButton.addSubview(self.expandMediaInputButtonIcon)
236236

237237
self.expandMediaInputButton.highligthedChanged = { [weak self] highlighted in
238238
guard let self else {
@@ -265,8 +265,9 @@ public final class ChatTextInputActionButtonsNode: ASDisplayNode, ChatSendMessag
265265

266266
public func updateTheme(theme: PresentationTheme, wallpaper: TelegramWallpaper) {
267267
self.micButton.updateTheme(theme: theme)
268-
self.expandMediaInputButtonIcon.tintColor = theme.chat.inputPanel.panelControlColor
269-
self.expandMediaInputButtonIcon.setMonochromaticEffect(tintColor: theme.chat.inputPanel.panelControlColor)
268+
self.expandMediaInputButtonIcon.tintColor = theme.chat.inputPanel.panelControlColor.withAlphaComponent(1.0)
269+
self.expandMediaInputButtonIcon.setMonochromaticEffect(tintColor: theme.chat.inputPanel.panelControlColor.withAlphaComponent(1.0))
270+
self.expandMediaInputButtonIcon.alpha = theme.chat.inputPanel.panelControlColor.alpha
270271
}
271272

272273
private var absoluteRect: (CGRect, CGSize)?
@@ -285,6 +286,7 @@ public final class ChatTextInputActionButtonsNode: ASDisplayNode, ChatSendMessag
285286
self.validLayout = size
286287

287288
var innerSize = size
289+
innerSize.width = 38.0 + 3.0 * 2.0
288290

289291
var starsAmount: Int64?
290292
if let sendPaidMessageStars = interfaceState.sendPaidMessageStars, interfaceState.interfaceState.editMessage == nil {
@@ -334,24 +336,19 @@ public final class ChatTextInputActionButtonsNode: ASDisplayNode, ChatSendMessag
334336
self.sendButton.imageNode.alpha = 1.0
335337
self.textNode.isHidden = true
336338
}
337-
338-
transition.updateFrame(view: self.micButtonBackgroundView, frame: CGRect(origin: CGPoint(), size: size))
339-
self.micButtonBackgroundView.update(size: size, cornerRadius: size.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: .init(kind: .panel, color: interfaceState.theme.chat.inputPanel.inputBackgroundColor.withMultipliedAlpha(0.7)), transition: ComponentTransition(transition))
340339

341-
transition.updateFrame(layer: self.micButton.layer, frame: CGRect(origin: CGPoint(), size: size))
340+
transition.updateFrame(layer: self.micButton.layer, frame: CGRect(origin: CGPoint(x: 7.0, y: 0.0), size: CGSize(width: size.width - 7.0, height: size.height)))
342341
self.micButton.layoutItems()
343342

344-
transition.updateFrame(view: self.sendButtonBackgroundView, frame: CGRect(origin: CGPoint(), size: innerSize))
345-
self.sendButtonBackgroundView.update(size: innerSize, cornerRadius: innerSize.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: .init(kind: .custom, color: interfaceState.theme.chat.inputPanel.actionControlFillColor), transition: ComponentTransition(transition))
343+
transition.updateFrame(view: self.sendButtonBackgroundView, frame: CGRect(origin: CGPoint(), size: innerSize).insetBy(dx: 3.0, dy: 3.0))
344+
self.sendButtonBackgroundView.tintColor = interfaceState.theme.chat.inputPanel.panelControlAccentColor
346345
transition.updateFrame(layer: self.sendButton.layer, frame: CGRect(origin: CGPoint(), size: innerSize))
347346
transition.updateFrame(node: self.sendContainerNode, frame: CGRect(origin: CGPoint(), size: innerSize))
348347

349348
let backgroundSize = CGSize(width: innerSize.width, height: 40.0)
350349
let backgroundFrame = CGRect(origin: CGPoint(x: showTitle ? 5.0 + UIScreenPixel : floorToScreenPixels((size.width - backgroundSize.width) / 2.0), y: floorToScreenPixels((size.height - backgroundSize.height) / 2.0)), size: backgroundSize)
351350

352351
transition.updateFrame(view: self.expandMediaInputButton, frame: CGRect(origin: CGPoint(), size: size))
353-
transition.updateFrame(view: self.expandMediaInputButtonBackgroundView, frame: CGRect(origin: CGPoint(), size: size))
354-
self.expandMediaInputButtonBackgroundView.update(size: size, cornerRadius: size.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: .init(kind: .panel, color: interfaceState.theme.chat.inputPanel.inputBackgroundColor.withMultipliedAlpha(0.7)), transition: ComponentTransition(transition))
355352
if let image = self.expandMediaInputButtonIcon.image {
356353
let expandIconFrame = CGRect(origin: CGPoint(x: floor((size.width - image.size.width) * 0.5), y: floor((size.height - image.size.height) * 0.5)), size: image.size)
357354
self.expandMediaInputButtonIcon.center = expandIconFrame.center

0 commit comments

Comments
 (0)