daf
This commit is contained in:
parent
f4d9147bcd
commit
a471816160
@ -40,6 +40,15 @@ class DownloadPageController extends GetxController {
|
|||||||
await DownloadManager.setWallpaperNative(imgUrl);
|
await DownloadManager.setWallpaperNative(imgUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//删除图片
|
||||||
|
void deleteWallpaper(String imgUrl,int index) async{
|
||||||
|
await DownloadManager.deleteWallpaperFile(imgUrl);
|
||||||
|
DBManager.deleteImg(dataItems[index]);
|
||||||
|
// ignore: invalid_use_of_protected_member
|
||||||
|
dataItems.value.removeAt(index);
|
||||||
|
|
||||||
|
// dataItems.value = DBManager.allImgs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -30,12 +30,12 @@ class DownloadPageView extends GetView<DownloadPageController> {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||||
// padding: const EdgeInsets.fromLTRB(5, 50, 5, 0),
|
// padding: const EdgeInsets.fromLTRB(5, 50, 5, 0),
|
||||||
children: List.generate(controller.dataItems.length, (index) {
|
children: List.generate(controller.dataItems.length, (index) {
|
||||||
return getBodyItem(controller.dataItems[index].localUrl!);
|
return getBodyItem(controller.dataItems[index].localUrl!,index);
|
||||||
}),
|
}),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Stack getBodyItem(String fileName) {
|
Stack getBodyItem(String fileName,int index) {
|
||||||
var imgUrl = '${controller.localDir.value}/$fileName';
|
var imgUrl = '${controller.localDir.value}/$fileName';
|
||||||
return Stack(//堆叠效果
|
return Stack(//堆叠效果
|
||||||
children: [
|
children: [
|
||||||
@ -45,15 +45,6 @@ class DownloadPageView extends GetView<DownloadPageController> {
|
|||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
// Image.file(imgUrl),
|
|
||||||
// FadeInImage.loadImageByFile(
|
|
||||||
// width: double.infinity,
|
|
||||||
// height: double.infinity,
|
|
||||||
// placeholder: kTransparentImage,
|
|
||||||
// image: imgUrl,
|
|
||||||
// fit: BoxFit.cover,
|
|
||||||
// ),
|
|
||||||
|
|
||||||
Material(
|
Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
@ -72,7 +63,7 @@ class DownloadPageView extends GetView<DownloadPageController> {
|
|||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
// 交叉轴的布局方式,对于column来说就是水平方向的布局方式
|
// 交叉轴的布局方式,对于column来说就是水平方向的布局方式
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: getButtomWidge(imgUrl),
|
children: getButtomWidge(imgUrl,index),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -84,7 +75,7 @@ class DownloadPageView extends GetView<DownloadPageController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<Widget> getButtomWidge(String imgUrl){
|
List<Widget> getButtomWidge(String imgUrl,int index){
|
||||||
List<Widget> wg = [
|
List<Widget> wg = [
|
||||||
IconButton(onPressed:() {
|
IconButton(onPressed:() {
|
||||||
controller.saveImgToAlbum(imgUrl);
|
controller.saveImgToAlbum(imgUrl);
|
||||||
@ -97,6 +88,10 @@ class DownloadPageView extends GetView<DownloadPageController> {
|
|||||||
|
|
||||||
}, icon: const Icon(Icons.wallpaper),color: Colors.white,));
|
}, icon: const Icon(Icons.wallpaper),color: Colors.white,));
|
||||||
}
|
}
|
||||||
|
wg.add(IconButton(onPressed:() {
|
||||||
|
controller.deleteWallpaper(imgUrl,index);
|
||||||
|
|
||||||
|
}, icon: const Icon(Icons.delete),color: Colors.red,));
|
||||||
return wg;
|
return wg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,8 +35,13 @@ class DBManager {
|
|||||||
|
|
||||||
static List<LocalImageInfo> allImgs() {
|
static List<LocalImageInfo> allImgs() {
|
||||||
var lis = DBManager.box.values.toList();
|
var lis = DBManager.box.values.toList();
|
||||||
|
|
||||||
return lis ;
|
return lis ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void deleteImg(LocalImageInfo item ) {
|
||||||
|
DBManager.box.delete(item.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -114,7 +114,17 @@ class DownloadManager {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//删除本地图片
|
||||||
|
static Future<void> deleteWallpaperFile(String urlStr) async{
|
||||||
|
// 删除文件
|
||||||
|
final file = File(urlStr);
|
||||||
|
if (await file.exists()) {
|
||||||
|
await file.delete();
|
||||||
|
print('文件已删除:$urlStr');
|
||||||
|
} else {
|
||||||
|
print('文件不存在:$urlStr');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user