feat(app): Initial layouts for subscribers, feed display fix, feed photo upload front end

This commit is contained in:
2024-06-27 13:17:53 +03:00
parent 6e7f1acf46
commit b1508c3553
12 changed files with 709 additions and 184 deletions

View File

@@ -50,12 +50,12 @@ class FeedBloc extends Bloc<FeedEvent, FeedState> {
emit((currentState).copyWith(
posts: data,
myProfileModelObj: currentState.myProfileModelObj,
),);
));
} else {
print('Got unloaded');
emit(FeedLoadedState(
posts: data,
),);
));
}
} else {
// Один или несколько ключевых полей отсутствуют, обрабатываем ошибку

View File

@@ -13,7 +13,10 @@ import 'package:intl/intl.dart';
class FeedScreen extends StatelessWidget {
static Widget builder(BuildContext context) {
return BlocProvider<FeedBloc>(create: (context) => FeedBloc(FeedState(myProfileModelObj: FeedModel()))..add(FeedInitialEvent()), child: FeedScreen());
return BlocProvider<FeedBloc>(
create: (context) => FeedBloc(FeedState(myProfileModelObj: FeedModel()))
..add(FeedInitialEvent()),
child: FeedScreen());
}
Widget build(BuildContext context) {
@@ -103,7 +106,8 @@ class FeedScreen extends StatelessWidget {
flex: 1,
child: CustomOutlinedButton(
text: "+",
onPressed: () => GoRouter.of(context).goNamed('blogPostCreateScreen'),
onPressed: () =>
GoRouter.of(context).goNamed('blogPostCreateScreen'),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
),
),
@@ -132,23 +136,25 @@ class FeedScreen extends StatelessWidget {
_buildFeedEntry(post, BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(children: [
margin: EdgeInsets.only(bottom: 10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
ListTile(
leading: CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! + (post["author"]['profile_photo_path'] ?? ''),
imageUrl: dotenv.env['STORAGE_URL']! +
(post['profile_photo_path'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
@@ -161,16 +167,17 @@ class FeedScreen extends StatelessWidget {
),
),
title: Text(
post?['author']['name'] ?? '',
post?['author_name'] ?? 'Authorae',
style: CustomTextStyles.titleMediumSemiBold,
),
subtitle: Text(
DateFormat('dd.MM.yyyy').format(DateTime.parse(post?['post']['updated_at'])),
DateFormat('dd.MM.yyyy')
.format(DateTime.parse(post?['updated_at'])),
style: theme.textTheme.bodyMedium,
),
onTap: () => GoRouter.of(context).goNamed(
'blogPostScreen',
extra: post?['post']['id'].toString(),
extra: post?['id'].toString(),
),
trailing: PopupMenuButton<String>(
onSelected: (value) => print("tap"),
@@ -197,7 +204,7 @@ class FeedScreen extends StatelessWidget {
Align(
alignment: Alignment.center,
child: Text(
post?['post']['title'],
post?['title'],
style: CustomTextStyles.titleMediumBlack,
),
),
@@ -206,16 +213,17 @@ class FeedScreen extends StatelessWidget {
),
SizedBox(height: 8.0),
Text(
post?['post']['description'],
post?['description'],
style: CustomTextStyles.bodyMediumBluegray800,
),
SizedBox(height: 16.0),
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! + (post?['post']['image'] ?? ''),
imageUrl: dotenv.env['STORAGE_URL']! + (post?['image'] ?? ''),
imageBuilder: (context, imageProvider) => Stack(
children: [
ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
borderRadius:
const BorderRadius.all(Radius.circular(8.0)),
child: Image(
image: imageProvider,
),
@@ -225,39 +233,47 @@ class FeedScreen extends StatelessWidget {
placeholder: (context, url) => CircularProgressIndicator(),
),
SizedBox(height: 16.0),
Row(children: [
Padding(
padding: EdgeInsets.only(left: 4),
child: Row(children: [
Padding(
padding: EdgeInsets.only(right: 4),
child: Icon(Icons.comment_outlined),
),
Text(
"Комментировать",
),
],),
),
Spacer(),
Row(children: [
Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 4),
child: Icon(Icons.favorite_outline),
padding: EdgeInsets.only(left: 4),
child: Row(
children: [
Padding(
padding: EdgeInsets.only(right: 4),
child: Icon(Icons.comment_outlined),
),
Text(
"Комментировать",
),
],
),
),
Text(
"Нравится",
Spacer(),
Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 4),
child: Icon(Icons.favorite_outline),
),
Text(
"Нравится",
),
],
),
],),
Spacer(),
Padding(
padding: EdgeInsets.only(right: 4),
child: Icon(Icons.share_outlined),
),
],),
Spacer(),
Padding(
padding: EdgeInsets.only(right: 4),
child: Icon(Icons.share_outlined),
),
],
),
],
),
),
],),);
],
),
);
}
Function onTapBack(BuildContext context) {