Skip to content

Commit 670f9d9

Browse files
author
Chuan Ren
committed
Fix pravicy policy view alignment
1 parent cd5ad5e commit 670f9d9

File tree

4 files changed

+196
-47
lines changed

4 files changed

+196
-47
lines changed

Auth/FirebaseAuthUI/FUIAuthPickerViewController.m

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,47 @@
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
*/
3030
static 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
*/
3535
static 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
*/
4040
static 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
*/
5050
static 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

Auth/FirebaseAuthUI/FUIPrivacyAndTermsOfServiceView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ - (void)useFullMessage {
3535
- (void)useFooterMessage {
3636
NSAttributedString *footerMessage = [self footerPrivacyPolicyAndTOSMessage];
3737
self.attributedText = footerMessage;
38-
self.textAlignment = NSTextAlignmentRight;
38+
self.textAlignment = NSTextAlignmentCenter;
3939
}
4040

4141
#pragma mark - Protected

Gemfile.lock

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,69 @@ GEM
22
remote: https://rubygems.org/
33
specs:
44
CFPropertyList (3.0.0)
5-
activesupport (4.2.10)
5+
activesupport (4.2.11.1)
66
i18n (~> 0.7)
77
minitest (~> 5.1)
88
thread_safe (~> 0.3, >= 0.3.4)
99
tzinfo (~> 1.1)
10-
atomos (0.1.2)
10+
atomos (0.1.3)
1111
claide (1.0.2)
12-
cocoapods (1.5.3)
12+
cocoapods (1.6.1)
1313
activesupport (>= 4.0.2, < 5)
1414
claide (>= 1.0.2, < 2.0)
15-
cocoapods-core (= 1.5.3)
15+
cocoapods-core (= 1.6.1)
1616
cocoapods-deintegrate (>= 1.0.2, < 2.0)
17-
cocoapods-downloader (>= 1.2.0, < 2.0)
17+
cocoapods-downloader (>= 1.2.2, < 2.0)
1818
cocoapods-plugins (>= 1.0.0, < 2.0)
1919
cocoapods-search (>= 1.0.0, < 2.0)
2020
cocoapods-stats (>= 1.0.0, < 2.0)
21-
cocoapods-trunk (>= 1.3.0, < 2.0)
21+
cocoapods-trunk (>= 1.3.1, < 2.0)
2222
cocoapods-try (>= 1.1.0, < 2.0)
2323
colored2 (~> 3.1)
2424
escape (~> 0.0.4)
25-
fourflusher (~> 2.0.1)
25+
fourflusher (>= 2.2.0, < 3.0)
2626
gh_inspector (~> 1.0)
27-
molinillo (~> 0.6.5)
27+
molinillo (~> 0.6.6)
2828
nap (~> 1.0)
29-
ruby-macho (~> 1.1)
30-
xcodeproj (>= 1.5.7, < 2.0)
31-
cocoapods-core (1.5.3)
29+
ruby-macho (~> 1.4)
30+
xcodeproj (>= 1.8.1, < 2.0)
31+
cocoapods-core (1.6.1)
3232
activesupport (>= 4.0.2, < 6)
3333
fuzzy_match (~> 2.0.4)
3434
nap (~> 1.0)
35-
cocoapods-deintegrate (1.0.2)
36-
cocoapods-downloader (1.2.1)
35+
cocoapods-deintegrate (1.0.3)
36+
cocoapods-downloader (1.2.2)
3737
cocoapods-plugins (1.0.0)
3838
nap
3939
cocoapods-search (1.0.0)
40-
cocoapods-stats (1.0.0)
41-
cocoapods-trunk (1.3.0)
40+
cocoapods-stats (1.1.0)
41+
cocoapods-trunk (1.3.1)
4242
nap (>= 0.8, < 2.0)
4343
netrc (~> 0.11)
4444
cocoapods-try (1.1.0)
4545
colored2 (3.1.2)
46-
concurrent-ruby (1.0.5)
46+
concurrent-ruby (1.1.5)
4747
escape (0.0.4)
48-
fourflusher (2.0.1)
48+
fourflusher (2.2.0)
4949
fuzzy_match (2.0.4)
5050
gh_inspector (1.1.3)
5151
i18n (0.9.5)
5252
concurrent-ruby (~> 1.0)
5353
minitest (5.11.3)
54-
molinillo (0.6.5)
54+
molinillo (0.6.6)
5555
nanaimo (0.2.6)
5656
nap (1.1.0)
5757
netrc (0.11.0)
58-
ruby-macho (1.2.0)
58+
ruby-macho (1.4.0)
5959
thread_safe (0.3.6)
6060
tzinfo (1.2.5)
6161
thread_safe (~> 0.1)
62-
xcodeproj (1.5.9)
62+
xcodeproj (1.8.1)
6363
CFPropertyList (>= 2.3.3, < 4.0)
64-
atomos (~> 0.1.2)
64+
atomos (~> 0.1.3)
6565
claide (>= 1.0.2, < 2.0)
6666
colored2 (~> 3.1)
67-
nanaimo (~> 0.2.5)
67+
nanaimo (~> 0.2.6)
6868

6969
PLATFORMS
7070
ruby
@@ -75,4 +75,4 @@ DEPENDENCIES
7575
xcodeproj
7676

7777
BUNDLED WITH
78-
1.16.1
78+
1.17.2

0 commit comments

Comments
 (0)