From cd3699a510dd9d98f8814ef61e8be9e216c320a7 Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Tue, 26 Dec 2023 10:58:40 +0300 Subject: [PATCH] chat implementation changes 1.0 --- lib/config/customer_routes.dart | 2 - lib/main.dart | 6 ++- lib/views/dashboard/dashboard_page.dart | 2 +- .../fragments/my_requests_fragment.dart | 49 ++++++++++--------- 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/lib/config/customer_routes.dart b/lib/config/customer_routes.dart index 609ab7d..7411547 100644 --- a/lib/config/customer_routes.dart +++ b/lib/config/customer_routes.dart @@ -1,5 +1,3 @@ -import 'package:mc_common_app/models/requests_models/offers_model.dart'; -import 'package:mc_common_app/models/requests_models/request_model.dart'; import 'package:mc_common_app/views/appointments/appointment_detail_view.dart'; import 'package:mc_common_app/views/appointments/book_appointment_schedules_view.dart'; import 'package:mc_common_app/views/appointments/book_appointment_services_view.dart'; diff --git a/lib/main.dart b/lib/main.dart index 5f0143b..1ea70a7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -69,7 +69,11 @@ Future main() async { ChangeNotifierProvider( create: (_) => PaymentVM(paymentService: injector.get(), paymentRepo: injector.get()), ), - ChangeNotifierProvider(create: (_) => ChatVM(chatRepo: injector.get())), + ChangeNotifierProvider( + create: (_) => ChatVM( + chatRepo: injector.get(), + requestRepo: injector.get(), + )), ChangeNotifierProvider( create: (_) => RequestsVM( requestRepo: injector.get(), diff --git a/lib/views/dashboard/dashboard_page.dart b/lib/views/dashboard/dashboard_page.dart index eeaed6d..89e53d9 100644 --- a/lib/views/dashboard/dashboard_page.dart +++ b/lib/views/dashboard/dashboard_page.dart @@ -76,7 +76,7 @@ class _DashboardPageState extends State { await adVM.getVehicleAdsDuration(); } - await chatVM.buildHubConnection(); + await chatVM.buildHubConnection(context); adVM.updateVehicleAdDurationId( SelectionModel( selectedId: adVM.vehicleAdsDurations.first.id ?? 0, diff --git a/lib/views/dashboard/fragments/my_requests_fragment.dart b/lib/views/dashboard/fragments/my_requests_fragment.dart index 2929f7b..d05cdc4 100644 --- a/lib/views/dashboard/fragments/my_requests_fragment.dart +++ b/lib/views/dashboard/fragments/my_requests_fragment.dart @@ -32,28 +32,33 @@ class MyRequestsFragment extends StatelessWidget { ), 8.height, Expanded( - child: RefreshIndicator( - onRefresh: () async => await requestsVM.getRequests(isNeedToRebuild: true, appType: AppType.customer), - child: requestsVM.state == ViewState.busy - ? const Center(child: CircularProgressIndicator()) - : requestsVM.myFilteredRequests.isEmpty - ? Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - "No Requests to show.".toText(fontSize: 16, color: MyColors.lightTextColor), - ], - ) - : ListView.separated( - itemBuilder: (context, index) { - return RequestItem(request: requestsVM.myFilteredRequests[index], appType: AppType.customer); - }, - separatorBuilder: (context, index) { - return 16.height; - }, - itemCount: requestsVM.myFilteredRequests.length, - padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 8), - ), - )) + child: RefreshIndicator( + onRefresh: () async => await requestsVM.getRequests(isNeedToRebuild: true, appType: AppType.customer), + child: requestsVM.state == ViewState.busy + ? const Center(child: CircularProgressIndicator()) + : requestsVM.myFilteredRequests.isEmpty + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + "No Requests to show.".toText(fontSize: 16, color: MyColors.lightTextColor), + ], + ) + : ListView.separated( + itemBuilder: (context, index) { + return RequestItem( + request: requestsVM.myFilteredRequests[index], + appType: AppType.customer, + requestIndex: index, + ); + }, + separatorBuilder: (context, index) { + return 16.height; + }, + itemCount: requestsVM.myFilteredRequests.length, + padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 8), + ), + ), + ) ], ); }),