|
|
|
@ -8,19 +8,14 @@ import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/api/chat/chat_provider_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/ui/chat/chat_bubble.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/image_picker.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
|
import 'package:sizer/sizer.dart';
|
|
|
|
|
import 'package:swipe_to/swipe_to.dart';
|
|
|
|
|
|
|
|
|
|
class ChatDetailScreen extends StatelessWidget {
|
|
|
|
@ -30,13 +25,13 @@ class ChatDetailScreen extends StatelessWidget {
|
|
|
|
|
ScrollController scrollController = ScrollController();
|
|
|
|
|
RefreshController _refreshController = RefreshController(initialRefresh: false);
|
|
|
|
|
|
|
|
|
|
void onRefresh() async {
|
|
|
|
|
print("Refresh Triggered");
|
|
|
|
|
await Future.delayed(Duration(milliseconds: 1000));
|
|
|
|
|
void getMoreChat() async {
|
|
|
|
|
|
|
|
|
|
if (userDetails != null) {
|
|
|
|
|
data.paginationVal = data.paginationVal + 10;
|
|
|
|
|
data.getSingleUserChatHistory(senderUID: AppState().chatDetails!.response!.id.toString(), receiverUID: userDetails["targetUser"].id, loadMore: true);
|
|
|
|
|
}
|
|
|
|
|
await Future.delayed(Duration(milliseconds: 1000));
|
|
|
|
|
_refreshController.refreshCompleted();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -45,16 +40,6 @@ class ChatDetailScreen extends StatelessWidget {
|
|
|
|
|
userDetails = ModalRoute.of(context)!.settings.arguments;
|
|
|
|
|
data = Provider.of<ChatProviderModel>(context, listen: false);
|
|
|
|
|
if (userDetails != null) data.getSingleUserChatHistory(senderUID: AppState().chatDetails!.response!.id.toString(), receiverUID: userDetails["targetUser"].id, loadMore: false);
|
|
|
|
|
//
|
|
|
|
|
// if (userDetails != null) {
|
|
|
|
|
// scrollController.addListener(() {
|
|
|
|
|
// if (scrollController.position.minScrollExtent == scrollController.offset) {
|
|
|
|
|
// data.paginationVal++;
|
|
|
|
|
// data.getSingleUserChatHistory(senderUID: AppState().chatDetails!.response!.id.toString(), receiverUID: userDetails["targetUser"].id, loadMore: true);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: const Color(0xFFF8F8F8),
|
|
|
|
|
appBar: AppBarWidget(context, title: userDetails["targetUser"].userName, showHomeButton: false, image: userDetails["targetUser"].image),
|
|
|
|
@ -73,34 +58,28 @@ class ChatDetailScreen extends StatelessWidget {
|
|
|
|
|
color: MyColors.gradiantEndColor,
|
|
|
|
|
),
|
|
|
|
|
controller: _refreshController,
|
|
|
|
|
onRefresh: onRefresh,
|
|
|
|
|
onRefresh: getMoreChat,
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
controller: scrollController,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: m.userChatHistory.length,
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
itemBuilder: (BuildContext context, int i) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
m.logger.d(jsonEncode(m.userChatHistory[i]));
|
|
|
|
|
m.logger.d(jsonEncode(m.userChatHistory.length));
|
|
|
|
|
},
|
|
|
|
|
child: SwipeTo(
|
|
|
|
|
iconColor: MyColors.lightGreenColor,
|
|
|
|
|
child: ChatBubble(
|
|
|
|
|
text: m.userChatHistory[i].contant.toString(),
|
|
|
|
|
replyText: m.userChatHistory[i].userChatReplyResponse != null ? m.userChatHistory[i].userChatReplyResponse!.contant.toString() : "",
|
|
|
|
|
isSeen: m.userChatHistory[i].isSeen == true ? true : false,
|
|
|
|
|
isCurrentUser: m.userChatHistory[i].currentUserId == AppState().chatDetails!.response!.id ? true : false,
|
|
|
|
|
isDelivered: m.userChatHistory[i].currentUserId == AppState().chatDetails!.response!.id && m.userChatHistory[i].isDelivered == true ? true : false,
|
|
|
|
|
dateTime: m.dateFormte(m.userChatHistory[i].createdDate!),
|
|
|
|
|
isReplied: m.userChatHistory[i].userChatReplyResponse != null ? true : false,
|
|
|
|
|
userName: AppState().chatDetails!.response!.userName == m.userChatHistory[i].currentUserName.toString() ? "You" : m.userChatHistory[i].currentUserName.toString(),
|
|
|
|
|
),
|
|
|
|
|
onRightSwipe: () {
|
|
|
|
|
m.chatReply(m.userChatHistory[i]);
|
|
|
|
|
},
|
|
|
|
|
return SwipeTo(
|
|
|
|
|
iconColor: MyColors.lightGreenColor,
|
|
|
|
|
child: ChatBubble(
|
|
|
|
|
text: m.userChatHistory[i].contant.toString(),
|
|
|
|
|
replyText: m.userChatHistory[i].userChatReplyResponse != null ? m.userChatHistory[i].userChatReplyResponse!.contant.toString() : "",
|
|
|
|
|
isSeen: m.userChatHistory[i].isSeen == true ? true : false,
|
|
|
|
|
isCurrentUser: m.userChatHistory[i].currentUserId == AppState().chatDetails!.response!.id ? true : false,
|
|
|
|
|
isDelivered: m.userChatHistory[i].currentUserId == AppState().chatDetails!.response!.id && m.userChatHistory[i].isDelivered == true ? true : false,
|
|
|
|
|
dateTime: m.dateFormte(m.userChatHistory[i].createdDate!),
|
|
|
|
|
isReplied: m.userChatHistory[i].userChatReplyResponse != null ? true : false,
|
|
|
|
|
userName: AppState().chatDetails!.response!.userName == m.userChatHistory[i].currentUserName.toString() ? "You" : m.userChatHistory[i].currentUserName.toString(),
|
|
|
|
|
),
|
|
|
|
|
onRightSwipe: () {
|
|
|
|
|
m.chatReply(m.userChatHistory[i]);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
@ -203,7 +182,7 @@ class ChatDetailScreen extends StatelessWidget {
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
suffixIcon: Container(
|
|
|
|
|
suffixIcon: SizedBox(
|
|
|
|
|
width: 96,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
|