opt: member page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-15 10:05:22 +08:00
parent 5643ebfe48
commit 27b251b06e
4 changed files with 132 additions and 177 deletions

View File

@@ -35,7 +35,7 @@ class DynamicSliverAppBar extends StatefulWidget {
this.stretchTriggerOffset = 100.0,
this.onStretchTrigger,
this.shape,
this.toolbarHeight = kToolbarHeight + 20,
this.toolbarHeight = kToolbarHeight,
this.leadingWidth,
this.toolbarTextStyle,
this.titleTextStyle,
@@ -43,8 +43,10 @@ class DynamicSliverAppBar extends StatefulWidget {
this.forceMaterialTransparency = false,
this.clipBehavior,
this.appBarClipper,
this.hasTabBar = false,
});
final bool hasTabBar;
final Widget? flexibleSpace;
final Widget? leading;
final bool automaticallyImplyLeading;
@@ -95,7 +97,6 @@ class _DynamicSliverAppBarState extends State<DynamicSliverAppBar> {
// As long as the height is 0 instead of the sliver app bar a sliver to box adapter will be used
// to calculate dynamically the size for the sliver app bar
double _height = 0;
Orientation? _orientation;
@override
void initState() {
@@ -103,13 +104,6 @@ class _DynamicSliverAppBarState extends State<DynamicSliverAppBar> {
_updateHeight();
}
@override
void didUpdateWidget(covariant DynamicSliverAppBar oldWidget) {
super.didUpdateWidget(oldWidget);
_updateHeight();
}
void _updateHeight() {
// Gets the new height and updates the sliver app bar. Needs to be called after the last frame has been rebuild
// otherwise this will throw an error
@@ -123,23 +117,27 @@ class _DynamicSliverAppBarState extends State<DynamicSliverAppBar> {
});
}
@override
void didChangeDependencies() {
_height = 0;
_updateHeight();
super.didChangeDependencies();
}
@override
Widget build(BuildContext context) {
//Needed to lay out the flexibleSpace the first time, so we can calculate its intrinsic height
Orientation orientation = MediaQuery.orientationOf(context);
if (_orientation != orientation) {
_orientation = orientation;
_height = 0;
}
if (_height == 0) {
return SliverToBoxAdapter(
child: Container(
child: SizedBox(
key: _childKey,
child: widget.flexibleSpace ?? SizedBox(height: kToolbarHeight),
),
);
}
MediaQuery.orientationOf(context);
return SliverAppBar(
leading: widget.leading,
automaticallyImplyLeading: widget.automaticallyImplyLeading,
@@ -168,7 +166,7 @@ class _DynamicSliverAppBarState extends State<DynamicSliverAppBar> {
onStretchTrigger: widget.onStretchTrigger,
shape: widget.shape,
toolbarHeight: widget.toolbarHeight,
expandedHeight: _height,
expandedHeight: _height + (widget.hasTabBar ? 48 : 0),
leadingWidth: widget.leadingWidth,
toolbarTextStyle: widget.toolbarTextStyle,
titleTextStyle: widget.titleTextStyle,

View File

@@ -33,7 +33,7 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
late List<Tab> tabs;
List<Tab2>? tab2;
RxInt contributeInitialIndex = 0.obs;
double? top;
double top = 0;
bool? hasSeasonOrSeries;
final fromViewAid = Get.parameters['from_view_aid'];

View File

@@ -55,7 +55,7 @@ class _MemberPageNewState extends State<MemberPageNew> {
@override
Widget build(BuildContext context) {
if (_userController.top == null || _userController.top == 0) {
if (_userController.top == 0) {
_userController.top = MediaQuery.of(context).padding.top;
}
return Scaffold(
@@ -64,7 +64,6 @@ class _MemberPageNewState extends State<MemberPageNew> {
() => _userController.loadingState.value is Success
? LayoutBuilder(
builder: (context, constraints) {
// if (constraints.maxHeight > constraints.maxWidth) {
return ExtendedNestedScrollView(
key: _key,
controller: _userController.scrollController,
@@ -97,41 +96,6 @@ class _MemberPageNewState extends State<MemberPageNew> {
)
: Center(child: const Text('EMPTY')),
);
// } else {
// return Row(
// children: [
// Expanded(
// child: CustomScrollView(
// slivers: [
// _buildAppBar(false),
// ],
// ),
// ),
// Expanded(
// child: SafeArea(
// top: false,
// left: false,
// bottom: false,
// child: Column(
// children: [
// SizedBox(height: _userController.top),
// if ((_userController.tab2?.length ?? -1) > 1)
// _buildTab,
// Expanded(
// child:
// _userController.tab2?.isNotEmpty == true
// ? _buildBody
// : Center(
// child: const Text('EMPTY'),
// ),
// ),
// ],
// ),
// ),
// ),
// ],
// );
// }
},
)
: Center(
@@ -186,27 +150,25 @@ class _MemberPageNewState extends State<MemberPageNew> {
);
Widget _buildAppBar({bool needTab = true, bool isV = true}) =>
MediaQuery.removePadding(
context: context,
removeTop: true,
// removeRight: true,
child: DynamicSliverAppBar(
DynamicSliverAppBar(
primary: false,
leading: Padding(
padding: EdgeInsets.only(top: _userController.top ?? 0),
padding: EdgeInsets.only(top: _userController.top),
child: const BackButton(),
),
hasTabBar: (_userController.tab2?.length ?? 0) > 1,
toolbarHeight: kToolbarHeight + _userController.top,
title: IgnorePointer(
child: Obx(() => _userController.showUname.value &&
_userController.username != null
? Padding(
padding: EdgeInsets.only(top: _userController.top ?? 0),
padding: EdgeInsets.only(top: _userController.top),
child: Text(_userController.username!),
)
: const SizedBox.shrink()),
),
pinned: true,
flexibleSpace:
_buildUserInfo(_userController.loadingState.value, isV),
flexibleSpace: _buildUserInfo(_userController.loadingState.value, isV),
bottom: needTab && (_userController.tab2?.length ?? -1) > 1
? PreferredSize(
preferredSize: Size.fromHeight(48),
@@ -215,7 +177,7 @@ class _MemberPageNewState extends State<MemberPageNew> {
: null,
actions: [
Padding(
padding: EdgeInsets.only(top: _userController.top ?? 0),
padding: EdgeInsets.only(top: _userController.top),
child: IconButton(
tooltip: '搜索',
onPressed: () => Get.toNamed(
@@ -224,7 +186,7 @@ class _MemberPageNewState extends State<MemberPageNew> {
),
),
Padding(
padding: EdgeInsets.only(top: _userController.top ?? 0),
padding: EdgeInsets.only(top: _userController.top),
child: PopupMenuButton(
icon: const Icon(Icons.more_vert),
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
@@ -299,7 +261,6 @@ class _MemberPageNewState extends State<MemberPageNew> {
),
const SizedBox(width: 4),
],
),
);
Widget _errorWidget(msg) {
@@ -314,10 +275,7 @@ class _MemberPageNewState extends State<MemberPageNew> {
Loading() => const CircularProgressIndicator(),
Success() => userState.response is Data
? Obx(
() => Padding(
padding: EdgeInsets.only(
bottom: (_userController.tab2?.length ?? 0) > 1 ? 48 : 0),
child: UserInfoCard(
() => UserInfoCard(
isV: isV,
isOwner: _userController.mid == _userController.ownerMid,
relation: _userController.relation.value,
@@ -329,7 +287,6 @@ class _MemberPageNewState extends State<MemberPageNew> {
silence: _userController.silence,
endTime: _userController.endTime,
),
),
)
: GestureDetector(
onTap: _userController.onReload,

View File

@@ -436,13 +436,13 @@ class UserInfoCard extends StatelessWidget {
child: card.officialVerify?.icon?.isNotEmpty == true
? CachedNetworkImage(
imageUrl: card.officialVerify!.icon!.http2https,
width: 24,
height: 24,
width: 22,
height: 22,
)
: Image.asset(
'assets/images/big-vip.png',
width: 24,
height: 24,
width: 22,
height: 22,
),
),
);
@@ -508,8 +508,8 @@ class UserInfoCard extends StatelessWidget {
if (card.officialVerify?.icon?.isNotEmpty == true ||
(card.vip?.vipStatus ?? -1) > 0)
Positioned(
top: 170,
left: 80,
top: 172,
left: 82,
child: _buildBadge(context),
),
if (live is Map && ((live['liveStatus'] as int?) ?? 0) == 1)