Przeglądaj źródła

Breaking changes to OTT verification screens

Vishnu Mohandas 4 lat temu
rodzic
commit
739c69da22
2 zmienionych plików z 31 dodań i 8 usunięć
  1. 20 5
      lib/ui/email_entry_page.dart
  2. 11 3
      lib/ui/ott_verification_page.dart

+ 20 - 5
lib/ui/email_entry_page.dart

@@ -1,3 +1,5 @@
+import 'dart:developer';
+
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
@@ -5,14 +7,22 @@ import 'package:flutter_svg/svg.dart';
 import 'package:photos/user_authenticator.dart';
 
 class EmailEntryPage extends StatefulWidget {
-  EmailEntryPage({Key key}) : super(key: key);
+  final String email;
+
+  EmailEntryPage({this.email, Key key}) : super(key: key);
 
   @override
   _EmailEntryPageState createState() => _EmailEntryPageState();
 }
 
 class _EmailEntryPageState extends State<EmailEntryPage> {
-  final _emailController = TextEditingController();
+  String _email;
+
+  @override
+  void initState() {
+    _email = widget.email;
+    super.initState();
+  }
 
   @override
   Widget build(BuildContext context) {
@@ -40,18 +50,23 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
                 hintText: 'email@domain.com',
                 contentPadding: EdgeInsets.all(20),
               ),
-              controller: _emailController,
+              initialValue: widget.email == null ? "" : widget.email,
               autofocus: true,
               autocorrect: false,
               keyboardType: TextInputType.emailAddress,
+              onChanged: (email) {
+                log(email);
+                setState(() {
+                  _email = email;
+                });
+              },
             ),
             Padding(padding: EdgeInsets.all(8)),
             SizedBox(
                 width: double.infinity,
                 child: RaisedButton(
                   onPressed: () {
-                    UserAuthenticator.instance
-                        .getOtt(context, _emailController.text);
+                    UserAuthenticator.instance.getOtt(context, _email);
                   },
                   padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
                   child: Text("Sign In"),

+ 11 - 3
lib/ui/ott_verification_page.dart

@@ -3,6 +3,7 @@ import 'dart:ui';
 import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
 import 'package:flutter_svg/flutter_svg.dart';
+import 'package:photos/ui/email_entry_page.dart';
 import 'package:photos/user_authenticator.dart';
 
 class OTTVerificationPage extends StatefulWidget {
@@ -89,16 +90,23 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
                         },
                   padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
                   child: Text(
-                    "Sign In",
+                    "Verify",
                   ),
                   color: Colors.pink,
                   shape: RoundedRectangleBorder(
                     borderRadius: BorderRadius.circular(18.0),
                   ),
                 )),
+            Padding(padding: EdgeInsets.all(8)),
             TextButton(
                 onPressed: () {
-                  Navigator.of(context).pop();
+                  Navigator.of(context).push(
+                    MaterialPageRoute(
+                      builder: (BuildContext context) {
+                        return EmailEntryPage(email: widget.email);
+                      },
+                    ),
+                  );
                 },
                 child: Text(
                   "Did not get email?",
@@ -106,7 +114,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
                     decoration: TextDecoration.underline,
                     fontSize: 12,
                   ),
-                ))
+                )),
           ],
         ),
       ),