forked from eatvio/eatvio_app
refactor(app): Assemble release
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:image_picker/image_picker.dart';
|
|||||||
import 'package:eatvio_app/presentation/diary/diary_edit_screen/models/diary_edit_model.dart';
|
import 'package:eatvio_app/presentation/diary/diary_edit_screen/models/diary_edit_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:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
|
|
||||||
part 'diary_edit_event.dart';
|
part 'diary_edit_event.dart';
|
||||||
@@ -44,9 +45,10 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
|||||||
Emitter<DiaryEditState> emit,
|
Emitter<DiaryEditState> emit,
|
||||||
) async {
|
) async {
|
||||||
try {
|
try {
|
||||||
final token =
|
// final token =
|
||||||
"9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1neAggmpR2TidVGDPN34fa201a";
|
// "9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1neAggmpR2TidVGDPN34fa201a";
|
||||||
|
final box = await Hive.openBox('token');
|
||||||
|
final token = box.get('token');
|
||||||
//print(await fetchDiaryId(token));
|
//print(await fetchDiaryId(token));
|
||||||
final int diaryId = await fetchDiaryId(token);
|
final int diaryId = await fetchDiaryId(token);
|
||||||
try {
|
try {
|
||||||
@@ -215,9 +217,10 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
|||||||
) async {
|
) async {
|
||||||
print("Reloading...");
|
print("Reloading...");
|
||||||
try {
|
try {
|
||||||
final token =
|
//final token =
|
||||||
"9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1neAggmpR2TidVGDPN34fa201a";
|
// "9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1neAggmpR2TidVGDPN34fa201a"; final box = await Hive.openBox('token');
|
||||||
|
final box = await Hive.openBox('token');
|
||||||
|
final token = box.get('token');
|
||||||
final response = await http.get(
|
final response = await http.get(
|
||||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/diary/index'),
|
Uri.parse(dotenv.env['SERVER_ROOT']! + '/diary/index'),
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ 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';
|
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||||
|
import 'package:carousel_slider/carousel_slider.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class DiaryEditScreen extends StatelessWidget {
|
class DiaryEditScreen extends StatelessWidget {
|
||||||
@@ -401,13 +402,14 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
.map((portion) => _buildProduct(context, portion))
|
.map((portion) => _buildProduct(context, portion))
|
||||||
.toList(),
|
.toList(),
|
||||||
SizedBox(height: 30.v),
|
SizedBox(height: 30.v),
|
||||||
...state.photos != null
|
/*...state.photos != null
|
||||||
? state.photos!.isEmpty
|
? state.photos!.isEmpty
|
||||||
? [Text('Фото пока нет')]
|
? [Text('Фото пока нет')]
|
||||||
: state.photos!
|
: state.photos!
|
||||||
.map((photo) => _buildPhoto(context, photo))
|
.map((photo) => _buildPhoto(context, photo))
|
||||||
.toList()
|
.toList()
|
||||||
: [Text('Фото нет')],
|
: [Text('Фото нет')],*/
|
||||||
|
_buildCarousel(context, state),
|
||||||
SizedBox(height: 20.v),
|
SizedBox(height: 20.v),
|
||||||
_buildAddPhoto(context),
|
_buildAddPhoto(context),
|
||||||
SizedBox(height: 30.v),
|
SizedBox(height: 30.v),
|
||||||
@@ -601,6 +603,20 @@ class DiaryEditScreen extends StatelessWidget {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_buildCarousel(BuildContext context, DiaryEditLoadedState state) {
|
||||||
|
if (state.photos!.isEmpty) {
|
||||||
|
return Text("Фото нет");
|
||||||
|
} else {
|
||||||
|
return CarouselSlider(
|
||||||
|
options: CarouselOptions(height: 340.0),
|
||||||
|
items: state.photos!.map<Widget>((photo) {
|
||||||
|
return _buildPhoto(
|
||||||
|
context, photo); // Assuming photos are stored as strings
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_buildProduct(BuildContext context, Map<String, dynamic> portion) {
|
_buildProduct(BuildContext context, Map<String, dynamic> portion) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.symmetric(horizontal: 10.h),
|
margin: EdgeInsets.symmetric(horizontal: 10.h),
|
||||||
|
|||||||
@@ -76,16 +76,18 @@ class AdditionalInformationScreen extends StatelessWidget {
|
|||||||
UserRegistrationSheet sheet =
|
UserRegistrationSheet sheet =
|
||||||
state.additionalInformationModelObj!.userRegistrationSheet;
|
state.additionalInformationModelObj!.userRegistrationSheet;
|
||||||
sheet.additionalInfo = state.editTextController!.text;
|
sheet.additionalInfo = state.editTextController!.text;
|
||||||
//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: {
|
||||||
body: jsonEncode(sheet),
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json'
|
||||||
|
},
|
||||||
|
body: jsonEncode(sheet.toJson()),
|
||||||
encoding: utf8);
|
encoding: utf8);
|
||||||
print(jsonEncode(sheet.toJson()));
|
|
||||||
print(Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'));
|
var res = await jsonDecode(response.body);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
var res = await jsonDecode(response.body);
|
|
||||||
final box = await Hive.openBox('token');
|
final box = await Hive.openBox('token');
|
||||||
final token = res['token'];
|
final token = res['token'];
|
||||||
box.put('token', token);
|
box.put('token', token);
|
||||||
@@ -93,6 +95,8 @@ class AdditionalInformationScreen extends StatelessWidget {
|
|||||||
context,
|
context,
|
||||||
AppRoutes.myProfile,
|
AppRoutes.myProfile,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
showErrorMessage(context, res['message']);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -152,12 +156,12 @@ class AdditionalInformationScreen extends StatelessWidget {
|
|||||||
|
|
||||||
/// Displays an alert dialog when the action is triggered.
|
/// Displays an alert dialog when the action is triggered.
|
||||||
/// The dialog box contains a title and a message with the `Теперь вы можете пользоваться полным функционалом приложения`
|
/// The dialog box contains a title and a message with the `Теперь вы можете пользоваться полным функционалом приложения`
|
||||||
showSuccessMessage(BuildContext context, String text) {
|
showErrorMessage(BuildContext context, String text) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => AlertDialog(
|
builder: (_) => AlertDialog(
|
||||||
title: const Text('Регистрация завершена!'),
|
title: const Text('Ошибка'),
|
||||||
content: const Text('1'),
|
content: Text(text),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(onPressed: onTapOk(context), child: const Text('Ok'))
|
TextButton(onPressed: onTapOk(context), child: const Text('Ok'))
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class CustomBottomBarState extends State<CustomBottomBar> {
|
|||||||
type: BottomBarEnum.tf,
|
type: BottomBarEnum.tf,
|
||||||
),
|
),
|
||||||
BottomMenuModel(
|
BottomMenuModel(
|
||||||
icon: ImageConstant.imgNavBlueGray40024x23,
|
icon: ImageConstant.imgNavPrimary,
|
||||||
activeIcon: ImageConstant.imgNavBlueGray40024x23,
|
activeIcon: ImageConstant.imgNavBlueGray40024x23,
|
||||||
title: "Настройки",
|
title: "Настройки",
|
||||||
type: BottomBarEnum.tf,
|
type: BottomBarEnum.tf,
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ class _ExpandableListState extends State<ExpandableList> {
|
|||||||
'weight': state?.weightFormController?.text,
|
'weight': state?.weightFormController?.text,
|
||||||
'blood_pressure_up': state?.upPressureFormController?.text,
|
'blood_pressure_up': state?.upPressureFormController?.text,
|
||||||
'blood_pressure_down': state?.downPressureFormController?.text,
|
'blood_pressure_down': state?.downPressureFormController?.text,
|
||||||
'about_alergy': state?.allergiesFormController?.text,
|
'about_alergy': state?.allergiesFormController?.text ?? 'Нет аллергий',
|
||||||
'about_taking_pils': state?.pillsFormController?.text,
|
'about_taking_pils': state?.pillsFormController?.text,
|
||||||
'about_sport_hobbies': state?.sportsFormController?.text,
|
'about_sport_hobbies': state?.sportsFormController?.text,
|
||||||
'favorite_foods': state?.favoriteFormController?.text,
|
'favorite_foods': state?.favoriteFormController?.text,
|
||||||
@@ -362,6 +362,7 @@ class _ExpandableListState extends State<ExpandableList> {
|
|||||||
encoding: utf8,
|
encoding: utf8,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json',
|
||||||
'Authorization': 'Bearer $token',
|
'Authorization': 'Bearer $token',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -373,11 +374,12 @@ class _ExpandableListState extends State<ExpandableList> {
|
|||||||
AppRoutes.myProfile,
|
AppRoutes.myProfile,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
var res = await jsonDecode(response.body);
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
title: Text('Ошибка'),
|
title: Text('Ошибка'),
|
||||||
content: Text('Ошибка при отправке данных профиля'.tr),
|
content: Text(res['message']),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: onTapOk(context),
|
onPressed: onTapOk(context),
|
||||||
|
|||||||
Reference in New Issue
Block a user