Skip to content

Commit 7fe17ff

Browse files
Introduce FUIPrivacyAndTermsOfServiceView to make the message consistent across all sign in screens.
2 parents 8fd19df + 1f49c88 commit 7fe17ff

30 files changed

+1383
-204
lines changed

FirebaseAuthUI/FUIAuthPickerViewController.m

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#import "FUIAuthUtils.h"
2424
#import "FUIAuth_Internal.h"
2525
#import "FUIEmailEntryViewController.h"
26+
#import "FUIPrivacyAndTermsOfServiceView.h"
27+
2628

2729
/** @var kErrorUserInfoEmailKey
2830
@brief The key for the email address in the userinfo dictionary of a sign in error.
@@ -57,7 +59,7 @@
5759
@implementation FUIAuthPickerViewController {
5860
UIView *_buttonContainerView;
5961

60-
IBOutlet UITextView *_privacyPolicyAndTOSView;
62+
IBOutlet FUIPrivacyAndTermsOfServiceView *_privacyPolicyAndTOSView;
6163
}
6264

6365
- (instancetype)initWithAuthUI:(FUIAuth *)authUI {
@@ -135,48 +137,10 @@ - (void)viewDidLoad {
135137
emailButton.accessibilityIdentifier = kEmailButtonAccessibilityID;
136138
[_buttonContainerView addSubview:emailButton];
137139
}
138-
_privacyPolicyAndTOSView.attributedText = [self privacyPolicyAndTOS];
139-
_privacyPolicyAndTOSView.textColor = [UIColor lightGrayColor];
140+
_privacyPolicyAndTOSView.authUI = self.authUI;
141+
[_privacyPolicyAndTOSView useFullMessage];
140142
}
141143

142-
- (NSAttributedString *)privacyPolicyAndTOS {
143-
if (!self.authUI.TOSURL.absoluteString.length &&
144-
!self.authUI.privacyPolicyURL.absoluteString.length) {
145-
return nil;
146-
}
147-
if (!self.authUI.TOSURL.absoluteString.length ||
148-
!self.authUI.privacyPolicyURL.absoluteString.length) {
149-
NSLog(@"The terms of service and privacy policy URLs for your app must be provided together. Pl"
150-
"ease set the terms of service policy using [FUIAuth defaultAuthUI].TOSURL and the privacy"
151-
" policy URL using [FUIAuth defaultAuthUI].privacyPolicyURL");
152-
return nil;
153-
}
154-
NSString *privacyPolicyAndTOSString =
155-
[NSString stringWithFormat:FUILocalizedString(kStr_TermsOfServiceAuthPicker),
156-
FUILocalizedString(kStr_TermsOfService), FUILocalizedString(kStr_PrivacyPolicy)];
157-
NSMutableAttributedString *attributedLinkText =
158-
[[NSMutableAttributedString alloc] initWithString:privacyPolicyAndTOSString];
159-
160-
NSRange TOSRange =
161-
[privacyPolicyAndTOSString rangeOfString:FUILocalizedString(kStr_TermsOfService)];
162-
163-
if (TOSRange.length) {
164-
[attributedLinkText addAttribute:NSLinkAttributeName
165-
value:self.authUI.TOSURL
166-
range:TOSRange];
167-
}
168-
NSRange privacyPolicyRange =
169-
[privacyPolicyAndTOSString rangeOfString:FUILocalizedString(kStr_PrivacyPolicy)];
170-
171-
if (privacyPolicyRange.length) {
172-
[attributedLinkText addAttribute:NSLinkAttributeName
173-
value:self.authUI.privacyPolicyURL
174-
range:privacyPolicyRange];
175-
}
176-
return attributedLinkText;
177-
}
178-
179-
180144
- (void)viewDidLayoutSubviews {
181145
[super viewDidLayoutSubviews];
182146

FirebaseAuthUI/FUIAuthPickerViewController.xib

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
88
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
9+
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
910
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1011
</dependencies>
1112
<objects>
@@ -20,16 +21,23 @@
2021
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2122
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2223
<subviews>
23-
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" editable="NO" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Xez-8g-dy2">
24+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Xez-8g-dy2" customClass="FUIPrivacyAndTermsOfServiceView">
2425
<rect key="frame" x="16" y="618" width="343" height="49"/>
25-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2626
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
27+
<constraints>
28+
<constraint firstAttribute="height" constant="49" id="DYU-T6-FUV"/>
29+
</constraints>
2730
<attributedString key="attributedText"/>
2831
<textInputTraits key="textInputTraits" autocapitalizationType="sentences" textContentType="url"/>
2932
<dataDetectorType key="dataDetectorTypes" link="YES"/>
3033
</textView>
3134
</subviews>
3235
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
36+
<constraints>
37+
<constraint firstItem="Xez-8g-dy2" firstAttribute="leading" secondItem="kfP-Vq-eU2" secondAttribute="leadingMargin" id="146-w9-1AF"/>
38+
<constraint firstItem="Xez-8g-dy2" firstAttribute="trailing" secondItem="kfP-Vq-eU2" secondAttribute="trailingMargin" id="Hoh-mG-IDs"/>
39+
<constraint firstAttribute="bottom" secondItem="Xez-8g-dy2" secondAttribute="bottom" id="uZS-Dj-pya"/>
40+
</constraints>
3341
<point key="canvasLocation" x="25.5" y="51.5"/>
3442
</view>
3543
</objects>

FirebaseAuthUI/FUIAuthStrings.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ extern NSString *const kStr_SignInWithEmail;
6262
extern NSString *const kStr_SignUpTitle;
6363
extern NSString *const kStr_SignUpTooManyTimesError;
6464
extern NSString *const kStr_TermsOfService;
65-
extern NSString *const kStr_TermsOfServiceNotice;
66-
extern NSString *const kStr_TermsOfServiceAuthPicker;
6765
extern NSString *const kStr_PrivacyPolicy;
66+
extern NSString *const kStr_TermsOfServiceMessage;
6867
extern NSString *const kStr_UserNotFoundError;
6968
extern NSString *const kStr_WeakPasswordError;
7069
extern NSString *const kStr_WrongPasswordError;

FirebaseAuthUI/FUIAuthStrings.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@
6868
NSString *const kStr_SignUpTitle = @"SignUpTitle";
6969
NSString *const kStr_SignUpTooManyTimesError = @"SignUpTooManyTimesError";
7070
NSString *const kStr_TermsOfService = @"TermsOfService";
71-
NSString *const kStr_TermsOfServiceNotice = @"TermsOfServiceNotice";
72-
NSString *const kStr_TermsOfServiceAuthPicker = @"TermsOfServiceAuthPicker";
7371
NSString *const kStr_PrivacyPolicy = @"PrivacyPolicy";
72+
NSString *const kStr_TermsOfServiceMessage = @"TermsOfServiceMessage";
7473
NSString *const kStr_UserNotFoundError = @"UserNotFoundError";
7574
NSString *const kStr_WeakPasswordError = @"WeakPasswordError";
7675
NSString *const kStr_WrongPasswordError = @"WrongPasswordError";

FirebaseAuthUI/FUIAuthTableViewCell.xib

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
99
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
1010
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1111
</dependencies>
@@ -20,13 +20,13 @@
2020
<autoresizingMask key="autoresizingMask"/>
2121
<subviews>
2222
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="120" translatesAutoresizingMaskIntoConstraints="NO" id="sfp-hN-0cm">
23-
<rect key="frame" x="16" y="12" width="42" height="19.5"/>
23+
<rect key="frame" x="24" y="12" width="42" height="19.5"/>
2424
<fontDescription key="fontDescription" type="system" pointSize="17"/>
2525
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2626
<nil key="highlightedColor"/>
2727
</label>
2828
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="placeholder" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="h79-sO-Wvr">
29-
<rect key="frame" x="74" y="12" width="238" height="20"/>
29+
<rect key="frame" x="82" y="12" width="222" height="20"/>
3030
<fontDescription key="fontDescription" type="system" pointSize="16"/>
3131
<textInputTraits key="textInputTraits" enablesReturnKeyAutomatically="YES"/>
3232
</textField>

FirebaseAuthUI/FUIEmailEntryViewController.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#import "FUIAuth_Internal.h"
2626
#import "FUIPasswordSignInViewController.h"
2727
#import "FUIPasswordSignUpViewController.h"
28+
#import "FUIPrivacyAndTermsOfServiceView.h"
2829

2930
/** @var kCellReuseIdentifier
3031
@brief The reuse identifier for table view cell.
@@ -64,6 +65,12 @@ @implementation FUIEmailEntryViewController {
6465
@brief The @c UITableView used to store all UI elements.
6566
*/
6667
__weak IBOutlet UITableView *_tableView;
68+
69+
/** @var _termsOfServiceView
70+
@brief The @c Text view which displays Terms of Service.
71+
*/
72+
__weak IBOutlet FUIPrivacyAndTermsOfServiceView *_termsOfServiceView;
73+
6774
}
6875

6976
- (instancetype)initWithAuthUI:(FUIAuth *)authUI {
@@ -94,6 +101,8 @@ - (void)viewDidLoad {
94101
action:@selector(next)];
95102
nextButtonItem.accessibilityIdentifier = kNextButtonAccessibilityID;
96103
self.navigationItem.rightBarButtonItem = nextButtonItem;
104+
_termsOfServiceView.authUI = self.authUI;
105+
[_termsOfServiceView useFullMessage];
97106

98107
[self enableDynamicCellHeightForTableView:_tableView];
99108
}

FirebaseAuthUI/FUIEmailEntryViewController.xib

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1010
</dependencies>
1111
<objects>
1212
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="FUIEmailEntryViewController">
1313
<connections>
14-
<outlet property="_tableView" destination="H6t-i3-acV" id="ivu-Xo-dPw"/>
14+
<outlet property="_tableView" destination="sqQ-Fo-hB1" id="5Ek-qF-gTL"/>
15+
<outlet property="_termsOfServiceView" destination="9ea-qX-Sdg" id="T20-ZO-fz9"/>
1516
<outlet property="view" destination="bth-CL-c9r" id="F2l-k9-ffn"/>
1617
</connections>
1718
</placeholder>
@@ -20,21 +21,41 @@
2021
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2122
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2223
<subviews>
23-
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="H6t-i3-acV">
24+
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="sqQ-Fo-hB1">
2425
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
25-
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
26+
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
27+
<view key="tableFooterView" contentMode="scaleToFill" id="zAD-Xd-4qt">
28+
<rect key="frame" x="0.0" y="896.5" width="375" height="100"/>
29+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
30+
<subviews>
31+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" text="Terms of Service" textAlignment="natural" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9ea-qX-Sdg" customClass="FUIPrivacyAndTermsOfServiceView">
32+
<rect key="frame" x="10" y="0.0" width="355" height="100"/>
33+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
34+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
35+
<fontDescription key="fontDescription" type="system" pointSize="12"/>
36+
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
37+
</textView>
38+
</subviews>
39+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
40+
<constraints>
41+
<constraint firstAttribute="trailing" secondItem="9ea-qX-Sdg" secondAttribute="trailing" constant="10" id="XIO-RK-VZ7"/>
42+
<constraint firstItem="9ea-qX-Sdg" firstAttribute="top" secondItem="zAD-Xd-4qt" secondAttribute="top" id="b5A-Zf-YCc"/>
43+
<constraint firstAttribute="bottom" secondItem="9ea-qX-Sdg" secondAttribute="bottom" id="iuk-lu-1BT"/>
44+
<constraint firstItem="9ea-qX-Sdg" firstAttribute="leading" secondItem="zAD-Xd-4qt" secondAttribute="leading" constant="10" id="lMZ-cS-2hg"/>
45+
</constraints>
46+
</view>
2647
<connections>
27-
<outlet property="dataSource" destination="-1" id="33A-3M-w3R"/>
28-
<outlet property="delegate" destination="-1" id="bIJ-CI-bmt"/>
48+
<outlet property="dataSource" destination="-1" id="Sw5-oz-cWe"/>
49+
<outlet property="delegate" destination="-1" id="xr0-I0-wCb"/>
2950
</connections>
3051
</tableView>
3152
</subviews>
3253
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
3354
<constraints>
34-
<constraint firstItem="H6t-i3-acV" firstAttribute="centerY" secondItem="bth-CL-c9r" secondAttribute="centerY" id="HOf-5w-2pQ"/>
35-
<constraint firstItem="H6t-i3-acV" firstAttribute="height" secondItem="bth-CL-c9r" secondAttribute="height" id="Kxk-eP-6fy"/>
36-
<constraint firstItem="H6t-i3-acV" firstAttribute="width" secondItem="bth-CL-c9r" secondAttribute="width" id="Sjr-B8-2fW"/>
37-
<constraint firstItem="H6t-i3-acV" firstAttribute="centerX" secondItem="bth-CL-c9r" secondAttribute="centerX" id="eD1-nP-vHs"/>
55+
<constraint firstAttribute="trailing" secondItem="sqQ-Fo-hB1" secondAttribute="trailing" id="5Me-cs-Zxv"/>
56+
<constraint firstItem="sqQ-Fo-hB1" firstAttribute="top" secondItem="bth-CL-c9r" secondAttribute="top" id="OYw-Zf-Kez"/>
57+
<constraint firstAttribute="bottom" secondItem="sqQ-Fo-hB1" secondAttribute="bottom" id="c4f-G4-8CC"/>
58+
<constraint firstItem="sqQ-Fo-hB1" firstAttribute="leading" secondItem="bth-CL-c9r" secondAttribute="leading" id="y2b-6O-eFn"/>
3859
</constraints>
3960
</view>
4061
</objects>

FirebaseAuthUI/FUIPasswordRecoveryViewController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#import "FUIAuthTableViewCell.h"
2323
#import "FUIAuthUtils.h"
2424
#import "FUIAuth_Internal.h"
25+
#import "FUIPrivacyAndTermsOfServiceView.h"
2526

2627
/** @var kCellReuseIdentifier
2728
@brief The reuse identifier for table view cell.
@@ -38,6 +39,7 @@ @interface FUIPasswordRecoveryViewController () <UITableViewDataSource, UITextFi
3839
@brief The text view in the footer of the table.
3940
*/
4041
@property(nonatomic, strong) IBOutlet UITextView *footerTextView;
42+
@property(nonatomic, strong) IBOutlet FUIPrivacyAndTermsOfServiceView *termsOfServiceView;
4143

4244
@end
4345

@@ -103,6 +105,9 @@ - (void)viewDidLayoutSubviews {
103105
_footerTextView.textContainerInset =
104106
UIEdgeInsetsMake(0, kFooterTextViewHorizontalInset, 0, kFooterTextViewHorizontalInset);
105107
[self.footerTextView sizeToFit];
108+
109+
self.termsOfServiceView.authUI = self.authUI;
110+
[self.termsOfServiceView useFooterMessage];
106111
}
107112

108113
#pragma mark - Actions

0 commit comments

Comments
 (0)