WallPaper_ZZH_Flutter/wallpaper/lib/pages/imgscanpage/imgscanpage_view.dart
2024-05-14 19:04:37 +08:00

105 lines
4.0 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:wallpaper/models/imgnetodel.dart';
import 'package:photo_view/photo_view.dart';
import 'package:photo_view/photo_view_gallery.dart';
import 'package:wallpaper/pages/imgscanpage/imgscanpage_controller.dart';
class ImgScanPageView extends GetView<ImgScanPageController> {
// final NetImgCategory dataModel;
// 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,
),
),
body: Stack(
children: [
PhotoViewGallery.builder(
scrollPhysics: const BouncingScrollPhysics(),
builder: (BuildContext context, int index) {
return PhotoViewGalleryPageOptions(
imageProvider: NetworkImage(controller.dataModel.data![index].original!),
initialScale: PhotoViewComputedScale.contained * 0.8,
minScale: PhotoViewComputedScale.contained*0.4,
maxScale: PhotoViewComputedScale.contained * 4,
onTapDown: (context, details, controllerValue) {
print("touch down...");
},
// heroAttributes: PhotoViewHeroAttributes(tag: galleryItems[index].id),
);
},
itemCount: controller.dataModel.data!.length,
loadingBuilder: (context, event) => Center(
child: SizedBox(
width: 20.0,
height: 20.0,
child: CircularProgressIndicator(
value: event == null
? 0
: event.cumulativeBytesLoaded / event.expectedTotalBytes!,
),
),
),
// backgroundDecoration: widget.backgroundDecoration,
// pageController: widget.pageController,
onPageChanged: onPageChanged,
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
color: Colors.black.withAlpha(160),
height: 100,
width: double.infinity,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
// 交叉轴的布局方式对于column来说就是水平方向的布局方式
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Spacer(
),
IconButton(onPressed:() {
print("download....");
controller.downloadImg();
}, icon: const Icon(Icons.download),color: Colors.white,),
const Spacer(
),
IconButton(onPressed:() {
print("设置壁纸");
}, icon: const Icon(Icons.wallpaper),color: Colors.white,),
const Spacer(
),
],
),
),
),
],
),
);
}
void onPageChanged(int index){
print("切换了图片....");
controller.currentIndex.value = index;
}
}