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