Skip to content

Commit 7621e2f

Browse files
committed
Various fixes
1 parent 13a2fdf commit 7621e2f

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

submodules/Components/SheetComponent/Sources/SheetComponent.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,11 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
305305

306306
let transition = ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring)
307307
let targetPosition = self.scrollView.center
308-
self.scrollView.center = targetPosition.offsetBy(dx: 0.0, dy: self.scrollView.contentSize.height)
308+
var offset: CGFloat = self.scrollView.contentSize.height
309+
if self.isCentered {
310+
offset = self.frame.height + self.scrollView.frame.height * 0.5
311+
}
312+
self.scrollView.center = targetPosition.offsetBy(dx: 0.0, dy: offset)
309313
transition.animateView(allowUserInteraction: true, {
310314
self.scrollView.center = targetPosition
311315
})
@@ -338,18 +342,27 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
338342
let contentOffset = (self.scrollView.contentOffset.y + self.scrollView.contentInset.top - self.scrollView.contentSize.height) * -1.0
339343
let dismissalOffset = self.scrollView.contentSize.height + abs(contentView.frame.minY)
340344
let delta = dismissalOffset - contentOffset
345+
var targetPosition = self.scrollView.center.y + delta
346+
if self.isCentered {
347+
targetPosition = self.frame.height + self.scrollView.frame.height * 0.5
348+
}
341349

342-
transition.updatePosition(layer: self.scrollView.layer, position: CGPoint(x: self.scrollView.center.x, y: self.scrollView.center.y + delta), completion: { _ in
350+
transition.updatePosition(layer: self.scrollView.layer, position: CGPoint(x: self.scrollView.center.x, y: targetPosition), completion: { _ in
343351
completion()
344352
})
345353
} else {
346-
self.scrollView.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: self.scrollView.contentSize.height + abs(contentView.frame.minY)), duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false, additive: true, completion: { _ in
354+
var targetOffset: CGFloat = self.scrollView.contentSize.height + abs(contentView.frame.minY)
355+
if self.isCentered {
356+
targetOffset = self.frame.height + self.scrollView.frame.height * 0.5
357+
}
358+
self.scrollView.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: targetOffset), duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false, additive: true, completion: { _ in
347359
completion()
348360
})
349361
}
350362
}
351363

352364
private var currentHasInputHeight = false
365+
private var isCentered = false
353366
private var currentAvailableSize: CGSize?
354367
func update(component: SheetComponent<ChildEnvironmentType>, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
355368
let previousHasInputHeight = self.currentHasInputHeight
@@ -364,6 +377,7 @@ public final class SheetComponent<ChildEnvironmentType: Sendable & Equatable>: C
364377
}
365378

366379
self.component = component
380+
self.isCentered = sheetEnvironment.isCentered
367381
self.currentHasInputHeight = sheetEnvironment.hasInputHeight
368382

369383
if self.isAnimatingOut {

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionViewScreen.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,9 @@ private final class GiftAuctionViewSheetContent: CombinedComponent {
738738
} else {
739739
return false
740740
}
741-
}), case let .backdrop(_, _, innerColor, outerColor, _, _, _) = backdropAttribute {
742-
let topColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultiplied(hue: 1.01, saturation: 1.22, brightness: 1.04)
743-
let bottomColor = UIColor(rgb: UInt32(bitPattern: outerColor)).withMultiplied(hue: 0.97, saturation: 1.45, brightness: 0.89)
744-
buttonColor = topColor.mixedWith(bottomColor, alpha: 0.8).withMultipliedBrightnessBy(1.25)
745-
746-
secondaryTextColor = topColor.withMultiplied(hue: 1.0, saturation: 1.02, brightness: 1.25).mixedWith(UIColor.white, alpha: 0.5)
741+
}), case let .backdrop(_, _, innerColor, _, _, _, _) = backdropAttribute {
742+
buttonColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultipliedBrightnessBy(1.05)
743+
secondaryTextColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultiplied(hue: 1.0, saturation: 1.02, brightness: 1.25).mixedWith(UIColor.white, alpha: 0.3)
747744
}
748745

749746
let headerHeight: CGFloat = 264.0

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionWearPreviewScreen.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,19 +293,16 @@ private final class GiftAuctionWearPreviewSheetContent: CombinedComponent {
293293
} else {
294294
return false
295295
}
296-
}), case let .backdrop(_, _, innerColor, outerColor, _, _, _) = backdropAttribute {
297-
let topColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultiplied(hue: 1.01, saturation: 1.22, brightness: 1.04)
298-
let bottomColor = UIColor(rgb: UInt32(bitPattern: outerColor)).withMultiplied(hue: 0.97, saturation: 1.45, brightness: 0.89)
299-
buttonColor = topColor.mixedWith(bottomColor, alpha: 0.8)
300-
301-
secondaryTextColor = topColor.withMultiplied(hue: 1.0, saturation: 1.02, brightness: 1.25).mixedWith(UIColor.white, alpha: 0.5)
296+
}), case let .backdrop(_, _, innerColor, _, _, _, _) = backdropAttribute {
297+
buttonColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultipliedBrightnessBy(1.05)
298+
secondaryTextColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultiplied(hue: 1.0, saturation: 1.02, brightness: 1.25).mixedWith(UIColor.white, alpha: 0.3)
302299
}
303300

304301
let closeButton = closeButton.update(
305302
component: GlassBarButtonComponent(
306303
size: CGSize(width: 40.0, height: 40.0),
307-
backgroundColor: buttonColor.withMultipliedBrightnessBy(1.2),
308-
isDark: theme.overallDarkAppearance,
304+
backgroundColor: buttonColor,
305+
isDark: false,
309306
state: .tintedGlass,
310307
component: AnyComponentWithIdentity(id: "close", component: AnyComponent(
311308
BundleIconComponent(

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftUpgradePreviewScreen.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,16 @@ private final class GiftUpgradePreviewScreenComponent: Component {
680680
} else {
681681
return false
682682
}
683-
}), case let .backdrop(_, _, innerColor, _, _, _, _) = backdropAttribute {
683+
}), case let .backdrop(_, _, innerColor, outerColor, _, _, _) = backdropAttribute {
684684
buttonColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultipliedBrightnessBy(1.05)
685685

686-
badgeColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultipliedBrightnessBy(1.14)
686+
badgeColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultipliedBrightnessBy(1.05)
687+
let outer = UIColor(rgb: UInt32(bitPattern: outerColor))
688+
if outer.lightness < 0.06 {
689+
badgeColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultipliedBrightnessBy(1.45)
690+
} else if outer.lightness < 0.295 {
691+
badgeColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultipliedBrightnessBy(1.19)
692+
}
687693
secondaryTextColor = UIColor(rgb: UInt32(bitPattern: innerColor)).withMultiplied(hue: 1.0, saturation: 1.02, brightness: 1.25).mixedWith(UIColor.white, alpha: 0.3)
688694
}
689695

0 commit comments

Comments
 (0)