taafee-mobile/lib/features/chat/presentation_layer/widgets/recieved_message_widget.dart
2023-10-17 17:22:55 +03:00

78 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:taafee_mobile/common/const/const.dart';
import 'package:taafee_mobile/common/widgets/text.dart';
import 'package:taafee_mobile/features/chat/data_layer/model/message.dart';
import 'package:taafee_mobile/features/home/business_logic_layer/home_controller.dart';
import '../../business logic layer/chat_controller.dart';
class RecievedMessageWidget extends StatelessWidget {
RecievedMessageWidget({
super.key,
this.dismissibleKey = const Key('recivied'),
required this.messageModel,
required this.textFieldFocusNode,
});
final Key dismissibleKey;
final MessageModel messageModel;
final FocusNode textFieldFocusNode;
final ChatController chatController = Get.find<ChatController>();
final HomeController homeController = Get.find<HomeController>();
@override
Widget build(BuildContext context) {
return Dismissible(
key: dismissibleKey,
confirmDismiss: (direction) async {
chatController.updateReplyModel(
messageModel: messageModel,
);
if (chatController.isReplying.value == false) {
chatController.toggleIsReplying();
}
FocusScope.of(context).requestFocus(textFieldFocusNode);
return false;
},
onDismissed: null,
child: Container(
alignment: Alignment.centerLeft,
margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 7),
width: Get.width * 0.45,
//height: 66,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: Responsive.isTablet()
? Get.width * 0.3
: Get.width * 0.35,
child: RegularTextWidget(
messageModel.content,
color: AppColors.textMessageColor,
fontSize: 14,
),
).paddingOnly(top: 8),
],
).paddingOnly(left: 2, top: 4),
RegularTextWidget(
messageModel.createdAt.toString().substring(11, 16),
color: AppColors.timeMessageColor,
fontSize: 10,
).paddingOnly(top: 15, left: 2, bottom: 4)
],
).paddingSymmetric(horizontal: 15),
),
);
}
}