mirror of
https://github.com/johrpan/christmas_cats.git
synced 2025-10-28 19:27:25 +01:00
Version 0.1.0
This commit is contained in:
commit
5dda59a6cd
73 changed files with 5741 additions and 0 deletions
82
lib/screens/home.dart
Normal file
82
lib/screens/home.dart
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import 'package:firebase_admob/firebase_admob.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../localizations.dart';
|
||||
import '../widgets/menu.dart';
|
||||
import '../widgets/menu_entry.dart';
|
||||
|
||||
import 'game.dart';
|
||||
import 'intro.dart';
|
||||
import 'records.dart';
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localizations = ChristmasCatsLocalizations.of(context);
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Menu(
|
||||
title: localizations.title,
|
||||
subtitle: localizations.dedication,
|
||||
children: <Widget>[
|
||||
MenuEntry(
|
||||
text: localizations.play,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => GameScreen(),
|
||||
)),
|
||||
),
|
||||
MenuEntry(
|
||||
text: localizations.records,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RecordsScreen(),
|
||||
)),
|
||||
),
|
||||
MenuEntry(
|
||||
text: localizations.intro,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => IntroScreen(),
|
||||
)),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) => MenuEntry(
|
||||
text: localizations.ad,
|
||||
onTap: () {
|
||||
final ad = RewardedVideoAd.instance;
|
||||
|
||||
ad.listener = (event, {rewardAmount, rewardType}) {
|
||||
if (event == RewardedVideoAdEvent.loaded) {
|
||||
ad.show();
|
||||
} else if (event == RewardedVideoAdEvent.failedToLoad) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text(localizations.noAds),
|
||||
duration: const Duration(seconds: 2),
|
||||
));
|
||||
} else if (event == RewardedVideoAdEvent.rewarded) {
|
||||
// TODO: Reward user
|
||||
}
|
||||
};
|
||||
|
||||
ad.load(
|
||||
adUnitId: 'ca-app-pub-4129701777413448/6712208196',
|
||||
targetingInfo: MobileAdTargetingInfo(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
MenuEntry(
|
||||
text: localizations.exit,
|
||||
onTap: () => SystemNavigator.pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue