s
This commit is contained in:
parent
33537c10fd
commit
39ea0327ba
@ -2,10 +2,13 @@ import 'package:get/get.dart';
|
||||
import 'package:get/get_rx/get_rx.dart';
|
||||
import 'package:wallpaper/models/imgnetodel.dart';
|
||||
import 'package:wallpaper/utils/downloadmanager.dart';
|
||||
import 'dart:async';
|
||||
|
||||
class ImgScanPageController extends GetxController {
|
||||
late NetImgCategory dataModel;
|
||||
RxInt currentIndex = RxInt(0);
|
||||
RxInt showAppbar = RxInt(0);//控制appbar显示....
|
||||
Timer? _timer;
|
||||
|
||||
@override
|
||||
void onInit(){
|
||||
@ -14,10 +17,36 @@ class ImgScanPageController extends GetxController {
|
||||
dataModel = Get.arguments["dataModel"];
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
cancelTimer();
|
||||
super.onClose();
|
||||
|
||||
}
|
||||
|
||||
void cancelTimer() {
|
||||
if (_timer != null) {
|
||||
_timer!.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
Future < void> downloadImg() async {
|
||||
String urlStr = dataModel.data![currentIndex.value].original!;
|
||||
await DownloadManager.downloadImgWithUrl(urlStr);
|
||||
//提示框
|
||||
//....已下载
|
||||
}
|
||||
|
||||
void showAppbarAction(){
|
||||
showAppbar.value = 1;
|
||||
cancelTimer();
|
||||
|
||||
const oneSec = Duration(seconds: 3);
|
||||
_timer = Timer.periodic(oneSec, (Timer timer) {
|
||||
timer.cancel();
|
||||
_timer = null;
|
||||
showAppbar.value = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -12,22 +12,22 @@ class ImgScanPageView extends GetView<ImgScanPageController> {
|
||||
// final int currentIndex;
|
||||
|
||||
// const ImgScanPageView({super.key,required this.dataModel,required this.currentIndex});
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
backgroundColor: Colors.black,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(44),
|
||||
child: AppBar(
|
||||
centerTitle: true,
|
||||
title: const Text("查看大图"),
|
||||
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
),
|
||||
appBar:PreferredSize(
|
||||
preferredSize: const Size.fromHeight(44),
|
||||
child: Obx(() => controller.showAppbar.value == 0 ? Text("") :AppBar(
|
||||
centerTitle: true,
|
||||
title: const Text("查看大图"),
|
||||
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: Colors.white,
|
||||
)),
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
PhotoViewGallery.builder(
|
||||
@ -39,7 +39,7 @@ class ImgScanPageView extends GetView<ImgScanPageController> {
|
||||
minScale: PhotoViewComputedScale.contained*0.4,
|
||||
maxScale: PhotoViewComputedScale.contained * 4,
|
||||
onTapDown: (context, details, controllerValue) {
|
||||
print("touch down...");
|
||||
controller.showAppbarAction();
|
||||
},
|
||||
// heroAttributes: PhotoViewHeroAttributes(tag: galleryItems[index].id),
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user