feature(registration): remove .env

This commit is contained in:
mso7nueh
2024-07-15 17:06:13 +03:00
parent 726b74a236
commit d859a15cfd
188 changed files with 2509 additions and 3147 deletions

View File

@@ -142,4 +142,4 @@ buildChart(
),
);
}
*/
*/

View File

@@ -76,4 +76,4 @@ class MyApp extends StatelessWidget {
);
}
}
*/
*/

View File

@@ -26,9 +26,10 @@ class _AboutListState extends State<AboutList> {
Text(
widget.title,
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.bold,),
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
Icon(isExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down),
],
@@ -38,8 +39,9 @@ class _AboutListState extends State<AboutList> {
Padding(
padding: const EdgeInsets.only(left: 16.0),
child: Column(
//children: widget.items.map((item) => Text(item)).toList(),
children: [Text(widget.items.join('\n'))],),
//children: widget.items.map((item) => Text(item)).toList(),
children: [Text(widget.items.join('\n'))],
),
),
Divider(),
],

View File

@@ -1,16 +1,16 @@
import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart';
import 'package:eatvio_app/widgets/custom_hyper_switch.dart';
import 'package:eatvio_app/widgets/custom_hypo_switch.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import 'package:eatvio_app/widgets/next_step_button.dart';
import 'dart:convert';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:hive/hive.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart';
import 'package:hive/hive.dart';
import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
class ExpandableList extends StatefulWidget {
final String title;
@@ -37,9 +37,10 @@ class _ExpandableListState extends State<ExpandableList> {
Text(
widget.title,
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.bold,),
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
Icon(isExpanded ? Icons.arrow_drop_up : Icons.arrow_drop_down),
],
@@ -49,24 +50,25 @@ class _ExpandableListState extends State<ExpandableList> {
Padding(
padding: const EdgeInsets.only(left: 16.0),
child: BlocBuilder<MyProfileBloc, MyProfileState>(
builder: (context, state) {
if (state is MyProfileInitialState) {
// Это начальное состояние, данные ещё не загружены.
return CircularProgressIndicator(
color: Colors.white,
backgroundColor: Colors.white,
);
} else if (state is MyProfileLoadedState) {
// Данные загружены, можно строить форму.
return _buildForm(context, state);
} else if (state is MyProfileErrorState) {
// Произошла ошибка при загрузке данных.
return Center(child: Text(state.errorMessage));
} else {
// Другие состояния, если они есть.
return Container(); // Пустой контейнер для необработанных состояний.
}
},),
builder: (context, state) {
if (state is MyProfileInitialState) {
// Это начальное состояние, данные ещё не загружены.
return CircularProgressIndicator(
color: Colors.white,
backgroundColor: Colors.white,
);
} else if (state is MyProfileLoadedState) {
// Данные загружены, можно строить форму.
return _buildForm(context, state);
} else if (state is MyProfileErrorState) {
// Произошла ошибка при загрузке данных.
return Center(child: Text(state.errorMessage));
} else {
// Другие состояния, если они есть.
return Container(); // Пустой контейнер для необработанных состояний.
}
},
),
),
Divider(),
],
@@ -125,142 +127,152 @@ class _ExpandableListState extends State<ExpandableList> {
'экстремальный (несколько интенсивных тренировок в день)',
];
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
return Column(children: [
TextField(
controller: state.firstNameFormController,
decoration: InputDecoration(labelText: 'first_name'.tr),
),
TextField(
controller: state.lastNameFormController,
decoration: InputDecoration(labelText: 'last_name'.tr),
),
TextField(
return Column(
children: [
TextField(
controller: state.firstNameFormController,
decoration: InputDecoration(labelText: 'first_name'.tr),
),
TextField(
controller: state.lastNameFormController,
decoration: InputDecoration(labelText: 'last_name'.tr),
),
TextField(
decoration: InputDecoration(labelText: 'date_of_birth'.tr),
controller: state.dateFormController,
onTap: inputTime(context, state),),
DropdownButtonFormField<String>(
value: state.selectedCountry,
hint: Text(state.selectedCountry ?? "Не выбрано"),
onChanged: setCountry(state),
items: countries.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
decoration: InputDecoration(labelText: 'country'.tr),
),
DropdownButtonFormField<String>(
hint: Text(state.selectedCity ?? "Не выбрано"),
value: state.selectedCity,
onChanged: setCity(state),
items: cities.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
decoration: InputDecoration(labelText: 'city_of_living'.tr),
),
TextField(
onTap: inputTime(context, state),
),
DropdownButtonFormField<String>(
value: state.selectedCountry,
hint: Text(state.selectedCountry ?? "Не выбрано"),
onChanged: setCountry(state),
items: countries.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
decoration: InputDecoration(labelText: 'country'.tr),
),
DropdownButtonFormField<String>(
hint: Text(state.selectedCity ?? "Не выбрано"),
value: state.selectedCity,
onChanged: setCity(state),
items: cities.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
decoration: InputDecoration(labelText: 'city_of_living'.tr),
),
TextField(
controller: state.weightFormController,
decoration: InputDecoration(labelText: 'weight_measurements'.tr),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[digitsOnly],),
TextField(
inputFormatters: <TextInputFormatter>[digitsOnly],
),
TextField(
controller: state.heightFormController,
decoration: InputDecoration(labelText: 'height_measurements'.tr),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[digitsOnly],),
TextField(
inputFormatters: <TextInputFormatter>[digitsOnly],
),
TextField(
controller: state.chestCircumferenceFormController,
decoration: InputDecoration(labelText: 'chest_circumference'.tr),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[digitsOnly],),
TextField(
inputFormatters: <TextInputFormatter>[digitsOnly],
),
TextField(
controller: state.waistCircumferenceFormController,
decoration: InputDecoration(labelText: 'waist_circumference'.tr),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[digitsOnly],),
TextField(
inputFormatters: <TextInputFormatter>[digitsOnly],
),
TextField(
controller: state.hipCircumferenceFormController,
decoration: InputDecoration(labelText: 'hip_circumference'.tr),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[digitsOnly],),
TextField(
inputFormatters: <TextInputFormatter>[digitsOnly],
),
TextField(
controller: state.upPressureFormController,
decoration: InputDecoration(labelText: 'up_pressure'.tr),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[digitsOnly],),
TextField(
inputFormatters: <TextInputFormatter>[digitsOnly],
),
TextField(
controller: state.downPressureFormController,
decoration: InputDecoration(labelText: 'down_pressure'.tr),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[digitsOnly],),
TextField(
controller: state.allergiesFormController,
decoration: InputDecoration(labelText: 'allergies_presence'.tr),
maxLines: null,
),
TextField(
controller: state.pillsFormController,
decoration: InputDecoration(labelText: 'do_you_take_pills'.tr),
maxLines: null,
),
TextField(
controller: state.sportsFormController,
decoration: InputDecoration(labelText: 'your_favorite_sports'.tr),
maxLines: null,
),
TextField(
controller: state.favoriteFormController,
decoration: InputDecoration(labelText: 'favorite_foods'.tr),
maxLines: null,
),
TextField(
controller: state.unfavoriteFormController,
decoration: InputDecoration(labelText: 'unfavorite_foods'.tr),
maxLines: null,
),
TextField(
controller: state.additionalFormController,
decoration: InputDecoration(labelText: 'additional_information'.tr),
maxLines: null,
),
DropdownButtonFormField<String>(
hint: Text(state.selectedActivity ?? "Не выбрано"),
value: state.selectedActivity,
onChanged: setActivity(state),
items: activities.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: SizedBox(
// Используем SizedBox для ограничения ширины элемента списка
width: MediaQuery.of(context).size.width *
0.8, // Устанавливаем желаемую ширину элемента списка
child: Text(value),
),
);
}).toList(),
isExpanded: true, // Расширяем список на всю доступную ширину
decoration: InputDecoration(labelText: 'Активность'),
),
Row(
children: [
HypoSwitch('do_you_have_hypotension_tendency'.tr, state),
],
),
Row(
children: [
HyperSwitch('do_you_have_hypertension_tendency'.tr, state),
],
),
NextStepButton(
inputFormatters: <TextInputFormatter>[digitsOnly],
),
TextField(
controller: state.allergiesFormController,
decoration: InputDecoration(labelText: 'allergies_presence'.tr),
maxLines: null,
),
TextField(
controller: state.pillsFormController,
decoration: InputDecoration(labelText: 'do_you_take_pills'.tr),
maxLines: null,
),
TextField(
controller: state.sportsFormController,
decoration: InputDecoration(labelText: 'your_favorite_sports'.tr),
maxLines: null,
),
TextField(
controller: state.favoriteFormController,
decoration: InputDecoration(labelText: 'favorite_foods'.tr),
maxLines: null,
),
TextField(
controller: state.unfavoriteFormController,
decoration: InputDecoration(labelText: 'unfavorite_foods'.tr),
maxLines: null,
),
TextField(
controller: state.additionalFormController,
decoration: InputDecoration(labelText: 'additional_information'.tr),
maxLines: null,
),
DropdownButtonFormField<String>(
hint: Text(state.selectedActivity ?? "Не выбрано"),
value: state.selectedActivity,
onChanged: setActivity(state),
items: activities.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: SizedBox(
// Используем SizedBox для ограничения ширины элемента списка
width: MediaQuery.of(context).size.width * 0.8, // Устанавливаем желаемую ширину элемента списка
child: Text(value),
),
);
}).toList(),
isExpanded: true, // Расширяем список на всю доступную ширину
decoration: InputDecoration(labelText: 'Активность'),
),
Row(
children: [
HypoSwitch('do_you_have_hypotension_tendency'.tr, state),
],
),
Row(
children: [
HyperSwitch('do_you_have_hypertension_tendency'.tr, state),
],
),
NextStepButton(
onPressed: () => sendProfileData(state),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
text: "save".tr.toUpperCase(),
margin: EdgeInsets.only(top: 20.h, bottom: 20.h),),
],);
margin: EdgeInsets.only(top: 20.h, bottom: 20.h),
),
],
);
}
sendData(MyProfileLoadedState state) {
@@ -300,8 +312,7 @@ class _ExpandableListState extends State<ExpandableList> {
).then((selectedDate) {
if (selectedDate != null) {
setState(() {
state.dateFormController!.text =
DateFormat('dd-MM-yyyy').format(selectedDate);
state.dateFormController!.text = DateFormat('dd-MM-yyyy').format(selectedDate);
});
}
});
@@ -367,8 +378,7 @@ class _ExpandableListState extends State<ExpandableList> {
'city': state?.selectedCity ?? 'Москва',
'has_hypo': state?.hypoFormController,
'has_hyper': state?.hyperFormController,
'activity_coefficient':
determineActivityFactor(state?.selectedActivity ?? 'сидячий'),
'activity_coefficient': determineActivityFactor(state?.selectedActivity ?? 'сидячий'),
};
}
@@ -378,11 +388,14 @@ class _ExpandableListState extends State<ExpandableList> {
}
String _buildApiUrl() {
return dotenv.env['SERVER_ROOT']! + '/profile/update';
return baseUrl + '/api/profile/update';
}
Future<http.Response> _sendHttpRequest(
Map<String, dynamic> profileData, String apiUrl, String? token,) {
Map<String, dynamic> profileData,
String apiUrl,
String? token,
) {
return http.post(
Uri.parse(apiUrl),
body: json.encode(profileData),

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart';
import 'package:flutter/material.dart';
class HyperSwitch extends StatefulWidget {
final String title;
@@ -30,7 +30,10 @@ class _HyperState extends State<HyperSwitch> {
Text(
widget.title,
style: TextStyle(
color: Colors.black, fontSize: 14, fontWeight: FontWeight.bold,),
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
Switch(
value: switchValue,

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart';
import 'package:flutter/material.dart';
class HypoSwitch extends StatefulWidget {
final String title;
@@ -30,7 +30,10 @@ class _HypoState extends State<HypoSwitch> {
Text(
widget.title,
style: TextStyle(
color: Colors.black, fontSize: 14, fontWeight: FontWeight.bold,),
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
Switch(
value: switchValue,

View File

@@ -45,7 +45,8 @@ class CustomIconButton extends StatelessWidget {
color: Colors.black,
borderRadius: const BorderRadius.all(Radius.circular(9)),
border: const Border.fromBorderSide(
BorderSide(color: Colors.blueGrey, width: 1),),
BorderSide(color: Colors.blueGrey, width: 1),
),
),
child: child,
),

View File

@@ -1,9 +1,8 @@
import 'package:eatvio_app/core/app_export.dart';
import 'package:flutter/material.dart';
import 'package:eatvio_app/widgets/custom_navigation_menu_item.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hive/hive.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:http/http.dart' as http;
class CustomNavigationMenu extends StatelessWidget {
@@ -66,7 +65,7 @@ _onTapLogout(BuildContext context) {
final box = await Hive.openBox('token');
final token = box.get('token');
final response = await http.post(
Uri.parse(dotenv.env['SERVER_ROOT']! + '/profile/logout'),
Uri.parse(baseUrl + '/api/profile/logout'),
headers: {
'Authorization': 'Bearer $token',
},

View File

@@ -1,6 +1,6 @@
import 'package:eatvio_app/core/app_export.dart';
import 'package:flutter/material.dart';
import 'package:eatvio_app/widgets/custom_image_view.dart';
import 'package:flutter/material.dart';
class MenuItem extends StatelessWidget {
final String icon;

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:eatvio_app/core/app_export.dart';
import 'package:flutter/material.dart';
class NotificationSwitch extends StatefulWidget {
final String title;
@@ -21,7 +21,10 @@ class _NotificationSwitchState extends State<NotificationSwitch> {
Text(
widget.title,
style: TextStyle(
color: Colors.black, fontSize: 14, fontWeight: FontWeight.bold,),
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
Switch(
value: switchValue,

View File

@@ -181,7 +181,7 @@ class CustomTextFormField extends StatelessWidget {
);
}
}
/* InputDecoration _buildInputDecoration() {
/* InputDecoration _buildInputDecoration() {
return InputDecoration(
hintText: hintText ?? "",
hintStyle: hintStyle ?? theme.textTheme.bodyLarge,