Files
eatvio_app/lib/features/profile/presentation/pages/profile_screen.dart

71 lines
2.3 KiB
Dart

import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart';
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_state.dart';
import 'package:eatvio_app/locator_service.dart';
import 'package:flutter/material.dart';
class ProfileScreen extends StatelessWidget {
final Author author;
const ProfileScreen({super.key, required this.author});
@override
Widget build(BuildContext context) {
return BlocProvider<ProfileCubit>(
create: (BuildContext context) => sl<ProfileCubit>()..getProfileBySlug(author.authorSlug),
child: BlocBuilder<ProfileCubit, ProfileState>(
builder: (BuildContext context, ProfileState state) {
if (state is ProfileStateLoaded) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
state.profile.user.name,
style: TextStyle(
color: Colors.black,
fontSize: 24,
fontWeight: FontWeight.w400,
height: 1,
),
),
),
body: SingleChildScrollView(
padding: EdgeInsets.all(16),
child: Column(
children: [
Center(
child: CircleAvatar(
maxRadius: 128,
minRadius: 128,
backgroundImage: NetworkImage(state.profile.user.profilePhotoUrl),
),
),
],
),
),
);
} else if (state is ProfileStateError) {
return Scaffold(
appBar: AppBar(),
body: Center(
child: Padding(
padding: const EdgeInsets.all(16),
child: Text(state.errorMessage),
),
),
);
} else {
return Scaffold(
appBar: AppBar(),
body: Center(
child: CircularProgressIndicator(),
),
);
}
},
),
);
}
}