forked from eatvio/eatvio_app
feat(consultant): diplomas and certificates
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DiplomaEntity {
|
||||
TextEditingController textEditingController;
|
||||
DateTime? date;
|
||||
bool enableDeleteButton;
|
||||
|
||||
DiplomaEntity({
|
||||
this.date,
|
||||
required this.textEditingController,
|
||||
required this.enableDeleteButton,
|
||||
});
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||
import 'package:eatvio_app/features/consultant/become_consultant/entities/diploma_entity.dart';
|
||||
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||
|
||||
class CertificatesAndDiplomasScreen extends StatefulWidget {
|
||||
const CertificatesAndDiplomasScreen({super.key});
|
||||
@@ -11,7 +12,13 @@ class CertificatesAndDiplomasScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CertificatesAndDiplomasScreenState extends State<CertificatesAndDiplomasScreen> {
|
||||
late DateTime selectedDate = DateTime.now();
|
||||
List<DiplomaEntity> diplomasList = [
|
||||
DiplomaEntity(
|
||||
textEditingController: TextEditingController(),
|
||||
enableDeleteButton: false,
|
||||
date: null,
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -30,30 +37,77 @@ class _CertificatesAndDiplomasScreenState extends State<CertificatesAndDiplomasS
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
CustomTextFormField(),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width - 92,
|
||||
child: ListTile(
|
||||
onTap: onTapCalendar(context),
|
||||
trailing: Icon(
|
||||
Icons.keyboard_arrow_down_rounded,
|
||||
color: Colors.grey.shade700,
|
||||
),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 12),
|
||||
title: Text(selectedDate.format('dd MMMM yyyy', 'ru')),
|
||||
tileColor: Color(0xFFF6F6F6),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
ListView.separated(
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (context, index) => _diplomaInfo(diploma: diplomasList[index]),
|
||||
separatorBuilder: (context, index) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: _divider(context),
|
||||
),
|
||||
itemCount: diplomasList.length,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_divider(BuildContext context) {
|
||||
return Container(
|
||||
height: 0.4,
|
||||
width: MediaQuery.of(context).size.width - 32,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black26,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_diplomaInfo({
|
||||
required DiplomaEntity diploma,
|
||||
}) {
|
||||
return Column(
|
||||
children: [
|
||||
CustomTextFormField(
|
||||
controller: diploma.textEditingController,
|
||||
onChanged: (value) {
|
||||
checkLast();
|
||||
enableDeleteButton(diploma);
|
||||
},
|
||||
hintText: 'Наименование',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width - (diploma.enableDeleteButton ? 92 : 32),
|
||||
child: ListTile(
|
||||
onTap: onTapCalendar(context, diploma),
|
||||
trailing: Icon(
|
||||
Icons.keyboard_arrow_down_rounded,
|
||||
color: Colors.grey.shade700,
|
||||
),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 12),
|
||||
title: Text(
|
||||
diploma.date?.format('dd MMMM yyyy', 'ru') ?? 'Дата выдачи',
|
||||
style: TextStyle(
|
||||
color: diploma.date == null ? Colors.grey.shade400 : Colors.black,
|
||||
),
|
||||
),
|
||||
tileColor: Color(0xFFF6F6F6),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
),
|
||||
if (diploma.enableDeleteButton) const SizedBox(width: 8),
|
||||
if (diploma.enableDeleteButton)
|
||||
InkWell(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
setState(() {
|
||||
diplomasList.remove(diploma);
|
||||
});
|
||||
},
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Ink(
|
||||
height: 52,
|
||||
@@ -67,25 +121,26 @@ class _CertificatesAndDiplomasScreenState extends State<CertificatesAndDiplomasS
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
onTapCalendar(BuildContext context) {
|
||||
onTapCalendar(BuildContext context, DiplomaEntity diploma) {
|
||||
return () {
|
||||
_showDialog(
|
||||
CupertinoDatePicker(
|
||||
initialDateTime: selectedDate,
|
||||
initialDateTime: DateTime.now(),
|
||||
maximumDate: DateTime.now(),
|
||||
minimumDate: DateTime(1900),
|
||||
mode: CupertinoDatePickerMode.date,
|
||||
onDateTimeChanged: (DateTime newDateTime) {
|
||||
setState(() {
|
||||
selectedDate = newDateTime;
|
||||
diplomasList[diplomasList.indexOf(diploma)].date = newDateTime;
|
||||
});
|
||||
checkLast();
|
||||
enableDeleteButton(diploma);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -109,4 +164,26 @@ class _CertificatesAndDiplomasScreenState extends State<CertificatesAndDiplomasS
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
checkLast() {
|
||||
if (diplomasList.last.textEditingController.text.isNotEmpty || diplomasList.last.date != null) {
|
||||
setState(() {
|
||||
diplomasList.add(
|
||||
DiplomaEntity(
|
||||
textEditingController: TextEditingController(),
|
||||
enableDeleteButton: false,
|
||||
date: null,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
enableDeleteButton(DiplomaEntity diploma) {
|
||||
if (diploma.textEditingController.text.isNotEmpty || diploma.date != null) {
|
||||
setState(() {
|
||||
diplomasList[diplomasList.indexOf(diploma)].enableDeleteButton = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user