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.
146 lines
6.3 KiB
Dart
146 lines
6.3 KiB
Dart
import 'package:car_provider_app/config/provider_routes.dart';
|
|
import 'package:car_provider_app/view_models/dashboard_view_model.dart';
|
|
import 'package:car_provider_app/views/dashboard/widget/my_service_provider.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/theme/colors.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/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:badges/badges.dart' as b;
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
class HomeFragment extends StatelessWidget {
|
|
const HomeFragment({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: CustomAppBar(
|
|
isDrawerEnabled: true,
|
|
leadingWidth: 100,
|
|
onTap: () => navigateWithName(context, AppRoutes.settingOptionsLanguages),
|
|
actions: [
|
|
IconButton(
|
|
onPressed: () => context.read<DashboardVM>().onRefresh(context),
|
|
icon: const b.Badge(
|
|
badgeContent: Text(
|
|
'3',
|
|
style: TextStyle(
|
|
fontSize: 10,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
badgeStyle: b.BadgeStyle(
|
|
badgeColor: MyColors.primaryColor,
|
|
padding: EdgeInsets.all(5),
|
|
),
|
|
child: Icon(Icons.notifications_active),
|
|
),
|
|
),
|
|
10.width,
|
|
],
|
|
),
|
|
body: SizedBox(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: RefreshIndicator(
|
|
onRefresh: () async => await context.read<DashboardVM>().onRefresh(context),
|
|
child: ListView(
|
|
children: [
|
|
10.height,
|
|
ViewAllWidget(
|
|
title: LocaleKeys.upcoming_appointment.tr(),
|
|
subTitle: LocaleKeys.view_all.tr(),
|
|
onSubtitleTapped: () {
|
|
context.read<DashboardVM>().onNavbarTapped(1);
|
|
}).horPaddingMain(),
|
|
// const AppointmentSliderWidget().horPaddingMain(),
|
|
CommonAppointmentSliderWidget(
|
|
onAppointmentClick: (AppointmentListModel value) {
|
|
navigateWithName(context, ProviderAppRoutes.appointmentDetailList, arguments: value);
|
|
},
|
|
),
|
|
21.height,
|
|
ViewAllWidget(
|
|
title: LocaleKeys.myBranches.tr(),
|
|
subTitle: LocaleKeys.view_all.tr(),
|
|
onSubtitleTapped: () {
|
|
context.read<DashboardVM>().onNavbarTapped(0);
|
|
},
|
|
).horPaddingMain(),
|
|
const ServiceProviderWidget().horPaddingMain(),
|
|
|
|
Consumer(
|
|
builder: (BuildContext context, AdVM adVM, Widget? child) {
|
|
if (adVM.state == ViewState.busy) {
|
|
return const 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<DashboardVM>().onNavbarTapped(3);
|
|
// context.read<AdVM>().updateIsExploreAds(false);
|
|
},
|
|
).horPaddingMain(),
|
|
AdsListWidget(
|
|
shouldShowAdStatus: true,
|
|
isAdsFragment: false,
|
|
adsList: adVM.myActiveAdsForHome,
|
|
scrollPhysics: const NeverScrollableScrollPhysics(),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
if (adVM.exploreAds.isNotEmpty) ...[
|
|
Column(
|
|
children: [
|
|
15.height,
|
|
ViewAllWidget(
|
|
title: LocaleKeys.myRecommendedAds.tr().toUpperCase(),
|
|
subTitle: LocaleKeys.view_all.tr(),
|
|
onSubtitleTapped: () {
|
|
context.read<DashboardVM>().onNavbarTapped(3);
|
|
context.read<AdVM>().updateIsExploreAds(true);
|
|
context.read<AdVM>().applyFilterOnExploreAds(createdByRoleFilter: CreatedByRoleEnum.allAds);
|
|
},
|
|
).horPaddingMain(),
|
|
AdsListWidget(
|
|
shouldShowAdStatus: false,
|
|
adsList: adVM.exploreAds.length >= 3 ? adVM.exploreAds.take(3).toList() : adVM.exploreAds,
|
|
isAdsFragment: false,
|
|
scrollPhysics: const NeverScrollableScrollPhysics(),
|
|
),
|
|
],
|
|
)
|
|
]
|
|
],
|
|
);
|
|
}
|
|
},
|
|
),
|
|
21.height,
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|