feat(diary): timer picker

This commit is contained in:
mso7nueh
2024-11-11 17:14:18 +03:00
parent cbc596cc45
commit 9af7ad09cd
2 changed files with 94 additions and 8 deletions

View File

@@ -37,6 +37,59 @@ class _DiaryScreenState extends State<DiaryScreen> {
final productNameController = TextEditingController();
final quantityController = TextEditingController();
int currentSelectedPhotoIndex = 0;
String time = "${DateTime.now().hour.toString().padLeft(2, '0')} : ${DateTime.now().minute.toString().padLeft(2, '0')}";
DateTime _time = DateTime.now();
_showDatePicker() {
showModalBottomSheet<void>(
context: context,
useRootNavigator: true,
builder: (context) => SizedBox(
height: MediaQuery.of(context).copyWith().size.height / 3,
child: Column(
children: [
Expanded(
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.time,
use24hFormat: true,
initialDateTime: DateTime.now(),
onDateTimeChanged: (newTime) {
setState(() {
_time = newTime;
time = "${_time.hour.toString().padLeft(2, '0')} : ${_time.minute.toString().padLeft(2, '0')}";
});
},
),
),
InkWell(
onTap: () {
Navigator.of(context).pop();
},
borderRadius: BorderRadius.circular(20),
child: Ink(
width: MediaQuery.of(context).size.width - 16,
height: 52,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: appTheme.blueA400,
),
child: Center(
child: Text(
'Сохранить',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
),
),
),
],
),
),
);
}
@override
Widget build(BuildContext context) {
@@ -78,6 +131,31 @@ class _DiaryScreenState extends State<DiaryScreen> {
);
}
_timeOfMeal(String time) {
return InkWell(
onTap: () => _showDatePicker(),
borderRadius: BorderRadius.circular(100),
child: Ink(
width: MediaQuery.of(context).size.width / 5,
height: 32,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: Color(0xFFF1F2F6),
),
child: Center(
child: Text(
time,
style: TextStyle(
color: Color(0xFF6D6F71),
fontSize: 17,
fontWeight: FontWeight.w500,
),
),
),
),
);
}
_arrowDown() {
return GestureDetector(
behavior: HitTestBehavior.translucent,
@@ -180,13 +258,19 @@ class _DiaryScreenState extends State<DiaryScreen> {
const SizedBox(height: 12),
_divider(context),
const SizedBox(height: 12),
Text(
'Время приема пищи',
style: TextStyle(
color: Color(0xFF323F4B),
fontSize: 16,
fontWeight: FontWeight.w500,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Время приема пищи',
style: TextStyle(
color: Color(0xFF323F4B),
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
_timeOfMeal(time),
],
),
const SizedBox(height: 12),
_divider(context),
@@ -634,7 +718,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
child: Text(
'$mealNumber',
style: TextStyle(
color: isActive ? Colors.white : Colors.black,
color: isActive ? Colors.white : Color(0xFF6D6F71),
fontSize: 16,
fontWeight: FontWeight.w600,
),

View File

@@ -51,6 +51,8 @@ dependencies:
rive: ^0.13.15
mask_text_input_formatter: ^2.9.0
lottie: ^3.1.3
flutter_portal: ^1.1.4
fluttertoast: ^8.2.8
flutter_rating_bar: ^4.0.1
dev_dependencies: