ott_verification_page.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import 'dart:ui';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/widgets.dart';
  4. import 'package:photos/core/configuration.dart';
  5. import 'package:photos/ui/common_elements.dart';
  6. import 'package:photos/services/user_service.dart';
  7. class OTTVerificationPage extends StatefulWidget {
  8. OTTVerificationPage({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 Center(
  25. child: SingleChildScrollView(
  26. child: Container(
  27. padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
  28. child: Column(
  29. crossAxisAlignment: CrossAxisAlignment.center,
  30. mainAxisSize: MainAxisSize.max,
  31. mainAxisAlignment: MainAxisAlignment.center,
  32. children: [
  33. Text(
  34. "we've sent a mail to",
  35. style: TextStyle(fontSize: 18),
  36. ),
  37. Padding(padding: EdgeInsets.all(2)),
  38. Text(
  39. Configuration.instance.getEmail(),
  40. style: TextStyle(
  41. color: Theme.of(context).accentColor,
  42. fontSize: 18,
  43. ),
  44. ),
  45. Padding(
  46. padding: const EdgeInsets.all(32),
  47. child: Text(
  48. "please check your inbox (and spam) to complete verification.",
  49. textAlign: TextAlign.center,
  50. style: TextStyle(fontSize: 12),
  51. ),
  52. ),
  53. Padding(
  54. padding: const EdgeInsets.fromLTRB(60, 0, 60, 32),
  55. child: TextFormField(
  56. decoration: InputDecoration(
  57. hintText: 'tap to enter code',
  58. contentPadding: EdgeInsets.all(12),
  59. ),
  60. controller: _verificationCodeController,
  61. autofocus: false,
  62. autocorrect: false,
  63. keyboardType: TextInputType.visiblePassword,
  64. textAlign: TextAlign.center,
  65. onChanged: (_) {
  66. setState(() {});
  67. },
  68. ),
  69. ),
  70. Container(
  71. padding: const EdgeInsets.fromLTRB(60, 0, 60, 0),
  72. width: double.infinity,
  73. height: 64,
  74. child: button(
  75. "verify",
  76. onPressed: _verificationCodeController.text == null ||
  77. _verificationCodeController.text.isEmpty
  78. ? null
  79. : () {
  80. UserService.instance.getCredentials(
  81. context, _verificationCodeController.text);
  82. },
  83. fontSize: 18,
  84. ),
  85. ),
  86. Padding(padding: EdgeInsets.all(8)),
  87. FlatButton(
  88. onPressed: () {
  89. Navigator.of(context).pop();
  90. },
  91. child: Text(
  92. "did not get email?",
  93. style: TextStyle(
  94. decoration: TextDecoration.underline,
  95. fontSize: 12,
  96. ),
  97. )),
  98. ],
  99. ),
  100. ),
  101. ),
  102. );
  103. }
  104. }