forked from eatvio/eatvio_app
148 lines
5.4 KiB
Dart
148 lines
5.4 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:eatvio_app/core/const.dart';
|
|
import 'package:eatvio_app/core/locator_service.dart';
|
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart';
|
|
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart';
|
|
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
|
import 'package:eatvio_app/features/feed/models/feed_consultant_model.dart';
|
|
import 'package:eatvio_app/features/profile/models/badge_model.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
class ConsultantWidget extends StatelessWidget {
|
|
final FeedConsultantModel consultant;
|
|
|
|
const ConsultantWidget({
|
|
super.key,
|
|
required this.consultant,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
onTap: () {
|
|
GoRouter.of(context).pushNamed(
|
|
'profileScreen',
|
|
extra: Author(
|
|
authorSlug: consultant.slug,
|
|
authorName: consultant.name,
|
|
authorProfileIcon: consultant.photo,
|
|
authorIsMe: (sl<ProfileAvatarCubit>().state as ProfileAvatarStateLoaded).profile.slug == consultant.slug ? true : false,
|
|
),
|
|
);
|
|
},
|
|
borderRadius: BorderRadius.circular(20),
|
|
child: Ink(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(20),
|
|
color: const Color(0xFFF6F6F6),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Ink(
|
|
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Text(
|
|
'${consultant.ratingPlace}',
|
|
style: TextStyle(
|
|
fontSize: 20,
|
|
color: appTheme.blueA400,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
CircleAvatar(
|
|
foregroundImage: NetworkImage(baseUrl + consultant.photo),
|
|
backgroundImage: const AssetImage('assets/images/no_avatar.png'),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
consultant.name,
|
|
style: const TextStyle(
|
|
height: 1,
|
|
fontWeight: FontWeight.w500,
|
|
fontSize: 15,
|
|
color: Color(0xFF323F4B),
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
'Рейтинг: ${consultant.totalScores}',
|
|
style: TextStyle(
|
|
color: appTheme.blueA400,
|
|
height: 1,
|
|
fontWeight: FontWeight.w500,
|
|
fontSize: 12,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
Ink(
|
|
padding: const EdgeInsets.all(6),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(4),
|
|
color: Colors.white,
|
|
),
|
|
child: SvgPicture.asset(
|
|
'assets/icons/go_to_arrow.svg',
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
consultant.description,
|
|
maxLines: 2,
|
|
),
|
|
if (consultant.badges.isNotEmpty) const SizedBox(height: 8),
|
|
_badges(consultant.badges, context),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
_badges(List<BadgeModel> badges, BuildContext context) {
|
|
return SingleChildScrollView(
|
|
scrollDirection: Axis.horizontal,
|
|
child: Row(
|
|
children: [
|
|
for (int i = 0; i < badges.length; i++) ...[
|
|
badges[i].image.contains('svg')
|
|
? SvgPicture.network(
|
|
'$baseUrl/storage/${badges[i].image}',
|
|
width: 28,
|
|
height: 28,
|
|
)
|
|
: CachedNetworkImage(
|
|
imageUrl: '$baseUrl/storage/${badges[i].image}',
|
|
width: 28,
|
|
height: 28,
|
|
),
|
|
i < badges.length - 1 ? const SizedBox(width: 8) : const SizedBox.shrink(),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|