2525#import " FUIPrivacyAndTermsOfServiceView.h"
2626
2727/* * @var kSignInButtonWidth
28- @brief The width of the sign in buttons.
28+ @brief The width of the sign in buttons.
2929 */
3030static const CGFloat kSignInButtonWidth = 220 .0f ;
3131
3232/* * @var kSignInButtonHeight
33- @brief The height of the sign in buttons.
33+ @brief The height of the sign in buttons.
3434 */
3535static const CGFloat kSignInButtonHeight = 40 .0f ;
3636
3737/* * @var kSignInButtonVerticalMargin
38- @brief The vertical margin between sign in buttons.
38+ @brief The vertical margin between sign in buttons.
3939 */
4040static const CGFloat kSignInButtonVerticalMargin = 24 .0f ;
4141
4242/* * @var kButtonContainerBottomMargin
43- @brief The magin between sign in buttons and the bottom of the content view.
43+ @brief The magin between sign in buttons and the bottom of the content view.
4444 */
45- static const CGFloat kButtonContainerBottomMargin = 56 .0f ;
45+ static const CGFloat kButtonContainerBottomMargin = 48 .0f ;
4646
4747/* * @var kButtonContainerTopMargin
48- @brief The margin between sign in buttons and the top of the content view.
48+ @brief The margin between sign in buttons and the top of the content view.
4949 */
5050static const CGFloat kButtonContainerTopMargin = 16 .0f ;
5151
52+ /* * @var kTOSViewBottomMargin
53+ @brief The margin between privacy policy and TOS view and the bottom of the content view.
54+ */
55+ static const CGFloat kTOSViewBottomMargin = 24 .0f ;
56+
57+ /* * @var kTOSViewHorizontalMargin
58+ @brief The margin between privacy policy and TOS view and the left or right of the content view.
59+ */
60+ static const CGFloat kTOSViewHorizontalMargin = 16 .0f ;
61+
5262@implementation FUIAuthPickerViewController {
5363 UIView *_buttonContainerView;
5464
5565 IBOutlet FUIPrivacyAndTermsOfServiceView *_privacyPolicyAndTOSView;
5666
5767 IBOutlet UIView *_contentView;
58-
68+
5969 IBOutlet UIScrollView *_scrollView;
6070}
6171
@@ -83,21 +93,21 @@ - (void)viewDidLoad {
8393
8494 if (!self.authUI .shouldHideCancelButton ) {
8595 UIBarButtonItem *cancelBarButton =
86- [[UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemCancel
87- target: self
88- action: @selector (cancelAuthorization )];
96+ [[UIBarButtonItem alloc ] initWithBarButtonSystemItem: UIBarButtonSystemItemCancel
97+ target: self
98+ action: @selector (cancelAuthorization )];
8999 self.navigationItem .leftBarButtonItem = cancelBarButton;
90100 }
91101 self.navigationItem .backBarButtonItem =
92- [[UIBarButtonItem alloc ] initWithTitle: FUILocalizedString (kStr_Back )
93- style: UIBarButtonItemStylePlain
94- target: nil
95- action: nil ];
102+ [[UIBarButtonItem alloc ] initWithTitle: FUILocalizedString (kStr_Back )
103+ style: UIBarButtonItemStylePlain
104+ target: nil
105+ action: nil ];
96106
97107 NSInteger numberOfButtons = self.authUI .providers .count ;
98108
99109 CGFloat buttonContainerViewHeight =
100- kSignInButtonHeight * numberOfButtons + kSignInButtonVerticalMargin * (numberOfButtons);
110+ kSignInButtonHeight * numberOfButtons + kSignInButtonVerticalMargin * (numberOfButtons);
101111 CGRect buttonContainerViewFrame = CGRectMake (0 , 0 , kSignInButtonWidth , buttonContainerViewHeight);
102112 _buttonContainerView = [[UIView alloc ] initWithFrame: buttonContainerViewFrame];
103113 if (_scrollView) {
@@ -111,7 +121,7 @@ - (void)viewDidLoad {
111121 CGRect buttonFrame = CGRectMake (0 , 0 , kSignInButtonWidth , kSignInButtonHeight );
112122 for (id <FUIAuthProvider> providerUI in self.authUI .providers ) {
113123 UIButton *providerButton =
114- [[FUIAuthSignInButton alloc ] initWithFrame: buttonFrame providerUI: providerUI];
124+ [[FUIAuthSignInButton alloc ] initWithFrame: buttonFrame providerUI: providerUI];
115125 [providerButton addTarget: self
116126 action: @selector (didTapSignInButton: )
117127 forControlEvents: UIControlEventTouchUpInside];
@@ -134,27 +144,27 @@ - (void)viewDidLayoutSubviews {
134144 // old layout behavior.
135145 if (!_scrollView) {
136146 CGFloat distanceFromCenterToBottom =
137- CGRectGetHeight (_buttonContainerView.frame ) / 2 .0f + kButtonContainerBottomMargin ;
147+ CGRectGetHeight (_buttonContainerView.frame ) / 2 .0f + kButtonContainerBottomMargin + kTOSViewBottomMargin ;
138148 CGFloat centerY = CGRectGetHeight (self.view .bounds ) - distanceFromCenterToBottom;
139149 // Compensate for bounds adjustment if any.
140150 centerY += self.view .bounds .origin .y ;
141151 _buttonContainerView.center = CGPointMake (self.view .center .x , centerY);
142152 return ;
143153 }
144-
154+
145155 CGFloat buttonContainerHeight = CGRectGetHeight (_buttonContainerView.frame );
146156 CGFloat buttonContainerWidth = CGRectGetWidth (_buttonContainerView.frame );
147- CGFloat contentViewHeight = kButtonContainerTopMargin +
148- buttonContainerHeight + kButtonContainerBottomMargin ;
157+ CGFloat contentViewHeight = kButtonContainerTopMargin + buttonContainerHeight
158+ + kButtonContainerBottomMargin + kTOSViewBottomMargin ;
149159 CGFloat contentViewWidth = CGRectGetWidth (self.view .bounds );
150160 _scrollView.frame = self.view .frame ;
151161 CGFloat scrollViewHeight;
152162 if (@available (iOS 11.0 , *)) {
153163 scrollViewHeight = CGRectGetHeight (_scrollView.frame ) - _scrollView.safeAreaInsets .top ;
154164 } else {
155165 scrollViewHeight = CGRectGetHeight (_scrollView.frame )
156- - CGRectGetHeight (self.navigationController .navigationBar .frame )
157- - CGRectGetHeight ([UIApplication sharedApplication ].statusBarFrame );
166+ - CGRectGetHeight (self.navigationController .navigationBar .frame )
167+ - CGRectGetHeight ([UIApplication sharedApplication ].statusBarFrame );
158168 }
159169 CGFloat contentViewY = scrollViewHeight - contentViewHeight;
160170 if (contentViewY < 0 ) {
@@ -168,7 +178,10 @@ - (void)viewDidLayoutSubviews {
168178 buttonContainerWidth,
169179 buttonContainerHeight);
170180 CGFloat privacyViewHeight = CGRectGetHeight (_privacyPolicyAndTOSView.frame );
171- _privacyPolicyAndTOSView.frame = CGRectMake (0 , contentViewHeight - privacyViewHeight, contentViewWidth, privacyViewHeight);
181+ _privacyPolicyAndTOSView.frame = CGRectMake (kTOSViewHorizontalMargin , contentViewHeight
182+ - privacyViewHeight - kTOSViewBottomMargin ,
183+ contentViewWidth - kTOSViewHorizontalMargin *2 ,
184+ privacyViewHeight);
172185}
173186
174187#pragma mark - Actions
0 commit comments