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 { void getSingleUserChatHistory({required String senderUID, required int receiverUID, required bool loadMore}) async {
isLoading = true; isLoading = true;
print(loadMore);
print(senderUID);
print(receiverUID);
if (!loadMore) paginationVal = 0; if (!loadMore) paginationVal = 0;
print(paginationVal);
isChatScreenActive = true; isChatScreenActive = true;
Response response = await ApiClient().getJsonForResponse( Response response = await ApiClient().getJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$paginationVal", "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$paginationVal",
token: AppState().chatDetails!.response!.token, 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 (response.statusCode == 204) {
if (!loadMore) userChatHistory = []; if (!loadMore) userChatHistory = [];
Utils.showToast("No More Data To Load"); Utils.showToast("No More Data To Load");
@ -119,10 +111,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
} }
isLoading = false; isLoading = false;
//Timer(const Duration(milliseconds: 100),() => scrollToBottom());
notifyListeners(); notifyListeners();
// scrollToBottom();
} }
List<SingleUserChatModel> getSingleUserChatModel(String str) => List<SingleUserChatModel>.from(json.decode(str).map((x) => SingleUserChatModel.fromJson(x))); 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( Future<void> sendChatToServer(
{required int chatEventId, required fileTypeId, required int targetUserId, required String targetUserName, required chatReplyId, required bool isAttachment, required bool isReply}) async { {required int chatEventId, required fileTypeId, required int targetUserId, required String targetUserName, required chatReplyId, required bool isAttachment, required bool isReply}) async {
Uuid uuid = const Uuid(); Uuid uuid = const Uuid();
@ -605,22 +585,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
void scrollToBottom() { void scrollToBottom() {
//scrollController.jumpTo(scrollController.position.maxScrollExtent + 100 );
scrollController.animateTo( scrollController.animateTo(
scrollController.position.maxScrollExtent + 100, scrollController.position.maxScrollExtent + 100,
duration: const Duration(milliseconds: 500), duration: const Duration(milliseconds: 500),
curve: Curves.easeIn, 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 { class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server //static String baseUrl = "http://10.200.204.20:2801/"; // Local server
static String baseUrl = "https://uat.hmgwebservices.com"; // UAT 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 = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/";

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

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

Loading…
Cancel
Save