Skip to content

Commit 9c0f5c0

Browse files
author
Isaac
committed
Buttons update
1 parent 8e93744 commit 9c0f5c0

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
lines changed

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

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -418,33 +418,14 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
418418

419419
let _ = previousAction
420420

421-
/*var offset: CGFloat = 30.0
422-
423-
if let previousAction = previousAction, [.join, .muteNotifications].contains(previousAction) && action == .unmuteNotifications || [.join, .unmuteNotifications].contains(previousAction) && action == .muteNotifications {
424-
if [.join, .muteNotifications].contains(previousAction) {
425-
offset *= -1.0
426-
}
427-
if let snapshotView = self.button.view.snapshotContentTree() {
428-
snapshotView.frame = self.button.frame
429-
self.button.supernode?.view.addSubview(snapshotView)
430-
431-
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak snapshotView] _ in
432-
snapshotView?.removeFromSuperview()
433-
})
434-
snapshotView.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: offset), duration: 0.2, removeOnCompletion: false, additive: true)
435-
self.button.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
436-
self.button.layer.animatePosition(from: CGPoint(x: 0.0, y: -offset), to: CGPoint(), duration: 0.2, additive: true)
437-
}
438-
}*/
439-
440421
let titleColor: UIColor
441422
if case .join = self.action {
442423
titleColor = interfaceState.theme.chat.inputPanel.actionControlForegroundColor
443424
} else {
444425
titleColor = interfaceState.theme.chat.inputPanel.panelControlColor
445426
}
446-
self.buttonTitle.attributedText = NSAttributedString(string: title, font: Font.regular(17.0), textColor: titleColor)
447-
self.buttonTintTitle.attributedText = NSAttributedString(string: title, font: Font.regular(17.0), textColor: .black)
427+
self.buttonTitle.attributedText = NSAttributedString(string: title, font: Font.semibold(16.0), textColor: titleColor)
428+
self.buttonTintTitle.attributedText = NSAttributedString(string: title, font: Font.semibold(16.0), textColor: .black)
448429
self.button.accessibilityLabel = title
449430
} else {
450431
self.action = nil
@@ -493,7 +474,7 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
493474
transition.updateFrame(view: self.buttonBackgroundView, frame: CGRect(origin: CGPoint(), size: buttonFrame.size))
494475
let buttonTintColor: GlassBackgroundView.TintColor
495476
if case .join = self.action {
496-
buttonTintColor = .init(kind: .custom, color: interfaceState.theme.chat.inputPanel.actionControlFillColor)
477+
buttonTintColor = .init(kind: .custom, color: interfaceState.theme.chat.inputPanel.inputBackgroundColor.withMultipliedAlpha(0.7), innerColor: interfaceState.theme.chat.inputPanel.actionControlFillColor)
497478
} else {
498479
buttonTintColor = .init(kind: .panel, color: interfaceState.theme.chat.inputPanel.inputBackgroundColor.withMultipliedAlpha(0.7))
499480
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,14 +1566,14 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
15661566

15671567
let buttonTitle: String
15681568
if case let .webView(title, _) = interfaceState.botMenuButton {
1569-
buttonTitle = title.uppercased()
1569+
buttonTitle = title
15701570
} else {
1571-
buttonTitle = interfaceState.strings.Conversation_InputMenu.uppercased()
1571+
buttonTitle = interfaceState.strings.Conversation_InputMenu
15721572
}
15731573

15741574
buttonTitleUpdated = self.menuButtonTextNode.attributedText != nil && self.menuButtonTextNode.attributedText?.string != buttonTitle
15751575

1576-
self.menuButtonTextNode.attributedText = NSAttributedString(string: buttonTitle, font: Font.with(size: 16.0, design: .round, weight: .medium, traits: []), textColor: interfaceState.theme.chat.inputPanel.actionControlForegroundColor)
1576+
self.menuButtonTextNode.attributedText = NSAttributedString(string: buttonTitle, font: Font.with(size: 16.0, design: .round, weight: .semibold, traits: []), textColor: interfaceState.theme.chat.inputPanel.actionControlForegroundColor)
15771577
self.menuButton.accessibilityLabel = self.menuButtonTextNode.attributedText?.string
15781578

15791579
if buttonTitleUpdated, let buttonTextSnapshotView = self.menuButtonTextNode.view.snapshotView(afterScreenUpdates: false) {
@@ -1949,7 +1949,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
19491949
let menuButtonFrame = CGRect(x: leftInset + 8.0, y: menuButtonOriginY, width: menuButtonExpanded ? menuButtonWidth : menuCollapsedButtonWidth, height: menuButtonHeight)
19501950
transition.updateFrameAsPositionAndBounds(node: self.menuButton, frame: menuButtonFrame)
19511951
transition.updateFrame(view: self.menuButtonBackgroundView, frame: CGRect(origin: CGPoint(), size: menuButtonFrame.size))
1952-
self.menuButtonBackgroundView.update(size: menuButtonFrame.size, cornerRadius: menuButtonFrame.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: .init(kind: .custom, color: interfaceState.theme.chat.inputPanel.actionControlFillColor), transition: ComponentTransition(transition))
1952+
self.menuButtonBackgroundView.update(size: menuButtonFrame.size, cornerRadius: menuButtonFrame.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: .init(kind: .panel, color: interfaceState.theme.chat.inputPanel.inputBackgroundColor.withMultipliedAlpha(0.7), innerColor: interfaceState.theme.chat.inputPanel.actionControlFillColor), transition: ComponentTransition(transition))
19531953
transition.updateFrame(node: self.menuButtonClippingNode, frame: CGRect(origin: CGPoint(x: 19.0, y: 0.0), size: CGSize(width: menuButtonWidth - 19.0, height: menuButtonFrame.height)))
19541954
var menuButtonTitleTransition = transition
19551955
if buttonTitleUpdated {

submodules/TelegramUI/Components/GlassBackgroundComponent/Sources/GlassBackgroundComponent.swift

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,12 @@ public class GlassBackgroundView: UIView {
252252

253253
public let kind: Kind
254254
public let color: UIColor
255+
public let innerColor: UIColor?
255256

256-
public init(kind: Kind, color: UIColor) {
257+
public init(kind: Kind, color: UIColor, innerColor: UIColor? = nil) {
257258
self.kind = kind
258259
self.color = color
260+
self.innerColor = innerColor
259261
}
260262
}
261263

@@ -285,6 +287,8 @@ public class GlassBackgroundView: UIView {
285287
public let maskContentView: UIView
286288
private let contentContainer: ContentContainer
287289

290+
private var innerBackgroundView: UIView?
291+
288292
public var contentView: UIView {
289293
if let nativeView = self.nativeView {
290294
return nativeView.contentView
@@ -404,6 +408,30 @@ public class GlassBackgroundView: UIView {
404408
if self.params != params {
405409
self.params = params
406410

411+
if let innerColor = params.tintColor.innerColor {
412+
let innerBackgroundFrame = CGRect(origin: CGPoint(), size: size).insetBy(dx: 3.0, dy: 3.0)
413+
let innerBackgroundRadius = min(innerBackgroundFrame.width, innerBackgroundFrame.height) * 0.5
414+
415+
let innerBackgroundView: UIView
416+
if let current = self.innerBackgroundView {
417+
innerBackgroundView = current
418+
} else {
419+
innerBackgroundView = UIView()
420+
self.innerBackgroundView = innerBackgroundView
421+
self.contentView.insertSubview(innerBackgroundView, at: 0)
422+
423+
innerBackgroundView.frame = innerBackgroundFrame
424+
innerBackgroundView.layer.cornerRadius = innerBackgroundRadius
425+
}
426+
427+
innerBackgroundView.backgroundColor = innerColor
428+
transition.setFrame(view: innerBackgroundView, frame: innerBackgroundFrame)
429+
transition.setCornerRadius(layer: innerBackgroundView.layer, cornerRadius: innerBackgroundRadius)
430+
} else if let innerBackgroundView = self.innerBackgroundView {
431+
self.innerBackgroundView = nil
432+
innerBackgroundView.removeFromSuperview()
433+
}
434+
407435
if let shadowView = self.shadowView {
408436
let shadowInnerInset: CGFloat = 0.5
409437
shadowView.image = generateImage(CGSize(width: shadowInset * 2.0 + cornerRadius * 2.0, height: shadowInset * 2.0 + cornerRadius * 2.0), rotatedContext: { size, context in

0 commit comments

Comments
 (0)