diff --git a/lib/components/modalBottomSheet/patreon_modal_bottom_sheet.dart b/lib/components/modalBottomSheet/patreon_modal_bottom_sheet.dart index dc61c27b..49535de5 100644 --- a/lib/components/modalBottomSheet/patreon_modal_bottom_sheet.dart +++ b/lib/components/modalBottomSheet/patreon_modal_bottom_sheet.dart @@ -131,7 +131,6 @@ void handlePatreonBottomModalSheetWhenTapped( bool isPatron, { required DateTime unlockDate, required void Function(BuildContext dialogCtx) onTap, - Future Function(BuildContext dialogCtx)? onSettingsTap, }) { bool isLocked = isPatreonFeatureLocked(unlockDate, isPatron); if (isLocked == false) { @@ -143,8 +142,11 @@ void handlePatreonBottomModalSheetWhenTapped( navContext, hasRoundedCorners: true, builder: (BuildContext innerContext) => PatreonModalBottomSheet( - onSettingsTap: onSettingsTap, unlockDate: unlockDate, + onSettingsTap: (navCtx) => getNavigation().navigateAwayFromHomeAsync( + navCtx, + navigateToNamed: Routes.settings, + ), onTap: onTap, ), ); diff --git a/lib/components/tilePresenters/bait_tile_presenter.dart b/lib/components/tilePresenters/bait_tile_presenter.dart index 20611743..a1fce634 100644 --- a/lib/components/tilePresenters/bait_tile_presenter.dart +++ b/lib/components/tilePresenters/bait_tile_presenter.dart @@ -2,6 +2,7 @@ import 'package:assistantapps_flutter_common/assistantapps_flutter_common.dart'; import 'package:flutter/material.dart'; import '../../constants/app_image.dart'; +import '../../constants/patreon.dart'; import '../../constants/routes.dart'; import '../../contracts/data/bait_data.dart'; import '../../contracts/fishing/good_guy_free_bait_view_model.dart'; @@ -10,6 +11,7 @@ import '../../helpers/generic_helper.dart'; import '../../integration/dependency_injection.dart'; import '../../pages/generic/generic_page.dart'; import '../modalBottomSheet/good_guys_free_modal_bottom_sheet.dart'; +import 'patreon_tile_presenter.dart'; class BaitDataWithItemDetails { BaitData bait; @@ -331,11 +333,25 @@ Widget ggfBaitTilePresenter( List ggfBaitOnCatalogueTilePresenter( BuildContext context, String itemId, + bool isPatronLocked, ) { - return [ + var title = getTranslations().fromKey(LocaleKey.fishingBait); + List updateWidgets = [ const EmptySpace3x(), - GenericItemText(getTranslations().fromKey(LocaleKey.fishingBait)), - CachedFutureBuilder( + GenericItemText(title), + ]; + + if (isPatronLocked) { + updateWidgets.add(FlatCard( + child: patronFeatureTilePresenter( + context, + title, + Routes.fishingLocations, + PatreonEarlyAccessFeature.fishingDataPage, + ), + )); + } else { + updateWidgets.add(CachedFutureBuilder( future: getApiRepo().getGoodGuyFreeBaitForItem( getTranslations().currentLanguage, itemId, @@ -366,6 +382,8 @@ List ggfBaitOnCatalogueTilePresenter( }, ); }, - ), - ]; + )); + } + + return updateWidgets; } diff --git a/lib/components/tilePresenters/patreon_tile_presenter.dart b/lib/components/tilePresenters/patreon_tile_presenter.dart index b03c188c..c80c730a 100644 --- a/lib/components/tilePresenters/patreon_tile_presenter.dart +++ b/lib/components/tilePresenters/patreon_tile_presenter.dart @@ -1,9 +1,7 @@ import 'package:assistantapps_flutter_common/assistantapps_flutter_common.dart'; import 'package:flutter/material.dart'; -import '../../constants/app_image.dart'; -import '../../constants/nms_ui_constants.dart'; -import '../dialogs/pretty_dialog.dart'; +import '../modalBottomSheet/patreon_modal_bottom_sheet.dart'; Widget patronTilePresenter(BuildContext context, PatreonViewModel patron) { if (patron.url == ExternalUrls.patreon) { @@ -27,9 +25,12 @@ Widget patronTilePresenter(BuildContext context, PatreonViewModel patron) { ); } -Widget patronFeatureTilePresenter(BuildContext context, String featureName, - String navigateToNamed, DateTime unlockDate) { - var isFeatureAvailable = DateTime.now().isAfter(unlockDate); +Widget patronFeatureTilePresenter( + BuildContext context, + String featureName, + String navigateToNamed, + DateTime unlockDate, +) { var timeDiff = unlockDate.millisecondsSinceEpoch - DateTime.now().millisecondsSinceEpoch; var descripText = @@ -38,28 +39,19 @@ Widget patronFeatureTilePresenter(BuildContext context, String featureName, '{0}', getFriendlyTimeLeft(context, timeDiff), ); - void Function() onTap; - onTap = () { - Future Function() navigateAway; - navigateAway = () => getNavigation().navigateAwayFromHomeAsync( - context, - navigateToNamed: navigateToNamed, - ); - if (isFeatureAvailable) { - navigateAway(); - return; - } - - prettyDialog( - context, - AppImage.patreonFeature, - getTranslations().fromKey(LocaleKey.featureNotAvailable), - descrip, - okButtonText: getTranslations().fromKey(LocaleKey.patreon), - buttonOkColor: HexColor(NMSUIConstants.PatreonHex), - onSuccess: (_) => launchExternalURL(ExternalUrls.patreon), + void Function(BuildContext) onTap; + onTap = (navCtx) { + handlePatreonBottomModalSheetWhenTapped( + navCtx, + false, + unlockDate: unlockDate, + onTap: (innerNavCtx) => getNavigation().navigateAwayFromHomeAsync( + innerNavCtx, + navigateToNamed: navigateToNamed, + ), ); }; + return FlatCard( child: ListTile( leading: DonationImage.patreon(), @@ -76,9 +68,9 @@ Widget patronFeatureTilePresenter(BuildContext context, String featureName, trailing: IconButton( icon: const Icon(Icons.help), iconSize: 32.0, - onPressed: onTap, + onPressed: () => onTap(context), ), - onTap: onTap, + onTap: () => onTap(context), ), ); } diff --git a/lib/constants/patreon.dart b/lib/constants/patreon.dart index ebe9b8fa..92b88eb3 100644 --- a/lib/constants/patreon.dart +++ b/lib/constants/patreon.dart @@ -9,6 +9,7 @@ class PatreonEarlyAccessFeature { static DateTime newMilestonesPage = DateTime(2022, 4, 1); static DateTime newMajorUpdatesPage = DateTime(2022, 6, 18); static DateTime syncInventoryPage = DateTime(2022, 12, 24); + static DateTime fishingDataPage = DateTime(2024, 10, 1); } bool isPatreonFeatureLocked(DateTime unlockDate, bool isPatron) { diff --git a/lib/contracts/misc/custom_menu.dart b/lib/contracts/misc/custom_menu.dart index 5f5e36d2..07530c33 100644 --- a/lib/contracts/misc/custom_menu.dart +++ b/lib/contracts/misc/custom_menu.dart @@ -1,7 +1,9 @@ import 'package:assistantapps_flutter_common/assistantapps_flutter_common.dart'; import 'package:flutter/material.dart'; +import '../../components/modalBottomSheet/patreon_modal_bottom_sheet.dart'; import '../../constants/app_image.dart'; +import '../../constants/patreon.dart'; import '../../constants/routes.dart'; import '../../redux/modules/setting/drawer_settings_view_model.dart'; import '../enum/homepage_type.dart'; @@ -327,6 +329,24 @@ List getMenuOptionsSection3( drawerIcon: localGetDrawerFromIcon(Icons.phishing), title: LocaleKey.fishing, navigateToNamed: Routes.fishing, + isNew: DateTime.now().isBefore(PatreonEarlyAccessFeature.fishingDataPage), + isLocked: isPatreonFeatureLocked( + PatreonEarlyAccessFeature.fishingDataPage, + vm.isPatron, + ), + onTap: (tapCtx) { + handlePatreonBottomModalSheetWhenTapped( + tapCtx, + vm.isPatron, + unlockDate: PatreonEarlyAccessFeature.fishingDataPage, + onTap: (navCtx) { + getNavigation().navigateAwayFromHomeAsync( + navCtx, + navigateToNamed: Routes.fishing, + ); + }, + ); + }, ), // CustomMenu( // icon: const ListTileImage(partialPath:AppImage.techTree, size: imageSize), diff --git a/lib/env/app_version_num.dart b/lib/env/app_version_num.dart index 17034f6e..119393f0 100644 --- a/lib/env/app_version_num.dart +++ b/lib/env/app_version_num.dart @@ -1,3 +1,3 @@ -const appsBuildNum = 342; -const appsBuildName = '2.27.1'; -const appsCommit = '8fd62ef90ab7144cad1d016ec4fd3c7a84c2d538'; +const appsBuildNum = 343; +const appsBuildName = '2.28.0'; +const appsCommit = 'ea0e5d94ca1f08274ffebe3f15679bf56a63c244'; \ No newline at end of file diff --git a/lib/helpers/future_helper.dart b/lib/helpers/future_helper.dart index 3b2379c1..5d5b3d6b 100644 --- a/lib/helpers/future_helper.dart +++ b/lib/helpers/future_helper.dart @@ -34,6 +34,7 @@ Future> genericItemFuture( context, String itemId, int platformIndex, + bool isPatron, ) async { ResultWithValue genRepo = getRepoFromId(context, itemId); if (genRepo.hasFailed) { @@ -105,6 +106,7 @@ Future> genericItemFuture( if (usage.contains(UsageKey.hasCreatureHarvest)) { item.creatureHarvests = await creatureHarvestsFuture(context, itemId); } + if (usage.contains(UsageKey.hasFishingLocation)) { item.fishingData = await fishingLocationFuture(context, itemId); } diff --git a/lib/pages/generic/generic_page.dart b/lib/pages/generic/generic_page.dart index 62a791e8..91503b51 100644 --- a/lib/pages/generic/generic_page.dart +++ b/lib/pages/generic/generic_page.dart @@ -13,6 +13,7 @@ import '../../components/tilePresenters/required_item_details_tile_presenter.dar import '../../components/tilePresenters/required_item_tile_presenter.dart'; import '../../constants/analytics_event.dart'; import '../../constants/nms_ui_constants.dart'; +import '../../constants/patreon.dart'; import '../../constants/usage_key.dart'; import '../../contracts/cart/cart_item.dart'; import '../../contracts/charge_by.dart'; @@ -62,6 +63,7 @@ class GenericPage extends StatelessWidget { storeCtx, itemId, viewModel.platformIndex, + viewModel.isPatron, ), whileLoading: () => (itemTopContent != null) // ? itemTopContent @@ -294,10 +296,16 @@ class GenericPage extends StatelessWidget { // ---------------------------- Fishing Data ----------------------------- + var isFishingLocked = isPatreonFeatureLocked( + PatreonEarlyAccessFeature.fishingDataPage, + vm.isPatron, + ); + if (genericItem.fishingData != null) { widgets.addAll(getFishingLocation( bodyCtx, genericItem.fishingData!, + isFishingLocked, )); } @@ -305,6 +313,7 @@ class GenericPage extends StatelessWidget { widgets.addAll(getFishingBait( bodyCtx, genericItem.fishingBait!, + isFishingLocked, )); } @@ -312,6 +321,7 @@ class GenericPage extends StatelessWidget { widgets.addAll(ggfBaitOnCatalogueTilePresenter( bodyCtx, genericItem.id, + isFishingLocked, )); } diff --git a/lib/pages/generic/generic_page_components.dart b/lib/pages/generic/generic_page_components.dart index b3a5f830..facf2ac7 100644 --- a/lib/pages/generic/generic_page_components.dart +++ b/lib/pages/generic/generic_page_components.dart @@ -1,5 +1,6 @@ import 'package:assistantapps_flutter_common/assistantapps_flutter_common.dart'; import 'package:assistantnms_app/components/tilePresenters/fishing_page_tile_presenter.dart'; +import 'package:assistantnms_app/constants/patreon.dart'; import 'package:assistantnms_app/contracts/fishing/fishing_data.dart'; import 'package:ff_stars/ff_stars.dart'; import 'package:flutter/material.dart'; @@ -10,6 +11,7 @@ import '../../components/tilePresenters/creature_harvest_tile_presenter.dart'; import '../../components/tilePresenters/egg_trait_tile_presenter.dart'; import '../../components/tilePresenters/inventory_tile_presenter.dart'; import '../../components/tilePresenters/major_update_tile_presenter.dart'; +import '../../components/tilePresenters/patreon_tile_presenter.dart'; import '../../components/tilePresenters/required_item_tile_presenter.dart'; import '../../components/tilePresenters/reward_from_tile_presenter.dart'; import '../../components/tilePresenters/seasonal_expedition_tile_presenter.dart'; @@ -690,15 +692,40 @@ List getFromUpdate( return updateWidgets; } -List getFishingLocation(BuildContext context, FishingData fishingData) { +List getFishingLocation( + BuildContext context, + FishingData fishingData, + bool isPatronLocked, +) { List updateWidgets = List.empty(growable: true); updateWidgets.add(const EmptySpace3x()); String title = getTranslations().fromKey(LocaleKey.fishingLocation); updateWidgets.add(GenericItemText(title)); - fishingData.icon = AppImage.fishingLocation; - updateWidgets.add(FlatCard( - child: fishingDataTilePresenter(context, fishingData), - )); + + if (isPatronLocked) { + updateWidgets.add(FlatCard( + child: patronFeatureTilePresenter( + context, + title, + Routes.fishingLocations, + PatreonEarlyAccessFeature.fishingDataPage, + ), + )); + } else { + fishingData.icon = AppImage.fishingBait; + updateWidgets.add(FlatCard( + child: fishingDataTilePresenter( + context, + fishingData, + onTap: () { + getNavigation().navigateAwayFromHomeAsync( + context, + navigateToNamed: Routes.fishingLocations, + ); + }, + ), + )); + } return updateWidgets; } @@ -706,25 +733,37 @@ List getFishingLocation(BuildContext context, FishingData fishingData) { List getFishingBait( BuildContext context, BaitDataWithItemDetails fishingBait, + bool isPatronLocked, ) { List updateWidgets = List.empty(growable: true); updateWidgets.add(const EmptySpace3x()); String title = getTranslations().fromKey(LocaleKey.fishingBait); updateWidgets.add(GenericItemText(title)); - fishingBait.itemDetails.icon = AppImage.fishingBait; - updateWidgets.add(FlatCard( - child: baitTilePresenter( - context, - fishingBait, - wrapInCard: false, - onTap: () { - getNavigation().navigateAwayFromHomeAsync( - context, - navigateToNamed: Routes.fishingBait, - ); - }, - ), - )); + if (isPatronLocked) { + updateWidgets.add(FlatCard( + child: patronFeatureTilePresenter( + context, + title, + Routes.fishingLocations, + PatreonEarlyAccessFeature.fishingDataPage, + ), + )); + } else { + fishingBait.itemDetails.icon = AppImage.fishingBait; + updateWidgets.add(FlatCard( + child: baitTilePresenter( + context, + fishingBait, + wrapInCard: false, + onTap: () { + getNavigation().navigateAwayFromHomeAsync( + context, + navigateToNamed: Routes.fishingBait, + ); + }, + ), + )); + } return updateWidgets; }