@@ -78,7 +78,8 @@ private final class GiftUpgradePreviewScreenComponent: Component {
7878 private let containerView : UIView
7979 private let backgroundLayer : SimpleLayer
8080 private let navigationBarContainer : SparseContainerView
81- private let glassContainerView : GlassBackgroundContainerView
81+ private let closeGlassContainerView : GlassBackgroundContainerView
82+ private let playbackGlassContainerView : GlassBackgroundContainerView
8283 private let scrollView : ScrollView
8384 private let scrollContentClippingView : SparseContainerView
8485 private let scrollContentView : UIView
@@ -151,7 +152,8 @@ private final class GiftUpgradePreviewScreenComponent: Component {
151152 self . topEdgeEffectView = EdgeEffectView ( )
152153 self . topEdgeEffectView. alpha = 0.0
153154
154- self . glassContainerView = GlassBackgroundContainerView ( )
155+ self . closeGlassContainerView = GlassBackgroundContainerView ( )
156+ self . playbackGlassContainerView = GlassBackgroundContainerView ( )
155157
156158 self . scrollView = ScrollView ( )
157159
@@ -372,10 +374,18 @@ private final class GiftUpgradePreviewScreenComponent: Component {
372374
373375 let visibleBounds = self . scrollView. bounds. insetBy ( dx: 0.0 , dy: - 10.0 )
374376
375- let sideInset : CGFloat = 16.0 + environment. safeInsets. left
377+ let fillingSize : CGFloat
378+ if case . regular = environment. metrics. widthClass {
379+ fillingSize = min ( itemLayout. containerSize. width, 414.0 ) - environment. safeInsets. left * 2.0
380+ } else {
381+ fillingSize = min ( itemLayout. containerSize. width, environment. deviceMetrics. screenSize. width) - environment. safeInsets. left * 2.0
382+ }
383+
384+ let rawSideInset : CGFloat = floor ( ( itemLayout. containerSize. width - fillingSize) * 0.5 )
385+ let sideInset : CGFloat = rawSideInset + 16.0
376386
377387 let optionSpacing : CGFloat = 10.0
378- let optionWidth = ( itemLayout . containerSize . width - sideInset * 2.0 - optionSpacing * 2.0 ) / 3.0
388+ let optionWidth = ( fillingSize - 16.0 * 2.0 - optionSpacing * 2.0 ) / 3.0
379389 let optionSize = CGSize ( width: optionWidth, height: 126.0 )
380390
381391 let topInset : CGFloat = 393.0
@@ -520,7 +530,7 @@ private final class GiftUpgradePreviewScreenComponent: Component {
520530 }
521531 }
522532 itemFrame. origin. x += itemFrame. width + optionSpacing
523- if itemFrame. maxX > itemLayout . containerSize . width {
533+ if itemFrame. maxX > rawSideInset + fillingSize {
524534 itemFrame. origin. x = sideInset
525535 itemFrame. origin. y += optionSize. height + optionSpacing
526536 }
@@ -634,6 +644,7 @@ private final class GiftUpgradePreviewScreenComponent: Component {
634644
635645 var buttonColor : UIColor = . white. withAlphaComponent ( 0.1 )
636646 var secondaryTextColor : UIColor = . white. withAlphaComponent ( 0.4 )
647+ var badgeColor : UIColor = . white. withAlphaComponent ( 0.4 )
637648
638649 var attributes : [ StarGift . UniqueGift . Attribute ] = [ ]
639650 if !self . previewModels. isEmpty {
@@ -669,12 +680,11 @@ private final class GiftUpgradePreviewScreenComponent: Component {
669680 } else {
670681 return false
671682 }
672- } ) , case let . backdrop( _, _, innerColor, outerColor, _, _, _) = backdropAttribute {
673- let topColor = UIColor ( rgb: UInt32 ( bitPattern: innerColor) ) . withMultiplied ( hue: 1.01 , saturation: 1.22 , brightness: 1.04 )
674- let bottomColor = UIColor ( rgb: UInt32 ( bitPattern: outerColor) ) . withMultiplied ( hue: 0.97 , saturation: 1.45 , brightness: 0.89 )
675- buttonColor = topColor. mixedWith ( bottomColor, alpha: 0.8 ) . withMultipliedBrightnessBy ( 1.25 )
683+ } ) , case let . backdrop( _, _, innerColor, _, _, _, _) = backdropAttribute {
684+ buttonColor = UIColor ( rgb: UInt32 ( bitPattern: innerColor) ) . withMultipliedBrightnessBy ( 1.05 )
676685
677- secondaryTextColor = topColor. withMultiplied ( hue: 1.0 , saturation: 1.02 , brightness: 1.25 ) . mixedWith ( UIColor . white, alpha: 0.3 )
686+ badgeColor = UIColor ( rgb: UInt32 ( bitPattern: innerColor) ) . withMultipliedBrightnessBy ( 1.14 )
687+ secondaryTextColor = UIColor ( rgb: UInt32 ( bitPattern: innerColor) ) . withMultiplied ( hue: 1.0 , saturation: 1.02 , brightness: 1.25 ) . mixedWith ( UIColor . white, alpha: 0.3 )
678688 }
679689
680690 var contentHeight : CGFloat = 0.0
@@ -695,9 +705,9 @@ private final class GiftUpgradePreviewScreenComponent: Component {
695705 }
696706 ) ) ,
697707 environment: { } ,
698- containerSize: CGSize ( width: availableSize . width , height: 300.0 ) ,
708+ containerSize: CGSize ( width: fillingSize , height: 300.0 ) ,
699709 )
700- let headerFrame = CGRect ( origin: CGPoint ( x: floor ( ( fillingSize - headerSize. width) * 0.5 ) , y: 0.0 ) , size: headerSize)
710+ let headerFrame = CGRect ( origin: CGPoint ( x: floor ( ( availableSize . width - headerSize. width) * 0.5 ) , y: 0.0 ) , size: headerSize)
701711 if let headerView = self . header. view {
702712 if headerView. superview == nil {
703713 headerView. isUserInteractionEnabled = false
@@ -724,7 +734,7 @@ private final class GiftUpgradePreviewScreenComponent: Component {
724734 environment: { } ,
725735 containerSize: CGSize ( width: availableSize. width - sideInset * 2.0 , height: 100.0 )
726736 )
727- let titleFrame = CGRect ( origin: CGPoint ( x: floor ( ( fillingSize - titleSize. width) * 0.5 ) , y: contentHeight - 124.0 ) , size: titleSize)
737+ let titleFrame = CGRect ( origin: CGPoint ( x: floor ( ( availableSize . width - titleSize. width) * 0.5 ) , y: contentHeight - 124.0 ) , size: titleSize)
728738 if let titleView = self . title. view {
729739 if titleView. superview == nil {
730740 self . navigationBarContainer. addSubview ( titleView)
@@ -755,17 +765,16 @@ private final class GiftUpgradePreviewScreenComponent: Component {
755765 environment: { } ,
756766 containerSize: CGSize ( width: availableSize. width - sideInset * 2.0 , height: 100.0 )
757767 )
758- let subtitleFrame = CGRect ( origin: CGPoint ( x: floor ( ( fillingSize - subtitleSize. width) * 0.5 ) , y: contentHeight - 97.0 ) , size: subtitleSize)
768+ let subtitleFrame = CGRect ( origin: CGPoint ( x: floor ( ( availableSize . width - subtitleSize. width) * 0.5 ) , y: contentHeight - 97.0 ) , size: subtitleSize)
759769 if let subtitleView = self . subtitle. view {
760770 if subtitleView. superview == nil {
761771 self . navigationBarContainer. addSubview ( subtitleView)
762772 }
763773 transition. setFrame ( view: subtitleView, frame: subtitleFrame)
764774 }
765775
766-
767776 let attributeSpacing : CGFloat = 10.0
768- let attributeWidth : CGFloat = floor ( ( fillingSize - sideInset * 2.0 - attributeSpacing * CGFloat( attributes. count - 1 ) ) / CGFloat( attributes. count) )
777+ let attributeWidth : CGFloat = floor ( ( fillingSize - attributeSpacing * CGFloat( attributes. count - 1 ) ) / CGFloat( attributes. count) )
769778 let attributeHeight : CGFloat = 45.0
770779
771780 for i in 0 ..< attributes. count {
@@ -785,8 +794,9 @@ private final class GiftUpgradePreviewScreenComponent: Component {
785794 transition: transition,
786795 component: AnyComponent ( AttributeInfoComponent (
787796 strings: environment. strings,
788- backgroundColor: buttonColor,
789- secondaryTextColor: secondaryTextColor,
797+ backgroundColor: UIColor . white. withAlphaComponent ( 0.16 ) ,
798+ secondaryTextColor: secondaryTextColor. mixedWith ( . white, alpha: 0.3 ) ,
799+ badgeColor: badgeColor,
790800 attribute: attribute
791801 ) ) ,
792802 environment: { } ,
@@ -801,8 +811,8 @@ private final class GiftUpgradePreviewScreenComponent: Component {
801811 }
802812
803813 let edgeEffectHeight : CGFloat = 44.0
804- let edgeEffectFrame = CGRect ( origin: CGPoint ( x: 0.0 , y: contentHeight + 44.0 ) , size: CGSize ( width: availableSize . width , height: edgeEffectHeight) )
805- let edgeSolidFrame = CGRect ( origin: CGPoint ( x: 0.0 , y: contentHeight) , size: CGSize ( width: availableSize . width , height: 44.0 ) )
814+ let edgeEffectFrame = CGRect ( origin: CGPoint ( x: rawSideInset , y: contentHeight + 44.0 ) , size: CGSize ( width: fillingSize , height: edgeEffectHeight) )
815+ let edgeSolidFrame = CGRect ( origin: CGPoint ( x: rawSideInset , y: contentHeight) , size: CGSize ( width: fillingSize , height: 44.0 ) )
806816 transition. setFrame ( view: self . topEdgeSolidView, frame: edgeSolidFrame)
807817 transition. setFrame ( view: self . topEdgeEffectView, frame: edgeEffectFrame)
808818 self . topEdgeSolidView. backgroundColor = theme. list. blocksBackgroundColor
@@ -833,7 +843,7 @@ private final class GiftUpgradePreviewScreenComponent: Component {
833843 environment: { } ,
834844 containerSize: CGSize ( width: fillingSize - 8.0 * 2.0 , height: 100.0 )
835845 )
836- let segmentedControlFrame = CGRect ( origin: CGPoint ( x: floor ( ( fillingSize - segmentedSize. width) * 0.5 ) , y: contentHeight) , size: segmentedSize)
846+ let segmentedControlFrame = CGRect ( origin: CGPoint ( x: floor ( ( availableSize . width - segmentedSize. width) * 0.5 ) , y: contentHeight) , size: segmentedSize)
837847 if let segmentedControlComponentView = self . segmentControl. view {
838848 if segmentedControlComponentView. superview == nil {
839849 self . navigationBarContainer. addSubview ( self . topEdgeSolidView)
@@ -877,7 +887,7 @@ private final class GiftUpgradePreviewScreenComponent: Component {
877887 environment: { } ,
878888 containerSize: CGSize ( width: availableSize. width - sideInset * 2.0 , height: 100.0 )
879889 )
880- let descriptionFrame = CGRect ( origin: CGPoint ( x: floor ( ( fillingSize - descriptionSize. width) * 0.5 ) , y: contentHeight) , size: descriptionSize)
890+ let descriptionFrame = CGRect ( origin: CGPoint ( x: floor ( ( availableSize . width - descriptionSize. width) * 0.5 ) , y: contentHeight) , size: descriptionSize)
881891 if let descriptionView = self . descriptionText. view {
882892 if descriptionView. superview == nil {
883893 self . scrollContentView. addSubview ( descriptionView)
@@ -899,9 +909,12 @@ private final class GiftUpgradePreviewScreenComponent: Component {
899909 }
900910 transition. setFrame ( view: self . backgroundHandleView, frame: backgroundHandleFrame)
901911
902- self . glassContainerView. update ( size: CGSize ( width: fillingSize, height: 64.0 ) , isDark: false , transition: . immediate)
903- self . glassContainerView. frame = CGRect ( origin: CGPoint ( x: rawSideInset, y: 0.0 ) , size: CGSize ( width: fillingSize, height: 64.0 ) )
904-
912+ self . playbackGlassContainerView. update ( size: CGSize ( width: fillingSize, height: 64.0 ) , isDark: false , transition: . immediate)
913+ self . playbackGlassContainerView. frame = CGRect ( origin: CGPoint ( x: rawSideInset, y: 0.0 ) , size: CGSize ( width: fillingSize, height: 64.0 ) )
914+
915+ self . closeGlassContainerView. update ( size: CGSize ( width: 64.0 , height: 64.0 ) , isDark: false , transition: . immediate)
916+ self . closeGlassContainerView. frame = CGRect ( origin: CGPoint ( x: rawSideInset, y: 0.0 ) , size: CGSize ( width: 64.0 , height: 64.0 ) )
917+
905918 let closeButtonSize = self . closeButton. update (
906919 transition: transition,
907920 component: AnyComponent ( GlassBarButtonComponent (
@@ -928,8 +941,9 @@ private final class GiftUpgradePreviewScreenComponent: Component {
928941 let closeButtonFrame = CGRect ( origin: CGPoint ( x: 16.0 , y: 16.0 ) , size: closeButtonSize)
929942 if let closeButtonView = self . closeButton. view {
930943 if closeButtonView. superview == nil {
931- self . navigationBarContainer. addSubview ( self . glassContainerView)
932- self . navigationBarContainer. addSubview ( closeButtonView)
944+ self . navigationBarContainer. addSubview ( self . playbackGlassContainerView)
945+ self . navigationBarContainer. addSubview ( self . closeGlassContainerView)
946+ self . closeGlassContainerView. contentView. addSubview ( closeButtonView)
933947 }
934948 transition. setFrame ( view: closeButtonView, frame: closeButtonFrame)
935949 }
@@ -976,7 +990,7 @@ private final class GiftUpgradePreviewScreenComponent: Component {
976990 let playbackButtonFrame = CGRect ( origin: CGPoint ( x: fillingSize - 16.0 - playbackButtonSize. width, y: 16.0 ) , size: playbackButtonSize)
977991 if let playbackButtonView = self . playbackButton. view {
978992 if playbackButtonView. superview == nil {
979- self . glassContainerView . contentView. addSubview ( playbackButtonView)
993+ self . playbackGlassContainerView . contentView. addSubview ( playbackButtonView)
980994 }
981995 transition. setFrame ( view: playbackButtonView, frame: playbackButtonFrame)
982996 }
@@ -1120,17 +1134,20 @@ private final class AttributeInfoComponent: Component {
11201134 let strings : PresentationStrings
11211135 let backgroundColor : UIColor
11221136 let secondaryTextColor : UIColor
1137+ let badgeColor : UIColor
11231138 let attribute : StarGift . UniqueGift . Attribute
11241139
11251140 init (
11261141 strings: PresentationStrings ,
11271142 backgroundColor: UIColor ,
11281143 secondaryTextColor: UIColor ,
1144+ badgeColor: UIColor ,
11291145 attribute: StarGift . UniqueGift . Attribute
11301146 ) {
11311147 self . strings = strings
11321148 self . backgroundColor = backgroundColor
11331149 self . secondaryTextColor = secondaryTextColor
1150+ self . badgeColor = badgeColor
11341151 self . attribute = attribute
11351152 }
11361153
@@ -1144,6 +1161,9 @@ private final class AttributeInfoComponent: Component {
11441161 if lhs. secondaryTextColor != rhs. secondaryTextColor {
11451162 return false
11461163 }
1164+ if lhs. badgeColor != rhs. badgeColor {
1165+ return false
1166+ }
11471167 if lhs. attribute != rhs. attribute {
11481168 return false
11491169 }
@@ -1201,9 +1221,7 @@ private final class AttributeInfoComponent: Component {
12011221 subtitle = " "
12021222 rarity = 0
12031223 }
1204-
1205- let _ = rarity
1206-
1224+
12071225 let titleSize = self . title. update (
12081226 transition: . spring( duration: 0.2 ) ,
12091227 component: AnyComponent ( AnimatedTextComponent (
@@ -1274,7 +1292,7 @@ private final class AttributeInfoComponent: Component {
12741292
12751293 let badgeBackgroundFrame = badgeFrame. insetBy ( dx: - 5.5 , dy: - 2.0 )
12761294 transition. setFrame ( layer: self . badgeBackground, frame: badgeBackgroundFrame)
1277- transition. setBackgroundColor ( layer: self . badgeBackground, color: component. backgroundColor . mixedWith ( component . secondaryTextColor , alpha : 0.5 ) )
1295+ transition. setBackgroundColor ( layer: self . badgeBackground, color: component. badgeColor )
12781296
12791297
12801298 return availableSize
0 commit comments