Files
eatvio_app/lib/features/diets/presentation/widgets/author_card.dart

172 lines
6.2 KiB
Dart

import 'package:eatvio_app/core/app_config.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/utils/url_utils.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/features/user_details/presentation/user_details_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
class AuthorCard extends StatelessWidget {
const AuthorCard({
super.key,
required this.author,
required this.title,
this.backgroundColor,
this.titleStyle,
this.customerProfile,
});
final Author author;
final String title;
final Color? backgroundColor;
final TextStyle? titleStyle;
final ProfileModel? customerProfile;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
GoRouter.of(context).pushNamed(
'profileScreen',
extra: customerProfile != null
? customerProfile!.slug
: author.authorSlug,
);
},
child: Container(
width: MediaQuery.sizeOf(context).width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: backgroundColor ?? appTheme.cardBackground,
),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.only(
left: 16,
top: 16,
bottom: 24,
right: 16,
),
child: Column(
children: [
ListTile(
contentPadding: EdgeInsets.zero,
leading: Container(
width: 64,
height: 64,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: NetworkImage(
joinBaseUrl(
sl<AppConfig>().baseUrl,
customerProfile != null
? customerProfile!.profilePhotoUrl
: author.authorProfileIcon,
),
),
fit: BoxFit.cover,
),
),
),
subtitle: Text(
customerProfile != null
? customerProfile!.name
: author.authorName,
style: TextStyles.textLSemibold.copyWith(
color: appTheme.black,
),
),
title: Text(
title,
style:
titleStyle ??
TextStyles.textSSemibold.copyWith(
color: appTheme.gray,
),
),
),
Row(
children: [
if (customerProfile == null) ...[
Text(
'Консультант',
style: TextStyles.textMMedium.copyWith(
color: appTheme.black,
),
),
const SizedBox(width: 10),
if (author.authorPlaceInRating != null)
InfoBouble(
radius: 12,
backgroundColor: appTheme.cardBackground,
children: [
Text(
'${author.authorPlaceInRating}-й в рейтинге',
style: TextStyles.textMMediumAuto.copyWith(
color: appTheme.blueA400,
),
),
],
),
] else
Expanded(
child: GestureDetector(
onTap: () {
GoRouter.of(context).pushNamed(
UserDetailsScreen.name,
extra: customerProfile!.slug,
);
},
child: InfoBouble(
radius: 12,
backgroundColor: appTheme.cardBackground,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Анкета пользователя',
style: TextStyles.textMMediumAuto.copyWith(
color: appTheme.blueA400,
),
),
],
),
),
),
],
),
],
),
),
Positioned(
right: 8,
top: 8,
child: Container(
width: 28,
height: 28,
decoration: BoxDecoration(
color: appTheme.whiteA700,
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: SvgPicture.asset(
'assets/icons/arrow.svg',
width: 12,
height: 12,
fit: BoxFit.none,
),
),
),
),
],
),
),
);
}
}