mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 08:38:18 +08:00
@@ -66,10 +66,13 @@ class _UpowerRankPageState extends State<UpowerRankPage>
|
||||
if (widget.privilegeType == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Obx(() => _controller.name.value == null
|
||||
? const SizedBox.shrink()
|
||||
: Text(
|
||||
'${_controller.name.value} 充电排行榜${_controller.memberTotal == 0 ? '' : '(${_controller.memberTotal})'}')),
|
||||
title: Obx(() {
|
||||
final name = _controller.name.value;
|
||||
return name == null
|
||||
? const SizedBox.shrink()
|
||||
: Text(
|
||||
'$name 充电排行榜${_controller.memberTotal == 0 ? '' : '(${_controller.memberTotal})'}');
|
||||
}),
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
@@ -78,58 +81,62 @@ class _UpowerRankPageState extends State<UpowerRankPage>
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 625),
|
||||
child: Obx(
|
||||
() => _controller.tabs.value != null
|
||||
? DefaultTabController(
|
||||
length: _controller.tabs.value!.length,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
return Column(
|
||||
children: [
|
||||
TabBar(
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
tabs: _controller.tabs.value!
|
||||
.map((e) => Tab(
|
||||
text:
|
||||
'${e.name!}(${e.memberTotal ?? 0})'))
|
||||
.toList(),
|
||||
onTap: (index) {
|
||||
if (!DefaultTabController.of(context)
|
||||
.indexIsChanging) {
|
||||
try {
|
||||
if (index == 0) {
|
||||
_controller.animateToTop();
|
||||
} else {
|
||||
Get.find<UpowerRankController>(
|
||||
tag:
|
||||
'$_tag${_controller.tabs.value![index].privilegeType}')
|
||||
.animateToTop();
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: tabBarView(
|
||||
children: [
|
||||
KeepAliveWrapper(
|
||||
builder: (context) => child),
|
||||
..._controller.tabs.value!
|
||||
.sublist(1)
|
||||
.map((e) => UpowerRankPage(
|
||||
upMid: _upMid,
|
||||
tag: _tag,
|
||||
privilegeType: e.privilegeType,
|
||||
))
|
||||
],
|
||||
() {
|
||||
final tabs = _controller.tabs.value;
|
||||
return tabs != null
|
||||
? DefaultTabController(
|
||||
length: tabs.length,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
return Column(
|
||||
children: [
|
||||
TabBar(
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
tabs: tabs
|
||||
.map((e) => Tab(
|
||||
text:
|
||||
'${e.name!}(${e.memberTotal ?? 0})'))
|
||||
.toList(),
|
||||
onTap: (index) {
|
||||
if (!DefaultTabController.of(context)
|
||||
.indexIsChanging) {
|
||||
try {
|
||||
if (index == 0) {
|
||||
_controller.animateToTop();
|
||||
} else {
|
||||
Get.find<UpowerRankController>(
|
||||
tag:
|
||||
'$_tag${tabs[index].privilegeType}')
|
||||
.animateToTop();
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
: child,
|
||||
Expanded(
|
||||
child: tabBarView(
|
||||
children: [
|
||||
KeepAliveWrapper(
|
||||
builder: (context) => child),
|
||||
...tabs
|
||||
.sublist(1)
|
||||
.map((e) => UpowerRankPage(
|
||||
upMid: _upMid,
|
||||
tag: _tag,
|
||||
privilegeType:
|
||||
e.privilegeType,
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
: child;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user