email_entry_page.dart 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/widgets.dart';
  4. import 'package:flutter_svg/svg.dart';
  5. import 'package:photos/user_authenticator.dart';
  6. class EmailEntryPage extends StatefulWidget {
  7. final String email;
  8. EmailEntryPage({this.email, Key key}) : super(key: key);
  9. @override
  10. _EmailEntryPageState createState() => _EmailEntryPageState();
  11. }
  12. class _EmailEntryPageState extends State<EmailEntryPage> {
  13. String _email;
  14. @override
  15. void initState() {
  16. _email = widget.email;
  17. super.initState();
  18. }
  19. @override
  20. Widget build(BuildContext context) {
  21. return Scaffold(
  22. appBar: AppBar(
  23. title: Text("Preserve Memories"),
  24. ),
  25. body: _getBody(),
  26. );
  27. }
  28. Widget _getBody() {
  29. return SingleChildScrollView(
  30. child: Container(
  31. padding: EdgeInsets.all(8),
  32. child: Column(
  33. children: [
  34. SvgPicture.asset(
  35. "assets/around_the_world.svg",
  36. width: 256,
  37. height: 256,
  38. ),
  39. TextFormField(
  40. decoration: InputDecoration(
  41. hintText: 'email@domain.com',
  42. contentPadding: EdgeInsets.all(20),
  43. ),
  44. initialValue: widget.email == null ? "" : widget.email,
  45. autofocus: true,
  46. autocorrect: false,
  47. keyboardType: TextInputType.emailAddress,
  48. onChanged: (email) {
  49. setState(() {
  50. _email = email;
  51. });
  52. },
  53. ),
  54. Padding(padding: EdgeInsets.all(8)),
  55. SizedBox(
  56. width: double.infinity,
  57. child: RaisedButton(
  58. onPressed: () {
  59. UserAuthenticator.instance.getOtt(context, _email);
  60. },
  61. padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
  62. child: Text("Sign In"),
  63. color: Theme.of(context).buttonColor,
  64. shape: RoundedRectangleBorder(
  65. borderRadius: BorderRadius.circular(18.0),
  66. ),
  67. )),
  68. ],
  69. ),
  70. ),
  71. );
  72. }
  73. }