From 51af7c4f09d61c0124629c2a71826aa73f8ebbca Mon Sep 17 00:00:00 2001 From: bluesea <307723040@qq.com> Date: Thu, 16 May 2024 12:01:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9C=9F=E7=9A=84=E6=94=B6=E5=B7=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/homepage/homepage_controller.dart | 2 +- .../lib/pages/homepage/homepage_view.dart | 22 +++-- .../imgcategorypage/imgcategorypage_view.dart | 22 +++-- .../pages/imgscanpage/imgscanpage_view.dart | 1 + .../Flutter/GeneratedPluginRegistrant.swift | 2 + wallpaper/pubspec.lock | 96 +++++++++++++++++++ wallpaper/pubspec.yaml | 2 + 7 files changed, 132 insertions(+), 15 deletions(-) diff --git a/wallpaper/lib/pages/homepage/homepage_controller.dart b/wallpaper/lib/pages/homepage/homepage_controller.dart index ba69fbd..81b9f7d 100644 --- a/wallpaper/lib/pages/homepage/homepage_controller.dart +++ b/wallpaper/lib/pages/homepage/homepage_controller.dart @@ -1,3 +1,4 @@ +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:wallpaper/routes/app_routes.dart'; import "package:wallpaper/utils/assettool.dart"; @@ -9,7 +10,6 @@ class HomePageController extends GetxController { super.onReady(); setupTypeListData(); - } void setupTypeListData() async{ diff --git a/wallpaper/lib/pages/homepage/homepage_view.dart b/wallpaper/lib/pages/homepage/homepage_view.dart index a61c9ea..6aa355f 100644 --- a/wallpaper/lib/pages/homepage/homepage_view.dart +++ b/wallpaper/lib/pages/homepage/homepage_view.dart @@ -2,7 +2,9 @@ // import 'dart:js'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:get/get.dart'; import 'package:transparent_image/transparent_image.dart'; import 'package:wallpaper/pages/homepage/homepage_controller.dart'; @@ -42,7 +44,10 @@ class HomePageView extends GetView { padding: const EdgeInsets.symmetric(horizontal: 5), // padding: const EdgeInsets.fromLTRB(5, 50, 5, 0), children: List.generate(controller.typeList.length, (index) { - return getBodyItem(controller.typeList[index].data![0].previewThumb!,controller.typeList[index].name!,index); + return Scaffold( + backgroundColor: Colors.grey, + body: getBodyItem(controller.typeList[index].data![0].previewThumb!,controller.typeList[index].name!,index), + ); }), )); } @@ -50,12 +55,15 @@ class HomePageView extends GetView { Stack getBodyItem(String imgUrl,String title,int index){ return Stack(//堆叠效果 children: [ - FadeInImage.memoryNetwork( - width: double.infinity, - height: double.infinity, - placeholder: kTransparentImage, - image: imgUrl, - fit: BoxFit.cover, + CachedNetworkImage( + imageUrl: imgUrl, + width: double.infinity, + height: double.infinity, + fit: BoxFit.cover, + placeholder: (context, url) => const SizedBox(height: 30,width: 30,child: Center( + child: CircularProgressIndicator(color: Colors.white,), + ),), + errorWidget: (context, url, error) => const Icon(Icons.error_outline_outlined,color: Colors.white,), ), diff --git a/wallpaper/lib/pages/imgcategorypage/imgcategorypage_view.dart b/wallpaper/lib/pages/imgcategorypage/imgcategorypage_view.dart index 6bb450b..af181cb 100644 --- a/wallpaper/lib/pages/imgcategorypage/imgcategorypage_view.dart +++ b/wallpaper/lib/pages/imgcategorypage/imgcategorypage_view.dart @@ -1,3 +1,4 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:wallpaper/pages/imgcategorypage/imgcategorypage_controller.dart'; @@ -42,7 +43,11 @@ class ImgCategoryPageView extends GetView { childAspectRatio: 0.7, padding: const EdgeInsets.symmetric(horizontal: 5), children: List.generate(controller.dataModel.data!.length, (index) { - return getBodyItem(controller.dataModel.data![index].previewThumb!, index); + return + Scaffold( + backgroundColor: Colors.grey, + body: getBodyItem(controller.dataModel.data![index].previewThumb!, index), + ); })); // return Obx(() => GridView.count( // crossAxisCount: 2, @@ -59,12 +64,15 @@ class ImgCategoryPageView extends GetView { Stack getBodyItem(String imgUrl,int index) { return Stack(//堆叠效果 children: [ - FadeInImage.memoryNetwork( - width: double.infinity, - height: double.infinity, - placeholder: kTransparentImage, - image: imgUrl, - fit: BoxFit.cover, + CachedNetworkImage( + imageUrl: imgUrl, + width: double.infinity, + height: double.infinity, + fit: BoxFit.cover, + placeholder: (context, url) => const SizedBox(height: 30,width: 30,child: Center( + child: CircularProgressIndicator(color: Colors.white,), + ),), + errorWidget: (context, url, error) => const Icon(Icons.error_outline_outlined,color: Colors.white,), ), Material( diff --git a/wallpaper/lib/pages/imgscanpage/imgscanpage_view.dart b/wallpaper/lib/pages/imgscanpage/imgscanpage_view.dart index 9104a25..dafaff7 100644 --- a/wallpaper/lib/pages/imgscanpage/imgscanpage_view.dart +++ b/wallpaper/lib/pages/imgscanpage/imgscanpage_view.dart @@ -51,6 +51,7 @@ class ImgScanPageView extends GetView { width: 20.0, height: 20.0, child: CircularProgressIndicator( + color: Colors.white, value: event == null ? 0 : event.cumulativeBytesLoaded / event.expectedTotalBytes!, diff --git a/wallpaper/macos/Flutter/GeneratedPluginRegistrant.swift b/wallpaper/macos/Flutter/GeneratedPluginRegistrant.swift index f4894ad..751673c 100644 --- a/wallpaper/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/wallpaper/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,8 +7,10 @@ import Foundation import flutter_inappwebview_macos import path_provider_foundation +import sqflite func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) } diff --git a/wallpaper/pubspec.lock b/wallpaper/pubspec.lock index b6cd093..a10738f 100644 --- a/wallpaper/pubspec.lock +++ b/wallpaper/pubspec.lock @@ -113,6 +113,30 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "8.9.2" + cached_network_image: + dependency: "direct main" + description: + name: cached_network_image + sha256: "28ea9690a8207179c319965c13cd8df184d5ee721ae2ce60f398ced1219cea1f" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.3.1" + cached_network_image_platform_interface: + dependency: transitive + description: + name: cached_network_image_platform_interface + sha256: "9e90e78ae72caa874a323d78fa6301b3fb8fa7ea76a8f96dc5b5bf79f283bf2f" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.0.0" + cached_network_image_web: + dependency: transitive + description: + name: cached_network_image_web + sha256: "205d6a9f1862de34b93184f22b9d2d94586b2f05c581d546695e3d8f6a805cd7" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.0" characters: dependency: transitive description: @@ -222,6 +246,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_cache_manager: + dependency: transitive + description: + name: flutter_cache_manager + sha256: "395d6b7831f21f3b989ebedbb785545932adb9afe2622c1ffacf7f4b53a7e544" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.3.2" flutter_easyloading: dependency: "direct main" description: @@ -432,6 +464,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.1" + http: + dependency: transitive + description: + name: http + sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.1" http_multi_server: dependency: transitive description: @@ -560,6 +600,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.0" + octo_image: + dependency: transitive + description: + name: octo_image + sha256: "45b40f99622f11901238e18d48f5f12ea36426d8eced9f4cbf58479c7aa2430d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" package_config: dependency: transitive description: @@ -720,6 +768,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.2.3" + rxdart: + dependency: transitive + description: + name: rxdart + sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.27.7" shelf: dependency: transitive description: @@ -765,6 +821,30 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.0.0" + sqflite: + dependency: transitive + description: + name: sqflite + sha256: a43e5a27235518c03ca238e7b4732cf35eabe863a369ceba6cbefa537a66f16d + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.3+1" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + sha256: "3da423ce7baf868be70e2c0976c28a1bb2f73644268b7ffa7d2e08eab71f16a4" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.5.4" stack_trace: dependency: transitive description: @@ -797,6 +877,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.2.0" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.0+1" term_glyph: dependency: transitive description: @@ -837,6 +925,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.3.2" + uuid: + dependency: transitive + description: + name: uuid + sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.4.0" vector_math: dependency: transitive description: diff --git a/wallpaper/pubspec.yaml b/wallpaper/pubspec.yaml index 9a19338..7bd7c96 100644 --- a/wallpaper/pubspec.yaml +++ b/wallpaper/pubspec.yaml @@ -63,6 +63,8 @@ dependencies: #将图片导出到相册 image_gallery_saver: ^2.0.3 permission_handler: ^10.0.0 + #网络图片加载(支持缓存) + cached_network_image: ^3.3.1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.6