-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add native ads in list pages * load new ads in each page This is done to avoid 'ad already in the widget tree' error. * add ads_mixin * refresh ads when filtering lists * fix hasSavedQuery * don't load native ads if ads are removed * fix rebase errors * format files * refactoring: move show ad conditions in AdsMixin
- Loading branch information
Showing
26 changed files
with
509 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:azure_devops/src/services/ads_service.dart'; | ||
import 'package:azure_devops/src/widgets/ad_widget.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
mixin AdsMixin { | ||
List<AdWithKey> ads = []; | ||
|
||
/// Load new native ads and map them to [AdWithKey] objects with a new global key to force refresh the UI. | ||
Future<void> getNewNativeAds(AdsService adsService) async { | ||
final newAds = await adsService.getNewNativeAds(); | ||
ads = newAds.map((ad) => (ad: ad, key: GlobalKey())).toList(); | ||
} | ||
|
||
/// Whether to show a native ad at the given [index] inside [items] list. | ||
bool shouldShowNativeAd<T>(List<T> items, T item, int index) => | ||
items.indexOf(item) % 5 == 4 && item != items.first && index < ads.length; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.