forked from eatvio/eatvio_app
Circumference edit success
This commit is contained in:
@@ -55,6 +55,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
|
|||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
user: data['user'],
|
user: data['user'],
|
||||||
userDetails: data['userDetails'],
|
userDetails: data['userDetails'],
|
||||||
|
token: token,
|
||||||
chartPoints: data['chartPoints'],
|
chartPoints: data['chartPoints'],
|
||||||
plans: data['plans'],
|
plans: data['plans'],
|
||||||
chestCircumferenceController: TextEditingController(),
|
chestCircumferenceController: TextEditingController(),
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class MyProfileState extends Equatable {
|
|||||||
this.userDetails,
|
this.userDetails,
|
||||||
this.chartPoints,
|
this.chartPoints,
|
||||||
this.plans,
|
this.plans,
|
||||||
|
this.token,
|
||||||
this.circumferences});
|
this.circumferences});
|
||||||
|
|
||||||
MyProfileModel? myProfileModelObj;
|
MyProfileModel? myProfileModelObj;
|
||||||
@@ -24,6 +25,7 @@ class MyProfileState extends Equatable {
|
|||||||
TextEditingController? chestCircumferenceController;
|
TextEditingController? chestCircumferenceController;
|
||||||
TextEditingController? waistCircumferenceController;
|
TextEditingController? waistCircumferenceController;
|
||||||
TextEditingController? hipCircumferenceController;
|
TextEditingController? hipCircumferenceController;
|
||||||
|
String? token;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [
|
List<Object?> get props => [
|
||||||
@@ -34,7 +36,8 @@ class MyProfileState extends Equatable {
|
|||||||
plans,
|
plans,
|
||||||
chestCircumferenceController,
|
chestCircumferenceController,
|
||||||
waistCircumferenceController,
|
waistCircumferenceController,
|
||||||
hipCircumferenceController
|
hipCircumferenceController,
|
||||||
|
token
|
||||||
];
|
];
|
||||||
MyProfileState copyWith({
|
MyProfileState copyWith({
|
||||||
MyProfileModel? myProfileModelObj,
|
MyProfileModel? myProfileModelObj,
|
||||||
@@ -46,6 +49,7 @@ class MyProfileState extends Equatable {
|
|||||||
TextEditingController? chestCircumferenceController,
|
TextEditingController? chestCircumferenceController,
|
||||||
TextEditingController? waistCircumferenceController,
|
TextEditingController? waistCircumferenceController,
|
||||||
TextEditingController? hipCircumferenceController,
|
TextEditingController? hipCircumferenceController,
|
||||||
|
String? token,
|
||||||
}) {
|
}) {
|
||||||
return MyProfileState(
|
return MyProfileState(
|
||||||
myProfileModelObj: myProfileModelObj ?? this.myProfileModelObj,
|
myProfileModelObj: myProfileModelObj ?? this.myProfileModelObj,
|
||||||
@@ -60,6 +64,7 @@ class MyProfileState extends Equatable {
|
|||||||
waistCircumferenceController ?? this.waistCircumferenceController,
|
waistCircumferenceController ?? this.waistCircumferenceController,
|
||||||
hipCircumferenceController:
|
hipCircumferenceController:
|
||||||
hipCircumferenceController ?? this.hipCircumferenceController,
|
hipCircumferenceController ?? this.hipCircumferenceController,
|
||||||
|
token: token ?? this.token,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,7 +190,9 @@ class MyProfileScreen extends StatelessWidget {
|
|||||||
|
|
||||||
// Отправка HTTP-запроса
|
// Отправка HTTP-запроса
|
||||||
print(jsonData);
|
print(jsonData);
|
||||||
|
print(state.token);
|
||||||
try {
|
try {
|
||||||
|
final token = state.token;
|
||||||
final response =
|
final response =
|
||||||
await http.post(
|
await http.post(
|
||||||
Uri.parse(dotenv.env[
|
Uri.parse(dotenv.env[
|
||||||
@@ -199,15 +201,15 @@ class MyProfileScreen extends StatelessWidget {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type':
|
'Content-Type':
|
||||||
'application/json',
|
'application/json',
|
||||||
|
'Authorization':
|
||||||
|
'Bearer $token',
|
||||||
},
|
},
|
||||||
body: jsonData,
|
body: jsonData,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode ==
|
if (response.statusCode ==
|
||||||
200) {
|
200) {
|
||||||
// Успешный ответ от сервера
|
Navigator.pop(context);
|
||||||
print(
|
|
||||||
"Данные успешно отправлены");
|
|
||||||
} else {
|
} else {
|
||||||
// Ошибка от сервера
|
// Ошибка от сервера
|
||||||
print(
|
print(
|
||||||
@@ -218,7 +220,6 @@ class MyProfileScreen extends StatelessWidget {
|
|||||||
print(
|
print(
|
||||||
"Ошибка при отправке запроса: $e");
|
"Ошибка при отправке запроса: $e");
|
||||||
}
|
}
|
||||||
//Navigator.pop(context);
|
|
||||||
},
|
},
|
||||||
child: Text("Изменить",
|
child: Text("Изменить",
|
||||||
style: CustomTextStyles
|
style: CustomTextStyles
|
||||||
|
|||||||
Reference in New Issue
Block a user