opt: common ctr

opt: state

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-11 12:21:42 +08:00
parent 5bff1747e6
commit 574bf861f0
129 changed files with 1065 additions and 1058 deletions

View File

@@ -50,7 +50,7 @@ class LiveAreaChildController
@override
Future<LoadingState<LiveSecondData>> customGetData() =>
LiveHttp.liveSecondList(
pn: currentPage,
pn: page,
isLogin: isLogin,
areaId: areaId,
parentAreaId: parentAreaId,

View File

@@ -74,7 +74,7 @@ class _LiveAreaChildPageState extends State<LiveAreaChildPage>
childCount: 10,
),
),
Success() => SliverMainAxisGroup(
Success(:var response) => SliverMainAxisGroup(
slivers: [
if (_controller.newTags?.isNotEmpty == true)
SliverToBoxAdapter(
@@ -111,7 +111,7 @@ class _LiveAreaChildPageState extends State<LiveAreaChildPage>
),
),
),
loadingState.response?.isNotEmpty == true
response?.isNotEmpty == true
? SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: StyleString.cardSpace,
@@ -123,13 +123,12 @@ class _LiveAreaChildPageState extends State<LiveAreaChildPage>
),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == loadingState.response!.length - 1) {
if (index == response.length - 1) {
_controller.onLoadMore();
}
return LiveCardVApp(
item: loadingState.response![index]);
return LiveCardVApp(item: response[index]);
},
childCount: loadingState.response!.length,
childCount: response!.length,
),
)
: HttpError(
@@ -137,8 +136,8 @@ class _LiveAreaChildPageState extends State<LiveAreaChildPage>
),
],
),
Error() => HttpError(
errMsg: loadingState.errMsg,
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _controller.onReload,
),
};

View File

@@ -58,10 +58,10 @@ class _LiveAreaDetailPageState extends State<LiveAreaDetailPage> {
ThemeData theme, LoadingState<List<AreaItem>?> loadingState) {
return switch (loadingState) {
Loading() => const SizedBox.shrink(),
Success() => loadingState.response?.isNotEmpty == true
Success(:var response) => response?.isNotEmpty == true
? DefaultTabController(
initialIndex: _controller.initialIndex,
length: loadingState.response!.length,
length: response!.length,
child: Builder(
builder: (context) {
return Column(
@@ -75,7 +75,7 @@ class _LiveAreaDetailPageState extends State<LiveAreaDetailPage> {
dividerColor: Colors.transparent,
isScrollable: true,
tabAlignment: TabAlignment.start,
tabs: loadingState.response!
tabs: response
.map((e) => Tab(text: e.name ?? ''))
.toList(),
),
@@ -85,7 +85,7 @@ class _LiveAreaDetailPageState extends State<LiveAreaDetailPage> {
icon: Icons.menu,
bgColor: Colors.transparent,
onPressed: () {
_showTags(context, theme, loadingState.response!);
_showTags(context, theme, response);
},
),
],
@@ -93,7 +93,7 @@ class _LiveAreaDetailPageState extends State<LiveAreaDetailPage> {
const Divider(height: 1),
Expanded(
child: tabBarView(
children: loadingState.response!
children: response
.map((e) => LiveAreaChildPage(
areaId: e.id,
parentAreaId: e.parentId,