import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:photo_view/photo_view.dart'; import 'package:photo_view/photo_view_gallery.dart'; import 'package:wallpaper/common/components/base_appbar.dart'; import 'package:wallpaper/common/components/view_state_widget.dart'; import 'package:wallpaper/modules/wallpaper_det/wallpaper_det_controller.dart'; class WallpaperDetView extends GetView { const WallpaperDetView({super.key}); @override Widget build(BuildContext context) { return Scaffold( extendBodyBehindAppBar: true, appBar: const BaseAppBar('', backgroundColor: Colors.transparent, iconColor: Colors.white), body: Stack( alignment: Alignment.center, children: [ _photoView(), _bottomOption(), ], ), ); } /// 图片查看器 Widget _photoView() { return PhotoViewGallery.builder( itemCount: controller.wallpaperList.length, builder: (BuildContext context, int index) { return PhotoViewGalleryPageOptions( imageProvider: NetworkImage('${controller.wallpaperList[index].original}'), initialScale: PhotoViewComputedScale.contained, minScale: PhotoViewComputedScale.contained * 0.5, maxScale: PhotoViewComputedScale.covered * 3, heroAttributes: PhotoViewHeroAttributes(tag: controller.wallpaperList[index]), // onTapUp: (context, details, controllerValue) => Get.back(), ); }, loadingBuilder: (context, event) => loadingView( // value: event == null ? 0 : event.cumulativeBytesLoaded / (event.expectedTotalBytes ?? 1), ), scrollPhysics: const BouncingScrollPhysics(), backgroundDecoration: const BoxDecoration(color: Colors.black), pageController: controller.pageController, onPageChanged: (i) => controller.onPageChanged(i), ); } /// 底部选项 Widget _bottomOption() { return Positioned( bottom: ScreenUtil().bottomBarHeight + 20.h, child: Container( width: 0.94.sw, height: kBottomNavigationBarHeight, decoration: BoxDecoration( color: Colors.white.withOpacity(0.9), borderRadius: BorderRadius.circular(8).r, ), child: Row( children: controller.options.asMap().entries.map((e) { return Expanded( child: Material( color: Colors.transparent, child: InkWell( borderRadius: BorderRadius.circular(8).r, onTap: () => controller.optionOnTap(e.key), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(e.value.icons, color: Colors.black), Text( e.value.option, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.black, fontSize: 14.sp, fontWeight: FontWeight.w500, ), ), ], ), ), ), ); }).toList(), ), ), ); } }