3333static const CGFloat kFooterTextViewHorizontalInset = 8 .0f ;
3434
3535@interface FIRPasswordRecoveryViewController () <UITableViewDataSource, UITextFieldDelegate>
36+ /* * @property footerTextView
37+ @brief The text view in the footer of the table.
38+ */
39+ @property (nonatomic , strong ) IBOutlet UITextView *footerTextView;
40+
3641@end
3742
3843@implementation FIRPasswordRecoveryViewController {
3944 /* * @var _email
40- @brief The @c The email address of the user from the previous screen.
45+ @brief The @c email address of the user from the previous screen.
4146 */
4247 NSString *_email;
4348
@@ -47,10 +52,12 @@ @implementation FIRPasswordRecoveryViewController {
4752 UITextField *_emailField;
4853}
4954
50- - (instancetype )initWithAuthUI : (FIRAuthUI *)authUI
51- email : (NSString *_Nullable)email {
52- self = [super initWithNibName: NSStringFromClass ([self class ])
53- bundle: [FIRAuthUIUtils frameworkBundle ]
55+ - (instancetype )initWithNibName : (nullable NSString *)nibNameOrNil
56+ bundle : (nullable NSBundle *)nibBundleOrNil
57+ authUI : (FIRAuthUI *)authUI
58+ email : (NSString *_Nullable)email {
59+ self = [super initWithNibName: nibNameOrNil
60+ bundle: nibBundleOrNil
5461 authUI: authUI];
5562 if (self) {
5663 _email = [email copy ];
@@ -86,7 +93,10 @@ - (void)viewDidLayoutSubviews {
8693#pragma mark - Actions
8794
8895- (void )send {
89- NSString *email = _emailField.text ;
96+ [self recoverEmail: _emailField.text];
97+ }
98+
99+ - (void )recoverEmail : (NSString *)email {
90100 if (![[self class ] isValidEmail: email]) {
91101 [self showAlertWithMessage: [FIRAuthUIStrings invalidEmailError ]];
92102 return ;
@@ -96,36 +106,37 @@ - (void)send {
96106
97107 [self .auth sendPasswordResetWithEmail: email
98108 completion: ^(NSError *_Nullable error) {
99- // The dispatch is a workaround for a bug in FirebaseAuth 3.0.2, which doesn't call the
100- // completion block on the main queue.
101- dispatch_async (dispatch_get_main_queue (), ^{
102- [self decrementActivity ];
103-
104- if (error) {
105- if (error.code == FIRAuthErrorCodeUserNotFound) {
106- [self showAlertWithMessage: [FIRAuthUIStrings userNotFoundError ]];
107- return ;
108- }
109-
110- [self .navigationController dismissViewControllerAnimated: YES completion: ^{
111- [self .authUI invokeResultCallbackWithUser: nil error: error];
112- }];
113- return ;
114- }
115-
116- NSString *message =
117- [NSString stringWithFormat: [FIRAuthUIStrings passwordRecoveryEmailSentMessage ], email];
118- [self showAlertWithMessage: message];
119- });
120- }];
109+ // The dispatch is a workaround for a bug in FirebaseAuth 3.0.2, which doesn't call the
110+ // completion block on the main queue.
111+ dispatch_async (dispatch_get_main_queue (), ^{
112+ [self decrementActivity ];
113+
114+ if (error) {
115+ if (error.code == FIRAuthErrorCodeUserNotFound) {
116+ [self showAlertWithMessage: [FIRAuthUIStrings userNotFoundError ]];
117+ return ;
118+ }
119+
120+ [self .navigationController dismissViewControllerAnimated: YES completion: ^{
121+ [self .authUI invokeResultCallbackWithUser: nil error: error];
122+ }];
123+ return ;
124+ }
125+
126+ NSString *message =
127+ [NSString stringWithFormat: [FIRAuthUIStrings passwordRecoveryEmailSentMessage ], email];
128+ [self showAlertWithMessage: message];
129+ });
130+ }];
121131}
122132
123133- (void )textFieldDidChange {
124- [self updateActionButton ];
134+ [self didChangeEmail: _emailField.text ];
125135}
126136
127- - (void )updateActionButton {
128- self.navigationItem .rightBarButtonItem .enabled = (_emailField.text .length > 0 );
137+ - (void )didChangeEmail : (NSString *)email {
138+ self.navigationItem .rightBarButtonItem .enabled = (email.length > 0 );
139+
129140}
130141
131142#pragma mark - UITableViewDataSource
@@ -153,7 +164,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView
153164 [cell.textField addTarget: self
154165 action: @selector (textFieldDidChange )
155166 forControlEvents: UIControlEventEditingChanged];
156- [self updateActionButton ];
167+ [self didChangeEmail: _emailField.text ];
157168 return cell;
158169}
159170
0 commit comments