refactor(diary): Compiled version apk: profile, settings, diarym registration, auth, navigation bar

This commit is contained in:
2024-04-10 17:07:56 +03:00
parent f4ddb7285c
commit bbbc20a15a
11 changed files with 164 additions and 133 deletions

View File

@@ -86,6 +86,7 @@ class UserRegistrationSheet {
'favorite_foods': favoriteFoods, 'favorite_foods': favoriteFoods,
'unfavorite_foods': unfavoriteFoods, 'unfavorite_foods': unfavoriteFoods,
'additional_info': additionalInfo, 'additional_info': additionalInfo,
'activity_coefficient': '1.2',
}; };
} }
} }

View File

@@ -65,7 +65,7 @@ class AuthScreen extends StatelessWidget {
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15, buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: onTapNoAccount(context)), onPressed: onTapNoAccount(context)),
NextStepButton( /*NextStepButton(
text: "Тест дневника".toUpperCase(), text: "Тест дневника".toUpperCase(),
margin: margin:
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
@@ -76,14 +76,14 @@ class AuthScreen extends StatelessWidget {
margin: margin:
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15, buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: onTapProfileTest(context)), onPressed: onTapProfileTest(context)),*/
BlocBuilder<AuthBloc, AuthState>(builder: (context, state) { BlocBuilder<AuthBloc, AuthState>(builder: (context, state) {
return NextStepButton( return NextStepButton(
text: "authentificate".tr.toUpperCase(), text: "authentificate".tr.toUpperCase(),
margin: margin:
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15, buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () => onTapAuth(state, context)); onPressed: onTapAuth(state, context));
}), }),
]))); ])));
} }
@@ -102,6 +102,7 @@ class AuthScreen extends StatelessWidget {
headers: {'Content-Type': 'application/json'}, headers: {'Content-Type': 'application/json'},
body: json.encode(credentials), body: json.encode(credentials),
encoding: utf8); encoding: utf8);
print(response.statusCode);
if (response.statusCode == 200) { if (response.statusCode == 200) {
var res = await jsonDecode(response.body); var res = await jsonDecode(response.body);
final box = await Hive.openBox('token'); final box = await Hive.openBox('token');

View File

@@ -89,9 +89,10 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
diaryEditModelObj: currentState.diaryEditModelObj)); diaryEditModelObj: currentState.diaryEditModelObj));
} else { } else {
// Если текущее состояние - начальное, создаем новое загруженное состояние // Если текущее состояние - начальное, создаем новое загруженное состояние
final List<SelectionPopupModel> meals =
fillMealList(diary['meals']);
emit(DiaryEditLoadedState( emit(DiaryEditLoadedState(
currentMeal: SelectionPopupModel( currentMeal: meals[0],
id: 1, title: "Прием пищи 1", isSelected: true),
portionController: SelectionPopupModel( portionController: SelectionPopupModel(
id: 0, title: "порций", isSelected: true), id: 0, title: "порций", isSelected: true),
wakeupExpanded: true, wakeupExpanded: true,
@@ -120,8 +121,8 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
diaryId: diaryId, diaryId: diaryId,
diaryDate: diaryDate, diaryDate: diaryDate,
autocompleteList: [], autocompleteList: [],
diaryEditModelObj: state.diaryEditModelObj?.copyWith( diaryEditModelObj: state.diaryEditModelObj
mealList: fillMealList(), portionList: fillPortions()))); ?.copyWith(mealList: meals, portionList: fillPortions())));
} }
} }
} catch (e) { } catch (e) {
@@ -200,7 +201,18 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
} }
} }
reloadScreen(DiaryEditEvent event, Emitter<DiaryEditState> emit) async { refreshScreen(
int mealID,
DiaryEditEvent event,
Emitter<DiaryEditState> emit,
) async {
await reloadScreen(event, emit);
}
reloadScreen(
DiaryEditEvent event,
Emitter<DiaryEditState> emit,
) async {
print("Reloading..."); print("Reloading...");
try { try {
final token = final token =
@@ -244,45 +256,46 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
responseChart.body)['dailyNutritionRecommendation']; responseChart.body)['dailyNutritionRecommendation'];
final consumedChartValues = final consumedChartValues =
jsonDecode(responseChart.body)['dailyNutritionIntake']; jsonDecode(responseChart.body)['dailyNutritionIntake'];
final List<SelectionPopupModel> meals =
fillMealList(diary['meals']);
try { try {
await Future(() => emit(DiaryEditLoadedState( await Future(() => emit(DiaryEditLoadedState(
currentMeal: SelectionPopupModel( diaryEditModelObj: state.diaryEditModelObj?.copyWith(
id: 1, title: "Прием пищи 1", isSelected: true), mealList: meals, portionList: fillPortions()),
portionController: SelectionPopupModel( currentMeal: meals[0],
id: 0, title: "порций", isSelected: true), portionController: SelectionPopupModel(
wakeupExpanded: true, id: 0, title: "порций", isSelected: true),
moodExpanded: true, wakeupExpanded: true,
moderationExpanded: false, moodExpanded: true,
token: token, moderationExpanded: false,
recommendedChartValues: recommendedChartValues.values token: token,
.map<int>((value) => value as int) recommendedChartValues: recommendedChartValues.values
.toList(), .map<int>((value) => value as int)
consumedChartValues: consumedChartValues.values .toList(),
.map<int>((value) => value as int) consumedChartValues: consumedChartValues.values
.toList(), .map<int>((value) => value as int)
meals: diary['meals'], .toList(),
portions: diary['meals'][0]['portions'], meals: diary['meals'],
photos: diary['meals'][0]['photos'], portions: diary['meals'][0]['portions'],
wakeupController: toTime(diary['wakeup'] ?? "09:00"), photos: diary['meals'][0]['photos'],
retireController: toTime(diary['retire'] ?? "23:00"), wakeupController: toTime(diary['wakeup'] ?? "09:00"),
mealTimeController: retireController: toTime(diary['retire'] ?? "23:00"),
toTime(diary['meals'][0]['time'] ?? "10:00"), mealTimeController:
selectedSatiety: diary['meals'][0]['satiety'], toTime(diary['meals'][0]['time'] ?? "10:00"),
selectedMood: diary['meals'][0]['mood'], selectedSatiety: diary['meals'][0]['satiety'],
commentController: selectedMood: diary['meals'][0]['mood'],
TextEditingController(text: diary['comment']), commentController:
productNameController: TextEditingController(), TextEditingController(text: diary['comment']),
productQuantityController: TextEditingController(), productNameController: TextEditingController(),
caloriesController: TextEditingController(), productQuantityController: TextEditingController(),
proteinsController: TextEditingController(), caloriesController: TextEditingController(),
fatsController: TextEditingController(), proteinsController: TextEditingController(),
carbsController: TextEditingController(), fatsController: TextEditingController(),
diaryId: diaryId, carbsController: TextEditingController(),
diaryDate: diaryDate, diaryId: diaryId,
autocompleteList: [], diaryDate: diaryDate,
diaryEditModelObj: state.diaryEditModelObj?.copyWith( autocompleteList: [],
mealList: fillMealList(), )));
portionList: fillPortions()))));
print("Updated"); print("Updated");
} catch (e) { } catch (e) {
@@ -364,6 +377,8 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
currentState.diaryId); currentState.diaryId);
if (response.statusCode == 200) { if (response.statusCode == 200) {
print(
'Mood change success! meal_id: ${currentState.currentMeal?.id}, mood: ${event.selectedElement}');
updatedState.selectedMood = event.selectedElement; updatedState.selectedMood = event.selectedElement;
emit(updatedState); // Передаем обновленное состояние в emit emit(updatedState); // Передаем обновленное состояние в emit
} }
@@ -511,11 +526,10 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
if (state is DiaryEditLoadedState) { if (state is DiaryEditLoadedState) {
var currentState = state as DiaryEditLoadedState; var currentState = state as DiaryEditLoadedState;
final meal = currentState.meals?.firstWhere( final meal = currentState.meals?.firstWhere(
(meal) => meal['type'] == event.value.id, (meal) => meal['id'] == event.value.id,
orElse: () => null); orElse: () => null);
print(meal);
int? id = event.value.id; int? id = event.value.id;
print(meal['photos']);
DiaryEditLoadedState updatedState = currentState.copyWith( DiaryEditLoadedState updatedState = currentState.copyWith(
currentMeal: event.value, currentMeal: event.value,
portions: meal['portions'], portions: meal['portions'],
@@ -523,6 +537,7 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
mealTimeController: toTime(meal['time'] ?? "1$id:00"), mealTimeController: toTime(meal['time'] ?? "1$id:00"),
selectedMood: meal['mood'], selectedMood: meal['mood'],
selectedSatiety: meal['satiety']); selectedSatiety: meal['satiety']);
print(updatedState.photos);
emit(updatedState); emit(updatedState);
} }
} }
@@ -916,15 +931,16 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
return timeOfDay; return timeOfDay;
} }
List<SelectionPopupModel> fillMealList() { List<SelectionPopupModel> fillMealList(List<dynamic> meals) {
return [ meals.sort(compareTypes);
SelectionPopupModel(id: 1, title: "Прием пищи 1", isSelected: true), return meals.map((meal) {
SelectionPopupModel(id: 2, title: "Прием пищи 2"), String title = "Прием пищи ${meal['type']}";
SelectionPopupModel(id: 3, title: "Прием пищи 3"), return SelectionPopupModel(id: meal['id'], title: title);
SelectionPopupModel(id: 4, title: "Прием пищи 4"), }).toList();
SelectionPopupModel(id: 5, title: "Прием пищи 5"), }
SelectionPopupModel(id: 6, title: "Прием пищи 6"),
]; int compareTypes(a, b) {
return a['type'].compareTo(b['type']);
} }
List<SelectionPopupModel> fillPortions() { List<SelectionPopupModel> fillPortions() {

View File

@@ -139,6 +139,7 @@ class DiaryEditLoadedState extends DiaryEditState {
diaryDate: diaryDate ?? this.diaryDate, diaryDate: diaryDate ?? this.diaryDate,
token: token ?? this.token, token: token ?? this.token,
meals: meals ?? this.meals, meals: meals ?? this.meals,
photos: photos ?? this.photos,
autocompleteList: autocompleteList ?? this.autocompleteList, autocompleteList: autocompleteList ?? this.autocompleteList,
portions: portions ?? this.portions, portions: portions ?? this.portions,
recommendedChartValues: recommendedChartValues:

View File

@@ -13,6 +13,7 @@ import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
import 'package:eatvio_app/widgets/custom_edit_drop_down.dart'; import 'package:eatvio_app/widgets/custom_edit_drop_down.dart';
import 'package:eatvio_app/widgets/custom_outlined_button.dart'; import 'package:eatvio_app/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/widgets/custom_scale_element.dart'; import 'package:eatvio_app/widgets/custom_scale_element.dart';
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class DiaryEditScreen extends StatelessWidget { class DiaryEditScreen extends StatelessWidget {
@@ -229,7 +230,6 @@ class DiaryEditScreen extends StatelessWidget {
state.autocompleteList!.map((dynamic item) => item as String).toList(); state.autocompleteList!.map((dynamic item) => item as String).toList();
//print(_options); //print(_options);
FocusNode focusNodeName = FocusNode(); FocusNode focusNodeName = FocusNode();
FocusNode focusNodeQuantity = FocusNode();
return Container( return Container(
margin: EdgeInsets.symmetric(horizontal: 16.h), margin: EdgeInsets.symmetric(horizontal: 16.h),
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
@@ -318,10 +318,7 @@ class DiaryEditScreen extends StatelessWidget {
hintText: "Введите название продукта", hintText: "Введите название продукта",
controller: productEditingController, controller: productEditingController,
focusNode: focusNodeName, focusNode: focusNodeName,
onChanged: getAutocomplete(context, focusNodeQuantity), onChanged: getAutocomplete(context, focusNodeName),
/*onFieldSubmitted: (String value) {
onFieldSubmitted();
},*/
); );
}, },
optionsViewBuilder: ( optionsViewBuilder: (
@@ -341,7 +338,7 @@ class DiaryEditScreen extends StatelessWidget {
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
final String option = options.elementAt(index); final String option = options.elementAt(index);
return GestureDetector( return GestureDetector(
onTap: selectProduct(onSelected, option), onTap: selectProduct(onSelected, option, state),
child: ListTile( child: ListTile(
title: Text(option), title: Text(option),
), ),
@@ -374,7 +371,7 @@ class DiaryEditScreen extends StatelessWidget {
width: 150.h, width: 150.h,
hintText: "Кол-во", hintText: "Кол-во",
textInputAction: TextInputAction.done, textInputAction: TextInputAction.done,
focusNode: focusNodeQuantity, // focusNode: focusNodeQuantity,
controller: state.productQuantityController, controller: state.productQuantityController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[digitsOnly], inputFormatters: <TextInputFormatter>[digitsOnly],
@@ -405,10 +402,12 @@ class DiaryEditScreen extends StatelessWidget {
.toList(), .toList(),
SizedBox(height: 30.v), SizedBox(height: 30.v),
...state.photos != null ...state.photos != null
? state.photos! ? state.photos!.isEmpty
.map((photo) => _buildPhoto(context, photo)) ? [Text('Фото пока нет')]
.toList() : state.photos!
: [], .map((photo) => _buildPhoto(context, photo))
.toList()
: [Text('Фото нет')],
SizedBox(height: 20.v), SizedBox(height: 20.v),
_buildAddPhoto(context), _buildAddPhoto(context),
SizedBox(height: 30.v), SizedBox(height: 30.v),
@@ -561,7 +560,9 @@ class DiaryEditScreen extends StatelessWidget {
}; };
} }
selectProduct(AutocompleteOnSelected<String> onSelected, String option) { selectProduct(AutocompleteOnSelected<String> onSelected, String option,
DiaryEditLoadedState state) {
state.productNameController?.text = option;
return () { return () {
onSelected(option); onSelected(option);
}; };
@@ -764,25 +765,37 @@ class DiaryEditScreen extends StatelessWidget {
BarChartGroupData(x: 0, barRods: [ BarChartGroupData(x: 0, barRods: [
BarChartRodData( BarChartRodData(
toY: consumedValues[0] / recommendedValues[0] * 100, toY: consumedValues[0] / recommendedValues[0] * 100,
color: Colors.blue, color: checkConsumedValues(
[recommendedValues[0]], [consumedValues[1]])
? Colors.red
: Colors.blue,
) )
]), ]),
BarChartGroupData(x: 1, barRods: [ BarChartGroupData(x: 1, barRods: [
BarChartRodData( BarChartRodData(
toY: consumedValues[1] / recommendedValues[1] * 100, toY: consumedValues[1] / recommendedValues[1] * 100,
color: Colors.red, color: checkConsumedValues(
[recommendedValues[1]], [consumedValues[1]])
? Colors.red
: Colors.blue,
) )
]), ]),
BarChartGroupData(x: 2, barRods: [ BarChartGroupData(x: 2, barRods: [
BarChartRodData( BarChartRodData(
toY: consumedValues[2] / recommendedValues[2] * 100, toY: consumedValues[2] / recommendedValues[2] * 100,
color: Colors.green, color: checkConsumedValues(
[recommendedValues[2]], [consumedValues[2]])
? Colors.red
: Colors.blue,
) )
]), ]),
BarChartGroupData(x: 3, barRods: [ BarChartGroupData(x: 3, barRods: [
BarChartRodData( BarChartRodData(
toY: consumedValues[3] / recommendedValues[3] * 100, toY: consumedValues[3] / recommendedValues[3] * 100,
color: Colors.orange, color: checkConsumedValues(
[recommendedValues[3]], [consumedValues[3]])
? Colors.red
: Colors.blue,
) )
]), ]),
], ],
@@ -889,7 +902,7 @@ class DiaryEditScreen extends StatelessWidget {
SizedBox(height: 19.v), SizedBox(height: 19.v),
if (checkConsumedValues(recommendedValues, consumedValues)) if (checkConsumedValues(recommendedValues, consumedValues))
Text( Text(
"*Превышенная суточная норма углеводов", "*Превышенная суточная норма",
style: theme.textTheme.labelLarge, style: theme.textTheme.labelLarge,
) )
], ],
@@ -1042,7 +1055,6 @@ class DiaryEditScreen extends StatelessWidget {
Function() onFinishDayPressed(BuildContext context) { Function() onFinishDayPressed(BuildContext context) {
return () { return () {
print("sad");
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext dialogContext) { builder: (BuildContext dialogContext) {

View File

@@ -4,7 +4,7 @@ import '/core/app_export.dart';
import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_profile_model.dart'; import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_profile_model.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'dart:convert'; import 'dart:convert';
//import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart';
part 'my_profile_event.dart'; part 'my_profile_event.dart';
@@ -21,28 +21,24 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
Emitter<MyProfileState> emit, Emitter<MyProfileState> emit,
) async { ) async {
try { try {
/*final box = await Hive.openBox('token'); final box = await Hive.openBox('token');
final token = box.get('token');*/ final token = box.get('token');
final token = //final token =
"9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1neAggmpR2TidVGDPN34fa201a"; // "9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1neAggmpR2TidVGDPN34fa201a";
final response = await http.get( final response = await http.get(
Uri.parse(dotenv.env['SERVER_ROOT']! + '/profile/index'), Uri.parse(dotenv.env['SERVER_ROOT']! + '/profile/index'),
headers: { headers: {
'Authorization': 'Bearer $token', 'Authorization': 'Bearer $token',
}, },
); );
if (response.statusCode == 200) { if (response.statusCode == 200) {
final data = jsonDecode(response.body); final data = jsonDecode(response.body);
// Проверка наличия ключевых полей в JSON
if (data is Map<String, dynamic> && if (data is Map<String, dynamic> &&
data.containsKey('user') && data.containsKey('user') &&
data.containsKey('userDetails') && data.containsKey('userDetails') &&
data.containsKey('chartPoints') && data.containsKey('chartPoints') &&
data.containsKey('circumferences')) { data.containsKey('circumferences')) {
// Все ключевые поля присутствуют, продолжаем обработку
if (state is MyProfileLoadedState) { if (state is MyProfileLoadedState) {
// Если текущее состояние уже загружено, обновляем его
var currentState = state as MyProfileLoadedState; var currentState = state as MyProfileLoadedState;
var plans = [] var plans = []
..addAll(data["finishedPlans"]) ..addAll(data["finishedPlans"])
@@ -51,9 +47,6 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
..addAll(data["paidPlan"]) ..addAll(data["paidPlan"])
..addAll(data["requestedPlan"]) ..addAll(data["requestedPlan"])
..addAll(data["initedPlan"]); ..addAll(data["initedPlan"]);
// Обновляем значения контроллеров только если они уже были созданы
emit((currentState).copyWith( emit((currentState).copyWith(
chartPoints: currentState.chartPoints, chartPoints: currentState.chartPoints,
chartDates: currentState.chartDates, chartDates: currentState.chartDates,
@@ -123,18 +116,6 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
}) })
: data["chartPoints"]; : data["chartPoints"];
/*List<double> weights = [0.0, 0.0, 0.0, 0.0];
List<String> dates = [
"0000-00-00 00:00:00",
"0000-00-00 00:00:00",
"0000-00-00 00:00:00",
"0000-00-00 00:00:00"
];
for (int i = 0; i < data["chartPoints"].length; i++) {
weights[i] = data["chartPoints"][i]["weight"].toDouble();
dates[i] = data["chartPoints"][i]["created_at"].toString();
}
print(data);*/
List<String> dates = [ List<String> dates = [
"0000-00-00 00:00:00", "0000-00-00 00:00:00",
"0000-00-00 00:00:00", "0000-00-00 00:00:00",
@@ -169,14 +150,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
}; };
} }
} }
print(data['userDetails']);
/*print(chartPoints);
print(circumferences);*/
/*print(weights);
print(weights.runtimeType);
print(circumferences);
print(circumferences.runtimeType);*/
// Если текущее состояние - начальное, создаем новое загруженное состояние
emit(MyProfileLoadedState( emit(MyProfileLoadedState(
chartPoints: chartPoints, chartPoints: chartPoints,
chartDates: dates, chartDates: dates,
@@ -231,7 +205,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
selectedCity: data['userDetails']['city'], selectedCity: data['userDetails']['city'],
selectedCountry: data['userDetails']['country'], selectedCountry: data['userDetails']['country'],
selectedActivity: determineActivityLevel( selectedActivity: determineActivityLevel(
double.parse(data['userDetails']['activity_coefficient'])), data['userDetails']['activity_coefficient']),
)); ));
} }
} else { } else {

View File

@@ -182,7 +182,7 @@ class MyProfileScreen extends StatelessWidget {
switch (chartType) { switch (chartType) {
case 1: // График веса case 1: // График веса
return GestureDetector( return GestureDetector(
onTap: _editWeight(context, state), onTap: () => _editWeight(context, state),
child: Column(children: [ child: Column(children: [
Text( Text(
"weight_chart".tr, "weight_chart".tr,
@@ -225,7 +225,7 @@ class MyProfileScreen extends StatelessWidget {
]); ]);
case 3: //График обхватов case 3: //График обхватов
return GestureDetector( return GestureDetector(
onTap: _editCircumference(context, state), onTap: () => _editCircumference(context, state),
child: Column(children: [ child: Column(children: [
Text( Text(
"circumferences_chart".tr, "circumferences_chart".tr,
@@ -279,10 +279,8 @@ class MyProfileScreen extends StatelessWidget {
); );
} }
/// Section Widget
_buildChart( _buildChart(
BuildContext context, List<double> chartPoints, List<String>? dates) { BuildContext context, List<double> chartPoints, List<String>? dates) {
// Определение осей графика
List<FlSpot> spots = []; List<FlSpot> spots = [];
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
spots.add( spots.add(
@@ -428,7 +426,7 @@ class MyProfileScreen extends StatelessWidget {
}; };
} }
mapSpots() { List<LineTooltipItem?> Function(List<LineBarSpot>) mapSpots() {
return (touchedSpots) { return (touchedSpots) {
return touchedSpots.map((LineBarSpot touchedSpot) { return touchedSpots.map((LineBarSpot touchedSpot) {
final textStyle = TextStyle( final textStyle = TextStyle(
@@ -635,7 +633,7 @@ class MyProfileScreen extends StatelessWidget {
); );
} }
mapTouchedSpots() { List<LineTooltipItem?> Function(List<LineBarSpot>) mapTouchedSpots() {
return (touchedSpots) { return (touchedSpots) {
return touchedSpots.map((LineBarSpot touchedSpot) { return touchedSpots.map((LineBarSpot touchedSpot) {
final textStyle = TextStyle( final textStyle = TextStyle(

View File

@@ -78,12 +78,12 @@ class AdditionalInformationScreen extends StatelessWidget {
sheet.additionalInfo = state.editTextController!.text; sheet.additionalInfo = state.editTextController!.text;
//print(json.encode(sheet.toJson())); //print(json.encode(sheet.toJson()));
final response = await http.post( final response = await http.post(
Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'), Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'),
headers: {'Content-Type': 'application/json'}, headers: {'Content-Type': 'application/json'},
body: jsonEncode(sheet.toJson()), body: jsonEncode(sheet),
); encoding: utf8);
print(response.statusCode); print(jsonEncode(sheet.toJson()));
print(response.body); print(Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'));
if (response.statusCode == 200) { if (response.statusCode == 200) {
var res = await jsonDecode(response.body); var res = await jsonDecode(response.body);
final box = await Hive.openBox('token'); final box = await Hive.openBox('token');

View File

@@ -21,12 +21,12 @@ class CustomBottomBarState extends State<CustomBottomBar> {
title: "diary".tr, title: "diary".tr,
type: BottomBarEnum.tf, type: BottomBarEnum.tf,
), ),
BottomMenuModel( /*BottomMenuModel(
icon: ImageConstant.imgNavBlueGray400, icon: ImageConstant.imgNavBlueGray400,
activeIcon: ImageConstant.imgNavBlueGray400, activeIcon: ImageConstant.imgNavBlueGray400,
title: "my_blog".tr, title: "my_blog".tr,
type: BottomBarEnum.tf, type: BottomBarEnum.tf,
), ),*/
BottomMenuModel( BottomMenuModel(
icon: ImageConstant.imgNavBlueGray40024x23, icon: ImageConstant.imgNavBlueGray40024x23,
activeIcon: ImageConstant.imgNavBlueGray40024x23, activeIcon: ImageConstant.imgNavBlueGray40024x23,
@@ -34,9 +34,9 @@ class CustomBottomBarState extends State<CustomBottomBar> {
type: BottomBarEnum.tf, type: BottomBarEnum.tf,
), ),
BottomMenuModel( BottomMenuModel(
icon: ImageConstant.imgNavPrimary, icon: ImageConstant.imgNavBlueGray40024x23,
activeIcon: ImageConstant.imgNavPrimary, activeIcon: ImageConstant.imgNavBlueGray40024x23,
title: "admin".tr, title: "Настройки",
type: BottomBarEnum.tf, type: BottomBarEnum.tf,
), ),
BottomMenuModel( BottomMenuModel(
@@ -72,12 +72,33 @@ class CustomBottomBarState extends State<CustomBottomBar> {
} }
void changeMeny(index) { void changeMeny(index) {
selectedIndex = index; setState(() {
widget.onChanged?.call(bottomMenuList[index].type); selectedIndex = index;
setState(() {}); });
switch (index) {
case 0:
Navigator.pushNamed(context, AppRoutes.diaryEdit);
break;
/*case 1:
Navigator.pushNamed(context, '/my_blog');
break;*/
case 1:
Navigator.pushNamed(context, AppRoutes.myProfile);
break;
case 2:
Navigator.pushNamed(context, AppRoutes.mySettings);
break;
case 3:
Navigator.pushNamed(context, '/chat');
break;
default:
}
} }
BottomNavigationBarItem bottomMenu(index) { BottomNavigationBarItem bottomMenu(index) {
bool isSelected = selectedIndex == index;
return BottomNavigationBarItem( return BottomNavigationBarItem(
icon: Column( icon: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@@ -86,14 +107,17 @@ class CustomBottomBarState extends State<CustomBottomBar> {
imagePath: bottomMenuList[index].icon, imagePath: bottomMenuList[index].icon,
height: 24.v, height: 24.v,
width: 19.h, width: 19.h,
color: appTheme.blueGray400, color:
isSelected ? theme.colorScheme.primary : appTheme.blueGray400,
), ),
Padding( Padding(
padding: EdgeInsets.only(top: 8.v), padding: EdgeInsets.only(top: 8.v),
child: Text( child: Text(
bottomMenuList[index].title ?? "", bottomMenuList[index].title ?? "",
style: CustomTextStyles.bodySmallMulishBluegray80012.copyWith( style: CustomTextStyles.bodySmallMulishBluegray80012.copyWith(
color: appTheme.blueGray800, color: isSelected
? theme.colorScheme.primary
: appTheme.blueGray800,
), ),
), ),
), ),

View File

@@ -20,6 +20,7 @@ class CustomTextFormField extends StatelessWidget {
this.prefixConstraints, this.prefixConstraints,
this.suffix, this.suffix,
this.suffixConstraints, this.suffixConstraints,
this.onFieldSubmitted,
this.initialValue, this.initialValue,
this.contentPadding, this.contentPadding,
this.inputFormatters, this.inputFormatters,
@@ -66,6 +67,8 @@ class CustomTextFormField extends StatelessWidget {
final Widget? suffix; final Widget? suffix;
final Function(String)? onFieldSubmitted;
final BoxConstraints? suffixConstraints; final BoxConstraints? suffixConstraints;
final EdgeInsets? contentPadding; final EdgeInsets? contentPadding;
@@ -112,6 +115,7 @@ class CustomTextFormField extends StatelessWidget {
keyboardType: keyboardType, keyboardType: keyboardType,
onSaved: onSaved, onSaved: onSaved,
onChanged: onChanged, onChanged: onChanged,
onFieldSubmitted: onFieldSubmitted,
inputFormatters: inputFormatters, inputFormatters: inputFormatters,
initialValue: initialValue, initialValue: initialValue,
), ),

View File

@@ -255,7 +255,7 @@ class _ExpandableListState extends State<ExpandableList> {
], ],
), ),
NextStepButton( NextStepButton(
onPressed: sendData(state), onPressed: () => sendProfileData(state),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15, buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
text: "save".tr.toUpperCase(), text: "save".tr.toUpperCase(),
margin: EdgeInsets.only(top: 20.h, bottom: 20.h)), margin: EdgeInsets.only(top: 20.h, bottom: 20.h)),
@@ -326,6 +326,7 @@ class _ExpandableListState extends State<ExpandableList> {
} }
Future<void> sendProfileData(MyProfileLoadedState? state) async { Future<void> sendProfileData(MyProfileLoadedState? state) async {
print("asd");
try { try {
// Создаем JSON объект с данными профиля // Создаем JSON объект с данными профиля
Map<String, dynamic> profileData = { Map<String, dynamic> profileData = {
@@ -350,8 +351,7 @@ class _ExpandableListState extends State<ExpandableList> {
'has_hypo': state?.hypoFormController, 'has_hypo': state?.hypoFormController,
'has_hyper': state?.hyperFormController, 'has_hyper': state?.hyperFormController,
'activity_coefficient': 'activity_coefficient':
determineActivityFactor(state?.selectedActivity ?? 'сидячий') determineActivityFactor(state?.selectedActivity ?? 'сидячий'),
.toString,
}; };
final box = await Hive.openBox('token'); final box = await Hive.openBox('token');
final token = box.get('token'); final token = box.get('token');