feat(profile): add badges and plans

This commit is contained in:
mso7nueh
2024-10-18 17:47:10 +03:00
parent 8b955bf2bf
commit e2b54cca99
8 changed files with 151 additions and 40 deletions

View File

@@ -1,4 +1,5 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/feed/presentation/widgets/blog_post_widget.dart';
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
@@ -121,6 +122,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
if (widget.author == null) const SizedBox(height: 16),
if (widget.author == null) _charts(),
if (widget.author == null) const SizedBox(height: 16),
_activePlans(state),
if (widget.author == null) const SizedBox(height: 16),
_newBlogPostButton(),
_blogPosts(state),
],
@@ -129,6 +132,74 @@ class _ProfileScreenState extends State<ProfileScreen> {
);
}
_activePlans(ProfileStateLoaded state) {
if (state.profile.role != 'consultant') {
return const SizedBox.shrink();
}
return Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Активные планы',
style: TextStyle(
color: Color(0xFF323F4B),
fontSize: 24,
height: 1,
fontWeight: FontWeight.w600,
),
),
Text(
widget.author == null ? 'Редактировать' : 'Показать все',
style: TextStyle(
color: Color(0xFF2F80ED),
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
],
),
),
const SizedBox(height: 8),
_bullets(0, 4),
],
);
}
_bullets(int currentBullet, int bulletCount) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
for (int i = 0; i < bulletCount; i++) ...[
_bullet(i == currentBullet),
i < bulletCount - 1 ? const SizedBox(width: 4) : const SizedBox.shrink(),
],
],
),
);
}
_bullet(bool isActive) {
return AnimatedContainer(
width: isActive ? 10 : 8,
height: isActive ? 10 : 8,
duration: Duration(milliseconds: 150),
decoration: BoxDecoration(
color: isActive ? appTheme.blueA400 : Color(0xFFD7D9DC),
shape: BoxShape.circle,
),
);
}
_newBlogPostButton() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
@@ -185,7 +256,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Дипломы\nисертификаты',
'Дипломы\nи сертификаты',
style: TextStyle(
color: Color(0xFF323F4B),
fontSize: 24,
@@ -206,12 +277,13 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
const SizedBox(height: 8),
Container(
width: MediaQuery.of(context).size.width - 8,
width: MediaQuery.of(context).size.width - 4,
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Material(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(
@@ -410,20 +482,14 @@ class _ProfileScreenState extends State<ProfileScreen> {
scrollDirection: Axis.horizontal,
child: Row(
children: [
CircleAvatar(
radius: 20,
backgroundColor: Colors.grey.shade200,
),
const SizedBox(width: 8),
CircleAvatar(
radius: 20,
backgroundColor: Colors.grey.shade200,
),
const SizedBox(width: 8),
CircleAvatar(
radius: 20,
backgroundColor: Colors.grey.shade200,
),
for (int i = 0; i < state.profile.badges.length; i++) ...[
SvgPicture.network(
baseUrl + '/storage/' + state.profile.badges[i].image,
width: 40,
height: 40,
),
i < state.profile.badges.length - 1 ? const SizedBox(width: 8) : const SizedBox.shrink(),
],
],
),
),