This commit is contained in:
xh 2024-07-22 18:01:11 +08:00
parent c4f44fdb2d
commit b64fcafff4
18 changed files with 18 additions and 466 deletions

View File

@ -1,130 +0,0 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'package:applovin_max/applovin_max.dart';
import 'package:wallpaperx/common/utils/log_print.dart';
class ApplovinManage {
ApplovinManage._();
static final ApplovinManage _instance = ApplovinManage._();
factory ApplovinManage() => _instance;
/// sdkKey
final String applovinKey = 'nEo4OHOhAZuAK9-IARuNaUfW-yDLBayq9FIGZs0L9XMNTByuDV6dsvMEIGnEAkQu-KR8D42QdKRlbniP910xnK';
/// 广Id
final String adUnitId1 = Platform.isAndroid ? 'a2ced77c3755055b' : 'a2ced77c3755055b';
final String adUnitId2 = Platform.isAndroid ? 'a3819ba97232d772' : 'a3819ba97232d772';
final String adUnitId3 = Platform.isAndroid ? 'bb0bfc77dcfd1fc4' : 'bb0bfc77dcfd1fc4';
///
bool isInitialized = false;
///
bool isSplashScreen = true;
///
final _maxExponentialRetryCount = 6;
var _interstitialRetryAttempt = 0;
/// 303广
// Timer? _timer;
// int _timeCount = 30;
///
Future<void> initApplovin() async {
MaxConfiguration? configuration = await AppLovinMAX.initialize(applovinKey);
if (configuration != null) {
isInitialized = true;
}
}
/// 广
void initializeInterstitialAds({required Function() onGoHomeTap}) {
if (isInitialized) {
AppLovinMAX.setInterstitialListener(InterstitialListener(
onAdLoadedCallback: (ad) async {
LogPrint.d('插页广告加载成功:${ad.adUnitId}');
if (ad.adUnitId == adUnitId1 && isSplashScreen) {
await showAdIfReady(adUnitId1);
AppLovinMAX.loadInterstitial(adUnitId1);
isSplashScreen = false;
onGoHomeTap();
}
_interstitialRetryAttempt = 0;
},
onAdLoadFailedCallback: (adUnitId, error) {
LogPrint.d('插页广告加载失败adUnitId:$adUnitId,code:${error.code},message:${error.message}');
if (adUnitId == adUnitId1 && isSplashScreen) {
isSplashScreen = false;
onGoHomeTap();
}
// Applovin建议您以指数级更高的延迟重试64
_interstitialRetryAttempt = _interstitialRetryAttempt + 1;
if (_interstitialRetryAttempt > _maxExponentialRetryCount) return;
int retryDelay = pow(2, min(_maxExponentialRetryCount, _interstitialRetryAttempt)).toInt();
Future.delayed(Duration(milliseconds: retryDelay * 1000), () {
AppLovinMAX.loadInterstitial(adUnitId);
});
},
onAdDisplayedCallback: (ad) {
LogPrint.d('插页广告显示成功:${ad.adUnitId}');
},
onAdDisplayFailedCallback: (ad, error) {
LogPrint.d('插页广告显示失败adUnitId:${ad.adUnitId},code:${error.code},message:${error.message}');
},
onAdClickedCallback: (ad) {},
onAdHiddenCallback: (ad) {
LogPrint.d('插页广告隐藏:${ad.adUnitId}');
AppLovinMAX.loadInterstitial(ad.adUnitId);
},
));
AppLovinMAX.loadInterstitial(adUnitId1);
AppLovinMAX.loadInterstitial(adUnitId2);
AppLovinMAX.loadInterstitial(adUnitId3);
}
}
/// 广
Future<void> showAdIfReady(String adUnitId) async {
return;
if (!isInitialized) {
return;
}
bool isReady = (await AppLovinMAX.isInterstitialReady(adUnitId))!;
if (isReady) {
// if (_timeCount == 30) {
// AppLovinMAX.showInterstitial(adUnitId);
// }
AppLovinMAX.showInterstitial(adUnitId);
} else {
AppLovinMAX.loadInterstitial(adUnitId);
}
}
// ///
// void _startTimer() {
// _timer = Timer.periodic(const Duration(seconds: 1), (Timer t) {
// if (_timeCount > 0) {
// _timeCount--;
// LogPrint.d('广告间隔倒计时$_timeCount秒');
// } else {
// _stopTimer();
// LogPrint.d('广告间隔计时停止');
// }
// });
// }
//
// ///
// void _stopTimer() {
// _timer?.cancel();
// _timer = null;
// _timeCount = 30;
// }
}

View File

@ -1,56 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wallpaperx/res/themes/app_styles.dart';
class BaseTextButton extends StatelessWidget {
final double? width;
final double? height;
final ButtonStyle? buttonStyle;
final Color? bgColor;
final double? radius;
final String? label;
final TextStyle? textStyle;
final Widget? child;
final Function()? onTap;
const BaseTextButton({
super.key,
this.label,
this.width,
this.height,
this.buttonStyle,
this.bgColor,
this.radius,
this.textStyle,
this.child,
this.onTap,
});
@override
Widget build(BuildContext context) {
return SizedBox(
width: width,
height: height,
child: TextButton(
onPressed: onTap,
style: buttonStyle ??
baseTextButtonStyle(
bgColor: bgColor,
radius: radius,
),
child: child ??
Text(
label ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: textStyle ??
TextStyle(
color: const Color(0xFF333333),
fontSize: 16.sp,
fontWeight: FontWeight.w600,
),
),
),
);
}
}

View File

@ -1,49 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/common/components/button/base_textbutton.dart';
import 'package:wallpaperx/common/components/divider_widget.dart';
class BottomSheetDialog {
static void show(void Function(int location) function) {
Get.bottomSheet(
Container(
color: Colors.white,
height: 150.h,
child: Column(
children: [
Expanded(
child: BaseTextButton(
label: 'Home Screen',
onTap: () {
Get.back();
function(0);
},
),
),
const DividerWidget(),
Expanded(
child: BaseTextButton(
label: 'Lock Screen',
onTap: () {
Get.back();
function(1);
},
),
),
const DividerWidget(),
Expanded(
child: BaseTextButton(
label: 'Both Screen',
onTap: () {
Get.back();
function(2);
},
),
),
],
),
),
);
}
}

View File

@ -1,94 +0,0 @@
// Author: fengshengxiong
// Date: 2024/5/9
// Description:
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wallpaperx/common/components/view_state_widget.dart';
import 'package:wallpaperx/common/utils/obj_util.dart';
class ProcessDialog extends StatelessWidget {
final double process;
final String processStr;
final Function() cancelOnTap;
final bool showCanCancel;
const ProcessDialog(
this.process,
this.processStr, {
super.key,
this.showCanCancel = true,
required this.cancelOnTap,
});
@override
Widget build(BuildContext context) {
return PopScope(
canPop: false,
child: Center(
child: IntrinsicWidth(
child: Container(
constraints: BoxConstraints(
minWidth: 80.w,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8).r,
),
child: IntrinsicHeight(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.h),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(height: 10.h),
loadingView(
color: Colors.black,
value: process,
),
if (ObjUtil.isNotEmptyStr(processStr)) ...[
SizedBox(height: 10.h),
Expanded(
child: Text(
processStr,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14.sp,
color: Colors.black,
),
),
),
],
if (!showCanCancel) ...[
SizedBox(height: 10.h),
],
if (showCanCancel) ...[
SizedBox(
height: 40.h,
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
backgroundColor: Colors.transparent,
),
onPressed: cancelOnTap,
child: Text(
'Cancel',
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
fontWeight: FontWeight.w500,
),
),
),
),
],
],
),
),
),
),
),
),
);
}
}

View File

@ -1,70 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class GetBindWidget extends StatefulWidget {
const GetBindWidget({
super.key,
this.bind,
this.tag,
this.binds,
this.tags,
required this.child,
}) : assert(
binds == null || tags == null || binds.length == tags.length,
'The binds and tags arrays length should be equal\n'
'and the elements in the two arrays correspond one-to-one',
);
final GetxController? bind;
final String? tag;
final List<GetxController>? binds;
final List<String>? tags;
final Widget child;
@override
GetBindWidgetState createState() => GetBindWidgetState();
}
class GetBindWidgetState extends State<GetBindWidget> {
@override
Widget build(BuildContext context) {
return widget.child;
}
@override
void dispose() {
_closeGetXController();
_closeGetXControllers();
super.dispose();
}
///Close GetxController bound to the current page
void _closeGetXController() {
if (widget.bind == null) {
return;
}
var key = widget.bind.runtimeType.toString() + (widget.tag ?? '');
GetInstance().delete(key: key);
}
///Batch close GetxController bound to the current page
void _closeGetXControllers() {
if (widget.binds == null) {
return;
}
for (var i = 0; i < widget.binds!.length; i++) {
var type = widget.binds![i].runtimeType.toString();
if (widget.tags == null) {
GetInstance().delete(key: type);
} else {
var key = type + (widget.tags?[i] ?? '');
GetInstance().delete(key: key);
}
}
}
}

View File

@ -4,8 +4,8 @@ import 'package:get/get.dart';
import 'package:wallpaperx/generated/assets.dart';
import 'package:wallpaperx/res/themes/app_colors.dart';
class BaseAppBar extends StatelessWidget implements PreferredSizeWidget {
const BaseAppBar(
class CustomAppbar extends StatelessWidget implements PreferredSizeWidget {
const CustomAppbar(
this.title, {
super.key,
this.backgroundColor,

View File

@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/applovin_max/applovin_manage.dart';
import 'package:wallpaperx/res/themes/app_colors.dart';
class NestedBottomBar extends StatelessWidget implements PreferredSizeWidget {
@ -48,7 +47,6 @@ class NestedBottomBar extends StatelessWidget implements PreferredSizeWidget {
child: InkWell(
onTap: onBackTap ?? () {
Get.back();
// ApplovinManage().showAdIfReady(ApplovinManage().adUnitId3);
},
child: Icon(Icons.close,color: Colors.white,size: 24.sp),
),

View File

@ -1,40 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wallpaperx/res/themes/app_sizes.dart';
class TitleBarWidget extends StatelessWidget {
const TitleBarWidget(
this.title, {
super.key,
this.fontSize,
this.backGroundColor,
});
final String title;
final double? fontSize;
final Color? backGroundColor;
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
color: backGroundColor??Colors.transparent,
child: SizedBox(
height: titleBarHeight,
child: Row(
mainAxisAlignment: MainAxisAlignment. center,
children: [
Text(
title,
style: TextStyle(
color: Colors.black87,
fontSize: fontSize??32.sp,
fontWeight: FontWeight.w600,
),
),
],
),
),
);
}
}

View File

@ -1,7 +1,3 @@
// Author: fengshengxiong
// Date: 2024/6/26
// Description:
import 'dart:async';
import 'dart:io';

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/common/components/navigation_bar/appbar_base.dart';
import 'package:wallpaperx/common/components/navigation_bar/custom_appbar.dart';
import 'package:wallpaperx/generated/assets.dart';
import 'package:wallpaperx/page/about/about_controller.dart';
import 'package:wallpaperx/res/values/strings.dart';
@ -22,7 +22,7 @@ class AboutView extends GetView<AboutController> {
alignment: Alignment.topCenter,
child: Column(
children: [
BaseAppBar(
CustomAppbar(
"About",
backgroundColor: Colors.transparent,
titleStyle: TextStyle(

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/common/components/navigation_bar/appbar_base.dart';
import 'package:wallpaperx/common/components/navigation_bar/custom_appbar.dart';
import 'package:wallpaperx/generated/assets.dart';
import 'package:wallpaperx/res/values/strings.dart';
@ -23,7 +23,7 @@ class AiManagerView extends GetView<AiManagerController> {
child: Obx(
() => Column(
children: [
BaseAppBar(
CustomAppbar(
appName,
backgroundColor: Colors.transparent,
titleStyle: TextStyle(

View File

@ -3,7 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/common/components/image_network_widget.dart';
import 'package:wallpaperx/common/components/keep_alive_wrapper.dart';
import 'package:wallpaperx/common/components/navigation_bar/appbar_base.dart';
import 'package:wallpaperx/common/components/navigation_bar/custom_appbar.dart';
import 'package:wallpaperx/entity/image_model.dart';
import 'package:wallpaperx/generated/assets.dart';
import 'package:wallpaperx/page/category/category_controller.dart';
@ -34,7 +34,7 @@ class CategoryView extends GetView<CategoryController> {
}
Widget _buildCategoryBar(title) {
return BaseAppBar(
return CustomAppbar(
title,
backgroundColor: Colors.transparent,
titleStyle: TextStyle(

View File

@ -4,7 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/common/components/image_network_widget.dart';
import 'package:wallpaperx/common/components/navigation_bar/appbar_base.dart';
import 'package:wallpaperx/common/components/navigation_bar/custom_appbar.dart';
import 'package:wallpaperx/entity/image_model.dart';
import 'package:wallpaperx/res/values/strings.dart';
@ -17,7 +17,7 @@ class CategoryItemView extends GetView<CategoryItemController> {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: BaseAppBar(
appBar: CustomAppbar(
appName,
backgroundColor: Colors.black,
titleStyle: TextStyle(

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/common/components/navigation_bar/appbar_base.dart';
import 'package:wallpaperx/common/components/navigation_bar/custom_appbar.dart';
import 'package:wallpaperx/generated/assets.dart';
import 'edit_userinfo_controller.dart';
@ -26,7 +26,7 @@ class EditUserinfoView extends GetView<EditUserinfoController> {
builder: (_) => Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
BaseAppBar(
CustomAppbar(
controller.title,
backgroundColor: Colors.transparent,
titleStyle: TextStyle(

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/common/components/navigation_bar/appbar_base.dart';
import 'package:wallpaperx/common/components/navigation_bar/custom_appbar.dart';
import 'package:wallpaperx/generated/assets.dart';
import 'package:wallpaperx/page/feed_back/feed_back_controller.dart';
@ -29,7 +29,7 @@ class FeedBackView extends GetView<FeedBackController> {
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
BaseAppBar(
CustomAppbar(
"Feed Back",
backgroundColor: Colors.transparent,
titleStyle: TextStyle(

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/common/components/navigation_bar/appbar_base.dart';
import 'package:wallpaperx/common/components/navigation_bar/custom_appbar.dart';
import 'package:wallpaperx/generated/assets.dart';
import 'package:wallpaperx/page/login/login_controller.dart';
@ -23,7 +23,7 @@ class LoginView extends GetView<LoginController> {
id: "loginInfo",
builder: (_) => Column(
children: [
BaseAppBar(
CustomAppbar(
"Login",
backgroundColor: Colors.transparent,
titleStyle: TextStyle(

View File

@ -6,15 +6,12 @@ import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:wallpaperx/common/components/dialog/bottomsheet_dialog.dart';
import 'package:wallpaperx/common/components/easy_loading.dart';
import 'package:wallpaperx/common/storage/favorite_data.dart';
import 'package:wallpaperx/common/storage/history_data.dart';
import 'package:wallpaperx/common/utils/download_util.dart';
import 'package:wallpaperx/common/utils/log_print.dart';
import 'package:wallpaperx/common/utils/obj_util.dart';
import 'package:wallpaperx/common/utils/permission_util.dart';
import 'package:wallpaperx/common/utils/wallpaper_manage.dart';
import 'package:wallpaperx/entity/generate_info_model.dart';
import 'package:wallpaperx/entity/image_model.dart';
import 'package:wallpaperx/page/browse_history/browse_history_controller.dart';

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallpaperx/common/components/navigation_bar/appbar_base.dart';
import 'package:wallpaperx/common/components/navigation_bar/custom_appbar.dart';
import 'package:wallpaperx/common/components/view_state_widget.dart';
import 'package:webview_flutter/webview_flutter.dart';
@ -14,7 +14,7 @@ class WebView extends GetView<WebController> {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: BaseAppBar(
appBar: CustomAppbar(
controller.title,
backgroundColor: Colors.black,
titleStyle: TextStyle(