forked from eatvio/eatvio_app
feat(feed): Blog post show layouts finished
This commit is contained in:
@@ -134,6 +134,7 @@ class BlogPostBloc extends Bloc<BlogPostEvent, BlogPostState> {
|
||||
List<CommentModel> fillCommentList(List<dynamic> comments) {
|
||||
List<CommentModel> list = [];
|
||||
for (int i = 0; i < comments.length; i++) {
|
||||
print(comments[i]);
|
||||
list.add(CommentModel(
|
||||
id: comments[i]['id'].toString(),
|
||||
userImage: comments[i]['profile_photo_path'],
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'models/comment_model.dart';
|
||||
import 'widgets/comment_widget.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
|
||||
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
|
||||
@@ -148,48 +149,168 @@ class BlogPostScreen extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
CachedNetworkImage(
|
||||
imageUrl:
|
||||
dotenv.env['STORAGE_URL']! + (state.blog_post?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => ClipRRect(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Spacer(),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
state.blog_post?['title'],
|
||||
style: CustomTextStyles.titleMediumBlack,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (value) => tapMenu(value, context, state),
|
||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'edit',
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
PopupMenuItem<String>(
|
||||
value: 'delete',
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
_buildImage(state),
|
||||
SizedBox(height: 16.0),
|
||||
Text(
|
||||
state.blog_post?['description'],
|
||||
style: CustomTextStyles.bodyMediumBluegray800,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(
|
||||
DateFormat('dd.MM.yyyy')
|
||||
.format(DateTime.parse(state.blog_post?['updated_at'])),
|
||||
style: theme.textTheme.bodyMedium,
|
||||
)),
|
||||
SizedBox(height: 16.0),
|
||||
Row(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 24),
|
||||
child: Row(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 8),
|
||||
child: Icon(Icons.favorite_outline),
|
||||
),
|
||||
Text(
|
||||
"Нравится",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
)
|
||||
]),
|
||||
),
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 24),
|
||||
child: Row(children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: Icon(Icons.share_outlined),
|
||||
),
|
||||
Text(
|
||||
"Поделиться",
|
||||
style: CustomTextStyles.titleMediumSemiBold,
|
||||
)
|
||||
]))
|
||||
]),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
_buildImage(BlogPostLoadedState state) {
|
||||
return CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + (state.blog_post?['image'] ?? ''),
|
||||
imageBuilder: (context, imageProvider) => Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
|
||||
child: Image(
|
||||
image: imageProvider,
|
||||
),
|
||||
),
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Text(state.blog_post?['title'],
|
||||
style: CustomTextStyles.titleMediumBlack),
|
||||
SizedBox(height: 8.0),
|
||||
Text(
|
||||
state.blog_post?['description'],
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.blogPostEditScreen,
|
||||
arguments: state.blog_post?['id'].toString(),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 48.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.remove_red_eye,
|
||||
color: Colors.white,
|
||||
),
|
||||
SizedBox(width: 4.0),
|
||||
Text(
|
||||
'24',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.favorite,
|
||||
color: Colors.white,
|
||||
),
|
||||
SizedBox(width: 4.0),
|
||||
Text(
|
||||
'24',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 48.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.comment_outlined,
|
||||
color: Colors.white,
|
||||
),
|
||||
SizedBox(width: 4.0),
|
||||
Text(
|
||||
'${state.comments?.length}',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text('Редактировать'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => context
|
||||
.read<BlogPostBloc>()
|
||||
.add(DeleteEntry(state.blog_post?['id'])),
|
||||
child: Text('Удалить'),
|
||||
),
|
||||
],
|
||||
)
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
void tapMenu(String value, BuildContext context, BlogPostLoadedState state) {
|
||||
if (value == 'edit') {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.blogPostEditScreen,
|
||||
arguments: state.blog_post?['id'].toString(),
|
||||
);
|
||||
} else if (value == 'delete') {
|
||||
context.read<BlogPostBloc>().add(DeleteEntry(state.blog_post?['id']));
|
||||
}
|
||||
}
|
||||
|
||||
_buildTextField(BuildContext context, BlogPostLoadedState state) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(
|
||||
@@ -216,7 +337,7 @@ class BlogPostScreen extends StatelessWidget {
|
||||
Column(
|
||||
children: [
|
||||
CustomTextFormField(
|
||||
maxLines: 8,
|
||||
maxLines: 4,
|
||||
),
|
||||
SizedBox(height: 15.h),
|
||||
CustomOutlinedButton(
|
||||
|
||||
Reference in New Issue
Block a user