feat: 分享视频&图片
This commit is contained in:
@ -64,7 +64,7 @@ class PreviewController extends GetxController {
|
|||||||
options: Options(responseType: ResponseType.bytes));
|
options: Options(responseType: ResponseType.bytes));
|
||||||
final temp = await getTemporaryDirectory();
|
final temp = await getTemporaryDirectory();
|
||||||
String imgName =
|
String imgName =
|
||||||
"pic_vvex${DateTime.now().toString().split('-').join()}.jpg";
|
"pic_plpl${DateTime.now().toString().split('-').join()}.jpg";
|
||||||
var path = '${temp.path}/$imgName';
|
var path = '${temp.path}/$imgName';
|
||||||
File(path).writeAsBytesSync(response.data);
|
File(path).writeAsBytesSync(response.data);
|
||||||
Share.shareXFiles([XFile(path)], subject: imgList[initialPage.value]);
|
Share.shareXFiles([XFile(path)], subject: imgList[initialPage.value]);
|
||||||
|
|||||||
@ -168,7 +168,7 @@ class _ImagePreviewState extends State<ImagePreview>
|
|||||||
bottom: 0,
|
bottom: 0,
|
||||||
child: Container(
|
child: Container(
|
||||||
// height: 45,
|
// height: 45,
|
||||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom + 10, top: 20),
|
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom, top: 20),
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
@ -199,10 +199,10 @@ class _ImagePreviewState extends State<ImagePreview>
|
|||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
FloatingActionButton(
|
const Spacer(),
|
||||||
onPressed: () => _previewController.onSaveImg(),
|
ElevatedButton(onPressed: () => _previewController.onShareImg(), child: Text('分享')),
|
||||||
child: const Icon(Icons.save_alt_rounded),
|
const SizedBox(width: 10),
|
||||||
),
|
ElevatedButton(onPressed: () => _previewController.onSaveImg(), child: Text('保存'))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -2,12 +2,14 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/http/constants.dart';
|
||||||
import 'package:pilipala/http/user.dart';
|
import 'package:pilipala/http/user.dart';
|
||||||
import 'package:pilipala/http/video.dart';
|
import 'package:pilipala/http/video.dart';
|
||||||
import 'package:pilipala/models/user/fav_folder.dart';
|
import 'package:pilipala/models/user/fav_folder.dart';
|
||||||
import 'package:pilipala/models/video_detail_res.dart';
|
import 'package:pilipala/models/video_detail_res.dart';
|
||||||
import 'package:pilipala/pages/video/detail/controller.dart';
|
import 'package:pilipala/pages/video/detail/controller.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
class VideoIntroController extends GetxController {
|
class VideoIntroController extends GetxController {
|
||||||
// 视频aid
|
// 视频aid
|
||||||
@ -161,12 +163,15 @@ class VideoIntroController extends GetxController {
|
|||||||
Future actionLikeVideo() async {
|
Future actionLikeVideo() async {
|
||||||
var result = await VideoHttp.likeVideo(aid: aid, type: !hasLike.value);
|
var result = await VideoHttp.likeVideo(aid: aid, type: !hasLike.value);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
hasLike.value = result["data"] == 1 ? true : false;
|
// hasLike.value = result["data"] == 1 ? true : false;
|
||||||
if (hasLike.value) {
|
if (!hasLike.value) {
|
||||||
SmartDialog.showToast('已点赞 👍');
|
SmartDialog.showToast('点赞成功 👍');
|
||||||
} else {
|
hasLike.value = true;
|
||||||
|
} else if(hasLike.value){
|
||||||
SmartDialog.showToast('取消赞');
|
SmartDialog.showToast('取消赞');
|
||||||
|
hasLike.value = false;
|
||||||
}
|
}
|
||||||
|
hasLike.refresh();
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
@ -206,7 +211,12 @@ class VideoIntroController extends GetxController {
|
|||||||
|
|
||||||
// 分享视频
|
// 分享视频
|
||||||
Future actionShareVideo() async {
|
Future actionShareVideo() async {
|
||||||
print('分享视频');
|
var result = await Share.share(
|
||||||
|
'${HttpString.baseUrl}/video/$aid'
|
||||||
|
).whenComplete(() {
|
||||||
|
print("share completion block ");
|
||||||
|
});
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future queryVideoInFolder() async {
|
Future queryVideoInFolder() async {
|
||||||
|
|||||||
@ -467,8 +467,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.star),
|
icon: const Icon(FontAwesomeIcons.heart),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.star),
|
selectIcon: const Icon(FontAwesomeIcons.heartCircleCheck),
|
||||||
onTap: () => showFavBottomSheet(),
|
onTap: () => showFavBottomSheet(),
|
||||||
selectStatus: videoIntroController.hasFav.value,
|
selectStatus: videoIntroController.hasFav.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
|
|||||||
Reference in New Issue
Block a user