mirror of
https://github.com/johrpan/christmas_cats.git
synced 2025-10-28 19:27:25 +01:00
Remove shop
The items can be bought directly from the running game in the future. The player can get free coins from the main and pause menu.
This commit is contained in:
parent
03c94fe48c
commit
d258d415a2
5 changed files with 54 additions and 78 deletions
49
lib/widgets/get_coins.dart
Normal file
49
lib/widgets/get_coins.dart
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import 'package:firebase_admob/firebase_admob.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../localizations.dart';
|
||||
import '../storage.dart';
|
||||
|
||||
import 'menu_entry.dart';
|
||||
|
||||
class GetCoins extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localizations = ChristmasCatsLocalizations.of(context);
|
||||
|
||||
return MenuEntry(
|
||||
text: localizations.getCoins,
|
||||
onTap: () {
|
||||
final scaffold = Scaffold.of(context);
|
||||
scaffold.showSnackBar(SnackBar(
|
||||
content: Text(localizations.adLoading),
|
||||
// Show it until the ad is loaded
|
||||
duration: Duration(minutes: 1),
|
||||
));
|
||||
|
||||
final ad = RewardedVideoAd.instance;
|
||||
ad.listener = (event, {rewardAmount, rewardType}) {
|
||||
scaffold.removeCurrentSnackBar();
|
||||
if (event == RewardedVideoAdEvent.loaded) {
|
||||
ad.show();
|
||||
} else if (event == RewardedVideoAdEvent.failedToLoad) {
|
||||
scaffold.showSnackBar(SnackBar(
|
||||
content: Text(localizations.noAds),
|
||||
duration: const Duration(seconds: 2),
|
||||
));
|
||||
} else if (event == RewardedVideoAdEvent.rewarded) {
|
||||
storage.addCoins(rewardAmount);
|
||||
}
|
||||
};
|
||||
|
||||
ad.load(
|
||||
adUnitId: kReleaseMode
|
||||
? 'ca-app-pub-4129701777413448/6712208196'
|
||||
: RewardedVideoAd.testAdUnitId,
|
||||
targetingInfo: MobileAdTargetingInfo(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue