mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-24 02:56:58 +08:00
opt mention
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -4,6 +4,7 @@ import 'dart:math';
|
|||||||
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
|
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
|
||||||
import 'package:PiliPlus/common/widgets/draggable_sheet/draggable_scrollable_sheet_topic.dart'
|
import 'package:PiliPlus/common/widgets/draggable_sheet/draggable_scrollable_sheet_topic.dart'
|
||||||
as topic_sheet;
|
as topic_sheet;
|
||||||
|
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||||
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/models_new/dynamic/dyn_mention/group.dart';
|
import 'package:PiliPlus/models_new/dynamic/dyn_mention/group.dart';
|
||||||
@@ -162,7 +163,31 @@ class _DynMentionPanelState extends State<DynMentionPanel> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Obx(() => _buildBody(theme, _controller.loadingState.value)),
|
child: NotificationListener<ScrollNotification>(
|
||||||
|
onNotification: (notification) {
|
||||||
|
if (notification is UserScrollNotification) {
|
||||||
|
if (_controller.focusNode.hasFocus) {
|
||||||
|
_controller.focusNode.unfocus();
|
||||||
|
}
|
||||||
|
} else if (notification is ScrollEndNotification) {
|
||||||
|
widget.callback?.call(notification.metrics.pixels);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: CustomScrollView(
|
||||||
|
controller: widget.scrollController,
|
||||||
|
slivers: [
|
||||||
|
Obx(() => _buildBody(theme, _controller.loadingState.value)),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: SizedBox(
|
||||||
|
height: MediaQuery.paddingOf(context).bottom +
|
||||||
|
MediaQuery.viewInsetsOf(context).bottom +
|
||||||
|
80,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -171,73 +196,50 @@ class _DynMentionPanelState extends State<DynMentionPanel> {
|
|||||||
Widget _buildBody(
|
Widget _buildBody(
|
||||||
ThemeData theme, LoadingState<List<MentionGroup>?> loadingState) {
|
ThemeData theme, LoadingState<List<MentionGroup>?> loadingState) {
|
||||||
return switch (loadingState) {
|
return switch (loadingState) {
|
||||||
Loading() => loadingWidget,
|
Loading() => SliverPadding(
|
||||||
|
padding: const EdgeInsets.only(top: 8),
|
||||||
|
sliver: linearLoading,
|
||||||
|
),
|
||||||
Success<List<MentionGroup>?>(:var response) =>
|
Success<List<MentionGroup>?>(:var response) =>
|
||||||
response?.isNotEmpty == true
|
response?.isNotEmpty == true
|
||||||
? NotificationListener<ScrollNotification>(
|
? SliverMainAxisGroup(
|
||||||
onNotification: (notification) {
|
slivers: response!.map((group) {
|
||||||
if (notification is UserScrollNotification) {
|
if (group.items.isNullOrEmpty) {
|
||||||
if (_controller.focusNode.hasFocus) {
|
return const SliverToBoxAdapter();
|
||||||
_controller.focusNode.unfocus();
|
|
||||||
}
|
|
||||||
} else if (notification is ScrollEndNotification) {
|
|
||||||
widget.callback?.call(notification.metrics.pixels);
|
|
||||||
}
|
}
|
||||||
return false;
|
return SliverMainAxisGroup(
|
||||||
},
|
slivers: [
|
||||||
child: CustomScrollView(
|
SliverPersistentHeader(
|
||||||
controller: widget.scrollController,
|
pinned: true,
|
||||||
slivers: [
|
delegate: CustomSliverPersistentHeaderDelegate(
|
||||||
...response!.map((group) {
|
extent: 40,
|
||||||
if (group.items!.isNullOrEmpty) {
|
bgColor: theme.colorScheme.surface,
|
||||||
return const SliverToBoxAdapter();
|
child: Container(
|
||||||
}
|
height: 40,
|
||||||
return SliverMainAxisGroup(
|
alignment: Alignment.centerLeft,
|
||||||
slivers: [
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
SliverPersistentHeader(
|
child: Text(group.groupName!),
|
||||||
pinned: true,
|
|
||||||
delegate: CustomSliverPersistentHeaderDelegate(
|
|
||||||
extent: 40,
|
|
||||||
bgColor: theme.colorScheme.surface,
|
|
||||||
child: Container(
|
|
||||||
height: 40,
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 16),
|
|
||||||
child: Text(group.groupName!),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SliverList.builder(
|
),
|
||||||
itemCount: group.items!.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return DynMentionItem(
|
|
||||||
item: group.items![index],
|
|
||||||
onTap: (e) => Get.back(result: e),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: SizedBox(
|
|
||||||
height: MediaQuery.paddingOf(context).bottom +
|
|
||||||
MediaQuery.viewInsetsOf(context).bottom +
|
|
||||||
80,
|
|
||||||
),
|
),
|
||||||
),
|
SliverList.builder(
|
||||||
],
|
itemCount: group.items!.length,
|
||||||
),
|
itemBuilder: (context, index) {
|
||||||
|
return DynMentionItem(
|
||||||
|
item: group.items![index],
|
||||||
|
onTap: (e) => Get.back(result: e),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
)
|
)
|
||||||
: _errWidget(),
|
: HttpError(onReload: _controller.onReload),
|
||||||
Error(:var errMsg) => _errWidget(errMsg),
|
Error(:var errMsg) => HttpError(
|
||||||
|
errMsg: errMsg,
|
||||||
|
onReload: _controller.onReload,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _errWidget([String? errMsg]) => scrollErrorWidget(
|
|
||||||
errMsg: errMsg,
|
|
||||||
controller: widget.scrollController,
|
|
||||||
onReload: _controller.onReload,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,19 @@ class _SelectTopicPanelState extends State<SelectTopicPanel> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Obx(() => _buildBody(theme, _controller.loadingState.value)),
|
child: NotificationListener<ScrollNotification>(
|
||||||
|
onNotification: (notification) {
|
||||||
|
if (notification is UserScrollNotification) {
|
||||||
|
if (_controller.focusNode.hasFocus) {
|
||||||
|
_controller.focusNode.unfocus();
|
||||||
|
}
|
||||||
|
} else if (notification is ScrollEndNotification) {
|
||||||
|
widget.callback?.call(notification.metrics.pixels);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
child: Obx(() => _buildBody(theme, _controller.loadingState.value)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -171,35 +183,23 @@ class _SelectTopicPanelState extends State<SelectTopicPanel> {
|
|||||||
return switch (loadingState) {
|
return switch (loadingState) {
|
||||||
Loading() => loadingWidget,
|
Loading() => loadingWidget,
|
||||||
Success<List<TopicItem>?>(:var response) => response?.isNotEmpty == true
|
Success<List<TopicItem>?>(:var response) => response?.isNotEmpty == true
|
||||||
? NotificationListener<ScrollNotification>(
|
? ListView.builder(
|
||||||
onNotification: (notification) {
|
padding: EdgeInsets.only(
|
||||||
if (notification is UserScrollNotification) {
|
bottom: MediaQuery.paddingOf(context).bottom +
|
||||||
if (_controller.focusNode.hasFocus) {
|
MediaQuery.viewInsetsOf(context).bottom +
|
||||||
_controller.focusNode.unfocus();
|
80,
|
||||||
}
|
|
||||||
} else if (notification is ScrollEndNotification) {
|
|
||||||
widget.callback?.call(notification.metrics.pixels);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
child: ListView.builder(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
bottom: MediaQuery.paddingOf(context).bottom +
|
|
||||||
MediaQuery.viewInsetsOf(context).bottom +
|
|
||||||
80,
|
|
||||||
),
|
|
||||||
controller: widget.scrollController,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
if (index == response.length - 1) {
|
|
||||||
_controller.onLoadMore();
|
|
||||||
}
|
|
||||||
return DynTopicItem(
|
|
||||||
item: response[index],
|
|
||||||
onTap: (item) => Get.back(result: item),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemCount: response!.length,
|
|
||||||
),
|
),
|
||||||
|
controller: widget.scrollController,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == response.length - 1) {
|
||||||
|
_controller.onLoadMore();
|
||||||
|
}
|
||||||
|
return DynTopicItem(
|
||||||
|
item: response[index],
|
||||||
|
onTap: (item) => Get.back(result: item),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: response!.length,
|
||||||
)
|
)
|
||||||
: _errWidget(),
|
: _errWidget(),
|
||||||
Error(:var errMsg) => _errWidget(errMsg),
|
Error(:var errMsg) => _errWidget(errMsg),
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class LiveRoomController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initDm(LiveDmInfoData info) {
|
void initDm(LiveDmInfoData info) {
|
||||||
if (info.hostList!.isNullOrEmpty) {
|
if (info.hostList.isNullOrEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
msgStream = LiveMessageStream(
|
msgStream = LiveMessageStream(
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class _PgcPageState extends CommonPageState<PgcPage, PgcController>
|
|||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
children: response.map((item) {
|
children: response.map((item) {
|
||||||
if (item.episodes!.isNullOrEmpty) {
|
if (item.episodes.isNullOrEmpty) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
|
|||||||
Reference in New Issue
Block a user