Skip to content

Commit da23f77

Browse files
committed
Various fixes
1 parent abb6abd commit da23f77

File tree

4 files changed

+51
-38
lines changed

4 files changed

+51
-38
lines changed

submodules/AttachmentUI/Sources/AttachmentPanel.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,8 +2411,24 @@ final class AttachmentPanel: ASDisplayNode, ASScrollViewDelegate, ASGestureRecog
24112411
lensSelection.x = max(0.0, min(lensSelection.x, panelSize.width - lensSelection.width))
24122412
}
24132413

2414+
var isLifted = self.selectionGestureState?.isLifted == true || self.lensIsLifted
2415+
if let widthClass = self.validLayout?.metrics.widthClass, case .regular = widthClass {
2416+
isLifted = false
2417+
}
2418+
24142419
let inset: CGFloat = 3.0
2415-
liquidLensView.update(size: CGSize(width: panelSize.width - inset * 2.0, height: panelSize.height - inset * 2.0), cornerRadius: 28.0, selectionOrigin: CGPoint(x: lensSelection.x, y: 0.0), selectionSize: CGSize(width: lensSelection.width, height: panelSize.height), inset: 0.0, isDark: self.presentationData.theme.overallDarkAppearance, isLifted: self.selectionGestureState?.isLifted == true || self.lensIsLifted, isCollapsed: self.isSelecting || self.buttons.count < 2, transition: transition)
2420+
liquidLensView.update(size: CGSize(width: panelSize.width - inset * 2.0, height: panelSize.height - inset * 2.0), cornerRadius: 28.0, selectionOrigin: CGPoint(x: lensSelection.x, y: 0.0), selectionSize: CGSize(width: lensSelection.width, height: panelSize.height), inset: 0.0, isDark: self.presentationData.theme.overallDarkAppearance, isLifted: isLifted, isCollapsed: self.isSelecting || self.buttons.count < 2, transition: transition)
2421+
}
2422+
2423+
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
2424+
if gestureRecognizer == self.tabSelectionRecognizer {
2425+
return true
2426+
}
2427+
return super.gestureRecognizerShouldBegin(gestureRecognizer)
2428+
}
2429+
2430+
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
2431+
return true
24162432
}
24172433

24182434
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {

submodules/ChatListUI/Sources/ChatListController.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,15 +2874,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
28742874
self.push(controller)
28752875
return
28762876
}
2877-
2878-
#if DEBUG
2879-
if "".isEmpty {
2880-
(self.navigationController as? NavigationController)?.pushViewController(oldChannelsController(context: self.context, intent: .join, completed: { value in
2881-
}))
2882-
return
2883-
}
2884-
#endif
2885-
2877+
28862878
var reachedCountLimit = false
28872879
var premiumNeeded = false
28882880
var hasActiveCall = false

submodules/TelegramUI/Components/CameraScreen/Sources/ModeComponent.swift

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ final class ModeComponent: Component {
106106
private var backgroundView = UIView()
107107
private var backgroundContainer = GlassBackgroundContainerView()
108108

109-
private let liquidLensView: LiquidLensView
109+
private var liquidLensView: LiquidLensView?
110110

111111
private var itemViews: [AnyHashable: ItemView] = [:]
112112
private var selectedItemViews: [AnyHashable: ItemView] = [:]
@@ -125,8 +125,6 @@ final class ModeComponent: Component {
125125
}
126126

127127
init() {
128-
self.liquidLensView = LiquidLensView(kind: .externalContainer)
129-
130128
super.init(frame: CGRect())
131129

132130
self.backgroundView.backgroundColor = UIColor(rgb: 0xffffff, alpha: 0.11)
@@ -136,12 +134,6 @@ final class ModeComponent: Component {
136134

137135
self.addSubview(self.backgroundView)
138136
self.backgroundView.addSubview(self.backgroundContainer)
139-
140-
self.backgroundContainer.contentView.addSubview(self.liquidLensView)
141-
142-
let tabSelectionRecognizer = TabSelectionRecognizer(target: self, action: #selector(self.onTabSelectionGesture(_:)))
143-
self.tabSelectionRecognizer = tabSelectionRecognizer
144-
self.liquidLensView.addGestureRecognizer(tabSelectionRecognizer)
145137
}
146138

147139
required init?(coder aDecoder: NSCoder) {
@@ -187,10 +179,10 @@ final class ModeComponent: Component {
187179
}
188180

189181
@objc private func onTabSelectionGesture(_ recognizer: TabSelectionRecognizer) {
190-
guard let component = self.component else {
182+
guard let component = self.component, let liquidLensView = self.liquidLensView else {
191183
return
192184
}
193-
let location = recognizer.location(in: self.liquidLensView.contentView)
185+
let location = recognizer.location(in: liquidLensView.contentView)
194186
switch recognizer.state {
195187
case .began:
196188
if let itemId = self.item(at: location), let itemView = self.itemViews[itemId] {
@@ -229,14 +221,26 @@ final class ModeComponent: Component {
229221

230222
let isTablet = component.isTablet
231223

224+
let liquidLensView: LiquidLensView
225+
if let current = self.liquidLensView {
226+
liquidLensView = current
227+
} else {
228+
liquidLensView = LiquidLensView(kind: isTablet ? .noContainer : .externalContainer)
229+
self.liquidLensView = liquidLensView
230+
self.backgroundContainer.contentView.addSubview(liquidLensView)
231+
232+
let tabSelectionRecognizer = TabSelectionRecognizer(target: self, action: #selector(self.onTabSelectionGesture(_:)))
233+
self.tabSelectionRecognizer = tabSelectionRecognizer
234+
liquidLensView.addGestureRecognizer(tabSelectionRecognizer)
235+
}
236+
232237
self.backgroundView.backgroundColor = component.isTablet ? .clear : UIColor(rgb: 0xffffff, alpha: 0.11)
233238

234239
let inset: CGFloat = 23.0
235240
let spacing: CGFloat = isTablet ? 9.0 : 40.0
236241

237242
var i = 0
238243
var itemFrame = CGRect(origin: isTablet ? .zero : CGPoint(x: inset, y: 0.0), size: buttonSize)
239-
var selectedCenter = itemFrame.minX
240244
var selectedFrame = itemFrame
241245

242246
var validKeys: Set<AnyHashable> = Set()
@@ -253,12 +257,12 @@ final class ModeComponent: Component {
253257
itemView = ItemView()
254258
itemView.isUserInteractionEnabled = false
255259
self.itemViews[id] = itemView
256-
self.liquidLensView.contentView.addSubview(itemView)
260+
liquidLensView.contentView.addSubview(itemView)
257261

258262
selectedItemView = ItemView()
259263
selectedItemView.isUserInteractionEnabled = false
260264
self.selectedItemViews[id] = selectedItemView
261-
self.liquidLensView.selectedContentView.addSubview(selectedItemView)
265+
liquidLensView.selectedContentView.addSubview(selectedItemView)
262266
}
263267

264268
let itemSize = itemView.update(isTablet: component.isTablet, value: mode.title(strings: component.strings), selected: false, tintColor: component.tintColor)
@@ -276,16 +280,10 @@ final class ModeComponent: Component {
276280
if isTablet {
277281
itemView.center = CGPoint(x: availableSize.width / 2.0, y: itemFrame.midY)
278282
selectedItemView.center = itemView.center
279-
if mode == component.currentMode {
280-
selectedCenter = itemFrame.midY
281-
}
282283
itemFrame = itemFrame.offsetBy(dx: 0.0, dy: tabletButtonSize.height + spacing)
283284
} else {
284285
itemView.center = CGPoint(x: itemFrame.midX, y: itemFrame.midY)
285286
selectedItemView.center = itemView.center
286-
if mode == component.currentMode {
287-
selectedCenter = itemFrame.midX
288-
}
289287
itemFrame = itemFrame.offsetBy(dx: itemFrame.width + spacing, dy: 0.0)
290288
}
291289
i += 1
@@ -307,10 +305,12 @@ final class ModeComponent: Component {
307305

308306
let totalSize: CGSize
309307
let size: CGSize
308+
var cornerRadius: CGFloat?
310309
if isTablet {
311310
totalSize = CGSize(width: availableSize.width, height: tabletButtonSize.height * CGFloat(component.availableModes.count) + spacing * CGFloat(component.availableModes.count - 1))
312311
size = CGSize(width: availableSize.width, height: availableSize.height)
313-
transition.setFrame(view: self.backgroundView, frame: CGRect(origin: CGPoint(x: 0.0, y: availableSize.height / 2.0 - selectedCenter), size: totalSize))
312+
transition.setFrame(view: self.backgroundView, frame: CGRect(origin: .zero, size: totalSize))
313+
cornerRadius = 20.0
314314
} else {
315315
size = CGSize(width: availableSize.width, height: buttonSize.height)
316316
totalSize = CGSize(width: itemFrame.minX - spacing + inset, height: buttonSize.height)
@@ -321,15 +321,19 @@ final class ModeComponent: Component {
321321
transition.setFrame(view: self.backgroundContainer, frame: containerFrame)
322322

323323
let selectionFrame = selectedFrame.insetBy(dx: -23.0, dy: 3.0)
324-
let lensSelection: (x: CGFloat, width: CGFloat)
325-
if let selectionGestureState = self.selectionGestureState {
326-
lensSelection = (selectionGestureState.currentX, selectionFrame.width)
324+
var lensSelection: (origin: CGPoint, size: CGSize)
325+
if let selectionGestureState = self.selectionGestureState, !isTablet {
326+
lensSelection = (CGPoint(x: selectionGestureState.currentX, y: 0.0), selectionFrame.size)
327327
} else {
328-
lensSelection = (selectionFrame.minX, selectionFrame.width)
328+
lensSelection = (CGPoint(x: selectionFrame.minX, y: selectionFrame.minY), selectionFrame.size)
329+
}
330+
331+
if isTablet {
332+
lensSelection.size.width = size.width
329333
}
330334

331-
transition.setFrame(view: self.liquidLensView, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: containerFrame.size))
332-
self.liquidLensView.update(size: containerFrame.size, selectionOrigin: CGPoint(x: max(0.0, min(lensSelection.x, containerFrame.size.width - lensSelection.width)), y: 0.0), selectionSize: CGSize(width: lensSelection.width, height: selectionFrame.height), inset: 3.0, isDark: true, isLifted: self.selectionGestureState != nil, isCollapsed: false, transition: transition)
335+
transition.setFrame(view: liquidLensView, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: containerFrame.size))
336+
liquidLensView.update(size: containerFrame.size, cornerRadius: cornerRadius, selectionOrigin: CGPoint(x: max(0.0, min(lensSelection.origin.x, containerFrame.size.width - lensSelection.size.width)), y: lensSelection.origin.y), selectionSize: lensSelection.size, inset: 3.0, isDark: true, isLifted: self.selectionGestureState != nil && !isTablet, isCollapsed: false, transition: transition)
333337
self.backgroundContainer.update(size: containerFrame.size, isDark: true, transition: .immediate)
334338

335339
return size

submodules/TelegramUI/Components/LiquidLens/Sources/LiquidLensView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ public final class LiquidLensView: UIView {
449449
transition.setCornerRadius(layer: self.liftedContainerView.layer, cornerRadius: params.cornerRadius ?? (params.size.height * 0.5))
450450
}
451451

452-
let baseLensFrame = CGRect(origin: CGPoint(x: params.selectionOrigin.x, y: 0.0), size: CGSize(width: params.selectionSize.width, height: params.size.height))
452+
453+
let baseLensFrame = CGRect(origin: params.selectionOrigin, size: params.selectionSize)
453454
self.updateLens(params: LensParams(baseFrame: baseLensFrame, inset: params.inset, liftedInset: params.liftedInset, isLifted: params.isLifted), transition: transition)
454455

455456
if let legacyContentMaskView = self.legacyContentMaskView {

0 commit comments

Comments
 (0)