|
|
|
|
@ -1,3 +1,6 @@
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
|
|
|
@ -12,7 +15,6 @@ import 'package:mc_common_app/utils/utils.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/ad_view_model.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
|
|
|
|
|
class AdsListWidget extends StatelessWidget {
|
|
|
|
|
final List<AdDetailsModel> adsList;
|
|
|
|
|
@ -21,12 +23,12 @@ class AdsListWidget extends StatelessWidget {
|
|
|
|
|
final bool shouldShowAdStatus;
|
|
|
|
|
|
|
|
|
|
const AdsListWidget({
|
|
|
|
|
Key? key,
|
|
|
|
|
super.key,
|
|
|
|
|
required this.adsList,
|
|
|
|
|
this.scrollPhysics,
|
|
|
|
|
required this.shouldShowAdStatus,
|
|
|
|
|
this.isAdsFragment = false,
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
@ -38,21 +40,29 @@ class AdsListWidget extends StatelessWidget {
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return ListView.separated(
|
|
|
|
|
itemCount: adsList.length,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: scrollPhysics,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return AdCard(
|
|
|
|
|
adDetails: adsList[index],
|
|
|
|
|
isAdsFragment: isAdsFragment,
|
|
|
|
|
shouldShowAdStatus: shouldShowAdStatus,
|
|
|
|
|
).onPress(() => navigateWithName(context, AppRoutes.adsDetailView, arguments: adsList[index]));
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
|
|
|
return 12.height;
|
|
|
|
|
return NotificationListener<ScrollNotification>(
|
|
|
|
|
onNotification: (ScrollNotification scrollInfo) {
|
|
|
|
|
if (scrollInfo.metrics.pixels == scrollInfo.metrics.maxScrollExtent && context.read<AdVM>().hasMoreData) {
|
|
|
|
|
log("should call more ads api:");
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 21),
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
itemCount: adsList.length,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: scrollPhysics,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return AdCard(
|
|
|
|
|
adDetails: adsList[index],
|
|
|
|
|
isAdsFragment: isAdsFragment,
|
|
|
|
|
shouldShowAdStatus: shouldShowAdStatus,
|
|
|
|
|
).onPress(() => navigateWithName(context, AppRoutes.adsDetailView, arguments: adsList[index]));
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
|
|
|
return 12.height;
|
|
|
|
|
},
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 21),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -62,7 +72,7 @@ class AdCard extends StatelessWidget {
|
|
|
|
|
final bool isAdsFragment;
|
|
|
|
|
final bool shouldShowAdStatus;
|
|
|
|
|
|
|
|
|
|
const AdCard({Key? key, required this.adDetails, required this.isAdsFragment, required this.shouldShowAdStatus}) : super(key: key);
|
|
|
|
|
const AdCard({super.key, required this.adDetails, required this.isAdsFragment, required this.shouldShowAdStatus});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|