forked from eatvio/eatvio_app
feat(chat): Layout Improvements and user avatars load
This commit is contained in:
@@ -23,23 +23,17 @@ class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
|
||||
List<ChatItemModel> fillChatEntryList(List<dynamic> chatRooms) {
|
||||
List<ChatItemModel> chats = [];
|
||||
for (int i = 0; i < chatRooms.length; i++) {
|
||||
String userName;
|
||||
String userAvatarPath;
|
||||
String text = chatRooms[i]['last_message']['data'];
|
||||
if (chatRooms[i]['last_message']['is_author_from_user']) {
|
||||
userName = chatRooms[i]['users']['from_chat_user']['name'];
|
||||
userAvatarPath =
|
||||
chatRooms[i]['users']['from_chat_user']['profile_photo_path'] ?? '';
|
||||
} else {
|
||||
userName = chatRooms[i]['users']['to_chat_user']['name'];
|
||||
userAvatarPath =
|
||||
chatRooms[i]['users']['to_chat_user']['profile_photo_path'] ?? '';
|
||||
text = "Вы: " + text;
|
||||
}
|
||||
chats.add(ChatItemModel(
|
||||
userImage: userAvatarPath,
|
||||
username: userName,
|
||||
userImage: chatRooms[i]['users']['to_chat_user']
|
||||
['profile_photo_path'],
|
||||
username: chatRooms[i]['users']['to_chat_user']['name'],
|
||||
dateText: DateFormat('dd.MM').format(
|
||||
DateTime.parse(chatRooms[i]['last_message']['updated_at'])),
|
||||
greetingText: chatRooms[i]['last_message']['data'] ?? ''));
|
||||
greetingText: text));
|
||||
}
|
||||
return chats;
|
||||
}
|
||||
|
||||
@@ -47,13 +47,14 @@ class ChatSelectScreen extends StatelessWidget {
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
decoration: AppDecoration.fillGray,
|
||||
child: Column(
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(height: 30.v),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h,
|
||||
right: 20.h,
|
||||
bottom: 10.h,
|
||||
),
|
||||
padding: EdgeInsets.all(12.h),
|
||||
decoration: BoxDecoration(
|
||||
@@ -77,9 +78,6 @@ class ChatSelectScreen extends StatelessWidget {
|
||||
),
|
||||
SizedBox(height: 20.v),
|
||||
_buildChatList(context, state),
|
||||
ElevatedButton(
|
||||
onPressed: (() => print(state.chatRooms)),
|
||||
child: Text("asdasd"))
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/chat/chat_select_screen/models/chat_entry.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
|
||||
class UserprofileItemWidget extends StatelessWidget {
|
||||
UserprofileItemWidget(this.userprofileItemModelObj, {Key? key})
|
||||
@@ -24,7 +25,21 @@ class UserprofileItemWidget extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CustomImageView(
|
||||
CachedNetworkImage(
|
||||
imageUrl:
|
||||
dotenv.env['STORAGE_URL']! + userprofileItemModelObj.userImage!,
|
||||
imageBuilder: (context, imageProvider) => CircleAvatar(
|
||||
backgroundImage: imageProvider,
|
||||
radius: 25,
|
||||
),
|
||||
placeholder: (context, url) => CircularProgressIndicator(),
|
||||
errorWidget: (context, url, error) => CircleAvatar(
|
||||
child: Icon(Icons.person),
|
||||
backgroundColor: Colors.white,
|
||||
radius: 25,
|
||||
),
|
||||
),
|
||||
/*CustomImageView(
|
||||
imagePath:
|
||||
dotenv.env['STORAGE_URL']! + userprofileItemModelObj.userImage!,
|
||||
height: 60.adaptSize,
|
||||
@@ -32,7 +47,7 @@ class UserprofileItemWidget extends StatelessWidget {
|
||||
radius: BorderRadius.circular(
|
||||
30.h,
|
||||
),
|
||||
),
|
||||
),*/
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
@@ -50,7 +65,11 @@ class UserprofileItemWidget extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
userprofileItemModelObj.username!,
|
||||
userprofileItemModelObj.username!.length <= 15
|
||||
? userprofileItemModelObj.username!
|
||||
: userprofileItemModelObj.username!
|
||||
.substring(0, 15) +
|
||||
'...',
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
Spacer(),
|
||||
|
||||
Reference in New Issue
Block a user