refactor(app): Assemble release

This commit is contained in:
2024-04-11 16:24:10 +03:00
parent bbbc20a15a
commit 5122665370
5 changed files with 45 additions and 20 deletions

View File

@@ -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:http/http.dart' as http;
import 'dart:convert';
import 'package:hive/hive.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
part 'diary_edit_event.dart';
@@ -44,9 +45,10 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
Emitter<DiaryEditState> emit,
) async {
try {
final token =
"9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1neAggmpR2TidVGDPN34fa201a";
// final token =
// "9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1neAggmpR2TidVGDPN34fa201a";
final box = await Hive.openBox('token');
final token = box.get('token');
//print(await fetchDiaryId(token));
final int diaryId = await fetchDiaryId(token);
try {
@@ -215,9 +217,10 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
) async {
print("Reloading...");
try {
final token =
"9|laravel_sanctum_KFXbccDcWEvTPfJmV99EQv1neAggmpR2TidVGDPN34fa201a";
//final token =
// "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(
Uri.parse(dotenv.env['SERVER_ROOT']! + '/diary/index'),
headers: {

View File

@@ -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_scale_element.dart';
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
import 'package:carousel_slider/carousel_slider.dart';
// ignore: must_be_immutable
class DiaryEditScreen extends StatelessWidget {
@@ -401,13 +402,14 @@ class DiaryEditScreen extends StatelessWidget {
.map((portion) => _buildProduct(context, portion))
.toList(),
SizedBox(height: 30.v),
...state.photos != null
/*...state.photos != null
? state.photos!.isEmpty
? [Text('Фото пока нет')]
: state.photos!
.map((photo) => _buildPhoto(context, photo))
.toList()
: [Text('Фото нет')],
: [Text('Фото нет')],*/
_buildCarousel(context, state),
SizedBox(height: 20.v),
_buildAddPhoto(context),
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) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 10.h),

View File

@@ -76,16 +76,18 @@ class AdditionalInformationScreen extends StatelessWidget {
UserRegistrationSheet sheet =
state.additionalInformationModelObj!.userRegistrationSheet;
sheet.additionalInfo = state.editTextController!.text;
//print(json.encode(sheet.toJson()));
final response = await http.post(
Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'),
headers: {'Content-Type': 'application/json'},
body: jsonEncode(sheet),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: jsonEncode(sheet.toJson()),
encoding: utf8);
print(jsonEncode(sheet.toJson()));
print(Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'));
var res = await jsonDecode(response.body);
if (response.statusCode == 200) {
var res = await jsonDecode(response.body);
final box = await Hive.openBox('token');
final token = res['token'];
box.put('token', token);
@@ -93,6 +95,8 @@ class AdditionalInformationScreen extends StatelessWidget {
context,
AppRoutes.myProfile,
);
} else {
showErrorMessage(context, res['message']);
}
};
}
@@ -152,12 +156,12 @@ class AdditionalInformationScreen extends StatelessWidget {
/// Displays an alert dialog when the action is triggered.
/// The dialog box contains a title and a message with the `Теперь вы можете пользоваться полным функционалом приложения`
showSuccessMessage(BuildContext context, String text) {
showErrorMessage(BuildContext context, String text) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('Регистрация завершена!'),
content: const Text('1'),
title: const Text('Ошибка'),
content: Text(text),
actions: [
TextButton(onPressed: onTapOk(context), child: const Text('Ok'))
],

View File

@@ -34,7 +34,7 @@ class CustomBottomBarState extends State<CustomBottomBar> {
type: BottomBarEnum.tf,
),
BottomMenuModel(
icon: ImageConstant.imgNavBlueGray40024x23,
icon: ImageConstant.imgNavPrimary,
activeIcon: ImageConstant.imgNavBlueGray40024x23,
title: "Настройки",
type: BottomBarEnum.tf,

View File

@@ -340,7 +340,7 @@ class _ExpandableListState extends State<ExpandableList> {
'weight': state?.weightFormController?.text,
'blood_pressure_up': state?.upPressureFormController?.text,
'blood_pressure_down': state?.downPressureFormController?.text,
'about_alergy': state?.allergiesFormController?.text,
'about_alergy': state?.allergiesFormController?.text ?? 'Нет аллергий',
'about_taking_pils': state?.pillsFormController?.text,
'about_sport_hobbies': state?.sportsFormController?.text,
'favorite_foods': state?.favoriteFormController?.text,
@@ -362,6 +362,7 @@ class _ExpandableListState extends State<ExpandableList> {
encoding: utf8,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer $token',
},
);
@@ -373,11 +374,12 @@ class _ExpandableListState extends State<ExpandableList> {
AppRoutes.myProfile,
);
} else {
var res = await jsonDecode(response.body);
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Ошибка'),
content: Text('Ошибка при отправке данных профиля'.tr),
content: Text(res['message']),
actions: [
TextButton(
onPressed: onTapOk(context),