|
|
|
@ -1,8 +1,12 @@
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:mc_common_app/classes/app_state.dart';
|
|
|
|
import 'package:mc_common_app/classes/app_state.dart';
|
|
|
|
|
|
|
|
import 'package:mc_common_app/config/dependencies.dart';
|
|
|
|
import 'package:mc_common_app/config/routes.dart';
|
|
|
|
import 'package:mc_common_app/config/routes.dart';
|
|
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
|
|
|
|
|
|
import 'package:mc_common_app/models/advertisment_models/ad_details_model.dart';
|
|
|
|
|
|
|
|
import 'package:mc_common_app/models/widgets_models.dart';
|
|
|
|
import 'package:mc_common_app/theme/colors.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/utils/navigator.dart';
|
|
|
|
import 'package:mc_common_app/view_models/ad_view_model.dart';
|
|
|
|
import 'package:mc_common_app/view_models/ad_view_model.dart';
|
|
|
|
import 'package:mc_common_app/views/advertisement/ads_list.dart';
|
|
|
|
import 'package:mc_common_app/views/advertisement/ads_list.dart';
|
|
|
|
@ -20,6 +24,20 @@ class AdsFragment extends StatelessWidget {
|
|
|
|
await adVM.getMyAds();
|
|
|
|
await adVM.getMyAds();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<AdDetailsModel> getAdsList(AdVM adVM) {
|
|
|
|
|
|
|
|
if (adVM.isExploreAdsTapped) {
|
|
|
|
|
|
|
|
if (adVM.exploreAdsFilteredList.isNotEmpty) {
|
|
|
|
|
|
|
|
return adVM.exploreAdsFilteredList;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return adVM.exploreAds;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (adVM.myAdsFilteredList.isNotEmpty) {
|
|
|
|
|
|
|
|
return adVM.myAdsFilteredList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
|
@ -85,15 +103,7 @@ class AdsFragment extends StatelessWidget {
|
|
|
|
onRefresh: () => onRefreshAds(context),
|
|
|
|
onRefresh: () => onRefreshAds(context),
|
|
|
|
child: Consumer(
|
|
|
|
child: Consumer(
|
|
|
|
builder: (BuildContext context, AdVM adVM, Widget? child) {
|
|
|
|
builder: (BuildContext context, AdVM adVM, Widget? child) {
|
|
|
|
return BuildAdsList(
|
|
|
|
return BuildAdsList(isAdsFragment: true, shouldShowAdStatus: !adVM.isExploreAdsTapped, adsList: getAdsList(adVM));
|
|
|
|
isAdsFragment: true,
|
|
|
|
|
|
|
|
shouldShowAdStatus: !adVM.isExploreAdsTapped,
|
|
|
|
|
|
|
|
adsList: adVM.isExploreAdsTapped && adVM.exploreAdsFilteredList.isNotEmpty
|
|
|
|
|
|
|
|
? adVM.exploreAdsFilteredList
|
|
|
|
|
|
|
|
: !adVM.isExploreAdsTapped && adVM.myAdsFilteredList.isNotEmpty
|
|
|
|
|
|
|
|
? adVM.myAdsFilteredList
|
|
|
|
|
|
|
|
: [],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -102,12 +112,24 @@ class AdsFragment extends StatelessWidget {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
floatingActionButton: FloatingActionButton(
|
|
|
|
floatingActionButton: FloatingActionButton(
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () async {
|
|
|
|
if (context.read<AdVM>().vehicleTypes.isEmpty) {
|
|
|
|
final adVM = context.read<AdVM>();
|
|
|
|
context.read<AdVM>().getVehicleTypes();
|
|
|
|
if (adVM.vehicleTypes.isEmpty) {
|
|
|
|
|
|
|
|
await adVM.getVehicleTypes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.selectAdTypeView);
|
|
|
|
if (adVM.vehicleAdsDurations.isEmpty) {
|
|
|
|
|
|
|
|
await adVM.getVehicleAdsDuration();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
adVM.updateVehicleAdDurationId(
|
|
|
|
|
|
|
|
SelectionModel(
|
|
|
|
|
|
|
|
selectedId: adVM.vehicleAdsDurations.first.id ?? 0,
|
|
|
|
|
|
|
|
selectedOption: "${adVM.vehicleAdsDurations.first.days} Days",
|
|
|
|
|
|
|
|
itemPrice: adVM.vehicleAdsDurations.first.price!.toInt().toString(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.selectAdTypeView, arguments: injector.get<AppState>().currentAppType == AppType.provider);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
backgroundColor: MyColors.darkPrimaryColor,
|
|
|
|
backgroundColor: MyColors.darkPrimaryColor,
|
|
|
|
child: Icon(
|
|
|
|
child: Icon(
|
|
|
|
|