Atualição da appbar | coreção de inserção de dados | outras optimizaçoes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
|
||||
import '../screens/video_screen.dart';
|
||||
@@ -65,6 +66,11 @@ class QuizQuestionScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _QuizQuestionScreenState extends State<QuizQuestionScreen> {
|
||||
// Uma criança não tem, na prática, mais do que ~20 dentes numa arcada
|
||||
// (dentição decídua + permanente em transição já é um caso extremo).
|
||||
// Serve para barrar valores absurdos como "400".
|
||||
static const int _maxTeethCount = 20;
|
||||
|
||||
int? _selected;
|
||||
TextEditingController? _numberController;
|
||||
int? _numberValue;
|
||||
@@ -89,7 +95,11 @@ class _QuizQuestionScreenState extends State<QuizQuestionScreen> {
|
||||
final size = MediaQuery.sizeOf(context);
|
||||
bool canProceed = _selected != null && !_navigating;
|
||||
if (widget.answerType == QuizAnswerType.number) {
|
||||
canProceed = _numberValue != null && _numberValue! >= 0 && !_navigating;
|
||||
canProceed =
|
||||
_numberValue != null &&
|
||||
_numberValue! >= 0 &&
|
||||
_numberValue! <= _maxTeethCount &&
|
||||
!_navigating;
|
||||
}
|
||||
|
||||
final bool hasSuggestedVideo =
|
||||
@@ -551,6 +561,10 @@ class _QuizQuestionScreenState extends State<QuizQuestionScreen> {
|
||||
controller: _numberController,
|
||||
keyboardType: TextInputType.number,
|
||||
textAlign: TextAlign.center,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
LengthLimitingTextInputFormatter(2),
|
||||
],
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w900,
|
||||
@@ -573,6 +587,18 @@ class _QuizQuestionScreenState extends State<QuizQuestionScreen> {
|
||||
},
|
||||
),
|
||||
),
|
||||
if (_numberValue != null && _numberValue! > _maxTeethCount) ...[
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
'Um número tão alto assim não é possível.\nO máximo é $_maxTeethCount.',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFFFF55A7),
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user