@@ -12,7 +12,6 @@ import ViewControllerComponent
1212import SheetComponent
1313import MultilineTextComponent
1414import BundleIconComponent
15- import SolidRoundedButtonComponent
1615import Markdown
1716import BalancedTextComponent
1817import ConfettiEffect
@@ -22,6 +21,8 @@ import TelegramStringFormatting
2221import UndoUI
2322import InvisibleInkDustNode
2423import PremiumStarComponent
24+ import GlassBarButtonComponent
25+ import ButtonComponent
2526
2627private final class PremiumGiftCodeSheetContent : CombinedComponent {
2728 typealias EnvironmentType = ViewControllerComponentContainer . Environment
@@ -74,9 +75,7 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent {
7475 var initialized = false
7576
7677 var peerMap : [ EnginePeer . Id : EnginePeer ] = [ : ]
77-
78- var cachedCloseImage : ( UIImage , PresentationTheme ) ?
79-
78+
8079 var inProgress = false
8180
8281 init ( context: AccountContext , subject: PremiumGiftCodeScreen . Subject ) {
@@ -132,14 +131,14 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent {
132131 }
133132
134133 static var body : Body {
135- let closeButton = Child ( Button . self)
134+ let closeButton = Child ( GlassBarButtonComponent . self)
136135 let title = Child ( MultilineTextComponent . self)
137136 let star = Child ( PremiumStarComponent . self)
138137 let description = Child ( BalancedTextComponent . self)
139138 let linkButton = Child ( Button . self)
140139 let table = Child ( TableComponent . self)
141140 let additional = Child ( BalancedTextComponent . self)
142- let button = Child ( SolidRoundedButtonComponent . self)
141+ let button = Child ( ButtonComponent . self)
143142
144143 return { context in
145144 let environment = context. environment [ ViewControllerComponentContainer . Environment. self] . value
@@ -155,22 +154,23 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent {
155154 let sideInset : CGFloat = 16.0 + environment. safeInsets. left
156155 let textSideInset : CGFloat = 32.0 + environment. safeInsets. left
157156
158- let closeImage : UIImage
159- if let ( image, theme) = state. cachedCloseImage, theme === environment. theme {
160- closeImage = image
161- } else {
162- closeImage = generateCloseButtonImage ( backgroundColor: UIColor ( rgb: 0x808084 , alpha: 0.1 ) , foregroundColor: theme. actionSheet. inputClearButtonColor) !
163- state. cachedCloseImage = ( closeImage, theme)
164- }
165-
166157 let closeButton = closeButton. update (
167- component: Button (
168- content: AnyComponent ( Image ( image: closeImage) ) ,
169- action: { [ weak component] in
170- component? . cancel ( true )
158+ component: GlassBarButtonComponent (
159+ size: CGSize ( width: 40.0 , height: 40.0 ) ,
160+ backgroundColor: theme. rootController. navigationBar. glassBarButtonBackgroundColor,
161+ isDark: theme. overallDarkAppearance,
162+ state: . generic,
163+ component: AnyComponentWithIdentity ( id: " close " , component: AnyComponent (
164+ BundleIconComponent (
165+ name: " Navigation/Close " ,
166+ tintColor: theme. rootController. navigationBar. glassBarButtonForegroundColor
167+ )
168+ ) ) ,
169+ action: { _ in
170+ component. cancel ( true )
171171 }
172172 ) ,
173- availableSize: CGSize ( width: 30 .0, height: 30 .0) ,
173+ availableSize: CGSize ( width: 40 .0, height: 40 .0) ,
174174 transition: . immediate
175175 )
176176
@@ -312,7 +312,7 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent {
312312 }
313313 }
314314 ) ,
315- availableSize: CGSize ( width: context. availableSize. width - sideInset * 2.0 , height: 50 .0) ,
315+ availableSize: CGSize ( width: context. availableSize. width - sideInset * 2.0 , height: 52 .0) ,
316316 transition: . immediate
317317 )
318318
@@ -462,20 +462,21 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent {
462462 availableSize: CGSize ( width: context. availableSize. width - textSideInset * 2.0 , height: context. availableSize. height) ,
463463 transition: . immediate
464464 )
465-
465+
466+ let buttonInsets = ContainerViewLayout . concentricInsets ( bottomInset: environment. safeInsets. bottom, innerDiameter: 52.0 , sideInset: 30.0 )
466467 let button = button. update (
467- component: SolidRoundedButtonComponent (
468- title : buttonText ,
469- theme : SolidRoundedButtonComponent . Theme ( theme : theme ) ,
470- font : . bold ,
471- fontSize : 17.0 ,
472- height : 50.0 ,
473- cornerRadius: 10.0 ,
474- gloss : gloss ,
475- iconName : nil ,
476- animationName : nil ,
477- iconPosition : . left ,
478- isLoading : state . inProgress ,
468+ component: ButtonComponent (
469+ background : ButtonComponent . Background (
470+ style : . glass ,
471+ color : theme . list . itemCheckColors . fillColor ,
472+ foreground : theme . list . itemCheckColors . foregroundColor ,
473+ pressedColor : theme . list . itemCheckColors . fillColor . withMultipliedAlpha ( 0.9 ) ,
474+ cornerRadius: 10.0 ,
475+ ) ,
476+ content : AnyComponentWithIdentity (
477+ id : AnyHashable ( 0 ) ,
478+ component : AnyComponent ( MultilineTextComponent ( text : . plain ( NSMutableAttributedString ( string : buttonText , font : Font . semibold ( 17.0 ) , textColor : theme . list . itemCheckColors . foregroundColor , paragraphAlignment : . center ) ) ) )
479+ ) ,
479480 action: { [ weak state] in
480481 if gloss {
481482 component. action ( )
@@ -488,20 +489,20 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent {
488489 }
489490 }
490491 ) ,
491- availableSize: CGSize ( width: context. availableSize. width - sideInset * 2.0 , height: 50 .0) ,
492- transition: context . transition
492+ availableSize: CGSize ( width: context. availableSize. width - buttonInsets . left - buttonInsets . right , height: 52 .0) ,
493+ transition: . immediate
493494 )
494495
495496 context. add ( title
496- . position ( CGPoint ( x: context. availableSize. width / 2.0 , y: 28 .0) )
497+ . position ( CGPoint ( x: context. availableSize. width / 2.0 , y: 36 .0) )
497498 )
498499
499500 context. add ( star
500501 . position ( CGPoint ( x: context. availableSize. width / 2.0 , y: star. size. height / 2.0 ) )
501502 )
502503
503504 var originY : CGFloat = 0.0
504- originY += star. size. height - 32 .0
505+ originY += star. size. height - 24 .0
505506
506507 context. add ( description
507508 . position ( CGPoint ( x: context. availableSize. width / 2.0 , y: originY + description. size. height / 2.0 ) )
@@ -523,16 +524,17 @@ private final class PremiumGiftCodeSheetContent: CombinedComponent {
523524 )
524525 originY += additional. size. height + 23.0
525526
526- let buttonFrame = CGRect ( origin: CGPoint ( x: sideInset, y: originY) , size: button. size)
527527 context. add ( button
528- . position ( CGPoint ( x: buttonFrame . midX , y: buttonFrame . midY ) )
528+ . position ( CGPoint ( x: context . availableSize . width / 2.0 , y: originY + button . size . height / 2.0 ) )
529529 )
530+ originY += button. size. height
531+ originY += buttonInsets. bottom
530532
531533 context. add ( closeButton
532- . position ( CGPoint ( x: context . availableSize . width - environment . safeInsets . left - closeButton. size. width , y : 28 .0) )
534+ . position ( CGPoint ( x: 16.0 + closeButton . size . width / 2.0 , y : 16.0 + closeButton. size. height / 2 .0) )
533535 )
534536
535- let contentSize = CGSize ( width: context. availableSize. width, height: buttonFrame . maxY + 5.0 + environment . safeInsets . bottom )
537+ let contentSize = CGSize ( width: context. availableSize. width, height: originY )
536538
537539 return contentSize
538540 }
@@ -612,6 +614,7 @@ private final class PremiumGiftCodeSheetComponent: CombinedComponent {
612614 shareLink: context. component. shareLink,
613615 displayHiddenTooltip: context. component. displayHiddenTooltip
614616 ) ) ,
617+ style: . glass,
615618 backgroundColor: . color( environment. theme. actionSheet. opaqueItemBackgroundColor) ,
616619 followContentSizeChanges: true ,
617620 clipsContent: true ,
@@ -799,10 +802,10 @@ final class GiftLinkButtonContentComponent: CombinedComponent {
799802 return { context in
800803 let component = context. component
801804
802- let sideInset : CGFloat = 38 .0
805+ let sideInset : CGFloat = 42 .0
803806
804807 let background = background. update (
805- component: RoundedRectangle ( color: component. isSeparateSection ? component. theme. list. itemBlocksBackgroundColor : component. theme. list. itemInputField. backgroundColor, cornerRadius: 10 .0) ,
808+ component: RoundedRectangle ( color: component. isSeparateSection ? component. theme. list. itemBlocksBackgroundColor : component. theme. list. itemInputField. backgroundColor, cornerRadius: 26 .0) ,
806809 availableSize: context. availableSize,
807810 transition: context. transition
808811 )
@@ -989,8 +992,8 @@ private final class TableComponent: CombinedComponent {
989992 if let ( currentImage, theme) = context. state. cachedBorderImage, theme === context. component. theme {
990993 borderImage = currentImage
991994 } else {
992- let borderRadius : CGFloat = 5 .0
993- borderImage = generateImage ( CGSize ( width: 16.0 , height: 16 .0) , rotatedContext: { size, context in
995+ let borderRadius : CGFloat = 14 .0
996+ borderImage = generateImage ( CGSize ( width: borderRadius * 2.0 + 6.0 , height: borderRadius * 2.0 + 6 .0) , rotatedContext: { size, context in
994997 let bounds = CGRect ( origin: . zero, size: size)
995998 context. setFillColor ( backgroundColor. cgColor)
996999 context. fill ( bounds)
@@ -1005,7 +1008,7 @@ private final class TableComponent: CombinedComponent {
10051008 context. setLineWidth ( borderWidth)
10061009 context. addPath ( path)
10071010 context. strokePath ( )
1008- } ) !. stretchableImage ( withLeftCapWidth: 5 , topCapHeight: 5 )
1011+ } ) !. stretchableImage ( withLeftCapWidth: Int ( borderRadius ) , topCapHeight: Int ( borderRadius ) )
10091012 context. state. cachedBorderImage = ( borderImage, context. component. theme)
10101013 }
10111014
0 commit comments