You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
7.3 KiB
Dart
155 lines
7.3 KiB
Dart
import 'package:car_provider_app/views/dashboard/widget/my_service_provider.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/config/routes.dart';
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
import 'package:mc_common_app/models/appointments_models/appointment_list_model.dart';
|
|
import 'package:mc_common_app/utils/enums.dart';
|
|
import 'package:mc_common_app/utils/navigator.dart';
|
|
import 'package:mc_common_app/view_models/ad_view_model.dart';
|
|
import 'package:mc_common_app/view_models/dashboard_view_model_provider.dart';
|
|
import 'package:mc_common_app/views/advertisement/components/ads_list_widget.dart';
|
|
import 'package:mc_common_app/views/appointments/widgets/common_appointment_slider_widget.dart';
|
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
|
import 'package:mc_common_app/widgets/common_widgets/view_all_widget.dart';
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class HomeFragment extends StatelessWidget {
|
|
const HomeFragment({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: CustomAppBar(
|
|
isDrawerEnabled: true,
|
|
leadingWidth: 100,
|
|
toolbarHeight: 59,
|
|
onTap: () => navigateWithName(context, AppRoutes.settingOptionsMore),
|
|
actions: const [
|
|
// IconButton(
|
|
// onPressed: () => context.read<AppointmentsVM>().onGeneralChatMessagesButtonPressed(context: context),
|
|
// icon: b.Badge(
|
|
// badgeContent: '3'.toText(color: MyColors.white),
|
|
// badgeStyle: const b.BadgeStyle(
|
|
// badgeColor: MyColors.primaryColor,
|
|
// padding: EdgeInsets.all(5),
|
|
// ),
|
|
// child: const Padding(padding: EdgeInsets.only(top: 8, bottom: 8, right: 25, left: 10), child: Icon(Icons.message, size: 21))),
|
|
// ),
|
|
// 10.width,
|
|
],
|
|
),
|
|
body: SizedBox(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: RefreshIndicator(
|
|
onRefresh: () async => await context.read<DashboardVMProvider>().onRefresh(context),
|
|
child: ListView(
|
|
padding: EdgeInsets.zero,
|
|
children: [
|
|
Column(
|
|
children: [
|
|
10.height,
|
|
ViewAllWidget(
|
|
title: LocaleKeys.upcoming_appointment.tr(),
|
|
subTitle: LocaleKeys.view_all.tr(),
|
|
onSubtitleTapped: () {
|
|
context.read<DashboardVMProvider>().onNavbarTapped(1);
|
|
},
|
|
).horPaddingMain(),
|
|
CommonAppointmentSliderWidget(
|
|
onAppointmentClick: (AppointmentListModel value) => navigateWithName(
|
|
context,
|
|
AppRoutes.appointmentDetailList,
|
|
arguments: value,
|
|
)).toWhiteContainer(width: double.infinity, backgroundColor: Colors.transparent).margin(
|
|
left: 21,
|
|
right: 21,
|
|
),
|
|
24.height,
|
|
ViewAllWidget(
|
|
title: LocaleKeys.myBranches.tr(),
|
|
subTitle: LocaleKeys.view_all.tr(),
|
|
onSubtitleTapped: () {
|
|
context.read<DashboardVMProvider>().onNavbarTapped(0);
|
|
},
|
|
).horPaddingMain(),
|
|
const ServiceProviderWidget().horPaddingMain(),
|
|
],
|
|
).toWhiteContainer(
|
|
width: double.infinity,
|
|
),
|
|
Consumer(
|
|
builder: (BuildContext context, AdVM adVM, Widget? child) {
|
|
if (adVM.state == ViewState.busy) {
|
|
return const Padding(
|
|
padding: EdgeInsets.all(30),
|
|
child: Center(child: CircularProgressIndicator()),
|
|
);
|
|
} else {
|
|
return Column(
|
|
children: [
|
|
if (adVM.myActiveAdsForHome.isNotEmpty) ...[
|
|
Column(
|
|
children: [
|
|
15.height,
|
|
ViewAllWidget(
|
|
title: LocaleKeys.my_active_Ads.tr().toUpperCase(),
|
|
subTitle: LocaleKeys.view_all.tr(),
|
|
onSubtitleTapped: () {
|
|
context.read<DashboardVMProvider>().onNavbarTapped(3);
|
|
context.read<AdVM>().updateIsExploreAds(true);
|
|
context.read<AdVM>().applyFilterOnExploreAds(vehicleBrandId: 0); // allAds
|
|
},
|
|
).horPaddingMain(),
|
|
AdsListWidget(
|
|
isDraftAds: false,
|
|
shouldShowAdStatus: true,
|
|
isAdsFragment: false,
|
|
adsList: adVM.myActiveAdsForHome,
|
|
scrollPhysics: const NeverScrollableScrollPhysics(),
|
|
hasMoreData: adVM.isExploreAdsTapped ? adVM.hasMoreDataForExploreAds : adVM.hasMoreDataForMyAds,
|
|
),
|
|
],
|
|
)
|
|
],
|
|
if (adVM.exploreAds.isNotEmpty) ...[
|
|
Column(
|
|
children: [
|
|
15.height,
|
|
ViewAllWidget(
|
|
title: LocaleKeys.myRecommendedAds.tr().toUpperCase(),
|
|
subTitle: LocaleKeys.view_all.tr(),
|
|
onSubtitleTapped: () {
|
|
context.read<DashboardVMProvider>().onNavbarTapped(3);
|
|
context.read<AdVM>().updateIsExploreAds(true);
|
|
context.read<AdVM>().applyFilterOnExploreAds(vehicleBrandId: 0); // allAds
|
|
},
|
|
).horPaddingMain(),
|
|
AdsListWidget(
|
|
isDraftAds: false,
|
|
shouldShowAdStatus: false,
|
|
adsList: adVM.exploreAds.length >= 3 ? adVM.exploreAds.take(3).toList() : adVM.exploreAds,
|
|
isAdsFragment: false,
|
|
scrollPhysics: const NeverScrollableScrollPhysics(),
|
|
hasMoreData: adVM.isExploreAdsTapped ? adVM.hasMoreDataForExploreAds : adVM.hasMoreDataForMyAds,
|
|
),
|
|
],
|
|
)
|
|
]
|
|
],
|
|
);
|
|
}
|
|
},
|
|
).toContainer(backgroundColor: const Color(0xFFF8F8F8), padding: EdgeInsets.zero, margin: EdgeInsets.zero),
|
|
21.height,
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|