AI_Drawing/lib/dialog/ad_free_dialog.dart
2024-06-03 15:30:15 +08:00

137 lines
4.9 KiB
Dart

import 'package:aiplot/network/NetworkConfig.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:ironsource_mediation/ironsource_mediation.dart';
import '../generated/l10n.dart';
///删除图片提示
class AdFreeDialog extends StatefulWidget {
Function onTap;
AdFreeDialog({required this.onTap});
@override
State<AdFreeDialog> createState() => _AdFreeDialogState();
}
class _AdFreeDialogState extends State<AdFreeDialog> {
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final w314 = size.width / 1.1464968152866;
final h343 = size.width / 1.0495626822157;
final h75 = size.width / 4.8;
final t40 = size.width / 9;
final w85 = size.width / 4.235294117647;
final h45 = size.width / 8;
final t143 = size.width / 2.5174825174825;
final w283 = size.width / 1.2720848056537;
final t235 = size.width / 1.531914893617;
return Material(
type: MaterialType.transparency, //透明类型
color: const Color(0x00000000),
child: Center(
child: Stack(
alignment: Alignment.center,
children: [
CachedNetworkImage(
fit: BoxFit.fitHeight,
width: w314,
height: h343,
imageUrl: NetworkConfig.appConfigBean!.AdFree!.BackgroundImage!,
errorWidget: (context, url, error) => Image(
fit: BoxFit.fitWidth,
width: w314,
height: h343,
image: AssetImage('assets/images/ad_free_bg.png'),
),
),
Positioned(
top: t143,
child: GestureDetector(
onTap: () {
Navigator.pop(context);
if (NetworkConfig.appConfigBean!.AdFree!.BtnAction == "mall") {
Navigator.pushNamed(context, "/ShopPage");
}
},
child: CachedNetworkImage(
fit: BoxFit.fitHeight,
width: w283,
imageUrl: NetworkConfig.appConfigBean!.AdFree!.BtnImage!,
errorWidget: (context, url, error) => const Icon(Icons.error),
),
),
),
///看广告
Positioned(
top: t235,
child: GestureDetector(
onTap: () {
if (NetworkConfig.usedRewardCount != NetworkConfig.totalRewardCount) {
if (NetworkConfig.isAdAvailable) {
Navigator.pop(context);
IronSource.showRewardedVideo();
} else {
EasyLoading.showToast(S.of(context).no_advertisements);
}
} else {
EasyLoading.showToast(S.of(context).received_all);
}
},
child: Container(
height: h75,
width: w283,
decoration: const BoxDecoration(
color: Color(0xFFF8F8FF),
borderRadius: BorderRadius.all(Radius.circular(7)),
),
margin: const EdgeInsets.only(left: 15, right: 15),
child: Stack(
children: [
Positioned(
top: 20,
left: 10,
child: Text(
"${S.of(context).Watch_the} (${NetworkConfig.usedRewardCount}/${NetworkConfig.totalRewardCount})",
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
),
),
Positioned(
top: t40,
left: 10,
child: Text(
S.of(context).Earn_paint,
style: TextStyle(fontSize: 10, color: Color(0xFF999999)),
),
),
Positioned(
right: 4,
top: 18,
child: Stack(
alignment: Alignment.center,
children: [
Image(width: w85, height: h45, image: AssetImage('assets/images/view_ad.png')),
Positioned(
top: 10,
child: Text(
S.of(context).Watch,
style: TextStyle(fontSize: 14, color: Colors.white),
))
],
))
],
),
),
),
),
],
),
),
);
}
}