mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-21 17:46:24 +08:00
opt: item
chore: clean up widgets Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
503
lib/pages/member/widget/edit_profile_page.dart
Normal file
503
lib/pages/member/widget/edit_profile_page.dart
Normal file
@@ -0,0 +1,503 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/index.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart' hide FormData, MultipartFile;
|
||||
import 'package:image_cropper/image_cropper.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mime/mime.dart';
|
||||
|
||||
enum ProfileType { uname, sign, sex, birthday }
|
||||
|
||||
class EditProfilePage extends StatefulWidget {
|
||||
const EditProfilePage({super.key});
|
||||
|
||||
@override
|
||||
State<EditProfilePage> createState() => _EditProfilePageState();
|
||||
}
|
||||
|
||||
class _EditProfilePageState extends State<EditProfilePage> {
|
||||
LoadingState _loadingState = LoadingState.loading();
|
||||
late final _textController = TextEditingController();
|
||||
late final _imagePicker = ImagePicker();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_getInfo();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_textController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('账号资料')),
|
||||
body: _buildBody(_loadingState),
|
||||
);
|
||||
}
|
||||
|
||||
_getInfo() async {
|
||||
Map<String, String> data = {
|
||||
'build': '1462100',
|
||||
'c_locale': 'zh_CN',
|
||||
'channel': 'yingyongbao',
|
||||
'mobi_app': 'android_hd',
|
||||
'platform': 'android',
|
||||
's_locale': 'zh_CN',
|
||||
'statistics': Constants.statistics,
|
||||
};
|
||||
Request()
|
||||
.get('${HttpString.appBaseUrl}/x/v2/account/myinfo',
|
||||
queryParameters: data)
|
||||
.then((data) {
|
||||
setState(() {
|
||||
if (data.data['code'] == 0) {
|
||||
_loadingState = LoadingState.success(data.data['data']);
|
||||
} else {
|
||||
_loadingState = LoadingState.error(data.data['message']);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Widget get _divider => Divider(
|
||||
height: 1,
|
||||
color: Theme.of(context).dividerColor.withOpacity(0.1),
|
||||
);
|
||||
|
||||
Widget get _divider1 => Divider(
|
||||
thickness: 16,
|
||||
color: Theme.of(context).dividerColor.withOpacity(0.1),
|
||||
);
|
||||
|
||||
Widget _buildBody(LoadingState loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => loadingWidget,
|
||||
Success() => SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
_item(
|
||||
title: '头像',
|
||||
widget: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
child: ClipOval(
|
||||
child: CachedNetworkImage(
|
||||
imageUrl:
|
||||
(loadingState.response['face'] as String).http2https,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
EasyThrottle.throttle(
|
||||
'imagePicker', const Duration(milliseconds: 500),
|
||||
() async {
|
||||
_pickImg();
|
||||
});
|
||||
},
|
||||
),
|
||||
_divider,
|
||||
_item(
|
||||
title: '昵称',
|
||||
text: loadingState.response['name'],
|
||||
onTap: () {
|
||||
if (loadingState.response['coins'] < 6) {
|
||||
SmartDialog.showToast('硬币不足');
|
||||
} else {
|
||||
_editDialog(
|
||||
type: ProfileType.uname,
|
||||
title: '昵称',
|
||||
text: loadingState.response['name'],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
_divider,
|
||||
_item(
|
||||
title: '性别',
|
||||
text: _sex(loadingState.response['sex']),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context_) =>
|
||||
_sexDialog(loadingState.response['sex']),
|
||||
);
|
||||
},
|
||||
),
|
||||
_divider,
|
||||
_item(
|
||||
title: '出生年月',
|
||||
text: loadingState.response['birthday'],
|
||||
onTap: () {
|
||||
showDatePicker(
|
||||
context: context,
|
||||
initialDate:
|
||||
DateTime.parse(loadingState.response['birthday']),
|
||||
firstDate: DateTime(1900, 1, 1),
|
||||
lastDate: DateTime.now(),
|
||||
).then((date) {
|
||||
if (date != null) {
|
||||
_update(
|
||||
type: ProfileType.birthday,
|
||||
datum: DateFormat('yyyy-MM-dd').format(date),
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
_divider,
|
||||
_item(
|
||||
title: '个性签名',
|
||||
text: loadingState.response['sign'].isEmpty
|
||||
? '无'
|
||||
: loadingState.response['sign'],
|
||||
onTap: () {
|
||||
_editDialog(
|
||||
type: ProfileType.sign,
|
||||
title: '个性签名',
|
||||
text: loadingState.response['sign'],
|
||||
);
|
||||
},
|
||||
),
|
||||
_divider1,
|
||||
_item(
|
||||
title: '头像挂件',
|
||||
onTap: () => Utils.launchURL(
|
||||
'https://www.bilibili.com/h5/mall/pendant/home'),
|
||||
),
|
||||
_divider1,
|
||||
_item(
|
||||
title: 'UID',
|
||||
needIcon: false,
|
||||
text: loadingState.response['mid'].toString(),
|
||||
onTap: () =>
|
||||
Utils.copyText(loadingState.response['mid'].toString()),
|
||||
),
|
||||
// _divider,
|
||||
// _item(
|
||||
// title: '二维码名片',
|
||||
// widget: Icon(
|
||||
// Icons.qr_code,
|
||||
// color: Theme.of(context).colorScheme.outline,
|
||||
// ),
|
||||
// onTap: () {},
|
||||
// ),
|
||||
_divider1,
|
||||
_item(
|
||||
title: '哔哩哔哩认证',
|
||||
onTap: () => Utils.launchURL(
|
||||
'https://account.bilibili.com/official/mobile/home'),
|
||||
),
|
||||
_divider,
|
||||
SizedBox(height: 25 + MediaQuery.paddingOf(context).bottom),
|
||||
],
|
||||
),
|
||||
),
|
||||
Error() => errorWidget(
|
||||
errMsg: loadingState.errMsg,
|
||||
callback: _getInfo,
|
||||
),
|
||||
LoadingState() => throw UnimplementedError(),
|
||||
};
|
||||
}
|
||||
|
||||
Widget _sexDialog(int current) {
|
||||
return AlertDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_sexDialogItem(1, current, '男'),
|
||||
_sexDialogItem(0, current, '保密'),
|
||||
_sexDialogItem(2, current, '女'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _sexDialogItem(
|
||||
int sex,
|
||||
int current,
|
||||
String text,
|
||||
) {
|
||||
return ListTile(
|
||||
dense: true,
|
||||
enabled: current != sex,
|
||||
title: Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
trailing: current == sex ? const Icon(size: 22, Icons.check) : null,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
_update(type: ProfileType.sex, datum: sex);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _editDialog({
|
||||
required ProfileType type,
|
||||
required String title,
|
||||
required String text,
|
||||
}) {
|
||||
_textController.text = text;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('修改$title'),
|
||||
content: TextField(
|
||||
controller: _textController,
|
||||
minLines: type == ProfileType.uname ? 1 : 4,
|
||||
maxLines: type == ProfileType.uname ? 1 : 4,
|
||||
autofocus: true,
|
||||
style: TextStyle(fontSize: 14),
|
||||
textInputAction:
|
||||
type == ProfileType.sign ? TextInputAction.newline : null,
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(
|
||||
type == ProfileType.uname ? 16 : 70),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
hintText: text,
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
if (_textController.text == text) {
|
||||
SmartDialog.showToast('与原$title相同');
|
||||
} else {
|
||||
_update(type: type);
|
||||
}
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
).then((_) {
|
||||
_textController.clear();
|
||||
});
|
||||
}
|
||||
|
||||
_update({
|
||||
required ProfileType type,
|
||||
dynamic datum,
|
||||
}) async {
|
||||
final accessKey = Accounts.main.accessKey;
|
||||
if (accessKey.isNullOrEmpty) {
|
||||
SmartDialog.showToast('请退出账号后重新登录');
|
||||
return;
|
||||
}
|
||||
Map<String, String> data = {
|
||||
'access_key': accessKey!,
|
||||
'build': '1462100',
|
||||
'c_locale': 'zh_CN',
|
||||
'channel': 'yingyongbao',
|
||||
'mobi_app': 'android_hd',
|
||||
'platform': 'android',
|
||||
's_locale': 'zh_CN',
|
||||
'statistics': Constants.statistics,
|
||||
'ts': (DateTime.now().millisecondsSinceEpoch ~/ 1000).toString(),
|
||||
if (type == ProfileType.uname)
|
||||
'uname': _textController.text
|
||||
else if (type == ProfileType.sign)
|
||||
'user_sign': _textController.text
|
||||
else if (type == ProfileType.birthday)
|
||||
'birthday': datum
|
||||
else if (type == ProfileType.sex)
|
||||
'sex': datum.toString(),
|
||||
};
|
||||
Utils.appSign(data);
|
||||
Request()
|
||||
.post(
|
||||
'/x/member/app/${type.name}/update',
|
||||
data: data,
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
),
|
||||
)
|
||||
.then((data) {
|
||||
if (data.data['code'] == 0) {
|
||||
if (type == ProfileType.uname) {
|
||||
(_loadingState as Success).response['name'] = _textController.text;
|
||||
(_loadingState as Success).response['coins'] -= 6;
|
||||
} else if (type == ProfileType.sign) {
|
||||
(_loadingState as Success).response['sign'] = _textController.text;
|
||||
} else if (type == ProfileType.birthday) {
|
||||
(_loadingState as Success).response['birthday'] = datum;
|
||||
} else if (type == ProfileType.sex) {
|
||||
(_loadingState as Success).response['sex'] = datum;
|
||||
}
|
||||
SmartDialog.showToast('修改成功');
|
||||
setState(() {});
|
||||
if (type == ProfileType.uname || type == ProfileType.sign) {
|
||||
Get.back();
|
||||
}
|
||||
} else {
|
||||
SmartDialog.showToast(data.data['message']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String _sex(int sex) {
|
||||
return switch (sex) {
|
||||
0 => '保密',
|
||||
1 => '男',
|
||||
2 => '女',
|
||||
_ => '未知',
|
||||
};
|
||||
}
|
||||
|
||||
Widget _item({
|
||||
required String title,
|
||||
Widget? widget,
|
||||
String? text,
|
||||
GestureTapCallback? onTap,
|
||||
bool needIcon = true,
|
||||
}) {
|
||||
return ListTile(
|
||||
onTap: onTap,
|
||||
dense: title != '头像',
|
||||
leading: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (text != null)
|
||||
Text(
|
||||
text,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
)
|
||||
else if (widget != null)
|
||||
widget,
|
||||
if (needIcon)
|
||||
Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _pickImg() async {
|
||||
try {
|
||||
XFile? pickedFile = await _imagePicker.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
imageQuality: 100,
|
||||
);
|
||||
if (pickedFile != null && mounted) {
|
||||
String? mimeType =
|
||||
lookupMimeType(pickedFile.path)?.split('/').getOrNull(1);
|
||||
if (mimeType == 'gif') {
|
||||
SmartDialog.showToast('不能选GIF');
|
||||
return;
|
||||
}
|
||||
CroppedFile? croppedFile = await ImageCropper().cropImage(
|
||||
sourcePath: pickedFile.path,
|
||||
uiSettings: [
|
||||
AndroidUiSettings(
|
||||
toolbarTitle: '裁剪',
|
||||
toolbarColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
toolbarWidgetColor:
|
||||
Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
aspectRatioPresets: [
|
||||
CropAspectRatioPresetCustom(),
|
||||
],
|
||||
lockAspectRatio: true,
|
||||
hideBottomControls: true,
|
||||
cropStyle: CropStyle.circle,
|
||||
initAspectRatio: CropAspectRatioPresetCustom(),
|
||||
),
|
||||
IOSUiSettings(
|
||||
title: '裁剪',
|
||||
aspectRatioPresets: [
|
||||
CropAspectRatioPresetCustom(),
|
||||
],
|
||||
cropStyle: CropStyle.circle,
|
||||
aspectRatioLockEnabled: true,
|
||||
resetAspectRatioEnabled: false,
|
||||
aspectRatioPickerButtonHidden: true,
|
||||
),
|
||||
],
|
||||
);
|
||||
if (croppedFile != null) {
|
||||
Request()
|
||||
.post(
|
||||
'/x/member/web/face/update',
|
||||
queryParameters: {
|
||||
'csrf': await Request.getCsrf(),
|
||||
},
|
||||
data: FormData.fromMap({
|
||||
'dopost': 'save',
|
||||
'DisplayRank': 10000,
|
||||
'face': await MultipartFile.fromFile(croppedFile.path),
|
||||
}),
|
||||
)
|
||||
.then((data) {
|
||||
if (data.data['code'] == 0) {
|
||||
(_loadingState as Success).response['face'] = data.data['data'];
|
||||
SmartDialog.showToast('修改成功');
|
||||
setState(() {});
|
||||
} else {
|
||||
SmartDialog.showToast(data.data['message']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CropAspectRatioPresetCustom implements CropAspectRatioPresetData {
|
||||
@override
|
||||
(int, int)? get data => (1, 1);
|
||||
|
||||
@override
|
||||
String get name => '1x1 (customized)';
|
||||
}
|
||||
702
lib/pages/member/widget/user_info_card.dart
Normal file
702
lib/pages/member/widget/user_info_card.dart
Normal file
@@ -0,0 +1,702 @@
|
||||
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart'
|
||||
show SourceModel;
|
||||
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/models/space/card.dart' as space;
|
||||
import 'package:PiliPlus/models/space/images.dart' as space;
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class UserInfoCard extends StatelessWidget {
|
||||
const UserInfoCard({
|
||||
super.key,
|
||||
required this.isV,
|
||||
required this.isOwner,
|
||||
required this.card,
|
||||
required this.images,
|
||||
required this.relation,
|
||||
required this.isFollow,
|
||||
required this.onFollow,
|
||||
this.live,
|
||||
this.silence,
|
||||
this.endTime,
|
||||
});
|
||||
|
||||
final bool isV;
|
||||
final bool isOwner;
|
||||
final int relation;
|
||||
final bool isFollow;
|
||||
final space.Card card;
|
||||
final space.Images images;
|
||||
final VoidCallback onFollow;
|
||||
final dynamic live;
|
||||
final int? silence;
|
||||
final String? endTime;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return isV ? _buildV(context) : _buildH(context);
|
||||
}
|
||||
|
||||
Widget _countWidget({
|
||||
required String title,
|
||||
required int count,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
Utils.numFormat(count),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontSize: 11,
|
||||
color: Theme.of(Get.context!).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildHeader(BuildContext context) {
|
||||
bool darken = Theme.of(context).brightness == Brightness.dark;
|
||||
String? imgUrl = darken
|
||||
? (images.nightImgurl?.isEmpty == true
|
||||
? images.imgUrl?.http2https
|
||||
: images.nightImgurl?.http2https)
|
||||
: images.imgUrl?.http2https;
|
||||
return Hero(
|
||||
tag: imgUrl ?? '',
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
context.imageView(
|
||||
imgList: [SourceModel(url: imgUrl ?? '')],
|
||||
);
|
||||
},
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: imgUrl?.http2https ?? '',
|
||||
width: double.infinity,
|
||||
height: 135,
|
||||
imageBuilder: (context, imageProvider) => Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: imageProvider,
|
||||
fit: BoxFit.cover,
|
||||
colorFilter: ColorFilter.mode(
|
||||
darken ? const Color(0x8D000000) : const Color(0x5DFFFFFF),
|
||||
darken ? BlendMode.darken : BlendMode.lighten,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_buildLeft(BuildContext context) => [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: FittedBox(
|
||||
child: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => Utils.copyText(card.name ?? ''),
|
||||
child: Text(
|
||||
card.name ?? '',
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: (card.vip?.vipStatus ?? -1) > 0 &&
|
||||
card.vip?.vipType == 2
|
||||
? context.vipColor
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Image.asset(
|
||||
'assets/images/lv/lv${card.levelInfo?.identity == 2 ? '6_s' : card.levelInfo?.currentLevel}.png',
|
||||
height: 11,
|
||||
semanticLabel: '等级${card.levelInfo?.currentLevel}',
|
||||
),
|
||||
if (card.vip?.vipStatus == 1) ...[
|
||||
const SizedBox(width: 8),
|
||||
Image.network(
|
||||
card.vip!.label!.image!.http2https,
|
||||
height: 20,
|
||||
),
|
||||
],
|
||||
if (card.nameplate?.image?.isNotEmpty == true) ...[
|
||||
const SizedBox(width: 8),
|
||||
Image.network(
|
||||
card.nameplate!.image!.http2https,
|
||||
height: 20,
|
||||
),
|
||||
],
|
||||
// GestureDetector(
|
||||
// onTap: () {
|
||||
// Utils.copyText(card.mid.toString());
|
||||
// },
|
||||
// child: Container(
|
||||
// padding:
|
||||
// const EdgeInsets.symmetric(horizontal: 8, vertical: 2.5),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Theme.of(context).colorScheme.secondaryContainer,
|
||||
// borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||
// ),
|
||||
// child: Text(
|
||||
// 'uid: ${card.mid}',
|
||||
// style: TextStyle(
|
||||
// height: 1,
|
||||
// fontSize: 12,
|
||||
// color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
// ),
|
||||
// strutStyle: const StrutStyle(
|
||||
// height: 1,
|
||||
// leading: 0,
|
||||
// fontSize: 12,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (card.officialVerify?.desc?.isNotEmpty == true)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 20, top: 8, right: 20),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
),
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
if (card.officialVerify?.icon?.isNotEmpty == true) ...[
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
child: CachedNetworkImage(
|
||||
width: 18,
|
||||
height: 18,
|
||||
imageUrl: card.officialVerify!.icon!.http2https,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: ' ',
|
||||
)
|
||||
],
|
||||
TextSpan(
|
||||
text: card.officialVerify!.spliceTitle!,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withOpacity(0.7),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (card.sign?.isNotEmpty == true)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20, top: 6, right: 20),
|
||||
child: SelectableText(
|
||||
card.sign!.trim().replaceAll(RegExp(r'\n{2,}'), '\n'),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 20, top: 6, right: 20),
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
crossAxisAlignment: WrapCrossAlignment.end,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Utils.copyText(card.mid.toString());
|
||||
},
|
||||
child: Text(
|
||||
'UID: ${card.mid}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!card.spaceTag.isNullOrEmpty)
|
||||
...card.spaceTag!.map(
|
||||
(item) => Text(
|
||||
item.title ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (silence == 1)
|
||||
Builder(builder: (context) {
|
||||
bool isLight = Theme.of(context).brightness == Brightness.light;
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
color: isLight
|
||||
? Theme.of(context).colorScheme.errorContainer
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
margin: const EdgeInsets.only(left: 20, top: 8, right: 20),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.info,
|
||||
size: 17,
|
||||
color: isLight
|
||||
? Theme.of(context).colorScheme.onErrorContainer
|
||||
: Theme.of(context).colorScheme.onError,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: ' 该账号封禁中${endTime ?? ''}',
|
||||
style: TextStyle(
|
||||
color: isLight
|
||||
? Theme.of(context).colorScheme.onErrorContainer
|
||||
: Theme.of(context).colorScheme.onError,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
];
|
||||
|
||||
_buildRight(BuildContext context) => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: List.generate(
|
||||
5,
|
||||
(index) => index % 2 == 0
|
||||
? _countWidget(
|
||||
title: ['粉丝', '关注', '获赞'][index ~/ 2],
|
||||
count: index == 0
|
||||
? card.fans
|
||||
: index == 2
|
||||
? card.attention
|
||||
: card.likes?.likeNum ?? 0,
|
||||
onTap: () {
|
||||
if (index == 0) {
|
||||
Get.toNamed('/fan?mid=${card.mid}&name=${card.name}');
|
||||
} else if (index == 2) {
|
||||
Get.toNamed(
|
||||
'/follow?mid=${card.mid}&name=${card.name}');
|
||||
}
|
||||
},
|
||||
)
|
||||
: SizedBox(
|
||||
height: 15,
|
||||
width: 1,
|
||||
child: VerticalDivider(),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(width: 20),
|
||||
if (!isOwner) ...[
|
||||
IconButton.outlined(
|
||||
onPressed: () {
|
||||
if (GStorage.userInfo.get('userInfoCache') != null) {
|
||||
Get.toNamed(
|
||||
'/whisperDetail',
|
||||
parameters: {
|
||||
'talkerId': card.mid ?? '',
|
||||
'name': card.name ?? '',
|
||||
'face': card.face ?? '',
|
||||
'mid': card.mid ?? '',
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.mail_outline, size: 21),
|
||||
style: IconButton.styleFrom(
|
||||
side: BorderSide(
|
||||
width: 1.0,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline
|
||||
.withOpacity(0.5),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
visualDensity: const VisualDensity(
|
||||
horizontal: -2,
|
||||
vertical: -2,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
Expanded(
|
||||
child: FilledButton.tonal(
|
||||
onPressed: onFollow,
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: relation == -1 || isFollow
|
||||
? Theme.of(context).colorScheme.onInverseSurface
|
||||
: null,
|
||||
visualDensity: const VisualDensity(
|
||||
horizontal: -2,
|
||||
vertical: -2,
|
||||
),
|
||||
),
|
||||
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: isOwner
|
||||
? '编辑资料'
|
||||
: relation == -1
|
||||
? '移除黑名单'
|
||||
: relation == 2
|
||||
? ' 特别关注'
|
||||
: isFollow
|
||||
? ' 已关注'
|
||||
: '关注',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
_buildBadge(BuildContext context) => IgnorePointer(
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
child: card.officialVerify?.icon?.isNotEmpty == true
|
||||
? CachedNetworkImage(
|
||||
imageUrl: card.officialVerify!.icon!.http2https,
|
||||
width: 22,
|
||||
height: 22,
|
||||
)
|
||||
: Image.asset(
|
||||
'assets/images/big-vip.png',
|
||||
width: 22,
|
||||
height: 22,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
_buildAvatar(BuildContext context) => Hero(
|
||||
tag: card.face ?? '',
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
context.imageView(
|
||||
imgList: [SourceModel(url: card.face ?? '')],
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 2.5,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: NetworkImgLayer(
|
||||
src: card.face,
|
||||
type: 'avatar',
|
||||
width: 80,
|
||||
height: 80,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
_buildV(BuildContext context) => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildHeader(context),
|
||||
const SizedBox(width: double.infinity, height: 85)
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
top: 110,
|
||||
left: 20,
|
||||
child: _buildAvatar(context),
|
||||
),
|
||||
if (ModuleAuthorModel.showDynDecorate &&
|
||||
card.pendant?.image?.isNotEmpty == true)
|
||||
Positioned(
|
||||
top: 82.5,
|
||||
left: -7.5,
|
||||
child: IgnorePointer(
|
||||
child: CachedNetworkImage(
|
||||
width: 140,
|
||||
height: 140,
|
||||
imageUrl: card.pendant!.image!,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (card.officialVerify?.icon?.isNotEmpty == true ||
|
||||
(card.vip?.vipStatus ?? -1) > 0)
|
||||
Positioned(
|
||||
top: 172,
|
||||
left: 82,
|
||||
child: _buildBadge(context),
|
||||
),
|
||||
if (live is Map && ((live['liveStatus'] as int?) ?? 0) == 1)
|
||||
Positioned(
|
||||
top: 180,
|
||||
left: 20,
|
||||
child: _buildLiveBadge(context),
|
||||
),
|
||||
Positioned(
|
||||
left: 120,
|
||||
top: 140,
|
||||
right: 20,
|
||||
bottom: 0,
|
||||
child: LayoutBuilder(
|
||||
builder: (_, constraints) => FittedBox(
|
||||
child: SizedBox(
|
||||
width: constraints.maxWidth,
|
||||
child: _buildRight(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
..._buildLeft(context),
|
||||
if (card.prInfo?.content?.isNotEmpty == true) buildPrInfo,
|
||||
const SizedBox(height: 5),
|
||||
],
|
||||
);
|
||||
|
||||
Widget get buildPrInfo => Builder(builder: (context) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
final textColor = isDark
|
||||
? Color(int.parse('FF${card.prInfo?.textColorNight?.substring(1)}',
|
||||
radix: 16))
|
||||
: Color(int.parse('FF${card.prInfo?.textColor?.substring(1)}',
|
||||
radix: 16));
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (card.prInfo?.url?.isNotEmpty == true) {
|
||||
Utils.handleWebview(card.prInfo!.url!);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 8),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
color: isDark
|
||||
? Color(int.parse(
|
||||
'FF${card.prInfo?.bgColorNight?.substring(1)}',
|
||||
radix: 16))
|
||||
: Color(int.parse('FF${card.prInfo?.bgColor?.substring(1)}',
|
||||
radix: 16)),
|
||||
child: Row(
|
||||
children: [
|
||||
if (isDark && card.prInfo?.iconNight?.isNotEmpty == true) ...[
|
||||
CachedNetworkImage(
|
||||
imageUrl: card.prInfo!.iconNight!,
|
||||
height: 20,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
] else if (card.prInfo?.icon?.isNotEmpty == true) ...[
|
||||
CachedNetworkImage(
|
||||
imageUrl: card.prInfo!.icon!,
|
||||
height: 20,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
Expanded(
|
||||
child: Text(
|
||||
card.prInfo!.content!,
|
||||
style: TextStyle(fontSize: 13, color: textColor),
|
||||
),
|
||||
),
|
||||
if (card.prInfo?.url?.isNotEmpty == true) ...[
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: textColor,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
_buildLiveBadge(context) => GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed('/liveRoom?roomid=${live['roomid']}');
|
||||
},
|
||||
child: Container(
|
||||
width: 85,
|
||||
alignment: Alignment.center,
|
||||
child: Badge(
|
||||
label: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.equalizer_rounded,
|
||||
size: MediaQuery.textScalerOf(context).scale(16),
|
||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
),
|
||||
Text(
|
||||
'直播中',
|
||||
style: TextStyle(height: 1),
|
||||
)
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 5,
|
||||
vertical: 1,
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
textColor: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
_buildH(BuildContext context) => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildHeader(context),
|
||||
SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 20),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 10,
|
||||
bottom: card.prInfo?.content?.isNotEmpty == true ? 0 : 10,
|
||||
),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
_buildAvatar(context),
|
||||
if (ModuleAuthorModel.showDynDecorate &&
|
||||
card.pendant?.image?.isNotEmpty == true)
|
||||
Positioned(
|
||||
top: -27.5,
|
||||
left: -27.5,
|
||||
child: IgnorePointer(
|
||||
child: CachedNetworkImage(
|
||||
width: 140,
|
||||
height: 140,
|
||||
imageUrl: card.pendant!.image!,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (card.officialVerify?.icon?.isNotEmpty == true ||
|
||||
(card.vip?.vipStatus ?? -1) > 0)
|
||||
Positioned(
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: _buildBadge(context),
|
||||
),
|
||||
if (live is Map &&
|
||||
((live['liveStatus'] as int?) ?? 0) == 1)
|
||||
Positioned(
|
||||
left: 0,
|
||||
bottom: -5,
|
||||
right: 0,
|
||||
child: _buildLiveBadge(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
..._buildLeft(context),
|
||||
const SizedBox(height: 5),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(child: _buildRight(context)),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (card.prInfo?.content?.isNotEmpty == true) buildPrInfo,
|
||||
],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user