Chat select navigation and data transfer

This commit is contained in:
2024-04-27 13:59:25 +03:00
parent c05ca6eaae
commit 7c30667aec
4 changed files with 24 additions and 22 deletions

View File

@@ -28,6 +28,7 @@ class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
text = "Вы: " + text;
}
chats.add(ChatItemModel(
id: int.parse(chatRooms[i]['id']),
userImage: chatRooms[i]['users']['to_chat_user']
['profile_photo_path'],
username: chatRooms[i]['users']['to_chat_user']['name'],

View File

@@ -98,8 +98,8 @@ _buildChatList(BuildContext context, ChatSelectLoadedState state) {
},
itemCount: state.chatRooms?.length ?? 0,
itemBuilder: (context, index) {
ChatItemModel model = state.chatRooms?[index] ?? ChatItemModel();
return UserprofileItemWidget(
ChatItemModel model = state.chatRooms?[index];
return ChatEntryWidget(
model,
);
},

View File

@@ -9,12 +9,12 @@ class ChatItemModel {
this.username,
this.dateText,
this.greetingText,
this.id}) {
required this.id}) {
userImage = userImage ?? ImageConstant.imageNotFound;
username = username ?? "Ксения Обрамова";
dateText = dateText ?? "9/29";
greetingText = greetingText ?? "Привет, хорошая статья";
id = id ?? "";
username = username;
dateText = dateText;
greetingText = greetingText;
id = id;
}
String? userImage;
@@ -25,5 +25,5 @@ class ChatItemModel {
String? greetingText;
String? id;
int id;
}

View File

@@ -6,13 +6,13 @@ 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})
class ChatEntryWidget extends StatelessWidget {
ChatEntryWidget(this.chatEntryObj, {Key? key})
: super(
key: key,
);
ChatItemModel userprofileItemModelObj;
ChatItemModel chatEntryObj;
@override
Widget build(BuildContext context) {
@@ -26,8 +26,7 @@ class UserprofileItemWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CachedNetworkImage(
imageUrl:
dotenv.env['STORAGE_URL']! + userprofileItemModelObj.userImage!,
imageUrl: dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!,
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
@@ -41,7 +40,7 @@ class UserprofileItemWidget extends StatelessWidget {
),
/*CustomImageView(
imagePath:
dotenv.env['STORAGE_URL']! + userprofileItemModelObj.userImage!,
dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!,
height: 60.adaptSize,
width: 60.adaptSize,
radius: BorderRadius.circular(
@@ -56,7 +55,11 @@ class UserprofileItemWidget extends StatelessWidget {
bottom: 11.v,
),
child: GestureDetector(
onTap: () => Navigator.pushNamed(context, AppRoutes.chatScreen),
onTap: () => Navigator.pushNamed(
context,
AppRoutes.chatScreen,
arguments: chatEntryObj.id,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -65,11 +68,9 @@ class UserprofileItemWidget extends StatelessWidget {
child: Row(
children: [
Text(
userprofileItemModelObj.username!.length <= 15
? userprofileItemModelObj.username!
: userprofileItemModelObj.username!
.substring(0, 15) +
'...',
chatEntryObj.username!.length <= 15
? chatEntryObj.username!
: chatEntryObj.username!.substring(0, 15) + '...',
style: theme.textTheme.titleMedium,
),
Spacer(),
@@ -85,7 +86,7 @@ class UserprofileItemWidget extends StatelessWidget {
Padding(
padding: EdgeInsets.only(left: 6.h),
child: Text(
userprofileItemModelObj.dateText!,
chatEntryObj.dateText!,
style: theme.textTheme.bodyMedium,
),
)
@@ -94,7 +95,7 @@ class UserprofileItemWidget extends StatelessWidget {
),
SizedBox(height: 6.v),
Text(
userprofileItemModelObj.greetingText!,
chatEntryObj.greetingText!,
style: CustomTextStyles.bodyMediumBluegray800,
)
],