mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: item
chore: clean up widgets Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -69,16 +69,8 @@ class _UpPanelState extends State<UpPanel> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SliverToBoxAdapter(
|
||||
child: SizedBox(height: 10),
|
||||
),
|
||||
SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 1,
|
||||
mainAxisExtent: 76,
|
||||
crossAxisSpacing: 0,
|
||||
mainAxisSpacing: 0,
|
||||
),
|
||||
const SliverToBoxAdapter(child: SizedBox(height: 10)),
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
if (widget.dynamicsController.showLiveItems &&
|
||||
@@ -102,9 +94,7 @@ class _UpPanelState extends State<UpPanel> {
|
||||
],
|
||||
),
|
||||
),
|
||||
const SliverToBoxAdapter(
|
||||
child: SizedBox(height: 200),
|
||||
),
|
||||
const SliverToBoxAdapter(child: SizedBox(height: 200)),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -112,119 +102,122 @@ class _UpPanelState extends State<UpPanel> {
|
||||
Widget upItemBuild(data, i) {
|
||||
bool isCurrent = widget.dynamicsController.currentMid == data.mid ||
|
||||
widget.dynamicsController.currentMid == -1;
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
feedBack();
|
||||
if (data.type == 'up') {
|
||||
widget.dynamicsController.currentMid = data.mid;
|
||||
// dynamicsController.mid.value = data.mid;
|
||||
widget.dynamicsController
|
||||
..upInfo.value = data
|
||||
..onSelectUp(data.mid);
|
||||
// int liveLen = liveList.length;
|
||||
// int upLen = upList.length;
|
||||
// double itemWidth = contentWidth + itemPadding.horizontal;
|
||||
// double screenWidth = MediaQuery.sizeOf(context).width;
|
||||
// double moveDistance = 0.0;
|
||||
// if (itemWidth * (upList.length + liveList.length) <= screenWidth) {
|
||||
// } else if ((upLen - i - 0.5) * itemWidth > screenWidth / 2) {
|
||||
// moveDistance =
|
||||
// (i + liveLen + 0.5) * itemWidth + 46 - screenWidth / 2;
|
||||
// } else {
|
||||
// moveDistance = (upLen + liveLen) * itemWidth + 46 - screenWidth;
|
||||
// }
|
||||
data.hasUpdate = false;
|
||||
// scrollController.animateTo(
|
||||
// moveDistance,
|
||||
// duration: const Duration(milliseconds: 500),
|
||||
// curve: Curves.easeInOut,
|
||||
// );
|
||||
setState(() {});
|
||||
} else if (data.type == 'live') {
|
||||
// LiveItemModel liveItem = LiveItemModel.fromJson({
|
||||
// 'title': data.title,
|
||||
// 'uname': data.uname,
|
||||
// 'face': data.face,
|
||||
// 'roomid': data.roomId,
|
||||
// });
|
||||
Get.toNamed('/liveRoom?roomid=${data.roomId}');
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
if (data.mid == -1) {
|
||||
return;
|
||||
}
|
||||
String heroTag = Utils.makeHeroTag(data.mid);
|
||||
Get.toNamed('/member?mid=${data.mid}',
|
||||
arguments: {'face': data.face, 'heroTag': heroTag});
|
||||
},
|
||||
child: AnimatedOpacity(
|
||||
opacity: isCurrent ? 1 : 0.6,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeInOut,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: data.face != ''
|
||||
? NetworkImgLayer(
|
||||
width: 38,
|
||||
height: 38,
|
||||
src: data.face,
|
||||
type: 'avatar',
|
||||
)
|
||||
: const CircleAvatar(
|
||||
backgroundColor: Color(0xFF5CB67B),
|
||||
backgroundImage: AssetImage(
|
||||
'assets/images/logo/logo.png',
|
||||
return SizedBox(
|
||||
height: 76,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
feedBack();
|
||||
if (data.type == 'up') {
|
||||
widget.dynamicsController.currentMid = data.mid;
|
||||
// dynamicsController.mid.value = data.mid;
|
||||
widget.dynamicsController
|
||||
..upInfo.value = data
|
||||
..onSelectUp(data.mid);
|
||||
// int liveLen = liveList.length;
|
||||
// int upLen = upList.length;
|
||||
// double itemWidth = contentWidth + itemPadding.horizontal;
|
||||
// double screenWidth = MediaQuery.sizeOf(context).width;
|
||||
// double moveDistance = 0.0;
|
||||
// if (itemWidth * (upList.length + liveList.length) <= screenWidth) {
|
||||
// } else if ((upLen - i - 0.5) * itemWidth > screenWidth / 2) {
|
||||
// moveDistance =
|
||||
// (i + liveLen + 0.5) * itemWidth + 46 - screenWidth / 2;
|
||||
// } else {
|
||||
// moveDistance = (upLen + liveLen) * itemWidth + 46 - screenWidth;
|
||||
// }
|
||||
data.hasUpdate = false;
|
||||
// scrollController.animateTo(
|
||||
// moveDistance,
|
||||
// duration: const Duration(milliseconds: 500),
|
||||
// curve: Curves.easeInOut,
|
||||
// );
|
||||
setState(() {});
|
||||
} else if (data.type == 'live') {
|
||||
// LiveItemModel liveItem = LiveItemModel.fromJson({
|
||||
// 'title': data.title,
|
||||
// 'uname': data.uname,
|
||||
// 'face': data.face,
|
||||
// 'roomid': data.roomId,
|
||||
// });
|
||||
Get.toNamed('/liveRoom?roomid=${data.roomId}');
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
if (data.mid == -1) {
|
||||
return;
|
||||
}
|
||||
String heroTag = Utils.makeHeroTag(data.mid);
|
||||
Get.toNamed('/member?mid=${data.mid}',
|
||||
arguments: {'face': data.face, 'heroTag': heroTag});
|
||||
},
|
||||
child: AnimatedOpacity(
|
||||
opacity: isCurrent ? 1 : 0.6,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeInOut,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: data.face != ''
|
||||
? NetworkImgLayer(
|
||||
width: 38,
|
||||
height: 38,
|
||||
src: data.face,
|
||||
type: 'avatar',
|
||||
)
|
||||
: const CircleAvatar(
|
||||
backgroundColor: Color(0xFF5CB67B),
|
||||
backgroundImage: AssetImage(
|
||||
'assets/images/logo/logo.png',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: data.type == 'live' ? -5 : 0,
|
||||
right: data.type == 'live' ? -6 : 4,
|
||||
child: Badge(
|
||||
smallSize: 8,
|
||||
label: data.type == 'live' ? const Text(' Live ') : null,
|
||||
textColor:
|
||||
Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
isLabelVisible: data.type == 'live' ||
|
||||
(data.type == 'up' && (data.hasUpdate ?? false)),
|
||||
backgroundColor: data.type == 'live'
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.secondaryContainer
|
||||
.withOpacity(0.75)
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
Positioned(
|
||||
top: data.type == 'live' ? -5 : 0,
|
||||
right: data.type == 'live' ? -6 : 4,
|
||||
child: Badge(
|
||||
smallSize: 8,
|
||||
label: data.type == 'live' ? const Text(' Live ') : null,
|
||||
textColor:
|
||||
Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
isLabelVisible: data.type == 'live' ||
|
||||
(data.type == 'up' && (data.hasUpdate ?? false)),
|
||||
backgroundColor: data.type == 'live'
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.secondaryContainer
|
||||
.withOpacity(0.75)
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text(
|
||||
data.uname,
|
||||
overflow: TextOverflow.clip,
|
||||
maxLines: 2,
|
||||
softWrap: true,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: widget.dynamicsController.currentMid == data.mid
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
height: 1.1,
|
||||
fontSize: 12.5,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text(
|
||||
data.uname,
|
||||
overflow: TextOverflow.clip,
|
||||
maxLines: 2,
|
||||
softWrap: true,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: widget.dynamicsController.currentMid == data.mid
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
height: 1.1,
|
||||
fontSize: 12.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user