mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: follow dialog
This commit is contained in:
@@ -210,11 +210,7 @@ class _MemberFavoriteState extends State<MemberFavorite>
|
||||
),
|
||||
subtitle: Text(
|
||||
item1.type == 0
|
||||
? '${item1.mediaCount}个内容 · ${[
|
||||
0,
|
||||
2,
|
||||
22
|
||||
].contains(item1.attr) ? '公开' : '私密'}'
|
||||
? '${item1.mediaCount}个内容'
|
||||
: item1.type == 11
|
||||
? '${item1.mediaCount}个内容 · ${item1.upper?.name}'
|
||||
: item1.type == 21
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:PiliPalaX/http/video.dart';
|
||||
import 'package:PiliPalaX/models/space/tab2.dart';
|
||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:PiliPalaX/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -114,13 +115,23 @@ class MemberControllerNew extends CommonController
|
||||
}
|
||||
}
|
||||
|
||||
void onFollow() async {
|
||||
void onFollow(BuildContext context) async {
|
||||
if (relation.value == -1) {
|
||||
_onBlock();
|
||||
} else if (!isFollow.value) {
|
||||
// TODO
|
||||
} else {
|
||||
// TODO
|
||||
if (ownerMid == null) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
Utils.actionRelationMod(
|
||||
context: context,
|
||||
mid: mid,
|
||||
isFollow: isFollow.value,
|
||||
callback: (attribute) {
|
||||
relation.value = 1;
|
||||
isFollow.value = attribute != 0;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ class _MemberPageNewState extends State<MemberPageNew>
|
||||
isFollow: _userController.isFollow.value,
|
||||
card: userState.response.card,
|
||||
images: userState.response.images,
|
||||
onFollow: _userController.onFollow,
|
||||
onFollow: () => _userController.onFollow(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -217,17 +217,33 @@ class UserInfoCard extends StatelessWidget {
|
||||
vertical: -2,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
relation == -1
|
||||
? '已拉黑'
|
||||
: isFollow
|
||||
? '取消关注'
|
||||
: '关注',
|
||||
child: Text.rich(
|
||||
style: TextStyle(
|
||||
color: relation == -1 || isFollow
|
||||
? Theme.of(context).colorScheme.outline
|
||||
: null,
|
||||
),
|
||||
TextSpan(
|
||||
children: [
|
||||
if (isFollow)
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.top,
|
||||
child: Icon(
|
||||
Icons.sort,
|
||||
size: 16,
|
||||
color:
|
||||
Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: relation == -1
|
||||
? '移除黑名单'
|
||||
: isFollow
|
||||
? ' 已关注'
|
||||
: '关注',
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -507,132 +507,15 @@ class VideoIntroController extends GetxController
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
if (videoDetail.value.owner?.mid == null) {
|
||||
return;
|
||||
}
|
||||
feedBack();
|
||||
int mid = videoDetail.value.owner!.mid!;
|
||||
if ((followStatus['attribute'] ?? 0) == 0) {
|
||||
var res = await VideoHttp.relationMod(
|
||||
mid: mid,
|
||||
act: 1,
|
||||
reSrc: 11,
|
||||
);
|
||||
SmartDialog.showToast(res['status'] ? "关注成功" : res['msg']);
|
||||
if (res['status']) {
|
||||
followStatus['attribute'] = 2;
|
||||
Utils.actionRelationMod(
|
||||
context: context,
|
||||
mid: videoDetail.value.owner?.mid,
|
||||
isFollow: (followStatus['attribute'] ?? 0) != 0,
|
||||
callback: (attribute) {
|
||||
followStatus['attribute'] = attribute;
|
||||
followStatus.refresh();
|
||||
}
|
||||
} else {
|
||||
/// TODO
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
bool isSpecialFollowed = followStatus['special'] == 1;
|
||||
String text = isSpecialFollowed ? '移除特别关注' : '加入特别关注';
|
||||
return AlertDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
final res = await MemberHttp.specialAction(
|
||||
fid: mid,
|
||||
isAdd: !isSpecialFollowed,
|
||||
);
|
||||
if (res['status']) {
|
||||
followStatus['special'] = isSpecialFollowed ? 0 : 1;
|
||||
List tags = followStatus['tag'] ?? [];
|
||||
if (isSpecialFollowed) {
|
||||
tags.remove(-10);
|
||||
} else {
|
||||
tags.add(-10);
|
||||
}
|
||||
followStatus['tag'] = tags;
|
||||
followStatus.refresh();
|
||||
SmartDialog.showToast('$text成功');
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
},
|
||||
title: Text(
|
||||
text,
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
dynamic result = await showModalBottomSheet(
|
||||
context: context,
|
||||
useSafeArea: true,
|
||||
isScrollControlled: true,
|
||||
transitionAnimationController: AnimationController(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
vsync: this,
|
||||
),
|
||||
sheetAnimationStyle: AnimationStyle(curve: Curves.ease),
|
||||
builder: (BuildContext context) {
|
||||
return DraggableScrollableSheet(
|
||||
minChildSize: 0,
|
||||
maxChildSize: 1,
|
||||
initialChildSize: 0.6,
|
||||
snap: true,
|
||||
expand: false,
|
||||
snapSizes: const [0.6],
|
||||
builder: (BuildContext context,
|
||||
ScrollController scrollController) {
|
||||
return GroupPanel(
|
||||
mid: mid,
|
||||
tags: followStatus['tag'],
|
||||
scrollController: scrollController,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
if (result == true) {
|
||||
queryFollowStatus();
|
||||
}
|
||||
},
|
||||
title: const Text(
|
||||
'设置分组',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
var res = await VideoHttp.relationMod(
|
||||
mid: mid,
|
||||
act: 2,
|
||||
reSrc: 11,
|
||||
);
|
||||
SmartDialog.showToast(
|
||||
res['status'] ? "取消关注成功" : res['msg']);
|
||||
if (res['status']) {
|
||||
followStatus['attribute'] = 0;
|
||||
followStatus.refresh();
|
||||
}
|
||||
},
|
||||
title: const Text(
|
||||
'取消关注',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// MemberController _ = Get.put<MemberController>(MemberController(mid: mid),
|
||||
// tag: mid.toString());
|
||||
|
||||
@@ -102,19 +102,22 @@ class _FavPanelState extends State<FavPanel> {
|
||||
1,
|
||||
index),
|
||||
dense: true,
|
||||
leading: [0, 22].contains(widget.ctr!
|
||||
.favFolderData.value.list![index].attr)
|
||||
? const Icon(Icons.folder_outlined)
|
||||
: const Icon(Icons.lock_outline),
|
||||
leading: const Icon(Icons.folder_outlined),
|
||||
// leading: [0, 22].contains(widget.ctr!
|
||||
// .favFolderData.value.list![index].attr)
|
||||
// ? const Icon(Icons.folder_outlined)
|
||||
// : const Icon(Icons.lock_outline),
|
||||
minLeadingWidth: 0,
|
||||
title: Text(widget.ctr!.favFolderData.value
|
||||
.list![index].title!),
|
||||
subtitle: Text(
|
||||
'${widget.ctr!.favFolderData.value.list![index].mediaCount}个内容 . ${[
|
||||
0,
|
||||
22
|
||||
].contains(widget.ctr!.favFolderData.value.list![index].attr) ? '公开' : '私密'}',
|
||||
),
|
||||
'${widget.ctr!.favFolderData.value.list![index].mediaCount}个内容'),
|
||||
// subtitle: Text(
|
||||
// '${widget.ctr!.favFolderData.value.list![index].mediaCount}个内容 . ${[
|
||||
// 0,
|
||||
// 22
|
||||
// ].contains(widget.ctr!.favFolderData.value.list![index].attr) ? '公开' : '私密'}',
|
||||
// ),
|
||||
trailing: Transform.scale(
|
||||
scale: 0.9,
|
||||
child: Checkbox(
|
||||
|
||||
@@ -5,9 +5,13 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'package:PiliPalaX/http/member.dart';
|
||||
import 'package:PiliPalaX/http/search.dart';
|
||||
import 'package:PiliPalaX/http/video.dart';
|
||||
import 'package:PiliPalaX/models/bangumi/info.dart';
|
||||
import 'package:PiliPalaX/models/common/search_type.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/introduction/widgets/group_panel.dart';
|
||||
import 'package:PiliPalaX/utils/feed_back.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
@@ -18,13 +22,158 @@ import 'package:get/get.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../common/widgets/custom_toast.dart';
|
||||
import '../http/index.dart';
|
||||
import '../models/github/latest.dart';
|
||||
|
||||
class Utils {
|
||||
static final Random random = Random();
|
||||
|
||||
static Future actionRelationMod({
|
||||
required BuildContext context,
|
||||
required dynamic mid,
|
||||
required bool isFollow,
|
||||
required Function callback,
|
||||
}) async {
|
||||
if (mid == null) {
|
||||
return;
|
||||
}
|
||||
feedBack();
|
||||
if (!isFollow) {
|
||||
var res = await VideoHttp.relationMod(
|
||||
mid: mid,
|
||||
act: 1,
|
||||
reSrc: 11,
|
||||
);
|
||||
SmartDialog.showToast(res['status'] ? "关注成功" : res['msg']);
|
||||
if (res['status']) {
|
||||
callback(2);
|
||||
// followStatus['attribute'] = 2;
|
||||
// followStatus.refresh();
|
||||
}
|
||||
} else {
|
||||
dynamic result = await VideoHttp.hasFollow(mid: mid);
|
||||
if (result['status'] && context.mounted) {
|
||||
Map followStatus = result['data'];
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
bool isSpecialFollowed = followStatus['special'] == 1;
|
||||
String text = isSpecialFollowed ? '移除特别关注' : '加入特别关注';
|
||||
return AlertDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
final res = await MemberHttp.specialAction(
|
||||
fid: mid,
|
||||
isAdd: !isSpecialFollowed,
|
||||
);
|
||||
if (res['status']) {
|
||||
// followStatus['special'] = isSpecialFollowed ? 0 : 1;
|
||||
// List tags = followStatus['tag'] ?? [];
|
||||
// if (isSpecialFollowed) {
|
||||
// tags.remove(-10);
|
||||
// } else {
|
||||
// tags.add(-10);
|
||||
// }
|
||||
// followStatus['tag'] = tags;
|
||||
// followStatus.refresh();
|
||||
SmartDialog.showToast('$text成功');
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
},
|
||||
title: Text(
|
||||
text,
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
await showModalBottomSheet(
|
||||
context: context,
|
||||
useSafeArea: true,
|
||||
isScrollControlled: true,
|
||||
// transitionAnimationController: AnimationController(
|
||||
// duration: const Duration(milliseconds: 200),
|
||||
// vsync: this,
|
||||
// ),
|
||||
sheetAnimationStyle: AnimationStyle(curve: Curves.ease),
|
||||
builder: (BuildContext context) {
|
||||
return DraggableScrollableSheet(
|
||||
minChildSize: 0,
|
||||
maxChildSize: 1,
|
||||
initialChildSize: 0.6,
|
||||
snap: true,
|
||||
expand: false,
|
||||
snapSizes: const [0.6],
|
||||
builder: (BuildContext context,
|
||||
ScrollController scrollController) {
|
||||
return GroupPanel(
|
||||
mid: mid,
|
||||
tags: followStatus['tag'],
|
||||
scrollController: scrollController,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
// await Future.delayed(const Duration(milliseconds: 500));
|
||||
// if (result == true) {
|
||||
// queryFollowStatus();
|
||||
// }
|
||||
},
|
||||
title: const Text(
|
||||
'设置分组',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
var res = await VideoHttp.relationMod(
|
||||
mid: mid,
|
||||
act: 2,
|
||||
reSrc: 11,
|
||||
);
|
||||
SmartDialog.showToast(
|
||||
res['status'] ? "取消关注成功" : res['msg']);
|
||||
if (res['status']) {
|
||||
callback(0);
|
||||
// followStatus['attribute'] = 0;
|
||||
// followStatus.refresh();
|
||||
}
|
||||
},
|
||||
title: const Text(
|
||||
'取消关注',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// MemberController _ = Get.put<MemberController>(MemberController(mid: mid),
|
||||
// tag: mid.toString());
|
||||
// await _.getInfo();
|
||||
// if (context.mounted) await _.actionRelationMod(context);
|
||||
// followStatus['attribute'] = _.attribute.value;
|
||||
// followStatus.refresh();
|
||||
// Get.delete<MemberController>(tag: mid.toString());
|
||||
}
|
||||
|
||||
static String generateRandomString(int length) {
|
||||
const characters = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
Random random = Random();
|
||||
@@ -538,7 +687,7 @@ class Utils {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setting.put(SettingBoxKey.autoUpdate, false);
|
||||
GStorage.setting.put(SettingBoxKey.autoUpdate, false);
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
child: Text(
|
||||
|
||||
Reference in New Issue
Block a user