forked from eatvio/eatvio_app
142 lines
5.1 KiB
Dart
142 lines
5.1 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:eatvio_app/core/app_config.dart';
|
|
import 'package:eatvio_app/core/locator_service.dart';
|
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|
import 'package:eatvio_app/core/utils/url_utils.dart';
|
|
import 'package:eatvio_app/core/widgets/network_svg_picture.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: consultant.slug);
|
|
},
|
|
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(
|
|
joinBaseUrl(sl<AppConfig>().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),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
SingleChildScrollView _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')
|
|
? NetworkSvgPicture(
|
|
url:
|
|
'${sl<AppConfig>().baseUrl}/storage/${badges[i].image}',
|
|
width: 28,
|
|
height: 28,
|
|
)
|
|
: CachedNetworkImage(
|
|
imageUrl:
|
|
'${sl<AppConfig>().baseUrl}/storage/${badges[i].image}',
|
|
width: 28,
|
|
height: 28,
|
|
),
|
|
i < badges.length - 1
|
|
? const SizedBox(width: 8)
|
|
: const SizedBox.shrink(),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|