diff --git a/lib/core/app_router.dart b/lib/core/app_router.dart index 70107e0a..223a8913 100644 --- a/lib/core/app_router.dart +++ b/lib/core/app_router.dart @@ -121,7 +121,7 @@ class AppRouter { GoRoute( path: 'forget-password-screen', name: 'forgetPasswordScreen', - builder: (context, state) => const ForgetPasswordScreen(), + builder: (context, state) => ForgetPasswordScreen(isAuth: state.extra as bool,), ), GoRoute( path: 'scan-qr-code-screen', diff --git a/lib/core/widgets/success_published_recipe_bottom_sheet.dart b/lib/core/widgets/success_published_recipe_bottom_sheet.dart index 9fb1ddeb..796e7d91 100644 --- a/lib/core/widgets/success_published_recipe_bottom_sheet.dart +++ b/lib/core/widgets/success_published_recipe_bottom_sheet.dart @@ -26,9 +26,13 @@ class SuccessPublishedRecipeBottomSheet extends StatelessWidget { s.recipe_publishing, style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black), ), - Text( - '"$title" ${s.successfully_published}', - style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Text( + '"$title" ${s.successfully_published}', + textAlign: TextAlign.center, + style: TextStyles.headingXLSemibold.copyWith(color: appTheme.black), + ), ), const SizedBox( height: 20, diff --git a/lib/features/auth/presentation/pages/auth_screen.dart b/lib/features/auth/presentation/pages/auth_screen.dart index c0847e0e..6b4ec260 100644 --- a/lib/features/auth/presentation/pages/auth_screen.dart +++ b/lib/features/auth/presentation/pages/auth_screen.dart @@ -141,7 +141,7 @@ class _AuthScreenState extends State { const SizedBox(height: 16), Center( child: GestureDetector( - onTap: () => GoRouter.of(context).goNamed('forgetPasswordScreen'), + onTap: () => GoRouter.of(context).goNamed('forgetPasswordScreen', extra: false), child: Text( 'Забыли пароль?', style: TextStyle( diff --git a/lib/features/auth/presentation/pages/forget_password_screen.dart b/lib/features/auth/presentation/pages/forget_password_screen.dart index 78313a15..d842fcfc 100644 --- a/lib/features/auth/presentation/pages/forget_password_screen.dart +++ b/lib/features/auth/presentation/pages/forget_password_screen.dart @@ -9,7 +9,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; class ForgetPasswordScreen extends StatefulWidget { - const ForgetPasswordScreen({super.key}); + final bool isAuth; + const ForgetPasswordScreen({super.key, required this.isAuth}); @override State createState() => _ForgetPasswordScreenState(); @@ -29,7 +30,7 @@ class _ForgetPasswordScreenState extends State { builder: (BuildContext context, ResetPasswordState state) { return Scaffold( appBar: AppBar( - title: const Text('Смена пароля'), + title: widget.isAuth ? const Text('Смена пароля') : const Text('Восстановление пароля'), centerTitle: false, ), body: state is ResetPasswordStateLoadingResetPassword || state is ResetPasswordStateLoadingSendEmailCode @@ -42,9 +43,9 @@ class _ForgetPasswordScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ if (state is ResetPasswordStateCodeSendError || state is ResetPasswordStateEmpty) ...[ - const Text( - 'Забыли пароль? Укажите свой email,\nи мы пришлём код для сброса.', - style: TextStyle( + Text( + '${widget.isAuth ? '' : 'Забыли пароль? '}Укажите свой email,\nи мы пришлём код для сброса.', + style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w500, ), @@ -156,7 +157,7 @@ class _ForgetPasswordScreenState extends State { } if (state is ResetPasswordStateResetPassowrdSuccess) { GoRouter.of(context).pop(); - showSuccessToast('Пароль успешно сменён. Войдите в аккаунт'); + showSuccessToast('Пароль успешно сменён. ${widget.isAuth ? '' : 'Войдите в аккаунт'}'); } }, ), diff --git a/lib/features/diets/presentation/widgets/expandable_text.dart b/lib/features/diets/presentation/widgets/expandable_text.dart index 18de6ae5..5832ec86 100644 --- a/lib/features/diets/presentation/widgets/expandable_text.dart +++ b/lib/features/diets/presentation/widgets/expandable_text.dart @@ -10,7 +10,11 @@ class ExpandableText extends StatefulWidget { final String text; final int maxLines; - const ExpandableText({super.key, required this.text, this.maxLines = 3}); + const ExpandableText({ + super.key, + required this.text, + this.maxLines = 5, // по умолчанию 5 строк + }); @override State createState() => _ExpandableTextState(); @@ -18,6 +22,29 @@ class ExpandableText extends StatefulWidget { class _ExpandableTextState extends State { bool isExpanded = false; + bool showExpandButton = false; + + final GlobalKey _textKey = GlobalKey(); + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + WidgetsBinding.instance.addPostFrameCallback((_) => _checkTextOverflow()); + } + + void _checkTextOverflow() { + final textRenderObject = _textKey.currentContext?.findRenderObject(); + if (textRenderObject is RenderBox) { + final maxLinesHeight = widget.maxLines * TextStyles.textMMediumAuto.fontSize! * 1.2; + final actualHeight = textRenderObject.size.height; + + if (actualHeight > maxLinesHeight && !showExpandButton) { + setState(() { + showExpandButton = true; + }); + } + } + } void toggleExpansion() { setState(() { @@ -33,52 +60,63 @@ class _ExpandableTextState extends State { children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 16), - child: Stack( - children: [ - Text( - widget.text, - style: TextStyles.textMMediumAuto.copyWith(color: appTheme.black), - // style: { - // "*": Style( - // margin: Margins.all(0), - // 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.withValues(alpha: 0.0), Colors.white.withValues(alpha: 0.6), Colors.white], + child: AnimatedSize( + duration: const Duration(milliseconds: 200), + curve: Curves.easeInOut, + child: Stack( + children: [ + Text( + widget.text, + key: _textKey, + style: TextStyles.textMMediumAuto.copyWith(color: appTheme.black), + maxLines: isExpanded ? null : widget.maxLines, + overflow: TextOverflow.clip, + ), + if (!isExpanded && showExpandButton) + Positioned.fill( + child: Align( + alignment: Alignment.bottomCenter, + child: Container( + height: 35, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Colors.white.withAlpha(0), + Colors.white.withAlpha((255 * 0.6).toInt()), + Colors.white, + ], + ), ), ), ), ), - ), - ], - ), - ), - Align( - alignment: Alignment.bottomCenter, - child: GestureDetector( - onTap: toggleExpansion, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(isExpanded ? s.hide : s.expand, style: TextStyles.textMMedium.copyWith(color: appTheme.blueA400)), - Transform.rotate(angle: isExpanded ? math.pi : 0, child: SvgPicture.asset('assets/icons/arrow_down.svg', width: 12, height: 12)), ], ), ), ), + if (showExpandButton) + Align( + alignment: Alignment.bottomCenter, + child: GestureDetector( + onTap: toggleExpansion, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + isExpanded ? s.hide : s.expand, + style: TextStyles.textMMedium.copyWith(color: appTheme.blueA400), + ), + const SizedBox(width: 4), + Transform.rotate( + angle: isExpanded ? math.pi : 0, + child: SvgPicture.asset('assets/icons/arrow_down.svg', width: 12, height: 12), + ), + ], + ), + ), + ), ], ); } diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index 359bd21a..7c94e537 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -216,7 +216,7 @@ class _ProfileScreenState extends State { Scaffold _myProfileScreen(ProfileStateLoaded state) { return Scaffold( backgroundColor: Colors.grey.shade200, - appBar: AppBar(toolbarHeight: 0), + appBar: AppBar(), body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/features/recipe/presentation/pages/about_recipe_screen.dart b/lib/features/recipe/presentation/pages/about_recipe_screen.dart index b9328ba3..8c6a5e8b 100644 --- a/lib/features/recipe/presentation/pages/about_recipe_screen.dart +++ b/lib/features/recipe/presentation/pages/about_recipe_screen.dart @@ -205,14 +205,14 @@ class _AboutRecipeScreenState extends State { appBar: AppBar( centerTitle: true, leading: BackButton( - onPressed: () { - if (context.canPop()) { - GoRouter.of(context).pop(); - return; - } - GoRouter.of(context).go('/feed-screen'); - }, - ), + onPressed: () { + if (context.canPop()) { + GoRouter.of(context).pop(); + return; + } + GoRouter.of(context).go('/feed-screen'); + }, + ), title: Text( recipeState.recipe.title ?? '', maxLines: 2, @@ -356,6 +356,7 @@ class _AboutRecipeScreenState extends State { ), ), ), + const SizedBox(height: 12), ExpandableText(text: recipeState.recipe.description), const SizedBox(height: 20), Padding( @@ -400,14 +401,14 @@ class _AboutRecipeScreenState extends State { appBar: AppBar( centerTitle: true, leading: BackButton( - onPressed: () { - if (context.canPop()) { - GoRouter.of(context).pop(); - return; - } - GoRouter.of(context).go('/feed-screen'); - }, - ), + onPressed: () { + if (context.canPop()) { + GoRouter.of(context).pop(); + return; + } + GoRouter.of(context).go('/feed-screen'); + }, + ), title: Text( '', maxLines: 2, diff --git a/lib/features/settings/presentation/pages/settings_screen.dart b/lib/features/settings/presentation/pages/settings_screen.dart index c5c9dc99..67460955 100644 --- a/lib/features/settings/presentation/pages/settings_screen.dart +++ b/lib/features/settings/presentation/pages/settings_screen.dart @@ -164,12 +164,8 @@ class _SettingsScreenState extends State { _divider(context), _tile( onTap: () => GoRouter.of(context).pushNamed( - 'changePasswordScreen', - extra: SettingsEntity( - profileSettingsModel: state.profileSettings, - profileDetailsModel: state.profileDetails, - settingsCubit: settingsCubit, - ), + 'forgetPasswordScreen', + extra: true, ), title: 'Сменить пароль', ),