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'; class ImgScanPageView extends GetView { final NetImgCategory dataModel; final int currentIndex; const ImgScanPageView({super.key,required this.dataModel,required this.currentIndex}); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: AppBar( 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(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: 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...."); }, 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("切换了图片...."); } }