|
|
@@ -28,6 +28,7 @@ import 'package:puzzleweave/utils/mybutton.dart';
|
|
|
import 'package:puzzleweave/utils/utils.dart';
|
|
|
import 'package:vector_math/vector_math.dart' as vmath;
|
|
|
import 'package:vibration/vibration.dart';
|
|
|
+import '../ads/ads_state.dart';
|
|
|
|
|
|
final Logger _log = Logger('board_play.dart');
|
|
|
|
|
|
@@ -70,7 +71,7 @@ class BoardPlay extends StatefulWidget {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class _BoardPlayState extends State<BoardPlay> with TickerProviderStateMixin {
|
|
|
+class _BoardPlayState extends AdsState<BoardPlay> with TickerProviderStateMixin {
|
|
|
final GlobalKey boardKey = GlobalKey();
|
|
|
Board? board;
|
|
|
bool _isLoading = true;
|
|
|
@@ -1055,10 +1056,10 @@ class _BoardPlayState extends State<BoardPlay> with TickerProviderStateMixin {
|
|
|
}
|
|
|
|
|
|
/// gallery页面加载的时候,可能广告模块还没有初始化完毕
|
|
|
- // Future<bool> _bannerReadyAndShouldShow() async {
|
|
|
- // bool ready = await adSDKReady();
|
|
|
- // return ready && shouldShowBannerAd(data.currentLevel);
|
|
|
- // }
|
|
|
+ Future<bool> _bannerReadyAndShouldShow() async {
|
|
|
+ bool ready = await adSDKReady();
|
|
|
+ return ready && shouldShowBannerAd(data.currentLevel);
|
|
|
+ }
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
@@ -1074,25 +1075,24 @@ class _BoardPlayState extends State<BoardPlay> with TickerProviderStateMixin {
|
|
|
bottom: 0,
|
|
|
left: 0,
|
|
|
right: 0,
|
|
|
- child: Container(),
|
|
|
- // child: SafeArea(
|
|
|
- // child: SizedBox(
|
|
|
- // // 始终预留一个固定的高度,防止布局跳变
|
|
|
- // height: context.read<Device>().bannerHeight,
|
|
|
- // width: double.infinity,
|
|
|
- // child: FutureBuilder<bool>(
|
|
|
- // future: _bannerReadyAndShouldShow(),
|
|
|
- // builder: (context, snapshot) {
|
|
|
- // if (snapshot.hasData && snapshot.data == true) {
|
|
|
- // return adBanner;
|
|
|
- // }
|
|
|
- // return Container(
|
|
|
- // // color: Colors.grey.shade100,
|
|
|
- // );
|
|
|
- // },
|
|
|
- // ),
|
|
|
- // ),
|
|
|
- // ),
|
|
|
+ child: SafeArea(
|
|
|
+ child: SizedBox(
|
|
|
+ // 始终预留一个固定的高度,防止布局跳变
|
|
|
+ height: context.read<Device>().bannerHeight,
|
|
|
+ width: double.infinity,
|
|
|
+ child: FutureBuilder<bool>(
|
|
|
+ future: _bannerReadyAndShouldShow(),
|
|
|
+ builder: (context, snapshot) {
|
|
|
+ if (snapshot.hasData && snapshot.data == true) {
|
|
|
+ return adBanner;
|
|
|
+ }
|
|
|
+ return Container(
|
|
|
+ // color: Colors.grey.shade100,
|
|
|
+ );
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
),
|
|
|
successBanner,
|
|
|
nextButton,
|
|
|
@@ -1231,10 +1231,12 @@ class _BoardPlayState extends State<BoardPlay> with TickerProviderStateMixin {
|
|
|
gradient: LinearGradient(colors: [SkinHelper.coreBgColor, SkinHelper.slotBorderColor]),
|
|
|
onPressed: () async {
|
|
|
audio.playSfx(SfxType.click);
|
|
|
- // audio.pauseMusic();
|
|
|
- // await showInterstitialAd('level_exit', widget.item.id, data.currentLevel);
|
|
|
- // audio.startMusic();
|
|
|
- // if (!mounted) return;
|
|
|
+ ///////////////// 播放插屏广告 //////////////////
|
|
|
+ audio.pauseMusic();
|
|
|
+ await showInterstitialAd('level_exit', widget.item.id, data.currentLevel);
|
|
|
+ audio.startMusic();
|
|
|
+ if (!mounted) return;
|
|
|
+ //////////////// 插屏广告结束 /////////////////
|
|
|
Navigator.pop(context, true);
|
|
|
},
|
|
|
child: Text(AppLocalizations.of(context)!.next, style: TextStyle(color: Colors.white, fontSize: 20)),
|