ente/lib/ui/ott_verification_page.dart

118 lines
3.8 KiB
Dart
Raw Normal View History

2020-08-25 06:00:19 +00:00
import 'dart:ui';
2020-08-25 05:51:56 +00:00
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
2020-08-25 23:02:43 +00:00
import 'package:photos/core/configuration.dart';
2020-10-24 21:07:12 +00:00
import 'package:photos/ui/common_elements.dart';
import 'package:photos/ui/email_entry_page.dart';
2020-10-03 17:56:18 +00:00
import 'package:photos/services/user_service.dart';
2020-08-25 05:51:56 +00:00
class OTTVerificationPage extends StatefulWidget {
2020-08-25 23:02:43 +00:00
OTTVerificationPage({Key key}) : super(key: key);
2020-08-25 05:51:56 +00:00
@override
_OTTVerificationPageState createState() => _OTTVerificationPageState();
}
class _OTTVerificationPageState extends State<OTTVerificationPage> {
final _verificationCodeController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Verify Email"),
),
body: _getBody(),
);
}
Widget _getBody() {
return SingleChildScrollView(
child: Container(
2020-08-25 22:39:11 +00:00
padding: EdgeInsets.fromLTRB(8, 40, 8, 8),
2020-08-25 05:51:56 +00:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
2020-08-25 06:00:19 +00:00
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
2020-08-25 05:51:56 +00:00
children: [
Image.asset(
"assets/email_sent.png",
2020-08-25 05:51:56 +00:00
width: 256,
height: 256,
),
Padding(padding: EdgeInsets.all(12)),
Text.rich(
TextSpan(
style: TextStyle(fontSize: 18),
children: <TextSpan>[
2020-08-25 06:00:19 +00:00
TextSpan(text: "We've sent a mail to "),
2020-08-25 05:51:56 +00:00
TextSpan(
2020-08-25 23:02:43 +00:00
text: Configuration.instance.getEmail(),
2020-08-25 05:51:56 +00:00
style: TextStyle(
2020-08-25 06:00:19 +00:00
color: Theme.of(context).accentColor,
2020-08-25 05:51:56 +00:00
)),
2020-08-25 06:00:19 +00:00
TextSpan(text: "."),
2020-08-25 05:51:56 +00:00
],
),
textAlign: TextAlign.center,
),
Padding(padding: EdgeInsets.all(12)),
Text(
2020-08-25 06:00:19 +00:00
"Please check your inbox (and spam) to complete verification.",
2020-08-25 05:51:56 +00:00
textAlign: TextAlign.center,
),
Padding(padding: EdgeInsets.all(12)),
TextFormField(
decoration: InputDecoration(
hintText: 'Tap to enter verification code',
contentPadding: EdgeInsets.all(20),
),
controller: _verificationCodeController,
2020-08-25 06:00:19 +00:00
autofocus: false,
2020-08-25 05:51:56 +00:00
autocorrect: false,
keyboardType: TextInputType.visiblePassword,
textAlign: TextAlign.center,
2020-08-25 06:00:19 +00:00
onChanged: (_) {
setState(() {});
},
2020-08-25 05:51:56 +00:00
),
2020-08-25 06:00:19 +00:00
Padding(padding: EdgeInsets.all(8)),
2020-10-24 21:07:12 +00:00
Container(
2020-08-25 06:00:19 +00:00
width: double.infinity,
2020-10-24 21:07:12 +00:00
height: 44,
child: button(
"Verify",
2020-08-25 06:00:19 +00:00
onPressed: _verificationCodeController.text == null ||
_verificationCodeController.text.isEmpty
? null
: () {
2020-10-03 17:56:18 +00:00
UserService.instance.getCredentials(
2020-08-25 23:02:43 +00:00
context, _verificationCodeController.text);
2020-08-25 06:00:19 +00:00
},
)),
Padding(padding: EdgeInsets.all(8)),
FlatButton(
2020-08-25 06:00:19 +00:00
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
2020-08-25 23:02:43 +00:00
return EmailEntryPage();
},
),
);
2020-08-25 06:00:19 +00:00
},
child: Text(
"Did not get email?",
style: TextStyle(
decoration: TextDecoration.underline,
fontSize: 12,
),
)),
2020-08-25 05:51:56 +00:00
],
),
),
);
}
}