From 8b955bf2bf400a52b739a2becebe9565390fb024 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Fri, 18 Oct 2024 15:52:21 +0300 Subject: [PATCH] feat(profile): create blog post button --- .../presentation/pages/photo_view_screen.dart | 4 +- .../widgets/chat_entry_widget.dart | 2 +- .../presentation/pages/profile_screen.dart | 60 +++++++++++++++++-- lib/old/auth/auth_screen/auth_screen.dart | 10 ++-- .../diet_create_screen.dart | 8 +-- 5 files changed, 66 insertions(+), 18 deletions(-) diff --git a/lib/features/chat/presentation/pages/photo_view_screen.dart b/lib/features/chat/presentation/pages/photo_view_screen.dart index b7fce0c5..6148c52c 100644 --- a/lib/features/chat/presentation/pages/photo_view_screen.dart +++ b/lib/features/chat/presentation/pages/photo_view_screen.dart @@ -70,9 +70,9 @@ class _PhotoViewScreenState extends State { body: SafeArea( child: Column( children: [ - SizedBox(height: 32), + const SizedBox(height: 32), Text('Файл'), - SizedBox(height: 8), + const SizedBox(height: 8), ListTile( shape: RoundedRectangleBorder( borderRadius: BorderRadiusStyle.circleBorder17, diff --git a/lib/features/chat/presentation/widgets/chat_entry_widget.dart b/lib/features/chat/presentation/widgets/chat_entry_widget.dart index e8150dc1..19c69160 100644 --- a/lib/features/chat/presentation/widgets/chat_entry_widget.dart +++ b/lib/features/chat/presentation/widgets/chat_entry_widget.dart @@ -55,7 +55,7 @@ class _ChatEntryWidgetState extends State { ), backgroundColor: Colors.white, ), - SizedBox(width: 12), + const SizedBox(width: 12), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index 62ef6e5f..bfb639c3 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -106,20 +106,22 @@ class _ProfileScreenState extends State { if (state.profileDetails.additionalInfo.isNotEmpty) _additionalInfo(state), if (widget.author != null) const SizedBox(height: 8), if (widget.author != null) _messageAndSubscribe(), - if (widget.author != null) SizedBox(height: 16), + if (widget.author != null) const SizedBox(height: 16), ], ), ), _subscriptionsAndSubscribers(state), _badges(state), - if (widget.author == null) SizedBox(height: 16), + if (widget.author == null) const SizedBox(height: 16), _socialLinks(state), - if (widget.author == null) SizedBox(height: 16), + if (widget.author == null) const SizedBox(height: 16), _education(state), - if (widget.author == null) SizedBox(height: 16), + if (widget.author == null) const SizedBox(height: 16), _diplomasAndCertificates(state), - if (widget.author == null) SizedBox(height: 16), + if (widget.author == null) const SizedBox(height: 16), if (widget.author == null) _charts(), + if (widget.author == null) const SizedBox(height: 16), + _newBlogPostButton(), _blogPosts(state), ], ), @@ -127,6 +129,50 @@ class _ProfileScreenState extends State { ); } + _newBlogPostButton() { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Material( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: InkWell( + onTap: () { + GoRouter.of(context).pushNamed('blogPostCreateScreen'); + }, + borderRadius: BorderRadius.circular(8), + child: Ink( + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Color(0xFFF6FAFF), + borderRadius: BorderRadius.circular(8), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.add_circle_outline_rounded, + color: Color(0xFF2F80ED), + ), + const SizedBox(width: 12), + Text( + 'Новая запись', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Color(0xFF2F80ED), + ), + ), + ], + ), + ), + ), + ), + ), + ); + } + _diplomasAndCertificates(ProfileStateLoaded state) { if (state.profile.role != 'consultant') { return const SizedBox.shrink(); @@ -513,7 +559,9 @@ class _ProfileScreenState extends State { padding: EdgeInsets.symmetric(vertical: 16), shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - itemBuilder: (context, index) => BlogPostWidget(feedBlogPostModel: state.blogPosts[index]), + itemBuilder: (context, index) => BlogPostWidget( + feedBlogPostModel: state.blogPosts[index], + ), separatorBuilder: (context, index) => SizedBox(height: 8), itemCount: state.blogPosts.length, ); diff --git a/lib/old/auth/auth_screen/auth_screen.dart b/lib/old/auth/auth_screen/auth_screen.dart index 3850cacf..4548111e 100644 --- a/lib/old/auth/auth_screen/auth_screen.dart +++ b/lib/old/auth/auth_screen/auth_screen.dart @@ -54,7 +54,7 @@ class _AuthScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(s.email), - SizedBox(height: 4), + const SizedBox(height: 4), BlocSelector( selector: (state) => state.emailController, builder: (context, emailController) { @@ -67,9 +67,9 @@ class _AuthScreenState extends State { ); }, ), - SizedBox(height: 16), + const SizedBox(height: 16), Text(s.password), - SizedBox(height: 4), + const SizedBox(height: 4), BlocSelector( selector: (state) => state.passwordController, builder: (context, passwordController) { @@ -91,7 +91,7 @@ class _AuthScreenState extends State { ); }, ), - SizedBox(height: 16), + const SizedBox(height: 16), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -135,7 +135,7 @@ class _AuthScreenState extends State { ), ], ), - SizedBox(height: 16), + const SizedBox(height: 16), BlocBuilder( builder: (context, state) { return Container( diff --git a/lib/old/diets/diet_create_screen/diet_create_screen.dart b/lib/old/diets/diet_create_screen/diet_create_screen.dart index bad75b05..d04fff59 100644 --- a/lib/old/diets/diet_create_screen/diet_create_screen.dart +++ b/lib/old/diets/diet_create_screen/diet_create_screen.dart @@ -47,7 +47,7 @@ class DietCreateScreen extends StatelessWidget { decoration: AppDecoration.fillGray, child: ListView( children: [ - SizedBox(height: 30), + const SizedBox(height: 30), Container( margin: EdgeInsets.only( left: 16, @@ -70,17 +70,17 @@ class DietCreateScreen extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - SizedBox(height: 16.0), + const SizedBox(height: 16.0), TextFormField( controller: state.name, decoration: InputDecoration(labelText: 'Заголовок'), ), - SizedBox(height: 16.0), + const SizedBox(height: 16.0), TextFormField( controller: state.details, decoration: InputDecoration(labelText: 'Описание'), ), - SizedBox(height: 16.0), + const SizedBox(height: 16.0), // Здесь нужно добавить виджет для загрузки картинки ElevatedButton( onPressed: () => context.read().add(CreateDiet()),