Skip to content

Commit 6e48514

Browse files
committed
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
2 parents ecd495e + 8c3bfe9 commit 6e48514

File tree

9 files changed

+87
-68
lines changed

9 files changed

+87
-68
lines changed

submodules/DebugSettingsUI/Sources/DebugController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
9595
case knockoutWallpaper(PresentationTheme, Bool)
9696
case experimentalCompatibility(Bool)
9797
case enableDebugDataDisplay(Bool)
98-
case rippleEffect(Bool)
98+
case fakeGlass(Bool)
9999
case browserExperiment(Bool)
100100
case allForumsHaveTabs(Bool)
101101
case enableReactionOverrides(Bool)
@@ -135,7 +135,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
135135
return DebugControllerSection.web.rawValue
136136
case .keepChatNavigationStack, .skipReadHistory, .alwaysDisplayTyping, .debugRatingLayout, .crashOnSlowQueries, .crashOnMemoryPressure:
137137
return DebugControllerSection.experiments.rawValue
138-
case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .compressedEmojiCache, .storiesJpegExperiment, .checkSerializedData, .enableQuickReactionSwitch, .experimentalCompatibility, .enableDebugDataDisplay, .rippleEffect, .browserExperiment, .allForumsHaveTabs, .enableReactionOverrides, .restorePurchases, .disableReloginTokens, .liveStreamV2, .experimentalCallMute, .playerV2, .devRequests, .enableUpdates, .fakeAds, .enableLocalTranslation:
138+
case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .compressedEmojiCache, .storiesJpegExperiment, .checkSerializedData, .enableQuickReactionSwitch, .experimentalCompatibility, .enableDebugDataDisplay, .fakeGlass, .browserExperiment, .allForumsHaveTabs, .enableReactionOverrides, .restorePurchases, .disableReloginTokens, .liveStreamV2, .experimentalCallMute, .playerV2, .devRequests, .enableUpdates, .fakeAds, .enableLocalTranslation:
139139
return DebugControllerSection.experiments.rawValue
140140
case .logTranslationRecognition, .resetTranslationStates:
141141
return DebugControllerSection.translation.rawValue
@@ -226,7 +226,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
226226
return 37
227227
case .enableDebugDataDisplay:
228228
return 38
229-
case .rippleEffect:
229+
case .fakeGlass:
230230
return 39
231231
case .browserExperiment:
232232
return 40
@@ -1258,12 +1258,12 @@ private enum DebugControllerEntry: ItemListNodeEntry {
12581258
})
12591259
}).start()
12601260
})
1261-
case let .rippleEffect(value):
1262-
return ItemListSwitchItem(presentationData: presentationData, title: "Ripple", value: value, sectionId: self.section, style: .blocks, updated: { value in
1261+
case let .fakeGlass(value):
1262+
return ItemListSwitchItem(presentationData: presentationData, title: "Fake glass", value: value, sectionId: self.section, style: .blocks, updated: { value in
12631263
let _ = arguments.sharedContext.accountManager.transaction ({ transaction in
12641264
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in
12651265
var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings
1266-
settings.rippleEffect = value
1266+
settings.fakeGlass = value
12671267
return PreferencesEntry(settings)
12681268
})
12691269
}).start()
@@ -1543,7 +1543,7 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
15431543
entries.append(.knockoutWallpaper(presentationData.theme, experimentalSettings.knockoutWallpaper))
15441544
entries.append(.experimentalCompatibility(experimentalSettings.experimentalCompatibility))
15451545
entries.append(.enableDebugDataDisplay(experimentalSettings.enableDebugDataDisplay))
1546-
entries.append(.rippleEffect(experimentalSettings.rippleEffect))
1546+
entries.append(.fakeGlass(experimentalSettings.fakeGlass))
15471547
#if DEBUG
15481548
entries.append(.browserExperiment(experimentalSettings.browserExperiment))
15491549
#else

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
335335

336336
Queue.mainQueue().after(0.4, {
337337
let absoluteFrame = self.giftButton.convert(self.giftButton.bounds, to: parentController.view)
338-
let location = CGRect(origin: CGPoint(x: absoluteFrame.midX, y: absoluteFrame.minY + 11.0), size: CGSize())
338+
let location = CGRect(origin: CGPoint(x: absoluteFrame.midX, y: absoluteFrame.minY), size: CGSize())
339339

340340
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
341341
let text: String = presentationData.strings.Chat_SendGiftTooltip
@@ -362,7 +362,7 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
362362

363363
Queue.mainQueue().after(0.4, {
364364
let absoluteFrame = self.suggestedPostButton.convert(self.suggestedPostButton.bounds, to: parentController.view)
365-
let location = CGRect(origin: CGPoint(x: absoluteFrame.midX, y: absoluteFrame.minY + 11.0), size: CGSize())
365+
let location = CGRect(origin: CGPoint(x: absoluteFrame.midX, y: absoluteFrame.minY), size: CGSize())
366366

367367
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
368368
let _ = presentationData

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,9 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
19941994
if interfaceState.interfaceState.mediaDraftState != nil {
19951995
audioRecordingItemsAlpha = 0.0
19961996
}
1997+
1998+
transition.updateAlpha(layer: self.actionButtons.micButtonBackgroundView.layer, alpha: mediaRecordingState != nil ? 0.01 : 1.0)
1999+
19972000
if let mediaRecordingState {
19982001
audioRecordingItemsAlpha = 0.0
19992002

@@ -2755,7 +2758,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
27552758
viewOnceIsVisible = isLocked
27562759
}
27572760
}
2758-
if interfaceState.interfaceState.mediaDraftState != nil {
2761+
if let mediaDraftState = interfaceState.interfaceState.mediaDraftState, case .audio = mediaDraftState.contentType {
27592762
recordMoreIsVisible = true
27602763
}
27612764

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,10 @@ public class GlassBackgroundView: UIView {
294294

295295
private var params: Params?
296296

297+
public static var useCustomGlassImpl: Bool = false
298+
297299
public override init(frame: CGRect) {
298-
if #available(iOS 26.0, *) {
300+
if #available(iOS 26.0, *), !GlassBackgroundView.useCustomGlassImpl {
299301
self.backgroundNode = nil
300302

301303
let glassEffect = UIGlassEffect(style: .regular)
@@ -407,7 +409,7 @@ public class GlassBackgroundView: UIView {
407409
context.clear(CGRect(origin: CGPoint(), size: size))
408410

409411
context.setFillColor(UIColor.black.cgColor)
410-
context.setShadow(offset: CGSize(width: 0.0, height: 1.0), blur: 40.0, color: UIColor(white: 0.0, alpha: 0.065).cgColor)
412+
context.setShadow(offset: CGSize(width: 0.0, height: 1.0), blur: 40.0, color: UIColor(white: 0.0, alpha: 0.04).cgColor)
411413
context.fillEllipse(in: CGRect(origin: CGPoint(x: shadowInset + shadowInnerInset, y: shadowInset + shadowInnerInset), size: CGSize(width: size.width - shadowInset * 2.0 - shadowInnerInset * 2.0, height: size.height - shadowInset * 2.0 - shadowInnerInset * 2.0)))
412414

413415
context.setFillColor(UIColor.clear.cgColor)
@@ -684,7 +686,8 @@ public extension GlassBackgroundView {
684686
}
685687
}
686688

687-
addShadow(context, true, CGPoint(), 6.0, 0.0, UIColor(white: 0.0, alpha: 0.08), .normal)
689+
addShadow(context, true, CGPoint(), 10.0, 0.0, UIColor(white: 0.0, alpha: 0.06), .normal)
690+
addShadow(context, true, CGPoint(), 20.0, 0.0, UIColor(white: 0.0, alpha: 0.06), .normal)
688691

689692
let innerImage = UIGraphicsImageRenderer(size: size).image { ctx in
690693
let context = ctx.cgContext
@@ -710,7 +713,7 @@ public extension GlassBackgroundView {
710713
addShadow(context, false, CGPoint(x: 0.64, y: 0.64), 0.8, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .normal)
711714
}
712715
} else if b >= 0.2 {
713-
let edgeAlpha: CGFloat = max(0.2, min(isDark ? 0.7 : 0.8, a * a * a))
716+
let edgeAlpha: CGFloat = max(0.2, min(isDark ? 0.7 : 0.7, a * a * a))
714717

715718
addShadow(context, false, CGPoint(x: -0.64, y: -0.64), 0.5, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .plusLighter)
716719
addShadow(context, false, CGPoint(x: 0.64, y: 0.64), 0.5, 0.0, UIColor(white: 1.0, alpha: edgeAlpha), .plusLighter)

submodules/TelegramUI/Components/TabBarComponent/Sources/TabBarComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public final class TabBarComponent: Component {
8989
private weak var state: EmptyComponentState?
9090

9191
public override init(frame: CGRect) {
92-
self.backgroundView = GlassBackgroundView(frame: CGRect())
92+
self.backgroundView = GlassBackgroundView()
9393
self.selectionView = GlassBackgroundView.ContentImageView()
9494

9595
self.contextGestureContainerView = ContextControllerSourceView()

submodules/TelegramUI/Sources/ChatControllerNode.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,12 +3761,6 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
37613761
return
37623762
}
37633763

3764-
if let view, let location {
3765-
if context.sharedContext.immediateExperimentalUISettings.rippleEffect {
3766-
self.wrappingNode.triggerRipple(at: self.contentContainerNode.view.convert(location, from: view))
3767-
}
3768-
}
3769-
37703764
switch self.chatPresentationInterfaceState.inputMode {
37713765
case .none:
37723766
break

submodules/TelegramUI/Sources/ChatUnblockInputPanelNode.swift

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ import SwiftSignalKit
88
import TelegramPresentationData
99
import ChatPresentationInterfaceState
1010
import ChatInputPanelNode
11+
import GlassBackgroundComponent
12+
import ComponentFlow
13+
import ComponentDisplayAdapters
14+
import MultilineTextComponent
1115

1216
final class ChatUnblockInputPanelNode: ChatInputPanelNode {
13-
private let button: HighlightableButtonNode
14-
private let activityIndicator: UIActivityIndicatorView
17+
private let backgroundView: GlassBackgroundView
18+
private let title = ComponentView<Empty>()
19+
private let button: HighlightTrackingButton
1520

1621
private var statusDisposable: Disposable?
1722

@@ -23,15 +28,7 @@ final class ChatUnblockInputPanelNode: ChatInputPanelNode {
2328
if let startingBot = self.interfaceInteraction?.statuses?.unblockingPeer {
2429
self.statusDisposable = (startingBot |> deliverOnMainQueue).startStrict(next: { [weak self] value in
2530
if let strongSelf = self {
26-
if value != !strongSelf.activityIndicator.isHidden {
27-
if value {
28-
strongSelf.activityIndicator.isHidden = false
29-
strongSelf.activityIndicator.startAnimating()
30-
} else {
31-
strongSelf.activityIndicator.isHidden = true
32-
strongSelf.activityIndicator.stopAnimating()
33-
}
34-
}
31+
strongSelf.title.view?.alpha = value ? 0.7 : 1.0
3532
}
3633
})
3734
}
@@ -46,16 +43,29 @@ final class ChatUnblockInputPanelNode: ChatInputPanelNode {
4643
self.theme = theme
4744
self.strings = strings
4845

49-
self.button = HighlightableButtonNode()
50-
self.activityIndicator = UIActivityIndicatorView(style: .medium)
51-
self.activityIndicator.isHidden = true
46+
self.backgroundView = GlassBackgroundView()
47+
self.backgroundView.isUserInteractionEnabled = false
48+
49+
self.button = HighlightTrackingButton()
5250

5351
super.init()
5452

55-
self.addSubnode(self.button)
56-
self.view.addSubview(self.activityIndicator)
53+
self.view.addSubview(self.button)
54+
self.view.addSubview(self.backgroundView)
55+
56+
self.button.addTarget(self, action: #selector(self.buttonPressed), for: [.touchUpInside])
5757

58-
self.button.addTarget(self, action: #selector(self.buttonPressed), forControlEvents: [.touchUpInside])
58+
self.button.highligthedChanged = { [weak self] highlighted in
59+
guard let self else {
60+
return
61+
}
62+
if highlighted {
63+
self.backgroundView.contentView.alpha = 0.6
64+
} else {
65+
self.backgroundView.contentView.alpha = 1.0
66+
self.backgroundView.contentView.layer.animateAlpha(from: 0.6, to: 1.0, duration: 0.2)
67+
}
68+
}
5969
}
6070

6171
deinit {
@@ -66,14 +76,12 @@ final class ChatUnblockInputPanelNode: ChatInputPanelNode {
6676
if self.theme !== theme || self.strings !== strings {
6777
self.theme = theme
6878
self.strings = strings
69-
70-
self.button.setAttributedTitle(NSAttributedString(string: self.button.attributedTitle(for: [])?.string ?? "", font: Font.regular(17.0), textColor: theme.chat.inputPanel.panelControlAccentColor), for: [])
7179
}
7280
}
7381

7482
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
7583
if self.bounds.contains(point) {
76-
return self.button.view
84+
return self.button
7785
} else {
7886
return nil
7987
}
@@ -86,33 +94,39 @@ final class ChatUnblockInputPanelNode: ChatInputPanelNode {
8694
override 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 {
8795
if self.presentationInterfaceState != interfaceState {
8896
self.presentationInterfaceState = interfaceState
89-
90-
91-
let string: NSAttributedString
92-
if let user = interfaceState.renderedPeer?.peer as? TelegramUser, user.botInfo != nil {
93-
string = NSAttributedString(string: strings.Bot_Unblock, font: Font.regular(17.0), textColor: theme.chat.inputPanel.panelControlAccentColor)
94-
} else {
95-
string = NSAttributedString(string: strings.Conversation_Unblock, font: Font.regular(17.0), textColor: theme.chat.inputPanel.panelControlAccentColor)
96-
}
97-
let updated: Bool
98-
if let current = self.button.attributedTitle(for: []) {
99-
updated = !current.isEqual(to: string)
100-
} else {
101-
updated = true
102-
}
103-
if updated {
104-
self.button.setAttributedTitle(string, for: [])
105-
}
10697
}
10798

108-
let buttonSize = self.button.measure(CGSize(width: width - leftInset - rightInset - 80.0, height: 100.0))
99+
let string: String
100+
if let user = interfaceState.renderedPeer?.peer as? TelegramUser, user.botInfo != nil {
101+
string = strings.Bot_Unblock
102+
} else {
103+
string = strings.Conversation_Unblock
104+
}
105+
106+
let titleSize = self.title.update(
107+
transition: .immediate,
108+
component: AnyComponent(MultilineTextComponent(
109+
text: .plain(NSAttributedString(string: string, font: Font.regular(17.0), textColor: theme.chat.inputPanel.panelControlColor))
110+
)),
111+
environment: {},
112+
containerSize: CGSize(width: width - leftInset - rightInset, height: 100.0)
113+
)
109114

110115
let panelHeight = defaultHeight(metrics: metrics)
111116

112-
self.button.frame = CGRect(origin: CGPoint(x: leftInset + floor((width - leftInset - rightInset - buttonSize.width) / 2.0), y: floor((panelHeight - buttonSize.height) / 2.0)), size: buttonSize)
117+
let buttonSize = CGSize(width: titleSize.width + 16.0 * 2.0, height: 40.0)
118+
let buttonFrame = CGRect(origin: CGPoint(x: floor((width - buttonSize.width) / 2.0), y: floor((panelHeight - buttonSize.height) * 0.5)), size: buttonSize)
119+
transition.updateFrame(view: self.button, frame: buttonFrame)
120+
transition.updateFrame(view: self.backgroundView, frame: buttonFrame)
121+
self.backgroundView.update(size: buttonFrame.size, cornerRadius: buttonFrame.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: .init(kind: .panel, color: interfaceState.theme.chat.inputPanel.inputBackgroundColor.withMultipliedAlpha(0.7)), transition: ComponentTransition(transition))
113122

114-
let indicatorSize = self.activityIndicator.bounds.size
115-
self.activityIndicator.frame = CGRect(origin: CGPoint(x: width - rightInset - indicatorSize.width - 12.0, y: floor((panelHeight - indicatorSize.height) / 2.0)), size: indicatorSize)
123+
let titleFrame = CGRect(origin: CGPoint(x: floor((buttonFrame.width - titleSize.width) * 0.5), y: floor((buttonFrame.height - titleSize.height) * 0.5)), size: titleSize)
124+
if let titleView = self.title.view {
125+
if titleView.superview == nil {
126+
self.backgroundView.contentView.addSubview(titleView)
127+
}
128+
titleView.frame = titleFrame
129+
}
116130

117131
return panelHeight
118132
}

submodules/TelegramUI/Sources/SharedAccountContext.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ import SendInviteLinkScreen
8686
import PostSuggestionsSettingsScreen
8787
import ForumSettingsScreen
8888
import ForumCreateTopicScreen
89+
import GlassBackgroundComponent
8990

9091
private final class AccountUserInterfaceInUseContext {
9192
let subscribers = Bag<(Bool) -> Void>()
@@ -477,12 +478,16 @@ public final class SharedAccountContextImpl: SharedAccountContext {
477478

478479
let immediateExperimentalUISettingsValue = self.immediateExperimentalUISettingsValue
479480
let _ = immediateExperimentalUISettingsValue.swap(initialPresentationDataAndSettings.experimentalUISettings)
481+
482+
GlassBackgroundView.useCustomGlassImpl = immediateExperimentalUISettingsValue.with({ $0.fakeGlass })
483+
480484
self.experimentalUISettingsDisposable = (self.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.experimentalUISettings])
481485
|> deliverOnMainQueue).start(next: { sharedData in
482486
if let settings = sharedData.entries[ApplicationSpecificSharedDataKeys.experimentalUISettings]?.get(ExperimentalUISettings.self) {
483487
let _ = immediateExperimentalUISettingsValue.swap(settings)
484488

485489
flatBuffers_checkedGet = settings.checkSerializedData
490+
GlassBackgroundView.useCustomGlassImpl = settings.fakeGlass
486491
}
487492
})
488493

0 commit comments

Comments
 (0)