opt: img preview action type
This commit is contained in:
BIN
assets/images/pay/alipay.jpg
Normal file
BIN
assets/images/pay/alipay.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 143 KiB |
BIN
assets/images/pay/wechat.png
Normal file
BIN
assets/images/pay/wechat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
@ -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<AboutPage> {
|
||||
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<String> sources = [
|
||||
'assets/images/pay/wechat.png',
|
||||
'assets/images/pay/alipay.jpg'
|
||||
];
|
||||
Navigator.of(Get.context!).push(
|
||||
HeroDialogRoute<void>(
|
||||
builder: (BuildContext context) => InteractiveviewerGallery(
|
||||
sources: sources,
|
||||
initIndex: 0,
|
||||
itemBuilder: (context, index, isFocus, enablePageView) =>
|
||||
Image.asset(sources[index]),
|
||||
actionType: const [ImgActionType.save],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 官网
|
||||
|
@ -30,6 +30,13 @@ typedef IndexedFocusedWidgetBuilder = Widget Function(
|
||||
|
||||
typedef IndexedTagStringBuilder = String Function(int index);
|
||||
|
||||
// 图片操作类型
|
||||
enum ImgActionType {
|
||||
share,
|
||||
copy,
|
||||
save,
|
||||
}
|
||||
|
||||
class InteractiveviewerGallery<T> extends StatefulWidget {
|
||||
const InteractiveviewerGallery({
|
||||
required this.sources,
|
||||
@ -39,6 +46,11 @@ class InteractiveviewerGallery<T> 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<T> extends StatefulWidget {
|
||||
|
||||
final ValueChanged<int>? onDismissed;
|
||||
|
||||
final List<ImgActionType> actionType;
|
||||
|
||||
@override
|
||||
State<InteractiveviewerGallery> createState() =>
|
||||
_InteractiveviewerGalleryState();
|
||||
@ -247,8 +261,8 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
||||
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<InteractiveviewerGallery>
|
||||
: 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<InteractiveviewerGallery>
|
||||
}
|
||||
|
||||
// 图片分享
|
||||
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<InteractiveviewerGallery>
|
||||
}
|
||||
|
||||
// 复制图片
|
||||
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<InteractiveviewerGallery>
|
||||
);
|
||||
}
|
||||
|
||||
onDoubleTap() {
|
||||
_onDoubleTap() {
|
||||
Matrix4 matrix = _transformationController!.value.clone();
|
||||
double currentScale = matrix.row0.x;
|
||||
|
||||
@ -427,7 +420,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
||||
.whenComplete(() => _onScaleChanged(targetScale));
|
||||
}
|
||||
|
||||
onLongPress() {
|
||||
_onLongPress() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
@ -456,31 +449,81 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
||||
),
|
||||
),
|
||||
),
|
||||
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<PopupMenuEntry> _buildPopupMenuList() {
|
||||
List<PopupMenuItem> 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<Widget> _buildListTitles() {
|
||||
List<Widget> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user