Fixed bottom overflow; added GET-request for user profile

This commit is contained in:
2024-01-11 13:13:29 +03:00
parent cf84bf8e2f
commit d10b1acf7f
3 changed files with 22 additions and 3 deletions

View File

@@ -92,7 +92,6 @@ class AuthScreen extends StatelessWidget {
final box = await Hive.openBox('token');
final token = res['token']['plainTextToken'];
box.put('token', token);
print(token);
Navigator.pushNamed(
context,
AppRoutes.myProfile,

View File

@@ -2,6 +2,10 @@ import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import '/core/app_export.dart';
import 'package:eatvio_app/presentation/profile/my_profile_screen/models/my_profile_model.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:hive/hive.dart';
part 'my_profile_event.dart';
part 'my_profile_state.dart';
@@ -14,5 +18,21 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
_onInitialize(
MyProfileInitialEvent event,
Emitter<MyProfileState> emit,
) async {}
) async {
final box = await Hive.openBox('token');
final token = box.get('token');
final response = await http.get(
Uri.parse('http://10.55.5.126:1092/api/profile/index'),
headers: {
'Authorization': 'Bearer $token',
},
);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
print(data);
} else {
// Обработка ошибки
}
}
}

View File

@@ -313,7 +313,7 @@ class MyProfileScreen extends StatelessWidget {
alignment: Alignment.center,
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 5.h, vertical: 2.v),
horizontal: 5.h, vertical: 0.5.v),
decoration: AppDecoration.outlineBlueGray.copyWith(
borderRadius: BorderRadiusStyle.roundedBorder5),
child: Column(