diff --git a/lib/ui/email_entry_page.dart b/lib/ui/email_entry_page.dart index 5b5f30c4f..bad4fc500 100644 --- a/lib/ui/email_entry_page.dart +++ b/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 { - 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 { 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"), diff --git a/lib/ui/ott_verification_page.dart b/lib/ui/ott_verification_page.dart index 5f65babeb..f42765eb1 100644 --- a/lib/ui/ott_verification_page.dart +++ b/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 { }, 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 { decoration: TextDecoration.underline, fontSize: 12, ), - )) + )), ], ), ),