Merge branch 'design'

This commit is contained in:
guozhigq
2024-10-27 23:36:04 +08:00
5 changed files with 112 additions and 61 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

View File

@ -5,6 +5,7 @@ import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:pilipala/http/index.dart'; import 'package:pilipala/http/index.dart';
import 'package:pilipala/models/github/latest.dart'; import 'package:pilipala/models/github/latest.dart';
import 'package:pilipala/plugin/pl_gallery/index.dart';
import 'package:pilipala/utils/utils.dart'; import 'package:pilipala/utils/utils.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import '../../utils/cache_manage.dart'; import '../../utils/cache_manage.dart';
@ -168,7 +169,7 @@ class _AboutPageState extends State<AboutPage> {
onTap: () => _aboutController.tgChanel(), onTap: () => _aboutController.tgChanel(),
title: const Text('TG频道'), title: const Text('TG频道'),
trailing: Text( trailing: Text(
'https://t.me/+lm_oOVmF0RJiODk1', 'https://t.me/+1DFtqS6usUM5MDNl',
style: subTitleStyle, style: subTitleStyle,
), ),
), ),
@ -321,29 +322,35 @@ class AboutController extends GetxController {
// tg频道 // tg频道
tgChanel() { tgChanel() {
Clipboard.setData( Clipboard.setData(
const ClipboardData(text: 'https://t.me/+lm_oOVmF0RJiODk1'), const ClipboardData(text: 'https://t.me/+1DFtqS6usUM5MDNl'),
); );
SmartDialog.showToast( SmartDialog.showToast(
'已复制,即将在浏览器打开', '已复制,即将在浏览器打开',
displayTime: const Duration(milliseconds: 500), displayTime: const Duration(milliseconds: 500),
).then( ).then(
(value) => launchUrl( (value) => launchUrl(
Uri.parse('https://t.me/+lm_oOVmF0RJiODk1'), Uri.parse('https://t.me/+1DFtqS6usUM5MDNl'),
mode: LaunchMode.externalApplication, mode: LaunchMode.externalApplication,
), ),
); );
} }
aPay() { aPay() {
try { const List<String> sources = [
launchUrl( 'assets/images/pay/wechat.png',
Uri.parse( 'assets/images/pay/alipay.jpg'
'alipayqr://platformapi/startapp?saId=10000007&qrcode=https://qr.alipay.com/fkx14623ddwl1ping3ddd73'), ];
mode: LaunchMode.externalApplication, Navigator.of(Get.context!).push(
); HeroDialogRoute<void>(
} catch (e) { builder: (BuildContext context) => InteractiveviewerGallery(
print(e); sources: sources,
} initIndex: 0,
itemBuilder: (context, index, isFocus, enablePageView) =>
Image.asset(sources[index]),
actionType: const [ImgActionType.save],
),
),
);
} }
// 官网 // 官网

View File

@ -30,6 +30,13 @@ typedef IndexedFocusedWidgetBuilder = Widget Function(
typedef IndexedTagStringBuilder = String Function(int index); typedef IndexedTagStringBuilder = String Function(int index);
// 图片操作类型
enum ImgActionType {
share,
copy,
save,
}
class InteractiveviewerGallery<T> extends StatefulWidget { class InteractiveviewerGallery<T> extends StatefulWidget {
const InteractiveviewerGallery({ const InteractiveviewerGallery({
required this.sources, required this.sources,
@ -39,6 +46,11 @@ class InteractiveviewerGallery<T> extends StatefulWidget {
this.minScale = 1.0, this.minScale = 1.0,
this.onPageChanged, this.onPageChanged,
this.onDismissed, this.onDismissed,
this.actionType = const [
ImgActionType.share,
ImgActionType.copy,
ImgActionType.save
],
Key? key, Key? key,
}) : super(key: key); }) : super(key: key);
@ -59,6 +71,8 @@ class InteractiveviewerGallery<T> extends StatefulWidget {
final ValueChanged<int>? onDismissed; final ValueChanged<int>? onDismissed;
final List<ImgActionType> actionType;
@override @override
State<InteractiveviewerGallery> createState() => State<InteractiveviewerGallery> createState() =>
_InteractiveviewerGalleryState(); _InteractiveviewerGalleryState();
@ -247,8 +261,8 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
onDoubleTapDown: (TapDownDetails details) { onDoubleTapDown: (TapDownDetails details) {
_doubleTapLocalPosition = details.localPosition; _doubleTapLocalPosition = details.localPosition;
}, },
onDoubleTap: onDoubleTap, onDoubleTap: _onDoubleTap,
onLongPress: onLongPress, onLongPress: _onLongPress,
child: widget.itemBuilder != null child: widget.itemBuilder != null
? widget.itemBuilder!( ? widget.itemBuilder!(
context, context,
@ -298,28 +312,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
: const SizedBox(), : const SizedBox(),
PopupMenuButton( PopupMenuButton(
itemBuilder: (context) { itemBuilder: (context) {
return [ return _buildPopupMenuList();
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("保存图片"),
),
];
}, },
child: const Icon(Icons.more_horiz, color: Colors.white), 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(); SmartDialog.showLoading();
var response = await Dio() var response = await Dio()
.get(imgUrl, options: Options(responseType: ResponseType.bytes)); .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( Clipboard.setData(
ClipboardData(text: widget.sources[currentIndex!].toString())) ClipboardData(text: widget.sources[currentIndex!].toString()))
.then((value) { .then((value) {
@ -380,7 +373,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
); );
} }
onDoubleTap() { _onDoubleTap() {
Matrix4 matrix = _transformationController!.value.clone(); Matrix4 matrix = _transformationController!.value.clone();
double currentScale = matrix.row0.x; double currentScale = matrix.row0.x;
@ -427,7 +420,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
.whenComplete(() => _onScaleChanged(targetScale)); .whenComplete(() => _onScaleChanged(targetScale));
} }
onLongPress() { _onLongPress() {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
useRootNavigator: true, useRootNavigator: true,
@ -456,31 +449,81 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
), ),
), ),
), ),
ListTile( ..._buildListTitles(),
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('保存图片'),
),
], ],
), ),
); );
}, },
); );
} }
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;
}
} }

View File

@ -218,6 +218,7 @@ flutter:
- assets/images/logo/ - assets/images/logo/
- assets/images/live/ - assets/images/live/
- assets/images/video/ - assets/images/video/
- assets/images/pay/
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware # https://flutter.dev/assets-and-images/#resolution-aware