| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- import 'package:clean/base/base_page.dart';
- import 'package:clean/module/calendar/preview/calendar_preview_controller.dart';
- import 'package:flutter/Material.dart';
- import 'package:flutter/src/widgets/framework.dart';
- import 'package:flutter_card_swiper/flutter_card_swiper.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import 'package:lottie/lottie.dart';
- import 'package:wechat_assets_picker/wechat_assets_picker.dart';
- import '../../../resource/assets.gen.dart';
- import '../../../router/app_pages.dart';
- import '../../../utils/styles.dart';
- import '../../people_photo/photo_group.dart';
- import 'package:video_player/video_player.dart';
- class CalendarPreviewPage extends BasePage<CalendarPreviewController> {
- const CalendarPreviewPage({Key? key}) : super(key: key);
- static void start(
- {required PhotoGroup photoGroup, required String currentImageId}) {
- Get.toNamed(RoutePath.calendarPreview, arguments: {
- "photoGroup": photoGroup,
- "currentImageId": currentImageId,
- });
- }
- @override
- bool statusBarDarkFont() {
- return false;
- }
- @override
- bool immersive() {
- return true;
- }
- @override
- Widget buildBody(BuildContext context) {
- return Stack(children: [
- PopScope(
- canPop: false,
- onPopInvokedWithResult: (didPop, result) {
- if (didPop) {
- return;
- }
- controller.clickBack();
- },
- child: SafeArea(
- child: Obx(() {
- if (controller.isSwiperEnd.value ||
- controller.photoGroup.value.images.isEmpty) {
- return onSwiperEndCard();
- } else {
- return Column(
- children: [
- _titleCard(),
- Spacer(),
- SizedBox(
- width: 314.w,
- height: 392.h,
- child: CardSwiper(
- scale: 0.8,
- allowedSwipeDirection: AllowedSwipeDirection.only(
- right: true,
- left: true,
- ),
- isLoop: false,
- backCardOffset: Offset(0.w, -20.h),
- controller: controller.cardSwiperController,
- cardsCount: controller.photoGroup.value.images.length,
- onSwipe: controller.onSwipe,
- onUndo: controller.onSwiperUndo,
- numberOfCardsDisplayed:
- (controller.photoGroup.value.images.length == 1)
- ? 1
- : 1,
- onEnd: controller.onSwiperEnd,
- cardBuilder: (context, index, horizontalOffsetPercentage,
- verticalOffsetPercentage) {
- final assetEntity =
- controller.photoGroup.value.images[index];
- return Stack(
- children: [
- ClipRRect(
- borderRadius: BorderRadius.circular(20.r),
- child:
- // 判断这个是不是视频
- assetEntity.type == AssetType.video
- ? Stack(
- alignment: Alignment.center,
- children: [
- AssetEntityImage(
- assetEntity,
- width: 314.w,
- height: 392.h,
- fit: BoxFit.cover,
- ),
- GestureDetector(
- // 点击播放视频
- onTap: () => controller
- .playVideo(assetEntity),
- child: Icon(
- Icons.play_circle_filled,
- size: 50.w,
- color: Colors.white
- .withValues(alpha: 0.8),
- ),
- )
- ],
- )
- : AssetEntityImage(
- assetEntity,
- width: 314.w,
- height: 392.h,
- fit: BoxFit.cover,
- isOriginal: true,
- // errorBuilder:
- // (context, error, stackTrace) {
- // debugPrint(
- // 'AssetEntityImage error $error');
- // return Container();
- // },
- frameBuilder: Styles.animFrameBuilder(),
- )),
- if (horizontalOffsetPercentage != 0)
- Positioned(
- top: 0,
- right: horizontalOffsetPercentage < -10.w
- ? 0
- : null,
- left: horizontalOffsetPercentage > 10.w
- ? 0
- : null,
- child: Container(
- child: Column(
- children: [
- (horizontalOffsetPercentage < -10.w)
- ? Assets.images.iconPhotoPreviewDelete
- .image(
- width: 60.w,
- height: 60.w,
- )
- : (horizontalOffsetPercentage > 10.w)
- ? Assets.images.iconPhotoPreviewKeep
- .image(
- width: 60.w,
- height: 60.w,
- )
- : SizedBox(),
- (horizontalOffsetPercentage < -10.w)
- ? Text(
- 'Delete ',
- style: TextStyle(
- color: Colors.white,
- fontSize: 24.sp,
- fontWeight: FontWeight.w500,
- ),
- )
- : (horizontalOffsetPercentage > 10.w)
- ? Text(
- 'Keep',
- style: TextStyle(
- color: Colors.white,
- fontSize: 24.sp,
- fontWeight: FontWeight.w500,
- ),
- )
- : SizedBox(),
- ],
- )),
- ),
- ],
- );
- },
- ),
- ),
- Spacer(),
- bottomButtonCard(),
- _bottomBarCard(),
- ],
- );
- }
- }),
- ),
- ),
- Obx(() {
- if (controller.isSwiperEnd.value ||
- controller.photoGroup.value.images.isEmpty) {
- return IgnorePointer(
- child: Assets.images.bgPhotoSelectedPreviewFinish.image(
- width: 360.w,
- ),
- );
- } else {
- return IgnorePointer(
- child: Assets.images.bgHome.image(
- width: 360.w,
- ),
- );
- }
- }),
- ]);
- }
- Widget _titleCard() {
- return Container(
- alignment: Alignment.centerLeft,
- padding: EdgeInsets.only(left: 16.w, top: 14.h, right: 16.w),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- GestureDetector(
- onTap: controller.clickBack,
- child: Assets.images.iconBackArrow.image(
- width: 28.w,
- height: 28.h,
- ),
- ),
- Obx(() => Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- '${controller.groupIndex.value + 1}',
- textAlign: TextAlign.center,
- style: TextStyle(
- color: Colors.white,
- fontSize: 16.sp,
- fontWeight: FontWeight.w700,
- ),
- ),
- Text(
- ' / ${controller.photoGroup.value.images.length}',
- textAlign: TextAlign.center,
- style: TextStyle(
- color: Colors.white.withValues(alpha: 0.6),
- fontSize: 16.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- ],
- )),
- GestureDetector(
- onTap: controller.recoverSelectPhoto,
- child: Assets.images.iconPreviewRecover.image(
- width: 30.w,
- height: 30.h,
- ),
- ),
- ],
- ),
- SizedBox(height: 12.h),
- ],
- ),
- );
- }
- Widget _bottomBarCard() {
- return GestureDetector(
- onTap: controller.clickJumpSelected,
- child: Container(
- width: 360.w,
- height: 81.h,
- padding: EdgeInsets.symmetric(horizontal: 16.w),
- decoration: ShapeDecoration(
- color: Color(0xFF23232A),
- shape: RoundedRectangleBorder(
- side: BorderSide(
- width: 1.w, color: Colors.white.withValues(alpha: 0.1)),
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(14.r),
- topRight: Radius.circular(14.r),
- ),
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Obx(() {
- return Text(
- '${controller.photoGroup.value.selectedPhotosIds.length} files selected (${controller.selectedFilesSizeString} )',
- textAlign: TextAlign.center,
- style: TextStyle(
- color: Colors.white.withValues(alpha: 0.9),
- fontSize: 13.sp,
- fontWeight: FontWeight.w500,
- ),
- );
- }),
- GestureDetector(
- onTap: controller.clickDelete,
- child: Container(
- width: 108.w,
- height: 38.h,
- decoration: ShapeDecoration(
- color: Color(0xFF0279FB),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(10.r),
- ),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: [
- Text(
- 'Delete',
- textAlign: TextAlign.center,
- style: TextStyle(
- color: Colors.white,
- fontSize: 16.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- Assets.images.iconDelete.image(
- width: 18.w,
- height: 18.h,
- ),
- ],
- ),
- )),
- ],
- ),
- ));
- }
- Widget bottomButtonCard() {
- return Container(
- margin: EdgeInsets.only(bottom: 54.h),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: [
- GestureDetector(
- onTap: () => controller.clickSelect(),
- child: Assets.images.iconPreviewSelect.image(
- width: 62.w,
- height: 62.h,
- ),
- ),
- GestureDetector(
- onTap: () => controller.clickUnselect(),
- child: Assets.images.iconPreviewNoSelect.image(
- width: 62.w,
- height: 62.h,
- ),
- ),
- ],
- ),
- );
- }
- Widget onSwiperEndCard() {
- return Column(
- children: [
- Container(
- child: Lottie.asset(
- Assets.anim.animFireworks,
- controller: controller.animationController,
- height: 351.h,
- repeat: false,
- ),
- ),
- Visibility(
- visible: controller.animationIsComplete.value,
- child: Center(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- 'Perfect!',
- textAlign: TextAlign.center,
- style: TextStyle(
- color: Colors.white,
- fontSize: 32.sp,
- fontWeight: FontWeight.w700,
- ),
- ),
- SizedBox(height: 16.h),
- SizedBox(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Container(
- clipBehavior: Clip.antiAlias,
- decoration: BoxDecoration(),
- child:
- Assets.images.iconPreviewSwiperEndFirework.image(
- width: 40.w,
- height: 40.w,
- ),
- ),
- SizedBox(width: 4.w),
- Text(
- 'All Similar and Redundant\nPhotos Cleared',
- textAlign: TextAlign.center,
- style: TextStyle(
- color: Colors.white.withValues(alpha: 0.9),
- fontSize: 16.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- SizedBox(width: 4.w),
- Container(
- clipBehavior: Clip.antiAlias,
- decoration: BoxDecoration(),
- child:
- Assets.images.iconPreviewSwiperEndFirework.image(
- width: 40.w,
- height: 40.w,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- )),
- Spacer(
- flex: 5,
- ),
- controller.photoGroup.value.images.isEmpty
- ? SizedBox()
- : _bottomBarCard(),
- ],
- );
- }
- }
|