ott_verification_page.dart 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import 'dart:ui';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/widgets.dart';
  4. import 'package:flutter_svg/flutter_svg.dart';
  5. import 'package:photos/ui/email_entry_page.dart';
  6. import 'package:photos/user_authenticator.dart';
  7. class OTTVerificationPage extends StatefulWidget {
  8. final String email;
  9. OTTVerificationPage(this.email, {Key key}) : super(key: key);
  10. @override
  11. _OTTVerificationPageState createState() => _OTTVerificationPageState();
  12. }
  13. class _OTTVerificationPageState extends State<OTTVerificationPage> {
  14. final _verificationCodeController = TextEditingController();
  15. @override
  16. Widget build(BuildContext context) {
  17. return Scaffold(
  18. appBar: AppBar(
  19. title: Text("Verify Email"),
  20. ),
  21. body: _getBody(),
  22. );
  23. }
  24. Widget _getBody() {
  25. return SingleChildScrollView(
  26. child: Container(
  27. padding: EdgeInsets.fromLTRB(8, 40, 8, 8),
  28. child: Column(
  29. crossAxisAlignment: CrossAxisAlignment.center,
  30. mainAxisSize: MainAxisSize.max,
  31. mainAxisAlignment: MainAxisAlignment.end,
  32. children: [
  33. SvgPicture.asset(
  34. "assets/email_sent.svg",
  35. width: 256,
  36. height: 256,
  37. ),
  38. Padding(padding: EdgeInsets.all(12)),
  39. Text.rich(
  40. TextSpan(
  41. style: TextStyle(fontSize: 18),
  42. children: <TextSpan>[
  43. TextSpan(text: "We've sent a mail to "),
  44. TextSpan(
  45. text: widget.email,
  46. style: TextStyle(
  47. color: Theme.of(context).accentColor,
  48. )),
  49. TextSpan(text: "."),
  50. ],
  51. ),
  52. textAlign: TextAlign.center,
  53. ),
  54. Padding(padding: EdgeInsets.all(12)),
  55. Text(
  56. "Please check your inbox (and spam) to complete verification.",
  57. textAlign: TextAlign.center,
  58. ),
  59. Padding(padding: EdgeInsets.all(12)),
  60. TextFormField(
  61. decoration: InputDecoration(
  62. hintText: 'Tap to enter verification code',
  63. contentPadding: EdgeInsets.all(20),
  64. ),
  65. controller: _verificationCodeController,
  66. autofocus: false,
  67. autocorrect: false,
  68. keyboardType: TextInputType.visiblePassword,
  69. textAlign: TextAlign.center,
  70. onChanged: (_) {
  71. setState(() {});
  72. },
  73. ),
  74. Padding(padding: EdgeInsets.all(8)),
  75. SizedBox(
  76. width: double.infinity,
  77. child: RaisedButton(
  78. onPressed: _verificationCodeController.text == null ||
  79. _verificationCodeController.text.isEmpty
  80. ? null
  81. : () {
  82. UserAuthenticator.instance.getCredentials(context,
  83. widget.email, _verificationCodeController.text);
  84. },
  85. padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
  86. child: Text(
  87. "Verify",
  88. ),
  89. color: Colors.pink,
  90. shape: RoundedRectangleBorder(
  91. borderRadius: BorderRadius.circular(18.0),
  92. ),
  93. )),
  94. Padding(padding: EdgeInsets.all(8)),
  95. TextButton(
  96. onPressed: () {
  97. Navigator.of(context).push(
  98. MaterialPageRoute(
  99. builder: (BuildContext context) {
  100. return EmailEntryPage(email: widget.email);
  101. },
  102. ),
  103. );
  104. },
  105. child: Text(
  106. "Did not get email?",
  107. style: TextStyle(
  108. decoration: TextDecoration.underline,
  109. fontSize: 12,
  110. ),
  111. )),
  112. ],
  113. ),
  114. ),
  115. );
  116. }
  117. }