feat(profile): subscribers and subscriptions

This commit is contained in:
mso7nueh
2024-11-22 15:27:51 +03:00
parent f805505cb3
commit c909c75d47
45 changed files with 2790 additions and 451 deletions

View File

@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
import 'package:eatvio_app/features/diary/models/nutrition_model.dart';
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
@@ -18,7 +19,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:image_picker/image_picker.dart';
import 'package:rive/rive.dart';
import 'package:syncfusion_flutter_gauges/gauges.dart';
import 'package:table_calendar/table_calendar.dart';
@@ -42,7 +42,6 @@ class _DiaryScreenState extends State<DiaryScreen> {
int currentSelectedPhotoIndex = 0;
String time = "${DateTime.now().hour.toString().padLeft(2, '0')}:${DateTime.now().minute.toString().padLeft(2, '0')}";
DateTime _time = DateTime.now();
bool enableQuantity = false;
@override
void initState() {
@@ -124,7 +123,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
child: Column(
children: [
_calendar(state),
if (state is DiaryStateLoading) _loader(),
if (state is DiaryStateLoading) const Loader(),
if (state is DiaryStateLoaded)
_meals(
state.diary,
@@ -249,7 +248,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
_meals(
DiaryDayModel diaryDay,
double currentSelectedSatietyRating,
List<int> satietyRating,
) {
return Material(
borderRadius: BorderRadius.circular(20),
@@ -322,7 +321,9 @@ class _DiaryScreenState extends State<DiaryScreen> {
_selectedDay!.compareTo(today!) == 1
? const SizedBox.shrink()
: SatietyRatingWidget(
currentSelectedSatietyRating: currentSelectedSatietyRating,
currentSelectedSatietyRating: satietyRating,
diaryId: diaryDay.id,
meal: currentSelectedMealNumber,
),
],
),
@@ -767,18 +768,6 @@ class _DiaryScreenState extends State<DiaryScreen> {
);
}
_loader() {
return Center(
child: SizedBox(
height: 32,
width: 32,
child: RiveAnimation.asset(
'assets/rive_animations/loading.riv',
),
),
);
}
_calendar(DiaryState state) {
return Column(
mainAxisSize: MainAxisSize.min,
@@ -883,76 +872,74 @@ class _DiaryScreenState extends State<DiaryScreen> {
),
),
const SizedBox(height: 16),
TypeAheadField(
controller: productNameController,
itemBuilder: (context, glossary) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
glossary.name,
style: TextStyle(
height: 1,
fontSize: 16,
Row(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.8 - 32,
child: TypeAheadField(
controller: productNameController,
itemBuilder: (context, glossary) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
glossary.name,
style: TextStyle(
height: 1,
fontSize: 16,
),
),
);
},
itemSeparatorBuilder: (context, index) => _divider(context),
onSelected: (newSelectedGlossary) async {
setState(() {
selectedGlossary = newSelectedGlossary;
productNameController.text = selectedGlossary!.name;
});
},
suggestionsCallback: (query) async {
if (query.length < 1) return [];
final suggestionsList = await diaryCubit.getGlossaryListByQuery(query);
return suggestionsList;
},
builder: (context, controller, focusNode) {
return CustomTextFormField(
controller: controller,
autofocus: true,
focusNode: focusNode,
hintText: 'Введите название продукта/блюда',
);
},
emptyBuilder: (context) {
return const SizedBox.shrink();
},
errorBuilder: (context, object) => Padding(
padding: const EdgeInsets.all(8.0),
child: Text('Нет подходящих вариантов'),
),
),
);
},
itemSeparatorBuilder: (context, index) => _divider(context),
onSelected: (newSelectedGlossary) async {
setState(() {
selectedGlossary = newSelectedGlossary;
productNameController.text = selectedGlossary!.name;
});
},
suggestionsCallback: (query) async {
if (query.length < 1) return [];
final suggestionsList = await diaryCubit.getGlossaryListByQuery(query);
if (suggestionsList.length == 1) {
setState(() {
selectedGlossary = suggestionsList.first;
});
}
if (suggestionsList.length == 0) {
setState(() {
enableQuantity = true;
});
}
return suggestionsList;
},
builder: (context, controller, focusNode) {
return CustomTextFormField(
controller: controller,
autofocus: true,
focusNode: focusNode,
hintText: 'Введите название продукта/блюда',
);
},
emptyBuilder: (context) {
return const SizedBox.shrink();
},
errorBuilder: (context, object) => Padding(
padding: const EdgeInsets.all(8.0),
child: Text('Нет подходящих вариантов'),
),
),
if (selectedGlossary != null || enableQuantity)
Padding(
padding: const EdgeInsets.only(top: 8),
child: CustomTextFormField(
controller: quantityController,
keyboardType: TextInputType.number,
hintText: selectedGlossary == null
? '100'
: selectedGlossary!.grInPortion == 0
? '100'
: '1',
suffixText: selectedGlossary == null
? 'гр'
: selectedGlossary?.grInPortion == 0
? 'гр'
: 'шт',
),
),
const SizedBox(width: 4),
SizedBox(
width: MediaQuery.of(context).size.width * 0.2 - 4,
child: CustomTextFormField(
controller: quantityController,
keyboardType: TextInputType.number,
hintText: selectedGlossary == null
? '100'
: selectedGlossary!.grInPortion == 0
? '100'
: '1',
suffixText: selectedGlossary == null
? 'гр'
: selectedGlossary?.grInPortion == 0
? 'гр'
: 'шт',
),
),
],
),
const SizedBox(height: 16),
Row(
children: [
@@ -1013,7 +1000,7 @@ class _DiaryScreenState extends State<DiaryScreen> {
);
}
Navigator.of(context).pop();
if (enableQuantity) {
if (selectedGlossary == null) {
showModalBottomSheet(
isScrollControlled: true,
useRootNavigator: true,
@@ -1029,9 +1016,6 @@ class _DiaryScreenState extends State<DiaryScreen> {
),
);
}
setState(() {
enableQuantity = false;
});
},
borderRadius: BorderRadius.circular(20),
child: Ink(
@@ -1070,7 +1054,6 @@ class _DiaryScreenState extends State<DiaryScreen> {
onTap: () {
setState(() {
selectedGlossary = null;
enableQuantity = false;
productNameController.clear();
quantityController.clear();
});