Add 24 hour validation
This commit is contained in:
parent
1aab95869c
commit
39ae338fae
|
@ -4,8 +4,7 @@ import 'package:hub/components/templates_components/provisional_schedule_templat
|
||||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
import 'package:hub/shared/utils/storage_util.dart';
|
import 'package:hub/shared/utils/storage_util.dart';
|
||||||
|
|
||||||
class ScheduleProvisionalVisitPageModel
|
class ScheduleProvisionalVisitPageModel extends FlutterFlowModel<ScheduleProvisionalVisitPageWidget> {
|
||||||
extends FlutterFlowModel<ScheduleProvisionalVisitPageWidget> {
|
|
||||||
String cliUUID = '';
|
String cliUUID = '';
|
||||||
String devUUID = '';
|
String devUUID = '';
|
||||||
String userUUID = '';
|
String userUUID = '';
|
||||||
|
@ -19,25 +18,21 @@ class ScheduleProvisionalVisitPageModel
|
||||||
void addToVisitors(dynamic item) => visitors.add(item);
|
void addToVisitors(dynamic item) => visitors.add(item);
|
||||||
void removeFromVisitors(dynamic item) => visitors.remove(item);
|
void removeFromVisitors(dynamic item) => visitors.remove(item);
|
||||||
void removeAtIndexFromVisitors(int index) => visitors.removeAt(index);
|
void removeAtIndexFromVisitors(int index) => visitors.removeAt(index);
|
||||||
void insertAtIndexInVisitors(int index, dynamic item) =>
|
void insertAtIndexInVisitors(int index, dynamic item) => visitors.insert(index, item);
|
||||||
visitors.insert(index, item);
|
void updateVisitorsAtIndex(int index, Function(dynamic) updateFn) => visitors[index] = updateFn(visitors[index]);
|
||||||
void updateVisitorsAtIndex(int index, Function(dynamic) updateFn) =>
|
|
||||||
visitors[index] = updateFn(visitors[index]);
|
|
||||||
|
|
||||||
List<String> docs = [];
|
List<String> docs = [];
|
||||||
void addToDocs(String item) => docs.add(item);
|
void addToDocs(String item) => docs.add(item);
|
||||||
void removeFromDocs(String item) => docs.remove(item);
|
void removeFromDocs(String item) => docs.remove(item);
|
||||||
void removeAtIndexFromDocs(int index) => docs.removeAt(index);
|
void removeAtIndexFromDocs(int index) => docs.removeAt(index);
|
||||||
void insertAtIndexInDocs(int index, String item) => docs.insert(index, item);
|
void insertAtIndexInDocs(int index, String item) => docs.insert(index, item);
|
||||||
void updateDocsAtIndex(int index, Function(String) updateFn) =>
|
void updateDocsAtIndex(int index, Function(String) updateFn) => docs[index] = updateFn(docs[index]);
|
||||||
docs[index] = updateFn(docs[index]);
|
|
||||||
|
|
||||||
final formKey = GlobalKey<FormState>();
|
final formKey = GlobalKey<FormState>();
|
||||||
FocusNode? personNameFocusNode;
|
FocusNode? personNameFocusNode;
|
||||||
TextEditingController? personNameTextController;
|
TextEditingController? personNameTextController;
|
||||||
String? Function(BuildContext, String?)? personNameTextControllerValidator;
|
String? Function(BuildContext, String?)? personNameTextControllerValidator;
|
||||||
String? _personNameTextControllerValidator(
|
String? _personNameTextControllerValidator(BuildContext context, String? val) {
|
||||||
BuildContext context, String? val) {
|
|
||||||
if (val == null || val.isEmpty) {
|
if (val == null || val.isEmpty) {
|
||||||
return FFLocalizations.of(context).getText(
|
return FFLocalizations.of(context).getText(
|
||||||
'3hqg8buh',
|
'3hqg8buh',
|
||||||
|
@ -64,7 +59,7 @@ class ScheduleProvisionalVisitPageModel
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime selectedDateTime;
|
DateTime selectedDateTime;
|
||||||
DateTime currentDateTime = DateTime.now();
|
DateTime currentDateTime = DateTime.now().add(const Duration(hours: 24));
|
||||||
selectedDateTime = DateFormat('dd/MM/yyyy HH:mm:ss').parse(val);
|
selectedDateTime = DateFormat('dd/MM/yyyy HH:mm:ss').parse(val);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -102,6 +97,9 @@ class ScheduleProvisionalVisitPageModel
|
||||||
|
|
||||||
dateTimeTextController ??= TextEditingController();
|
dateTimeTextController ??= TextEditingController();
|
||||||
dateTimeFocusNode ??= FocusNode();
|
dateTimeFocusNode ??= FocusNode();
|
||||||
|
dateTimeTextController.text = DateFormat('dd/MM/yyyy HH:mm:ss').format(
|
||||||
|
DateTime.now().add(const Duration(hours: 24)),
|
||||||
|
);
|
||||||
|
|
||||||
notesTextController ??= TextEditingController();
|
notesTextController ??= TextEditingController();
|
||||||
notesFocusNode ??= FocusNode();
|
notesFocusNode ??= FocusNode();
|
||||||
|
@ -110,8 +108,7 @@ class ScheduleProvisionalVisitPageModel
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFormValid() {
|
bool isFormValid() {
|
||||||
if (personNameTextController.text == '' ||
|
if (personNameTextController.text == '' || personNameTextController.text.length > 80) {
|
||||||
personNameTextController.text.length > 80) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,13 +117,11 @@ class ScheduleProvisionalVisitPageModel
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime selectedDateTime;
|
DateTime selectedDateTime;
|
||||||
DateTime currentDateTime = DateTime.now();
|
DateTime currentDateTime = DateTime.now().add(const Duration(hours: 24));
|
||||||
selectedDateTime =
|
selectedDateTime = DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text);
|
||||||
DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
selectedDateTime =
|
selectedDateTime = DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text);
|
||||||
DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue