Send JSON to server

This commit is contained in:
2023-12-26 16:06:24 +03:00
parent 503a82f79e
commit a8ed8b75b1
9 changed files with 48 additions and 53 deletions

View File

@@ -7,21 +7,21 @@ class UserRegistrationSheet {
String email;
String password;
String passwordConfirmation;
bool termsAccepted;
DateTime birthdate;
String termsAccepted;
String birthdate;
String gender;
String country;
String city;
String lang;
int weight;
int height;
int chestCircumference;
int waistCircumference;
int hipCircumference;
int bloodPressureUp;
int bloodPressureDown;
bool hasHypo = false;
bool hasHyper = false;
String weight;
String height;
String chestCircumference;
String waistCircumference;
String hipCircumference;
String bloodPressureUp;
String bloodPressureDown;
String hasHypo = '';
String hasHyper = '';
String aboutAllergy = '';
String aboutTakingPils = '';
String aboutSportHobbies = '';
@@ -66,7 +66,7 @@ class UserRegistrationSheet {
'password': password,
'password_confirmation': passwordConfirmation,
'terms': termsAccepted,
'birthdate': birthdate.toIso8601String(),
'birthdate': birthdate.toString(),
'gender': gender,
'country': country,
'city': city,

View File

@@ -9,8 +9,9 @@ import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_m
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
class AdditionalInformationScreen extends StatefulWidget {
class AdditionalInformationScreen extends StatelessWidget {
const AdditionalInformationScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
@@ -25,13 +26,6 @@ class AdditionalInformationScreen extends StatefulWidget {
child: AdditionalInformationScreen());
}
@override
State<AdditionalInformationScreen> createState() =>
_AdditionalInformationScreenState();
}
class _AdditionalInformationScreenState
extends State<AdditionalInformationScreen> {
@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
@@ -70,14 +64,17 @@ class _AdditionalInformationScreenState
margin: EdgeInsets.only(
left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
var message;
onPressed: () async {
UserRegistrationSheet sheet = state
.additionalInformationModelObj!
.userRegistrationSheet;
sheet.additionalInfo = state.editTextController!.text;
message = sheet.toJson();
print(message);
final response = await http.post(
Uri.parse('http://10.55.5.126:1092/api/register'),
headers: {'Content-Type': 'application/json'},
body: json.encode(sheet),
);
print(response.body);
});
}),
SizedBox(height: 17.v),
@@ -140,7 +137,7 @@ class _AdditionalInformationScreenState
context: context,
builder: (_) => AlertDialog(
title: const Text('Регистрация завершена!'),
content: const Text(text),
content: const Text('1'),
actions: [
TextButton(
onPressed: () {

View File

@@ -18,9 +18,9 @@ class BloodPressureBloc extends Bloc<BloodPressureEvent, BloodPressureState> {
Emitter<BloodPressureState> emit,
) {
if (event.value.id == 1) {
state.bloodPressureModelObj!.userRegistrationSheet.hasHyper = true;
state.bloodPressureModelObj!.userRegistrationSheet.hasHyper = '1';
} else {
state.bloodPressureModelObj!.userRegistrationSheet.hasHyper = false;
state.bloodPressureModelObj!.userRegistrationSheet.hasHyper = '0';
}
emit(state.copyWith(selectedHyperValue: event.value));
}
@@ -30,9 +30,9 @@ class BloodPressureBloc extends Bloc<BloodPressureEvent, BloodPressureState> {
Emitter<BloodPressureState> emit,
) {
if (event.value.id == 1) {
state.bloodPressureModelObj!.userRegistrationSheet.hasHypo = true;
state.bloodPressureModelObj!.userRegistrationSheet.hasHypo = '1';
} else {
state.bloodPressureModelObj!.userRegistrationSheet.hasHypo = false;
state.bloodPressureModelObj!.userRegistrationSheet.hasHypo = '0';
}
emit(state.copyWith(selectedHypoValue: event.value));
}

View File

@@ -178,9 +178,9 @@ class _BloodPressureScreenState extends State<BloodPressureScreen> {
UserRegistrationSheet sheet = state
.bloodPressureModelObj!.userRegistrationSheet;
sheet.bloodPressureUp =
int.tryParse(state.upPressureController!.text)!;
state.upPressureController!.text;
sheet.bloodPressureDown =
int.tryParse(state.downPressureController!.text)!;
state.downPressureController!.text;
Navigator.pushNamed(
context,
AppRoutes.favoriteSportsScreen,

View File

@@ -109,12 +109,12 @@ class BodyCircumferencesScreen extends StatelessWidget {
UserRegistrationSheet sheet = state
.bodyCircumferencesModelObj!
.userRegistrationSheet;
sheet.chestCircumference = int.tryParse(
state.chestCircumferenceController!.text)!;
sheet.waistCircumference = int.tryParse(
state.waistCircumferenceController!.text)!;
sheet.hipCircumference = int.tryParse(
state.hipCircumferenceController!.text)!;
sheet.chestCircumference =
state.chestCircumferenceController!.text!;
sheet.waistCircumference =
state.waistCircumferenceController!.text!;
sheet.hipCircumference =
state.hipCircumferenceController!.text!;
Navigator.pushNamed(
context,
AppRoutes.weightScreen,

View File

@@ -72,7 +72,7 @@ class _DateOfBirthScreenState extends State<DateOfBirthScreen> {
onPressed: () {
UserRegistrationSheet sheet = state
.dateOfBirthModelObj!.userRegistrationSheet;
sheet.birthdate = selectedDate;
sheet.birthdate = selectedDate.toString();
Navigator.pushNamed(
context,
AppRoutes.cityOfLivingScreen,

View File

@@ -26,8 +26,7 @@ class HeightBloc extends Bloc<HeightEvent, HeightState> {
Emitter<HeightState> emit,
) {
emit(state.copyWith(selectedDropDownValue: event.value));
state.heightModelObj?.userRegistrationSheet.height =
int.tryParse(event.value.title)!;
state.heightModelObj?.userRegistrationSheet.height = event.value.title;
}
List<SelectionPopupModel> fillDropdownItemList() {

View File

@@ -14,21 +14,21 @@ class LanguageSelectModel extends Equatable {
email: '',
password: '',
passwordConfirmation: '',
termsAccepted: false,
birthdate: DateTime.now(),
termsAccepted: 'accepted',
birthdate: DateTime.now().toString(),
gender: '',
country: '',
city: '',
lang: '',
weight: 0,
height: 0,
chestCircumference: 0,
waistCircumference: 0,
hipCircumference: 0,
bloodPressureUp: 0,
bloodPressureDown: 0,
hasHypo: false,
hasHyper: false,
weight: '',
height: '',
chestCircumference: '',
waistCircumference: '',
hipCircumference: '',
bloodPressureUp: '',
bloodPressureDown: '',
hasHypo: '',
hasHyper: '',
aboutAllergy: '',
aboutTakingPils: '',
aboutSportHobbies: '',

View File

@@ -26,8 +26,7 @@ class WeightBloc extends Bloc<WeightEvent, WeightState> {
Emitter<WeightState> emit,
) {
emit(state.copyWith(selectedDropDownValue: event.value));
state.weightModelObj?.userRegistrationSheet.weight =
int.tryParse(event.value.title)!;
state.weightModelObj?.userRegistrationSheet.weight = event.value.title;
}
List<SelectionPopupModel> fillDropdownItemList() {