mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Improve security questions form
This commit is contained in:
parent
e78d526bbb
commit
3ffb24f7c5
@ -19,12 +19,15 @@ class ResetPasswordRoute extends StatelessWidget {
|
||||
appBar: AppBar(
|
||||
title: Text(tr("Password forgotten")),
|
||||
),
|
||||
body: Center(
|
||||
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<String> _questions;
|
||||
var _questionsControllers = List<TextEditingController>();
|
||||
|
||||
List<String> 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(
|
||||
Widget _buildSecurityQuestionField(int id) => Column(
|
||||
children: <Widget>[
|
||||
Text(_questions[id]),
|
||||
TextField(
|
||||
controller: _questionsControllers[id],
|
||||
onChanged: (s) => setState(() {}),
|
||||
onSubmitted:
|
||||
_canSubmitAnswers ? (s) => _submitSecurityAnswers() : null,
|
||||
decoration: InputDecoration(
|
||||
alignLabelWithHint: true,
|
||||
labelText: _questions[id],
|
||||
alignLabelWithHint: false,
|
||||
labelText: tr("Answer %num%", args: {"num": id.toString()})),
|
||||
),
|
||||
_Spacer()
|
||||
],
|
||||
);
|
||||
|
||||
/// Submit security answers
|
||||
Future<void> _submitSecurityAnswers() async {}
|
||||
}
|
||||
|
||||
class _Spacer extends StatelessWidget {
|
||||
|
Loading…
Reference in New Issue
Block a user