forked from eatvio/eatvio_app
feat(diary): Refresh on screen scroll
This commit is contained in:
@@ -65,6 +65,7 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
},
|
||||
);
|
||||
final diary = jsonDecode(response.body)['diary'];
|
||||
print(diary);
|
||||
if (diary is Map<String, dynamic>) {
|
||||
final String diaryDate =
|
||||
diary['date'] ?? DateTime.now().toString();
|
||||
@@ -500,7 +501,9 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
|
||||
final updatedState = currentState.copyWith(portions: updatedPortions);
|
||||
|
||||
emit(updatedState); // Emit the updated state
|
||||
await _onInitialize(
|
||||
DiaryEditInitialEvent(), emit); // Emit the updated state
|
||||
emit(updatedState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,17 +15,17 @@ import 'package:eatvio_app/widgets/custom_scale_element.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class DiaryEditScreen extends StatelessWidget {
|
||||
DiaryEditScreen({Key? key})
|
||||
: super(
|
||||
key: key,
|
||||
);
|
||||
final void Function() onInitialize;
|
||||
DiaryEditScreen({Key? key, required this.onInitialize}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<DiaryEditBloc>(
|
||||
create: (context) =>
|
||||
DiaryEditBloc(DiaryEditState(diaryEditModelObj: DiaryEditModel()))
|
||||
..add(DiaryEditInitialEvent()),
|
||||
child: DiaryEditScreen());
|
||||
child: DiaryEditScreen(
|
||||
onInitialize: () {},
|
||||
));
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
@@ -54,43 +54,45 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
Widget _buildDiaryEditScreen(
|
||||
BuildContext context, DiaryEditLoadedState state) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return FormBuilder(
|
||||
child: SafeArea(
|
||||
child: Scaffold(
|
||||
backgroundColor: Color.fromARGB(255, 240, 242, 245),
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 5.v),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildHeaderRow(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
_buildWakupRetire(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
_buildMeal(context, state),
|
||||
SizedBox(height: 20.v),
|
||||
_buildMood(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
_buildNutritionChart(context),
|
||||
SizedBox(height: 30.v),
|
||||
_buildComment(context, state),
|
||||
],
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {},
|
||||
child: FormBuilder(
|
||||
child: SafeArea(
|
||||
child: Scaffold(
|
||||
backgroundColor: Color.fromARGB(255, 240, 242, 245),
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(bottom: 5.v),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildHeaderRow(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
_buildWakupRetire(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
_buildMeal(context, state),
|
||||
SizedBox(height: 20.v),
|
||||
_buildMood(context, state),
|
||||
SizedBox(height: 30.v),
|
||||
_buildNutritionChart(context),
|
||||
SizedBox(height: 30.v),
|
||||
_buildComment(context, state),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: _buildEndDay(context),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: _buildEndDay(context),
|
||||
),
|
||||
));
|
||||
)));
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
|
||||
Reference in New Issue
Block a user