mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -437,16 +437,30 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
|
||||
|
||||
// 图片分享
|
||||
void onShareImg(String imgUrl) async {
|
||||
SmartDialog.showLoading();
|
||||
var response = await Request()
|
||||
.get(imgUrl, options: Options(responseType: ResponseType.bytes));
|
||||
final temp = await getTemporaryDirectory();
|
||||
SmartDialog.dismiss();
|
||||
String imgName =
|
||||
"plpl_pic_${DateTime.now().toString().split('-').join()}.jpg";
|
||||
var path = '${temp.path}/$imgName';
|
||||
File(path).writeAsBytesSync(response.data);
|
||||
Share.shareXFiles([XFile(path)], subject: imgUrl);
|
||||
try {
|
||||
SmartDialog.showLoading();
|
||||
var response = await Request()
|
||||
.get(imgUrl, options: Options(responseType: ResponseType.bytes));
|
||||
final temp = await getTemporaryDirectory();
|
||||
SmartDialog.dismiss();
|
||||
String imgName =
|
||||
"plpl_pic_${DateTime.now().toString().split('-').join()}.jpg";
|
||||
var path = '${temp.path}/$imgName';
|
||||
File(path).writeAsBytesSync(response.data);
|
||||
|
||||
Rect? sharePositionOrigin;
|
||||
if (Platform.isIOS && (await Utils.isIpad())) {
|
||||
sharePositionOrigin = Rect.fromLTWH(0, 0, Get.width, Get.height / 2);
|
||||
}
|
||||
|
||||
Share.shareXFiles(
|
||||
[XFile(path)],
|
||||
subject: imgUrl,
|
||||
sharePositionOrigin: sharePositionOrigin,
|
||||
);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Widget _itemBuilder(index) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import 'package:PiliPlus/pages/video/detail/reply/index.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:html/parser.dart' as html_parser;
|
||||
import 'package:html/dom.dart' as dom;
|
||||
|
||||
@@ -396,7 +395,7 @@ class BangumiIntroController extends CommonController {
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Share.share(videoUrl);
|
||||
Utils.shareText(videoUrl);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
|
||||
@@ -27,7 +27,6 @@ import 'package:PiliPlus/pages/dynamics/detail/index.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/widgets/author_panel.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply_reply/index.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../../utils/grid.dart';
|
||||
import '../widgets/dynamic_panel.dart';
|
||||
@@ -555,7 +554,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
Expanded(
|
||||
child: TextButton.icon(
|
||||
onPressed: () {
|
||||
Share.share(
|
||||
Utils.shareText(
|
||||
'${HttpString.dynamicShareBaseUrl}/${_dynamicDetailController.item.idStr}');
|
||||
},
|
||||
icon: Icon(
|
||||
|
||||
@@ -12,7 +12,6 @@ import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../../http/constants.dart';
|
||||
import '../controller.dart';
|
||||
@@ -290,7 +289,8 @@ class AuthorPanel extends StatelessWidget {
|
||||
leading: const Icon(Icons.share_outlined, size: 19),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Share.share('${HttpString.dynamicShareBaseUrl}/${item.idStr}');
|
||||
Utils.shareText(
|
||||
'${HttpString.dynamicShareBaseUrl}/${item.idStr}');
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
),
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../../http/constants.dart';
|
||||
import '../controller.dart';
|
||||
@@ -213,7 +212,8 @@ class MorePanel extends StatelessWidget {
|
||||
leading: const Icon(Icons.share_outlined, size: 19),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Share.share('${HttpString.dynamicShareBaseUrl}/${item.idStr}');
|
||||
Utils.shareText(
|
||||
'${HttpString.dynamicShareBaseUrl}/${item.idStr}');
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
),
|
||||
|
||||
@@ -24,7 +24,6 @@ import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/common/reply_type.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply_reply/index.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../utils/grid.dart';
|
||||
import 'controller.dart';
|
||||
@@ -312,7 +311,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () => Share.share(url),
|
||||
onTap: () => Utils.shareText(url),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
@@ -558,7 +557,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
Expanded(
|
||||
child: TextButton.icon(
|
||||
onPressed: () {
|
||||
Share.share(
|
||||
Utils.shareText(
|
||||
'${HttpString.dynamicShareBaseUrl}/${_htmlRenderCtr.item.value.idStr}');
|
||||
},
|
||||
icon: Icon(
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:PiliPlus/models/member/archive.dart';
|
||||
import 'package:PiliPlus/models/member/coin.dart';
|
||||
import 'package:PiliPlus/models/member/info.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../video/detail/introduction/widgets/group_panel.dart';
|
||||
|
||||
@@ -240,7 +239,8 @@ class MemberController extends GetxController {
|
||||
}
|
||||
|
||||
void shareUser() {
|
||||
Share.share('${memberInfo.value.name} - https://space.bilibili.com/$mid');
|
||||
Utils.shareText(
|
||||
'${memberInfo.value.name} - https://space.bilibili.com/$mid');
|
||||
}
|
||||
|
||||
// 请求专栏
|
||||
|
||||
@@ -12,7 +12,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
enum MemberTabType { none, home, dynamic, contribute, favorite, bangumi }
|
||||
|
||||
@@ -149,7 +148,7 @@ class MemberControllerNew extends CommonController
|
||||
}
|
||||
|
||||
void shareUser() {
|
||||
Share.share('https://space.bilibili.com/$mid');
|
||||
Utils.shareText('https://space.bilibili.com/$mid');
|
||||
}
|
||||
|
||||
void _onBlock() async {
|
||||
|
||||
@@ -23,7 +23,6 @@ import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../../../http/search.dart';
|
||||
import '../../../../models/model_hot_video_item.dart';
|
||||
@@ -498,7 +497,7 @@ class VideoIntroController extends GetxController
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Share.share('${videoDetail.value.title} '
|
||||
Utils.shareText('${videoDetail.value.title} '
|
||||
'UP主: ${videoDetail.value.owner!.name!}'
|
||||
' - $videoUrl');
|
||||
},
|
||||
|
||||
@@ -38,6 +38,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_navigation/src/dialog/dialog_route.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:html/dom.dart' as dom;
|
||||
import 'package:html/parser.dart' as html_parser;
|
||||
@@ -48,6 +49,33 @@ class Utils {
|
||||
|
||||
static const channel = MethodChannel("PiliPlus");
|
||||
|
||||
static bool? _isIpad;
|
||||
|
||||
static Future<bool> isIpad() async {
|
||||
if (_isIpad != null) {
|
||||
return _isIpad!;
|
||||
}
|
||||
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||
IosDeviceInfo info = await deviceInfo.iosInfo;
|
||||
_isIpad = info.model.toLowerCase().contains("ipad");
|
||||
return _isIpad!;
|
||||
}
|
||||
|
||||
static void shareText(String text) async {
|
||||
try {
|
||||
Rect? sharePositionOrigin;
|
||||
if (Platform.isIOS && (await isIpad())) {
|
||||
sharePositionOrigin = Rect.fromLTWH(0, 0, Get.width, Get.height / 2);
|
||||
}
|
||||
Share.share(
|
||||
text,
|
||||
sharePositionOrigin: sharePositionOrigin,
|
||||
);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
static void toViewPage(
|
||||
String page, {
|
||||
dynamic arguments,
|
||||
|
||||
Reference in New Issue
Block a user