forked from eatvio/eatvio_app
refactor(diary) Added more layouts and constrollers
This commit is contained in:
@@ -1,99 +0,0 @@
|
||||
import 'package:eatvio_app/presentation/diary/diary_edit_screen/bloc/diary_edit_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
|
||||
class ExpandableList extends StatefulWidget {
|
||||
final String title;
|
||||
|
||||
ExpandableList(this.title);
|
||||
@override
|
||||
_ExpandableListState createState() => _ExpandableListState();
|
||||
}
|
||||
|
||||
class _ExpandableListState extends State<ExpandableList> {
|
||||
bool isExpanded = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<DiaryEditBloc, DiaryEditState>(
|
||||
builder: (context, state) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.h,
|
||||
vertical: 12.v,
|
||||
),
|
||||
decoration: AppDecoration.outlinePrimary.copyWith(
|
||||
borderRadius: BorderRadiusStyle.roundedBorder12,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isExpanded = !isExpanded;
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.title,
|
||||
style: CustomTextStyles.bodyMediumBlack900,
|
||||
),
|
||||
Icon(isExpanded
|
||||
? Icons.arrow_drop_up
|
||||
: Icons.arrow_drop_down),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (isExpanded)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => _selectTime(context),
|
||||
child: AbsorbPointer(
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Во сколько вы просунились?',
|
||||
suffixIcon: Icon(Icons.access_time),
|
||||
),
|
||||
initialValue:
|
||||
'${TimeOfDay.now().hour}:${TimeOfDay.now().minute.toString().padLeft(2, '0')}',
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () => _selectTime(context),
|
||||
child: AbsorbPointer(
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: 'о сколько вы легли спать?',
|
||||
suffixIcon: Icon(Icons.access_time),
|
||||
),
|
||||
initialValue:
|
||||
'${TimeOfDay.now().hour}:${TimeOfDay.now().minute.toString().padLeft(2, '0')}',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _selectTime(
|
||||
BuildContext context, DiaryEditLoadedState state) async {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: state.wakeupController ?? TimeOfDay.now(),
|
||||
);
|
||||
if (pickedTime != null && pickedTime != state.wakeupController) {
|
||||
setState(() {
|
||||
state.wakeupController = pickedTime;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user