diff --git a/assets/images/pay/alipay.jpg b/assets/images/pay/alipay.jpg new file mode 100644 index 00000000..1c1fc4c6 Binary files /dev/null and b/assets/images/pay/alipay.jpg differ diff --git a/assets/images/pay/wechat.png b/assets/images/pay/wechat.png new file mode 100644 index 00000000..3aa3a6a2 Binary files /dev/null and b/assets/images/pay/wechat.png differ diff --git a/lib/pages/about/index.dart b/lib/pages/about/index.dart index 86cf657e..3a8e5a0a 100644 --- a/lib/pages/about/index.dart +++ b/lib/pages/about/index.dart @@ -5,6 +5,7 @@ import 'package:get/get.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:pilipala/http/index.dart'; import 'package:pilipala/models/github/latest.dart'; +import 'package:pilipala/plugin/pl_gallery/index.dart'; import 'package:pilipala/utils/utils.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../utils/cache_manage.dart'; @@ -168,7 +169,7 @@ class _AboutPageState extends State { onTap: () => _aboutController.tgChanel(), title: const Text('TG频道'), trailing: Text( - 'https://t.me/+lm_oOVmF0RJiODk1', + 'https://t.me/+1DFtqS6usUM5MDNl', style: subTitleStyle, ), ), @@ -321,29 +322,35 @@ class AboutController extends GetxController { // tg频道 tgChanel() { Clipboard.setData( - const ClipboardData(text: 'https://t.me/+lm_oOVmF0RJiODk1'), + const ClipboardData(text: 'https://t.me/+1DFtqS6usUM5MDNl'), ); SmartDialog.showToast( '已复制,即将在浏览器打开', displayTime: const Duration(milliseconds: 500), ).then( (value) => launchUrl( - Uri.parse('https://t.me/+lm_oOVmF0RJiODk1'), + Uri.parse('https://t.me/+1DFtqS6usUM5MDNl'), mode: LaunchMode.externalApplication, ), ); } aPay() { - try { - launchUrl( - Uri.parse( - 'alipayqr://platformapi/startapp?saId=10000007&qrcode=https://qr.alipay.com/fkx14623ddwl1ping3ddd73'), - mode: LaunchMode.externalApplication, - ); - } catch (e) { - print(e); - } + const List sources = [ + 'assets/images/pay/wechat.png', + 'assets/images/pay/alipay.jpg' + ]; + Navigator.of(Get.context!).push( + HeroDialogRoute( + builder: (BuildContext context) => InteractiveviewerGallery( + sources: sources, + initIndex: 0, + itemBuilder: (context, index, isFocus, enablePageView) => + Image.asset(sources[index]), + actionType: const [ImgActionType.save], + ), + ), + ); } // 官网 diff --git a/lib/plugin/pl_gallery/interactiveviewer_gallery.dart b/lib/plugin/pl_gallery/interactiveviewer_gallery.dart index cd13194e..f0b11619 100644 --- a/lib/plugin/pl_gallery/interactiveviewer_gallery.dart +++ b/lib/plugin/pl_gallery/interactiveviewer_gallery.dart @@ -30,6 +30,13 @@ typedef IndexedFocusedWidgetBuilder = Widget Function( typedef IndexedTagStringBuilder = String Function(int index); +// 图片操作类型 +enum ImgActionType { + share, + copy, + save, +} + class InteractiveviewerGallery extends StatefulWidget { const InteractiveviewerGallery({ required this.sources, @@ -39,6 +46,11 @@ class InteractiveviewerGallery extends StatefulWidget { this.minScale = 1.0, this.onPageChanged, this.onDismissed, + this.actionType = const [ + ImgActionType.share, + ImgActionType.copy, + ImgActionType.save + ], Key? key, }) : super(key: key); @@ -59,6 +71,8 @@ class InteractiveviewerGallery extends StatefulWidget { final ValueChanged? onDismissed; + final List actionType; + @override State createState() => _InteractiveviewerGalleryState(); @@ -247,8 +261,8 @@ class _InteractiveviewerGalleryState extends State onDoubleTapDown: (TapDownDetails details) { _doubleTapLocalPosition = details.localPosition; }, - onDoubleTap: onDoubleTap, - onLongPress: onLongPress, + onDoubleTap: _onDoubleTap, + onLongPress: _onLongPress, child: widget.itemBuilder != null ? widget.itemBuilder!( context, @@ -298,28 +312,7 @@ class _InteractiveviewerGalleryState extends State : const SizedBox(), PopupMenuButton( itemBuilder: (context) { - return [ - PopupMenuItem( - value: 0, - onTap: () => onShareImg(widget.sources[currentIndex!]), - child: const Text("分享图片"), - ), - PopupMenuItem( - value: 1, - onTap: () { - onCopyImg(widget.sources[currentIndex!].toString()); - }, - child: const Text("复制图片"), - ), - PopupMenuItem( - value: 2, - onTap: () { - DownloadUtils.downloadImg( - widget.sources[currentIndex!]); - }, - child: const Text("保存图片"), - ), - ]; + return _buildPopupMenuList(); }, child: const Icon(Icons.more_horiz, color: Colors.white), ), @@ -332,7 +325,7 @@ class _InteractiveviewerGalleryState extends State } // 图片分享 - void onShareImg(String imgUrl) async { + void _onShareImg(String imgUrl) async { SmartDialog.showLoading(); var response = await Dio() .get(imgUrl, options: Options(responseType: ResponseType.bytes)); @@ -346,7 +339,7 @@ class _InteractiveviewerGalleryState extends State } // 复制图片 - void onCopyImg(String imgUrl) { + void _onCopyImg(String imgUrl) { Clipboard.setData( ClipboardData(text: widget.sources[currentIndex!].toString())) .then((value) { @@ -380,7 +373,7 @@ class _InteractiveviewerGalleryState extends State ); } - onDoubleTap() { + _onDoubleTap() { Matrix4 matrix = _transformationController!.value.clone(); double currentScale = matrix.row0.x; @@ -427,7 +420,7 @@ class _InteractiveviewerGalleryState extends State .whenComplete(() => _onScaleChanged(targetScale)); } - onLongPress() { + _onLongPress() { showModalBottomSheet( context: context, useRootNavigator: true, @@ -456,31 +449,81 @@ class _InteractiveviewerGalleryState extends State ), ), ), - ListTile( - onTap: () { - onShareImg(widget.sources[currentIndex!]); - Navigator.of(context).pop(); - }, - title: const Text('分享图片'), - ), - ListTile( - onTap: () { - onCopyImg(widget.sources[currentIndex!].toString()); - Navigator.of(context).pop(); - }, - title: const Text('复制图片'), - ), - ListTile( - onTap: () { - DownloadUtils.downloadImg(widget.sources[currentIndex!]); - Navigator.of(context).pop(); - }, - title: const Text('保存图片'), - ), + ..._buildListTitles(), ], ), ); }, ); } + + List _buildPopupMenuList() { + List items = []; + for (var i in widget.actionType) { + switch (i) { + case ImgActionType.share: + items.add(PopupMenuItem( + value: 0, + onTap: () => _onShareImg(widget.sources[currentIndex!]), + child: const Text("分享图片"), + )); + break; + case ImgActionType.copy: + items.add(PopupMenuItem( + value: 1, + onTap: () { + _onCopyImg(widget.sources[currentIndex!].toString()); + }, + child: const Text("复制图片"), + )); + break; + case ImgActionType.save: + items.add(PopupMenuItem( + value: 2, + onTap: () { + DownloadUtils.downloadImg(widget.sources[currentIndex!]); + }, + child: const Text("保存图片"), + )); + break; + } + } + return items; + } + + List _buildListTitles() { + List items = []; + for (var i in widget.actionType) { + switch (i) { + case ImgActionType.share: + items.add(ListTile( + onTap: () { + _onShareImg(widget.sources[currentIndex!]); + Navigator.of(context).pop(); + }, + title: const Text('分享图片'), + )); + break; + case ImgActionType.copy: + items.add(ListTile( + onTap: () { + _onCopyImg(widget.sources[currentIndex!].toString()); + Navigator.of(context).pop(); + }, + title: const Text('复制图片'), + )); + break; + case ImgActionType.save: + items.add(ListTile( + onTap: () { + DownloadUtils.downloadImg(widget.sources[currentIndex!]); + Navigator.of(context).pop(); + }, + title: const Text('保存图片'), + )); + break; + } + } + return items; + } } diff --git a/pubspec.yaml b/pubspec.yaml index b9d29abf..0b9711ad 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -218,6 +218,7 @@ flutter: - assets/images/logo/ - assets/images/live/ - assets/images/video/ + - assets/images/pay/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware