diff --git a/lib/ui/routes/reset_password_route.dart b/lib/ui/routes/reset_password_route.dart index 0946412..6eab5f8 100644 --- a/lib/ui/routes/reset_password_route.dart +++ b/lib/ui/routes/reset_password_route.dart @@ -19,10 +19,13 @@ class ResetPasswordRoute extends StatelessWidget { appBar: AppBar( title: Text(tr("Password forgotten")), ), - body: Center( - child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: 300), - child: SingleChildScrollView(child: _ResetPasswordBody()), + body: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: ConstrainedBox( + constraints: BoxConstraints(maxWidth: 300), + child: SingleChildScrollView(child: _ResetPasswordBody()), + ), ), ), ); @@ -59,6 +62,11 @@ class _ResetPasswordBodyState extends SafeState<_ResetPasswordBody> { List _questions; var _questionsControllers = List(); + List get _answers => + _questionsControllers.map((f) => f.text).toList(); + + bool get _canSubmitAnswers => _answers.every((f) => f.isNotEmpty); + @override Widget build(BuildContext context) { if (_loading) return buildCenteredProgressBar(); @@ -189,19 +197,30 @@ class _ResetPasswordBodyState extends SafeState<_ResetPasswordBody> { ..addAll(List.generate(_questions.length, _buildSecurityQuestionField)) ..add(_Spacer()) ..add(OutlineButton( - onPressed: null, + onPressed: _canSubmitAnswers ? _submitSecurityAnswers : null, child: Text(tr("Submit")), )), ); } - Widget _buildSecurityQuestionField(int id) => TextField( - controller: _questionsControllers[id], - decoration: InputDecoration( - alignLabelWithHint: true, - labelText: _questions[id], - ), + Widget _buildSecurityQuestionField(int id) => Column( + children: [ + Text(_questions[id]), + TextField( + controller: _questionsControllers[id], + onChanged: (s) => setState(() {}), + onSubmitted: + _canSubmitAnswers ? (s) => _submitSecurityAnswers() : null, + decoration: InputDecoration( + alignLabelWithHint: false, + labelText: tr("Answer %num%", args: {"num": id.toString()})), + ), + _Spacer() + ], ); + + /// Submit security answers + Future _submitSecurityAnswers() async {} } class _Spacer extends StatelessWidget {