From d10b1acf7f19d00553843cb6e691ddcefbcb7525 Mon Sep 17 00:00:00 2001 From: maxxkim Date: Thu, 11 Jan 2024 13:13:29 +0300 Subject: [PATCH] Fixed bottom overflow; added GET-request for user profile --- .../auth/auth_screen/auth_screen.dart | 1 - .../bloc/my_profile_bloc.dart | 22 ++++++++++++++++++- .../my_profile_screen/my_profile_screen.dart | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/presentation/auth/auth_screen/auth_screen.dart b/lib/presentation/auth/auth_screen/auth_screen.dart index 143ab549..61d25848 100644 --- a/lib/presentation/auth/auth_screen/auth_screen.dart +++ b/lib/presentation/auth/auth_screen/auth_screen.dart @@ -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, diff --git a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart index 1bd2b992..bdb02f07 100644 --- a/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart +++ b/lib/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart @@ -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 { _onInitialize( MyProfileInitialEvent event, Emitter 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 { + // Обработка ошибки + } + } } diff --git a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart index a9b25c34..00beddde 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -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(