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["paidPlan"])
|
||||||
..addAll(data["requestedPlan"])
|
..addAll(data["requestedPlan"])
|
||||||
..addAll(data["initedPlan"]);
|
..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(
|
emit((currentState).copyWith(
|
||||||
chartPoints: data['chartPoints'],
|
chartPoints: chartPoints,
|
||||||
circumferences: data['circumferences'],
|
circumferences: circumferences,
|
||||||
user: data['user'],
|
user: data['user'],
|
||||||
userDetails: data['userDetails'],
|
userDetails: data['userDetails'],
|
||||||
plans: plans,
|
plans: plans,
|
||||||
@@ -88,14 +117,50 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
|
|||||||
hyperFormController: currentState.hyperFormController,
|
hyperFormController: currentState.hyperFormController,
|
||||||
));
|
));
|
||||||
} else {
|
} 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(
|
emit(MyProfileLoadedState(
|
||||||
chartPoints: data['chartPoints'],
|
chartPoints: chartPoints,
|
||||||
circumferences: data['circumferences'],
|
circumferences: circumferences,
|
||||||
user: data['user'],
|
user: data['user'],
|
||||||
userDetails: data['userDetails'],
|
userDetails: data['userDetails'],
|
||||||
plans: data['plans'],
|
plans: plans,
|
||||||
token: token,
|
token: token,
|
||||||
hypoFormController: data['userDetails']['has_hypo'].toString(),
|
hypoFormController: data['userDetails']['has_hypo'].toString(),
|
||||||
hyperFormController: data['userDetails']['has_hyper'].toString(),
|
hyperFormController: data['userDetails']['has_hyper'].toString(),
|
||||||
|
|||||||
Reference in New Issue
Block a user