s
This commit is contained in:
parent
e9a3a4eec5
commit
7533826a95
@ -3,12 +3,13 @@ import 'package:get/get_rx/get_rx.dart';
|
||||
import 'package:wallpaper/models/imgnetodel.dart';
|
||||
import 'package:wallpaper/utils/downloadmanager.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'dart:io';
|
||||
class ImgScanPageController extends GetxController {
|
||||
late NetImgCategory dataModel;
|
||||
RxInt currentIndex = RxInt(0);
|
||||
RxInt showAppbar = RxInt(0);//控制appbar显示....
|
||||
Timer? _timer;
|
||||
var isAndroid = Platform.isAndroid;
|
||||
var albumPermisonisDenied = false.obs;
|
||||
@override
|
||||
void onInit(){
|
||||
@ -59,4 +60,9 @@ class ImgScanPageController extends GetxController {
|
||||
showAppbar.value = 0;
|
||||
});
|
||||
}
|
||||
|
||||
Future <void> setWallpaper() async {
|
||||
String imgUrl = dataModel.data![currentIndex.value].original!;
|
||||
await DownloadManager.setWallpaper(imgUrl);
|
||||
}
|
||||
}
|
||||
@ -73,7 +73,23 @@ class ImgScanPageView extends GetView<ImgScanPageController> {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
// 交叉轴的布局方式,对于column来说就是水平方向的布局方式
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
children: getButtomWidge(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onPageChanged(int index){
|
||||
print("切换了图片....");
|
||||
controller.currentIndex.value = index;
|
||||
}
|
||||
|
||||
|
||||
List<Widget> getButtomWidge(){
|
||||
List<Widget> wg = [
|
||||
const Spacer(
|
||||
),
|
||||
IconButton(onPressed:() {
|
||||
@ -90,17 +106,15 @@ class ImgScanPageView extends GetView<ImgScanPageController> {
|
||||
}, icon: const Icon(Icons.wallpaper),color: Colors.white,),
|
||||
const Spacer(
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
];
|
||||
if (controller.isAndroid) {
|
||||
wg.add(IconButton(onPressed:() {
|
||||
controller.setWallpaper();
|
||||
|
||||
void onPageChanged(int index){
|
||||
print("切换了图片....");
|
||||
controller.currentIndex.value = index;
|
||||
}, icon: const Icon(Icons.wallpaper),color: Colors.white,));
|
||||
wg.add(const Spacer(
|
||||
));
|
||||
}
|
||||
return wg;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user