forked from eatvio/eatvio_app
Chart point validation
This commit is contained in:
@@ -50,11 +50,40 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
|
||||
..addAll(data["paidPlan"])
|
||||
..addAll(data["requestedPlan"])
|
||||
..addAll(data["initedPlan"]);
|
||||
|
||||
Map<String, dynamic> chartPoints = data["chartPoints"] ?? {};
|
||||
Map<String, dynamic> circumferences = data["circumferences"] ?? {};
|
||||
|
||||
if (chartPoints.length < 4) {
|
||||
for (int i = chartPoints.length; i < 4; i++) {
|
||||
chartPoints["$i"] = {
|
||||
"id": 0,
|
||||
"user_id": 0,
|
||||
"weight": 0,
|
||||
"created_at": "",
|
||||
"updated_at": ""
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (circumferences.length < 4) {
|
||||
for (int i = circumferences.length; i < 4; i++) {
|
||||
circumferences["$i"] = {
|
||||
"id": 0,
|
||||
"user_id": 0,
|
||||
"chest_circumference": 0,
|
||||
"waist_circumference": 0,
|
||||
"hip_circumference": 0,
|
||||
"created_at": "",
|
||||
"updated_at": ""
|
||||
};
|
||||
}
|
||||
}
|
||||
// Обновляем значения контроллеров только если они уже были созданы
|
||||
|
||||
emit((currentState).copyWith(
|
||||
chartPoints: data['chartPoints'],
|
||||
circumferences: data['circumferences'],
|
||||
chartPoints: chartPoints,
|
||||
circumferences: circumferences,
|
||||
user: data['user'],
|
||||
userDetails: data['userDetails'],
|
||||
plans: plans,
|
||||
@@ -88,14 +117,50 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
|
||||
hyperFormController: currentState.hyperFormController,
|
||||
));
|
||||
} else {
|
||||
print(data['userDetails']);
|
||||
var plans = []
|
||||
..addAll(data["finishedPlans"])
|
||||
..addAll(data["rejectedPlans"])
|
||||
..addAll(data["startedPlan"])
|
||||
..addAll(data["paidPlan"])
|
||||
..addAll(data["requestedPlan"])
|
||||
..addAll(data["initedPlan"]);
|
||||
|
||||
Map<String, dynamic> chartPoints = data["chartPoints"] ?? {};
|
||||
Map<String, dynamic> circumferences = data["circumferences"] ?? {};
|
||||
|
||||
if (chartPoints.length < 4) {
|
||||
for (int i = chartPoints.length; i < 4; i++) {
|
||||
chartPoints["$i"] = {
|
||||
"id": 0,
|
||||
"user_id": 0,
|
||||
"weight": 0,
|
||||
"created_at": "",
|
||||
"updated_at": ""
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (circumferences.length < 4) {
|
||||
for (int i = circumferences.length; i < 4; i++) {
|
||||
circumferences["$i"] = {
|
||||
"id": 0,
|
||||
"user_id": 0,
|
||||
"chest_circumference": 0,
|
||||
"waist_circumference": 0,
|
||||
"hip_circumference": 0,
|
||||
"created_at": "",
|
||||
"updated_at": ""
|
||||
};
|
||||
}
|
||||
}
|
||||
print(chartPoints);
|
||||
// Если текущее состояние - начальное, создаем новое загруженное состояние
|
||||
emit(MyProfileLoadedState(
|
||||
chartPoints: data['chartPoints'],
|
||||
circumferences: data['circumferences'],
|
||||
chartPoints: chartPoints,
|
||||
circumferences: circumferences,
|
||||
user: data['user'],
|
||||
userDetails: data['userDetails'],
|
||||
plans: data['plans'],
|
||||
plans: plans,
|
||||
token: token,
|
||||
hypoFormController: data['userDetails']['has_hypo'].toString(),
|
||||
hyperFormController: data['userDetails']['has_hyper'].toString(),
|
||||
|
||||
Reference in New Issue
Block a user