ott_verification_page.dart 3.7 KB

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