1
This commit is contained in:
parent
9930a7775d
commit
3bf5f4fa10
BIN
assets/images/splash_background.png
Executable file
BIN
assets/images/splash_background.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 438 KiB |
@ -3,17 +3,17 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>API_KEY</key>
|
||||
<string>AIzaSyCtr6QK7ixiotqBo4BlzoyS1X6ABMWni9E</string>
|
||||
<string>AIzaSyDmSYZIcHWdrLIDDKUpO2SugOfkIPeQ2R0</string>
|
||||
<key>GCM_SENDER_ID</key>
|
||||
<string>154597733455</string>
|
||||
<string>163289585689</string>
|
||||
<key>PLIST_VERSION</key>
|
||||
<string>1</string>
|
||||
<key>BUNDLE_ID</key>
|
||||
<string>com.ai.wallpaper.genie</string>
|
||||
<string>com.zt.atpaper</string>
|
||||
<key>PROJECT_ID</key>
|
||||
<string>wallpaper-genie-ios</string>
|
||||
<string>visualwallpaper-fdc23</string>
|
||||
<key>STORAGE_BUCKET</key>
|
||||
<string>wallpaper-genie-ios.appspot.com</string>
|
||||
<string>visualwallpaper-fdc23.appspot.com</string>
|
||||
<key>IS_ADS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_ANALYTICS_ENABLED</key>
|
||||
@ -25,6 +25,6 @@
|
||||
<key>IS_SIGNIN_ENABLED</key>
|
||||
<true></true>
|
||||
<key>GOOGLE_APP_ID</key>
|
||||
<string>1:154597733455:ios:d1981e1a0bcc03dab6663a</string>
|
||||
<string>1:163289585689:ios:b85946b1bb0a9234abf288</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:pin_code_fields/pin_code_fields.dart';
|
||||
import 'package:wallpaperx/common/utils/shared_util.dart';
|
||||
import 'package:wallpaperx/config/applovin.dart';
|
||||
import 'package:wallpaperx/generated/assets.dart';
|
||||
|
||||
class PinCodeVerificationScreen extends StatefulWidget {
|
||||
@ -195,6 +196,7 @@ class _PinCodeVerificationScreenState extends State<PinCodeVerificationScreen> {
|
||||
textEditingController.clear();
|
||||
});
|
||||
} else {
|
||||
ApplovinUtil().showAdIfReady();
|
||||
widget.callback();
|
||||
setState(() {
|
||||
hasError = false;
|
||||
|
||||
@ -22,6 +22,7 @@ class HttpUtil {
|
||||
ResponseType? responseType,
|
||||
Function? errorCallback,
|
||||
bool? isBackResponse = false, //是否返回Response类型数据
|
||||
bool? showLoading, //是否返回Response类型数据
|
||||
}) async {
|
||||
try {
|
||||
Map<String, dynamic> headers = {};
|
||||
@ -43,7 +44,7 @@ class HttpUtil {
|
||||
errorCallback!(e);
|
||||
dismiss(dismiss: true);
|
||||
LogPrint.d("e: $e");
|
||||
showError("Server error");
|
||||
showError("Server error", show: showLoading ?? true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
class Url {
|
||||
Url._();
|
||||
|
||||
static const String HOST = 'http://185.14.47.106:8001';
|
||||
static const String HOST = 'http://91.199.84.164:8001';
|
||||
|
||||
// 获取图片列表,分页
|
||||
static const String getImages = "$HOST/images";
|
||||
|
||||
138
lib/config/applovin.dart
Normal file
138
lib/config/applovin.dart
Normal file
@ -0,0 +1,138 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:applovin_max/applovin_max.dart';
|
||||
import 'package:wallpaperx/common/utils/log_print.dart';
|
||||
import 'package:wallpaperx/common/utils/shared_util.dart';
|
||||
import 'package:wallpaperx/firebase/firebase_analytics_manager.dart';
|
||||
|
||||
class ApplovinUtil {
|
||||
ApplovinUtil._();
|
||||
|
||||
static final ApplovinUtil _instance = ApplovinUtil._();
|
||||
|
||||
factory ApplovinUtil() => _instance;
|
||||
|
||||
/// sdkKey
|
||||
final String applovinKey =
|
||||
'HXOh4UBLahW9KzBBrxqwniKOvfD_JEDJgE9y2rv8DlmJaJ6xPEXUmmJyeAg0xipqdH_EiHg5NsnvfmIHubSu1k';
|
||||
|
||||
/// 广告单元Id
|
||||
final String adUnitId = 'f4d33bc86b44eb24';
|
||||
|
||||
final List<String> adUnitIds = [
|
||||
'e0ac389b7746be38',
|
||||
'a8ecc9c457dee7bf',
|
||||
'f4231f22c0314229',
|
||||
];
|
||||
|
||||
/// 是否已初始化
|
||||
bool isInitialized = false;
|
||||
|
||||
/// 是否是启动屏幕
|
||||
bool isSplashScreen = true;
|
||||
|
||||
/// 重试计数
|
||||
final _maxExponentialRetryCount = 6;
|
||||
var _interstitialRetryAttempt = 0;
|
||||
|
||||
/// 初始化
|
||||
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('AdLoadedSuccess:${ad.adUnitId}');
|
||||
if (ad.adUnitId == adUnitId && isSplashScreen) {
|
||||
await showAdIfReady(adUnitId: adUnitId);
|
||||
AppLovinMAX.loadInterstitial(adUnitId);
|
||||
isSplashScreen = false;
|
||||
onGoHomeTap();
|
||||
}
|
||||
_interstitialRetryAttempt = 0;
|
||||
},
|
||||
onAdLoadFailedCallback: (adUnitId, error) {
|
||||
LogPrint.d(
|
||||
'AdLoadFailed:$adUnitId,code:${error.code},message:${error.message}',
|
||||
);
|
||||
if (adUnitId == this.adUnitId && 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('AdDisplayedSuccess:${ad.adUnitId}');
|
||||
UPCache.getInstance().setData<int>(
|
||||
"lastAdTime",
|
||||
DateTime.now().millisecondsSinceEpoch,
|
||||
);
|
||||
// 打点
|
||||
FirebaseAnalyticsManager.logAdImpression(
|
||||
ad.adUnitId, ad.networkName, 1, 1, 0);
|
||||
},
|
||||
onAdDisplayFailedCallback: (ad, error) {
|
||||
LogPrint.d(
|
||||
'AdDisplayFailed:${ad.adUnitId},code:${error.code},message:${error.message}',
|
||||
);
|
||||
// 打点
|
||||
FirebaseAnalyticsManager.logAdImpression(
|
||||
ad.adUnitId, ad.networkName, 1, 0, 1);
|
||||
},
|
||||
onAdClickedCallback: (ad) {},
|
||||
onAdHiddenCallback: (ad) {
|
||||
LogPrint.d('AdHidden:${ad.adUnitId}');
|
||||
UPCache.getInstance().setData<int>(
|
||||
"lastAdTime",
|
||||
DateTime.now().millisecondsSinceEpoch,
|
||||
);
|
||||
AppLovinMAX.loadInterstitial(ad.adUnitId);
|
||||
},
|
||||
));
|
||||
|
||||
AppLovinMAX.loadInterstitial(adUnitId);
|
||||
for (var e in adUnitIds) {
|
||||
AppLovinMAX.loadInterstitial(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 显示插页广告,如果准备好
|
||||
Future showAdIfReady({String? adUnitId}) async {
|
||||
int lastAdTime = UPCache.getInstance().get<int>("lastAdTime") ?? 0;
|
||||
int now = DateTime.now().millisecondsSinceEpoch;
|
||||
DateTime timestamp1 = DateTime.fromMillisecondsSinceEpoch(lastAdTime);
|
||||
DateTime timestamp2 = DateTime.fromMillisecondsSinceEpoch(now);
|
||||
Duration difference = timestamp2.difference(timestamp1);
|
||||
LogPrint.d("广告间隔:${difference.inSeconds}");
|
||||
if (difference.inSeconds <= 5) return;
|
||||
if (!isInitialized) return;
|
||||
adUnitId ??= (adUnitIds..shuffle()).toList()[0];
|
||||
bool isReady = (await AppLovinMAX.isInterstitialReady(adUnitId))!;
|
||||
LogPrint.d("adUnitId:$adUnitId | isReady:$isReady");
|
||||
if (isReady) {
|
||||
AppLovinMAX.showInterstitial(adUnitId);
|
||||
} else {
|
||||
AppLovinMAX.loadInterstitial(adUnitId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -21,4 +21,18 @@ class FirebaseAnalyticsManager {
|
||||
parameters: parameters,
|
||||
);
|
||||
}
|
||||
|
||||
/// 广告日志记录
|
||||
static logAdImpression(String adId, String adName, int shouldCount, int successCount, int failCount) {
|
||||
FirebaseAnalytics.instance.logEvent(
|
||||
name: 'ad_impression',
|
||||
parameters: {
|
||||
'adId': adId,
|
||||
'adName': adName,
|
||||
'shouldCount': shouldCount,
|
||||
'successCount': successCount,
|
||||
'failCount': failCount,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,21 +49,13 @@ class DefaultFirebaseOptions {
|
||||
}
|
||||
}
|
||||
|
||||
// static const FirebaseOptions android = FirebaseOptions(
|
||||
// apiKey: 'AIzaSyDP6CpkN3HMpCofXlToug-hadYpTLEgE0E',
|
||||
// appId: '1:318284530945:android:c7dd2abf520a9840250700',
|
||||
// messagingSenderId: '318284530945',
|
||||
// projectId: 'nowwallpaper',
|
||||
// storageBucket: 'nowwallpaper.appspot.com',
|
||||
// );
|
||||
|
||||
static const FirebaseOptions ios = FirebaseOptions(
|
||||
apiKey: 'AIzaSyCtr6QK7ixiotqBo4BlzoyS1X6ABMWni9E',
|
||||
appId: '1:154597733455:ios:d1981e1a0bcc03dab6663a',
|
||||
messagingSenderId: '154597733455',
|
||||
projectId: 'wallpaper-genie-ios',
|
||||
storageBucket: 'wallpaper-genie-ios.appspot.com',
|
||||
iosBundleId: 'com.ai.wallpaper.genie',
|
||||
apiKey: 'AIzaSyDmSYZIcHWdrLIDDKUpO2SugOfkIPeQ2R0',
|
||||
appId: '1:163289585689:ios:b85946b1bb0a9234abf288',
|
||||
messagingSenderId: '163289585689',
|
||||
projectId: 'visualwallpaper-fdc23',
|
||||
storageBucket: 'visualwallpaper-fdc23.appspot.com',
|
||||
iosBundleId: 'com.zt.atpaper',
|
||||
);
|
||||
|
||||
}
|
||||
@ -53,5 +53,6 @@ class Assets {
|
||||
static const String imagesRecommendTopBackground = 'assets/images/recommend_top_background.png';
|
||||
static const String imagesSettingBackground = 'assets/images/setting_background.png';
|
||||
static const String imagesSettingSelected = 'assets/images/setting_selected.png';
|
||||
static const String imagesSplashBackground = 'assets/images/splash_background.png';
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import 'package:wallpaperx/common/components/easy_loading.dart';
|
||||
import 'package:wallpaperx/common/storage/hive_storage.dart';
|
||||
import 'package:wallpaperx/common/utils/log_print.dart';
|
||||
import 'package:wallpaperx/common/utils/shared_util.dart';
|
||||
import 'package:wallpaperx/config/applovin.dart';
|
||||
import 'package:wallpaperx/firebase/firebase_options.dart';
|
||||
import 'package:wallpaperx/res/themes/app_themes.dart';
|
||||
import 'package:wallpaperx/res/values/strings.dart';
|
||||
@ -48,6 +49,9 @@ void main() async {
|
||||
DeviceOrientation.portraitDown,
|
||||
]);
|
||||
|
||||
// 初始化广告sdk
|
||||
await ApplovinUtil().initApplovin();
|
||||
|
||||
// 初始化Hive
|
||||
await initHive();
|
||||
|
||||
@ -85,14 +89,13 @@ class MyApp extends StatelessWidget {
|
||||
builder: (context, child) {
|
||||
final botToastBuilder = BotToastInit();
|
||||
return GetMaterialApp(
|
||||
// defaultTransition:Transition.cupertino,
|
||||
navigatorObservers: [BotToastNavigatorObserver()],
|
||||
title: appName,
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: lightTheme,
|
||||
themeMode: ThemeMode.dark,
|
||||
getPages: AppPages.routes,
|
||||
initialRoute: AppPages.home,
|
||||
initialRoute: AppPages.splash,
|
||||
navigatorObservers: [BotToastNavigatorObserver()],
|
||||
builder: (context, widget) {
|
||||
widget = easyLoading(context, widget);
|
||||
child = botToastBuilder(context,widget);
|
||||
|
||||
@ -7,6 +7,7 @@ import 'package:wallpaperx/common/components/easy_loading.dart';
|
||||
import 'package:wallpaperx/common/components/view_state_widget.dart';
|
||||
import 'package:wallpaperx/common/http/http_util.dart';
|
||||
import 'package:wallpaperx/common/http/url.dart';
|
||||
import 'package:wallpaperx/config/applovin.dart';
|
||||
import 'package:wallpaperx/entity/image_model.dart';
|
||||
import 'package:wallpaperx/res/values/strings.dart';
|
||||
import 'package:wallpaperx/routes/app_pages.dart';
|
||||
@ -28,6 +29,7 @@ class CategoryController extends GetxController {
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
ApplovinUtil().showAdIfReady();
|
||||
scrollController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:get/get.dart';
|
||||
import 'package:wallpaperx/common/components/view_state_widget.dart';
|
||||
import 'package:wallpaperx/common/utils/shared_util.dart';
|
||||
import 'package:wallpaperx/config/app_tracking_transparency_manager.dart';
|
||||
import 'package:wallpaperx/config/applovin.dart';
|
||||
import 'package:wallpaperx/entity/userinfo_model.dart';
|
||||
import 'package:wallpaperx/generated/assets.dart';
|
||||
import 'package:wallpaperx/page/custom/custom_view.dart';
|
||||
@ -103,9 +104,11 @@ class HomeController extends GetxController with WidgetsBindingObserver {
|
||||
/// 跳转分类
|
||||
void toCategory(title, {String? jumpType}) {
|
||||
scaffoldKey.currentState?.openEndDrawer();
|
||||
ApplovinUtil().showAdIfReady().then((e) {
|
||||
Get.toNamed(AppPages.category, arguments: {
|
||||
'title': title,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ class RecommendController extends GetxController {
|
||||
super.onInit();
|
||||
scrollController = ScrollController();
|
||||
refreshController = EasyRefreshController(controlFinishLoad: true);
|
||||
getImages();
|
||||
getImages(showLoading: false);
|
||||
}
|
||||
|
||||
/// 停止定时器
|
||||
@ -57,7 +57,7 @@ class RecommendController extends GetxController {
|
||||
update(["discover_background"]);
|
||||
}
|
||||
|
||||
void getImages() {
|
||||
void getImages({bool? showLoading}) {
|
||||
List<String> tags = UPCache.getInstance().getStringList("labelSettingList");
|
||||
HttpUtil.get(
|
||||
Url.getImages,
|
||||
@ -78,9 +78,10 @@ class RecommendController extends GetxController {
|
||||
_stopTimer();
|
||||
}
|
||||
},
|
||||
showLoading: showLoading,
|
||||
errorCallback: (e) {
|
||||
_timer ??= Timer.periodic(const Duration(seconds: 2), (Timer t) {
|
||||
getImages();
|
||||
getImages(showLoading: false);
|
||||
});
|
||||
},
|
||||
params: {"limit": limit, "skip": skip, "tags": tags.join(",")},
|
||||
|
||||
@ -9,6 +9,7 @@ import 'package:wallpaperx/common/components/easy_loading.dart';
|
||||
import 'package:wallpaperx/common/http/http_util.dart';
|
||||
import 'package:wallpaperx/common/http/url.dart';
|
||||
import 'package:wallpaperx/common/utils/log_print.dart';
|
||||
import 'package:wallpaperx/config/applovin.dart';
|
||||
import 'package:wallpaperx/entity/image_model.dart';
|
||||
import 'package:wallpaperx/routes/app_pages.dart';
|
||||
|
||||
@ -34,11 +35,13 @@ class SearchImageController extends GetxController {
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
ApplovinUtil().showAdIfReady();
|
||||
refreshController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void searchImages({int? imageType}) {
|
||||
ApplovinUtil().showAdIfReady();
|
||||
if (searchController.text.isNotEmpty) {
|
||||
loading(show: true);
|
||||
HttpUtil.get(Url.searchImages, (callback) async {
|
||||
|
||||
@ -163,7 +163,7 @@ class SearchImageView extends GetView<SearchImageController> {
|
||||
Widget _buildTags(context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.only(bottom: 10).w,
|
||||
margin: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom).w,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
@ -173,15 +173,15 @@ class SearchImageView extends GetView<SearchImageController> {
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(bottom: 15.w),
|
||||
child: labelOptionColourItem(
|
||||
"Anime Characters",
|
||||
angle: 12.0 * (math.pi / 180.0),
|
||||
"Landscape",
|
||||
Text(
|
||||
"Anime Characters",
|
||||
"Landscape",
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: const Color.fromRGBO(255, 255, 255, 0.85),
|
||||
),
|
||||
),
|
||||
angle: 12.0 * (math.pi / 180.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -201,27 +201,18 @@ class SearchImageView extends GetView<SearchImageController> {
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
labelOptionItem(
|
||||
"",
|
||||
SizedBox(
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
angle: 0.0 * (math.pi / 180.0),
|
||||
padding: const EdgeInsets.all(13).w,
|
||||
),
|
||||
15.horizontalSpace,
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: labelOptionColourItem(
|
||||
"Landscape",
|
||||
"Anime Characters",
|
||||
Text(
|
||||
"Landscape",
|
||||
"Anime Characters",
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: const Color.fromRGBO(255, 255, 255, 0.85),
|
||||
),
|
||||
),
|
||||
angle: 0.0 * (math.pi / 180.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
9
lib/page/splash/splash_binding.dart
Normal file
9
lib/page/splash/splash_binding.dart
Normal file
@ -0,0 +1,9 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:wallpaperx/page/splash/splash_controller.dart';
|
||||
|
||||
class SplashBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => SplashController());
|
||||
}
|
||||
}
|
||||
41
lib/page/splash/splash_controller.dart
Normal file
41
lib/page/splash/splash_controller.dart
Normal file
@ -0,0 +1,41 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:wallpaperx/config/applovin.dart';
|
||||
import 'package:wallpaperx/routes/app_pages.dart';
|
||||
|
||||
class SplashController extends GetxController {
|
||||
Timer? _timer;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
ApplovinUtil().initializeInterstitialAds(onGoHomeTap: toIndex);
|
||||
_startTimer();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_stopTimer();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
/// 开始定时器
|
||||
void _startTimer() {
|
||||
_timer = Timer.periodic(const Duration(seconds: 10), (Timer t) {
|
||||
toIndex();
|
||||
});
|
||||
}
|
||||
|
||||
/// 停止定时器
|
||||
void _stopTimer() {
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
|
||||
/// 打开首页
|
||||
void toIndex() {
|
||||
_stopTimer();
|
||||
Get.offAndToNamed(AppPages.home);
|
||||
}
|
||||
}
|
||||
56
lib/page/splash/splash_view.dart
Normal file
56
lib/page/splash/splash_view.dart
Normal file
@ -0,0 +1,56 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:wallpaperx/generated/assets.dart';
|
||||
import 'package:wallpaperx/page/splash/splash_controller.dart';
|
||||
|
||||
class SplashView extends StatelessWidget {
|
||||
const SplashView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Get.put(SplashController());
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.black,
|
||||
image: DecorationImage(
|
||||
image: AssetImage(Assets.imagesSplashBackground),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: _buildProgress(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProgress() {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
margin: const EdgeInsets.only(bottom: 40).h,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 0.5.sw,
|
||||
child: LinearProgressIndicator(
|
||||
backgroundColor: Colors.grey,
|
||||
valueColor: const AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
borderRadius: BorderRadius.circular(8).r,
|
||||
),
|
||||
),
|
||||
14.verticalSpace,
|
||||
Text(
|
||||
'Resource Loading...',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12.sp,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,7 @@ 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/permission_util.dart';
|
||||
import 'package:wallpaperx/config/applovin.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';
|
||||
@ -46,6 +47,7 @@ class WallpaperDetailController extends GetxController {
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
ApplovinUtil().showAdIfReady();
|
||||
pageController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
@ -137,6 +139,10 @@ class WallpaperDetailController extends GetxController {
|
||||
/// 浏览记录
|
||||
void addHistory(index, {ImageModel? imageModel}) {
|
||||
ImageModel imageModel = wallpaperList[index];
|
||||
int indexOf = HistoryData().getWallpaperData().indexWhere(
|
||||
(element) => element.imageUrl == wallpaperList[index].imageUrl,
|
||||
);
|
||||
if (indexOf != -1) HistoryData().delete(indexOf);
|
||||
HistoryData().setWallpaperData(imageModel);
|
||||
// 刷新浏览列表
|
||||
if (Get.isRegistered<BrowseHistoryController>()) {
|
||||
@ -149,11 +155,6 @@ class WallpaperDetailController extends GetxController {
|
||||
Get.toNamed(AppPages.categoryItem, arguments: title);
|
||||
}
|
||||
|
||||
/// 翻转
|
||||
void flipCard() {
|
||||
flipCardController.toggleCard();
|
||||
}
|
||||
|
||||
/// 复制
|
||||
void copyPrompt(GenerateInfoModel? generateInfo) {
|
||||
Map textMap = {
|
||||
@ -164,8 +165,16 @@ class WallpaperDetailController extends GetxController {
|
||||
toast("Copied");
|
||||
}
|
||||
|
||||
/// 显示广告
|
||||
void showAd() {
|
||||
Get.back();
|
||||
/// 翻转并且播放广告
|
||||
void flipCardAndShowAd() {
|
||||
ApplovinUtil().showAdIfReady().then((e) {
|
||||
flipCardController.toggleCard();
|
||||
});
|
||||
}
|
||||
|
||||
/// 翻转
|
||||
void flipCard() {
|
||||
flipCardController.toggleCard();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -55,11 +55,11 @@ class WallpaperDetailView extends GetView<WallpaperDetailController> {
|
||||
builder: (context, index) {
|
||||
return PhotoViewGalleryPageOptions.customChild(
|
||||
child: PhotoView(
|
||||
enableRotation: true,
|
||||
enableRotation: false,
|
||||
imageProvider: CachedNetworkImageProvider(
|
||||
controller.wallpaperList[index].imageUrl,
|
||||
),
|
||||
initialScale: PhotoViewComputedScale.covered,
|
||||
initialScale: PhotoViewComputedScale.contained,
|
||||
minScale: PhotoViewComputedScale.contained * 0.5,
|
||||
maxScale: PhotoViewComputedScale.covered * 3,
|
||||
loadingBuilder: (context, event) => loadingView(),
|
||||
@ -101,7 +101,7 @@ class WallpaperDetailView extends GetView<WallpaperDetailController> {
|
||||
_buildOptionItem(
|
||||
Assets.iconBackBig,
|
||||
'',
|
||||
controller.showAd,
|
||||
Get.back,
|
||||
),
|
||||
Expanded(child: Container()),
|
||||
Obx(() => _buildOptionItem(
|
||||
@ -121,7 +121,7 @@ class WallpaperDetailView extends GetView<WallpaperDetailController> {
|
||||
_buildOptionItem(
|
||||
Assets.iconImgInfo,
|
||||
'',
|
||||
controller.flipCard,
|
||||
controller.flipCardAndShowAd,
|
||||
),
|
||||
16.horizontalSpace,
|
||||
],
|
||||
@ -301,7 +301,7 @@ class WallpaperDetailView extends GetView<WallpaperDetailController> {
|
||||
_buildOptionItem(
|
||||
Assets.iconBackBig,
|
||||
'',
|
||||
controller.showAd,
|
||||
Get.back,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () =>
|
||||
|
||||
@ -12,6 +12,7 @@ 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/permission_util.dart';
|
||||
import 'package:wallpaperx/config/applovin.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';
|
||||
@ -47,6 +48,7 @@ class WallpaperDetailV2Controller extends GetxController {
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
ApplovinUtil().showAdIfReady();
|
||||
pageController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
@ -137,6 +139,10 @@ class WallpaperDetailV2Controller extends GetxController {
|
||||
/// 浏览记录
|
||||
void addHistory(index, {ImageModel? imageModel}) {
|
||||
ImageModel imageModel = wallpaperList[index];
|
||||
int indexOf = HistoryData().getWallpaperData().indexWhere(
|
||||
(element) => element.imageUrl == wallpaperList[index].imageUrl,
|
||||
);
|
||||
if (indexOf != -1) HistoryData().delete(indexOf);
|
||||
HistoryData().setWallpaperData(imageModel);
|
||||
// 刷新浏览列表
|
||||
if (Get.isRegistered<BrowseHistoryController>()) {
|
||||
@ -149,11 +155,6 @@ class WallpaperDetailV2Controller extends GetxController {
|
||||
Get.toNamed(AppPages.categoryItem, arguments: title);
|
||||
}
|
||||
|
||||
/// 翻转
|
||||
void flipCard() {
|
||||
flipCardController.toggleCard();
|
||||
}
|
||||
|
||||
/// 复制
|
||||
void copyPrompt(GenerateInfoModel? generateInfo) {
|
||||
Map textMap = {
|
||||
@ -164,8 +165,16 @@ class WallpaperDetailV2Controller extends GetxController {
|
||||
toast("Copied");
|
||||
}
|
||||
|
||||
/// 显示广告
|
||||
void showAd() {
|
||||
Get.back();
|
||||
/// 翻转并且播放广告
|
||||
void flipCardAndShowAd() {
|
||||
ApplovinUtil().showAdIfReady().then((e) {
|
||||
flipCardController.toggleCard();
|
||||
});
|
||||
}
|
||||
|
||||
/// 翻转
|
||||
void flipCard() {
|
||||
flipCardController.toggleCard();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class WallpaperDetailV2View extends GetView<WallpaperDetailV2Controller> {
|
||||
imageProvider: CachedNetworkImageProvider(
|
||||
controller.wallpaperList[index].imageUrl,
|
||||
),
|
||||
initialScale: PhotoViewComputedScale.covered,
|
||||
initialScale: PhotoViewComputedScale.contained,
|
||||
minScale: PhotoViewComputedScale.contained * 0.5,
|
||||
maxScale: PhotoViewComputedScale.covered * 3,
|
||||
loadingBuilder: (context, event) => loadingView(),
|
||||
@ -100,28 +100,28 @@ class WallpaperDetailV2View extends GetView<WallpaperDetailV2Controller> {
|
||||
16.horizontalSpace,
|
||||
_buildOptionItem(
|
||||
Assets.iconBackBig,
|
||||
'Blur',
|
||||
controller.showAd,
|
||||
'',
|
||||
Get.back,
|
||||
),
|
||||
Expanded(child: Container()),
|
||||
Obx(() => _buildOptionItem(
|
||||
controller.isFavorite.value
|
||||
? Assets.iconFavorite
|
||||
: Assets.iconUnFavorite,
|
||||
'Favorite',
|
||||
'',
|
||||
controller.collectionImage,
|
||||
)),
|
||||
24.horizontalSpace,
|
||||
_buildOptionItem(
|
||||
Assets.iconDownload,
|
||||
'Download',
|
||||
'',
|
||||
controller.downloadImg,
|
||||
),
|
||||
24.horizontalSpace,
|
||||
_buildOptionItem(
|
||||
Assets.iconImgInfo,
|
||||
'Blur',
|
||||
controller.flipCard,
|
||||
'',
|
||||
controller.flipCardAndShowAd,
|
||||
),
|
||||
16.horizontalSpace,
|
||||
],
|
||||
@ -154,12 +154,6 @@ class WallpaperDetailV2View extends GetView<WallpaperDetailV2Controller> {
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
|
||||
child: Container(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
30,
|
||||
0,
|
||||
30,
|
||||
MediaQuery.of(context).padding.bottom + 55,
|
||||
).w,
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xff000000).withOpacity(.8),
|
||||
@ -169,15 +163,15 @@ class WallpaperDetailV2View extends GetView<WallpaperDetailV2Controller> {
|
||||
children: [
|
||||
63.verticalSpace,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
24.horizontalSpace,
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Image.asset(
|
||||
Assets.iconImgDelTip,
|
||||
color: Colors.white,
|
||||
width: 52.w,
|
||||
height: 52.w,
|
||||
),
|
||||
@ -207,20 +201,12 @@ class WallpaperDetailV2View extends GetView<WallpaperDetailV2Controller> {
|
||||
),
|
||||
],
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: controller.flipCard,
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
size: 24.w,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
37.verticalSpace,
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 30).w,
|
||||
children: [
|
||||
Wrap(
|
||||
spacing: 8.w,
|
||||
@ -233,6 +219,7 @@ class WallpaperDetailV2View extends GetView<WallpaperDetailV2Controller> {
|
||||
genInfo(
|
||||
Image.asset(
|
||||
Assets.iconSampler,
|
||||
color: Colors.white,
|
||||
width: 28.w,
|
||||
),
|
||||
"Sampler:",
|
||||
@ -242,6 +229,7 @@ class WallpaperDetailV2View extends GetView<WallpaperDetailV2Controller> {
|
||||
genInfo(
|
||||
Image.asset(
|
||||
Assets.iconCfgScale,
|
||||
color: Colors.white,
|
||||
width: 28.w,
|
||||
),
|
||||
"CFG scale:",
|
||||
@ -251,6 +239,7 @@ class WallpaperDetailV2View extends GetView<WallpaperDetailV2Controller> {
|
||||
genInfo(
|
||||
Image.asset(
|
||||
Assets.iconSteps,
|
||||
color: Colors.white,
|
||||
width: 28.w,
|
||||
),
|
||||
"Steps:",
|
||||
@ -260,6 +249,7 @@ class WallpaperDetailV2View extends GetView<WallpaperDetailV2Controller> {
|
||||
genInfo(
|
||||
Image.asset(
|
||||
Assets.iconSeed,
|
||||
color: Colors.white,
|
||||
width: 28.w,
|
||||
),
|
||||
"Seed:",
|
||||
@ -297,24 +287,49 @@ class WallpaperDetailV2View extends GetView<WallpaperDetailV2Controller> {
|
||||
),
|
||||
),
|
||||
24.verticalSpace,
|
||||
GestureDetector(
|
||||
onTap: () => controller.copyPrompt(model.generateInfo),
|
||||
child: Container(
|
||||
Container(
|
||||
height: 70.h,
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 15, horizontal: 8)
|
||||
.w,
|
||||
padding: EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: MediaQuery.of(context).padding.bottom,
|
||||
).w,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildOptionItem(
|
||||
Assets.iconBackBig,
|
||||
'',
|
||||
Get.back,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () =>
|
||||
controller.copyPrompt(model.generateInfo),
|
||||
child: Container(
|
||||
width: 200.w,
|
||||
height: 40.h,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xff322E31),
|
||||
borderRadius: BorderRadius.circular(30).r,
|
||||
color: Colors.white.withOpacity(.2),
|
||||
borderRadius: BorderRadius.circular(50).r,
|
||||
),
|
||||
child: Text(
|
||||
"copy",
|
||||
"Copy Prompt",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.white, fontSize: 14.sp),
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 14.sp),
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildOptionItem(
|
||||
Assets.iconImgInfo,
|
||||
'',
|
||||
controller.flipCard,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -17,6 +17,8 @@ import 'package:wallpaperx/page/login/login_binding.dart';
|
||||
import 'package:wallpaperx/page/login/login_view.dart';
|
||||
import 'package:wallpaperx/page/search_image/search_image_binding.dart';
|
||||
import 'package:wallpaperx/page/search_image/search_image_view.dart';
|
||||
import 'package:wallpaperx/page/splash/splash_binding.dart';
|
||||
import 'package:wallpaperx/page/splash/splash_view.dart';
|
||||
import 'package:wallpaperx/page/wallpaper_detail/wallpaper_detail_binding.dart';
|
||||
import 'package:wallpaperx/page/wallpaper_detail/wallpaper_detail_view.dart';
|
||||
import 'package:wallpaperx/page/wallpaper_detail_v2/wallpaper_detail_v2_binding.dart';
|
||||
@ -27,6 +29,9 @@ import 'package:wallpaperx/page/web/web_view_binding.dart';
|
||||
class AppPages {
|
||||
AppPages._();
|
||||
|
||||
/// 开屏页
|
||||
static const splash = '/splash';
|
||||
|
||||
/// 首页
|
||||
static const home = '/home';
|
||||
|
||||
@ -67,6 +72,11 @@ class AppPages {
|
||||
static const feedBack = '/feed_back';
|
||||
|
||||
static final routes = [
|
||||
GetPage(
|
||||
name: splash,
|
||||
page: () => const SplashView(),
|
||||
binding: SplashBinding(),
|
||||
),
|
||||
GetPage(
|
||||
name: home,
|
||||
page: () => const HomeView(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user