updated designe of aboute diet page

This commit is contained in:
Username1548
2024-11-11 21:10:38 +07:00
parent a9b28c27b9
commit c5e1c5d9b8
46 changed files with 2164 additions and 1012 deletions

View File

@@ -0,0 +1,107 @@
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/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.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});
final Author author;
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Container(
width: MediaQuery.sizeOf(context).width,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: appTheme.cardBackground),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.only(left: 16, top: 16, bottom: 24),
child: Column(
children: [
ListTile(
contentPadding: EdgeInsets.zero,
leading: Container(
width: 64,
height: 64,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: NetworkImage(author.authorProfileIcon),
fit: BoxFit.cover,
),
),
),
subtitle: Text(
author.authorName,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: appTheme.blueGray800,
),
),
title: Text(
s.diet_author,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Color(0xFF6D6F71),
),
),
),
Row(
children: [
Text(
'Конслуьтант',
style: TextStyle(
color: appTheme.blueGray800,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
SizedBox(width: 10),
InfoBouble(radius: 12, backgroundColor: appTheme.whiteA700, children: [
Text(
'128-й в рейтинге',
style: TextStyle(
color: appTheme.blueA400,
fontSize: 16,
fontWeight: FontWeight.w500,
),
)
])
],
)
],
),
),
Positioned(
right: 8,
top: 8,
child: GestureDetector(
onTap: () => GoRouter.of(context).pushNamed('profileScreen', extra: author),
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,
),
),
),
),
)
],
),
);
}
}

View File

@@ -0,0 +1,46 @@
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
class CpfcContainer extends StatelessWidget {
const CpfcContainer({super.key, required this.calories, required this.protein, required this.fat, required this.carbohydrates});
final double calories;
final double protein;
final double fat;
final double carbohydrates;
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Container(
color: appTheme.cardBackground,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Column(
children: [
Text('$calories', style: TextStyle(color: appTheme.blueGray800, fontSize: 16, fontWeight: FontWeight.w600)),
Text(s.calories, style: TextStyle(color: appTheme.blueGray800, fontSize: 12, fontWeight: FontWeight.w500)),
],
),
Column(
children: [
Text('$protein', style: TextStyle(color: appTheme.blueGray800, fontSize: 16, fontWeight: FontWeight.w600)),
Text(s.proteins, style: TextStyle(color: appTheme.blueGray800, fontSize: 12, fontWeight: FontWeight.w500)),
],
),
Column(
children: [
Text('$fat', style: TextStyle(color: appTheme.blueGray800, fontSize: 16, fontWeight: FontWeight.w600)),
Text(s.fats, style: TextStyle(color: appTheme.blueGray800, fontSize: 12, fontWeight: FontWeight.w500)),
],
),
Column(
children: [
Text('$carbohydrates', style: TextStyle(color: appTheme.blueGray800, fontSize: 16, fontWeight: FontWeight.w600)),
Text(s.carbohydrates, style: TextStyle(color: appTheme.blueGray800, fontSize: 12, fontWeight: FontWeight.w500)),
],
)
]),
);
}
}

View File

@@ -0,0 +1,87 @@
import 'dart:math' as math;
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_svg/svg.dart';
class ExpandableText extends StatefulWidget {
final String text;
final int maxLines;
ExpandableText({required this.text, this.maxLines = 3});
@override
_ExpandableTextState createState() => _ExpandableTextState();
}
class _ExpandableTextState extends State<ExpandableText> {
bool isExpanded = false;
void toggleExpansion() {
setState(() {
isExpanded = !isExpanded;
});
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
Html(
data: widget.text,
style: {
"*": Style(
color: Colors.black87,
maxLines: isExpanded ? null : widget.maxLines,
textOverflow: TextOverflow.clip,
),
},
),
if (!isExpanded)
Positioned.fill(
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 35,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.white.withOpacity(0.0),
Colors.white.withOpacity(0.6),
Colors.white,
],
),
),
),
),
),
],
),
Align(
alignment: Alignment.bottomCenter,
child: GestureDetector(
onTap: toggleExpansion,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
isExpanded ? s.hide : s.expand,
style: TextStyle(color: appTheme.blueA400, fontSize: 16, fontWeight: FontWeight.w500),
),
Transform.rotate(angle: isExpanded ? math.pi : 0, child: SvgPicture.asset('assets/icons/arrow_down.svg', width: 12, height: 12)),
],
),
),
),
],
);
}
}

View File

@@ -0,0 +1,20 @@
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
class InfoBouble extends StatelessWidget {
const InfoBouble({super.key, required this.children, this.backgroundColor, this.radius = 100});
final List<Widget> children;
final Color? backgroundColor;
final double radius;
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8.5),
decoration: BoxDecoration(
color: backgroundColor ?? appTheme.gray50,
borderRadius: BorderRadius.circular(radius),
),
child: Row(children: children),
);
}
}

View File

@@ -0,0 +1,38 @@
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
class MainBackgroundBouble extends StatelessWidget {
const MainBackgroundBouble(
{super.key, required this.child, this.width, this.padding, this.enableShadow = false});
final double? width;
final Widget child;
final bool enableShadow;
final EdgeInsetsGeometry? padding;
@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
boxShadow: enableShadow
? [
BoxShadow(
color: Color(0x00000000).withOpacity(0.2),
spreadRadius: 0,
blurRadius: 32,
offset: Offset(0, 0),
),
]
: null),
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Container(
decoration: BoxDecoration(
color: appTheme.whiteA700,
),
width: width ?? MediaQuery.sizeOf(context).width,
padding: padding,
child: child,
),
),
);
}
}

View File

@@ -0,0 +1,96 @@
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_divider.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/main_background_bouble.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:share_plus/share_plus.dart';
class MoreOptions extends StatelessWidget {
const MoreOptions({super.key, required this.id});
final int id;
@override
Widget build(BuildContext context) {
final s = S.of(context);
return MainBackgroundBouble(
enableShadow: true,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: baseUrl + '/ru/diet/' + id.toString()));
showInfoToast(s.link_was_copied);
},
child: Row(
children: [
Text(
s.copy_link,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: appTheme.blueGray800,
),
),
Spacer(),
SvgPicture.asset('assets/icons/copy2.svg', width: 16, height: 20),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
child: CustomDivider(),
),
GestureDetector(
onTap: () => Share.shareUri(
Uri.parse(
baseUrl + '/ru/diet/' + id.toString(),
),
),
child: Row(
children: [
Text(
s.share,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: appTheme.blueGray800,
),
),
Spacer(),
SvgPicture.asset('assets/icons/share2.svg', width: 16, height: 20),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
child: CustomDivider(),
),
GestureDetector(
onTap: () {},
child: Row(
children: [
Text(
s.complain,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: appTheme.blueGray800,
),
),
Spacer(),
SvgPicture.asset('assets/icons/complain.svg', width: 16, height: 20),
],
),
)
],
),
),
width: 272);
}
}

View File

@@ -0,0 +1,222 @@
import 'package:eatvio_app/features/diets/presentation/widgets/main_background_bouble.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_portal/flutter_portal.dart';
import 'package:flutter_svg/svg.dart';
class TypeBadges extends StatefulWidget {
const TypeBadges({super.key, required this.type});
final DietType type;
@override
State<TypeBadges> createState() => _TypeBadgesState();
}
class _TypeBadgesState extends State<TypeBadges> {
final List<bool> overlaysVisibilityState = [false, false, false, false];
@override
Widget build(BuildContext context) {
final s = S.of(context);
final List<(String, Widget)> badgeSource = [];
if (widget.type.alko == true) {
badgeSource.add((
'assets/icons/cocktail.svg',
_InfoOverlayEntry(
onClose: closeOverlay,
assetPath: 'assets/icons/cocktail.svg',
title: s.alko_type,
description: s.alko_type_desc,
)
));
}
if (widget.type.veg == true) {
badgeSource.add((
'assets/icons/broccoli.svg',
_InfoOverlayEntry(
onClose: closeOverlay,
assetPath: 'assets/icons/broccoli.svg',
title: s.vegan_type,
description: s.vegan_type_desc,
)
));
}
if (widget.type.corb == true) {
badgeSource.add((
'assets/icons/bread.svg',
_InfoOverlayEntry(
onClose: closeOverlay,
assetPath: 'assets/icons/bread.svg',
title: s.corb_type,
description: s.corb_type_desc,
)
));
}
if (widget.type.meat == true) {
badgeSource.add((
'assets/icons/meat2.svg',
_InfoOverlayEntry(
onClose: closeOverlay,
assetPath: 'assets/icons/meat2.svg',
title: s.meat_type,
description: s.meat_type_desc,
)
));
}
return Row(
children: List.generate(
badgeSource.length,
(index) => _Barrier(
visible: overlaysVisibilityState[index],
onClose: closeOverlay,
child: PortalTarget(
visible: overlaysVisibilityState[index],
anchor: Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
follower: Alignment.topRight,
target: Alignment.bottomRight,
),
portalFollower: badgeSource[index].$2,
child: GestureDetector(
onTap: () {
for (int stateIndex = 0; stateIndex < overlaysVisibilityState.length; stateIndex++) {
if (index != stateIndex) {
setState(() {
overlaysVisibilityState[stateIndex] = false;
});
} else {
setState(() {
overlaysVisibilityState[stateIndex] = true;
});
}
}
},
child: Padding(
padding: EdgeInsets.only(right: index != badgeSource.length - 1 ? 8.0 : 0),
child: SvgPicture.asset(
badgeSource[index].$1,
width: 16,
height: 16,
),
),
),
),
),
),
);
}
void closeOverlay() {
for (int stateIndex = 0; stateIndex < overlaysVisibilityState.length; stateIndex++) {
setState(() {
overlaysVisibilityState[stateIndex] = false;
});
}
}
}
class _InfoOverlayEntry extends StatelessWidget {
const _InfoOverlayEntry({super.key, required this.title, required this.description, required this.assetPath, required this.onClose});
final String title;
final String description;
final assetPath;
final void Function() onClose;
@override
Widget build(BuildContext context) {
return MainBackgroundBouble(
padding: EdgeInsets.all(8),
width: 343,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SvgPicture.asset(
assetPath,
width: 20,
height: 20,
),
SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
title,
style: TextStyle(
decoration: TextDecoration.none,
color: appTheme.blueGray800,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 4),
Text(
description,
softWrap: true,
style: TextStyle(
decoration: TextDecoration.none,
color: appTheme.blueGray800,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
],
),
),
GestureDetector(
onTap: onClose,
child: SvgPicture.asset(
'assets/icons/close_button.svg',
width: 20,
height: 20,
),
),
],
),
);
}
}
class _Barrier extends StatelessWidget {
const _Barrier({
Key? key,
required this.onClose,
required this.visible,
required this.child,
}) : super(key: key);
final Widget child;
final VoidCallback onClose;
final bool visible;
@override
Widget build(BuildContext context) {
return PortalTarget(
visible: visible,
closeDuration: kThemeAnimationDuration,
portalFollower: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onClose,
child: TweenAnimationBuilder<Color>(
duration: kThemeAnimationDuration,
tween: ColorTween(
begin: Colors.transparent,
end: visible ? Colors.black54 : Colors.transparent,
),
builder: (context, color, child) {
return ColoredBox(color: color);
},
),
),
child: child,
);
}
}
class ColorTween extends Tween<Color> {
ColorTween({required Color begin, required Color end}) : super(begin: begin, end: end);
@override
Color lerp(double t) => Color.lerp(begin, end, t)!;
}