Chat Favorite Screen & Fixes

merge-requests/55/head
Aamir Muhammad 3 years ago
parent 29626ea408
commit b18ebf7a54

@ -93,20 +93,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
void getSingleUserChatHistory({required String senderUID, required int receiverUID, required bool loadMore}) async {
isLoading = true;
print(loadMore);
print(senderUID);
print(receiverUID);
if (!loadMore) paginationVal = 0;
print(paginationVal);
isChatScreenActive = true;
Response response = await ApiClient().getJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$paginationVal",
token: AppState().chatDetails!.response!.token,
);
logger.d("${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$paginationVal");
logger.d("${AppState().chatDetails!.response!.token}");
logger.d(jsonEncode(response.body));
logger.d(jsonEncode(response.statusCode));
if (response.statusCode == 204) {
if (!loadMore) userChatHistory = [];
Utils.showToast("No More Data To Load");
@ -119,10 +111,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
}
isLoading = false;
//Timer(const Duration(milliseconds: 100),() => scrollToBottom());
notifyListeners();
// scrollToBottom();
}
List<SingleUserChatModel> getSingleUserChatModel(String str) => List<SingleUserChatModel>.from(json.decode(str).map((x) => SingleUserChatModel.fromJson(x)));
@ -364,15 +353,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
}
// void scrollDown() {
// scrollController.animateTo(
// scrollController.position.maxScrollExtent + 100,
// curve: Curves.easeOut,
// duration: const Duration(milliseconds: 300),
// );
// notifyListeners();
// }
Future<void> sendChatToServer(
{required int chatEventId, required fileTypeId, required int targetUserId, required String targetUserName, required chatReplyId, required bool isAttachment, required bool isReply}) async {
Uuid uuid = const Uuid();
@ -605,22 +585,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
void scrollToBottom() {
//scrollController.jumpTo(scrollController.position.maxScrollExtent + 100 );
scrollController.animateTo(
scrollController.position.maxScrollExtent + 100,
duration: const Duration(milliseconds: 500),
curve: Curves.easeIn,
);
}
// void scrollToMaxExtent() {
// WidgetsBinding.instance.addPostFrameCallback((_) {
// scrollController.animateTo(
// scrollController.position.maxScrollExtent,
// duration: const Duration(milliseconds: 100),
// curve: Curves.easeIn,
// );
// });
// }
}

@ -1,7 +1,7 @@
class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server
static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
//static String baseUrl = "https://hmgwebservices.com"; // Live server
// static String baseUrl = "https://hmgwebservices.com"; // Live server
static String baseUrlServices = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/";

@ -30,7 +30,9 @@ class _ChatHomeState extends State<ChatHome> {
@override
Widget build(BuildContext context) {
data = Provider.of<ChatProviderModel>(context, listen: false);
data.getUserAutoLoginToken().whenComplete(() => null);
data.getUserAutoLoginToken().then((value){
data.getUserRecentChats();
});
return Scaffold(
backgroundColor: MyColors.white,
appBar: AppBarWidget(

@ -23,19 +23,15 @@ class ChatHomeScreen extends StatefulWidget {
class _ChatHomeScreenState extends State<ChatHomeScreen> {
TextEditingController search = TextEditingController();
late ChatProviderModel data;
@override
void initState() {
super.initState();
data = Provider.of<ChatProviderModel>(context, listen: false);
data.getUserRecentChats();
}
@override
void dispose() {
super.dispose();
data.hubConnection.stop();
}
@override

Loading…
Cancel
Save