mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-20 09:06:36 +08:00
opt episode panel
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -91,7 +91,7 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
|
|||||||
: widget.list[_currentTabIndex.value];
|
: widget.list[_currentTabIndex.value];
|
||||||
|
|
||||||
// item
|
// item
|
||||||
late RxInt _currentItemIndex;
|
late int _currentItemIndex;
|
||||||
int get _findCurrentItemIndex => max(
|
int get _findCurrentItemIndex => max(
|
||||||
0,
|
0,
|
||||||
_getCurrEpisodes.indexWhere((item) => item.cid == widget.cid),
|
_getCurrEpisodes.indexWhere((item) => item.cid == widget.cid),
|
||||||
@@ -118,8 +118,8 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
|
|||||||
|
|
||||||
void jumpToCurrent() {
|
void jumpToCurrent() {
|
||||||
int newItemIndex = _findCurrentItemIndex;
|
int newItemIndex = _findCurrentItemIndex;
|
||||||
if (_currentItemIndex.value != _findCurrentItemIndex) {
|
if (_currentItemIndex != _findCurrentItemIndex) {
|
||||||
_currentItemIndex.value = newItemIndex;
|
_currentItemIndex = newItemIndex;
|
||||||
try {
|
try {
|
||||||
_itemScrollController[_currentTabIndex.value].jumpTo(
|
_itemScrollController[_currentTabIndex.value].jumpTo(
|
||||||
index: newItemIndex,
|
index: newItemIndex,
|
||||||
@@ -161,7 +161,7 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentItemIndex = _findCurrentItemIndex.obs;
|
_currentItemIndex = _findCurrentItemIndex;
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -170,7 +170,7 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
|
|||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
try {
|
try {
|
||||||
_itemScrollController[widget.initialTabIndex]
|
_itemScrollController[widget.initialTabIndex]
|
||||||
.jumpTo(index: _currentItemIndex.value);
|
.jumpTo(index: _currentItemIndex);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -272,18 +272,18 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody(ThemeData theme, int index, episodes) {
|
Widget _buildBody(ThemeData theme, int tabIndex, episodes) {
|
||||||
return KeepAliveWrapper(
|
return KeepAliveWrapper(
|
||||||
builder: (context) => ScrollablePositionedList.separated(
|
builder: (context) => ScrollablePositionedList.separated(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: 7,
|
top: 7,
|
||||||
bottom: MediaQuery.of(context).padding.bottom + 80,
|
bottom: MediaQuery.of(context).padding.bottom + 80,
|
||||||
),
|
),
|
||||||
reverse: _isReversed[index],
|
reverse: _isReversed[tabIndex],
|
||||||
itemCount: episodes.length,
|
itemCount: episodes.length,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int itemIndex) {
|
||||||
final episode = episodes[index];
|
final episode = episodes[itemIndex];
|
||||||
return widget.type == EpisodeType.season &&
|
return widget.type == EpisodeType.season &&
|
||||||
widget.showTitle != false &&
|
widget.showTitle != false &&
|
||||||
episode.pages.length > 1
|
episode.pages.length > 1
|
||||||
@@ -291,17 +291,14 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Obx(
|
_buildEpisodeItem(
|
||||||
() => _buildEpisodeItem(
|
theme: theme,
|
||||||
theme: theme,
|
episode: episode,
|
||||||
episode: episode,
|
index: itemIndex,
|
||||||
index: index,
|
length: episodes.length,
|
||||||
length: episodes.length,
|
isCurrentIndex: tabIndex == widget.initialTabIndex
|
||||||
isCurrentIndex:
|
? itemIndex == _currentItemIndex
|
||||||
_currentTabIndex.value == widget.initialTabIndex
|
: false,
|
||||||
? _currentItemIndex.value == index
|
|
||||||
: false,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
@@ -309,7 +306,7 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
|
|||||||
child: PagesPanel(
|
child: PagesPanel(
|
||||||
list:
|
list:
|
||||||
widget.initialTabIndex == _currentTabIndex.value &&
|
widget.initialTabIndex == _currentTabIndex.value &&
|
||||||
index == _currentItemIndex.value
|
itemIndex == _currentItemIndex
|
||||||
? null
|
? null
|
||||||
: episode.pages,
|
: episode.pages,
|
||||||
cover: episode.arc?.pic,
|
cover: episode.arc?.pic,
|
||||||
@@ -320,20 +317,17 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Obx(
|
: _buildEpisodeItem(
|
||||||
() => _buildEpisodeItem(
|
theme: theme,
|
||||||
theme: theme,
|
episode: episode,
|
||||||
episode: episode,
|
index: itemIndex,
|
||||||
index: index,
|
length: episodes.length,
|
||||||
length: episodes.length,
|
isCurrentIndex: tabIndex == widget.initialTabIndex
|
||||||
isCurrentIndex:
|
? itemIndex == _currentItemIndex
|
||||||
_currentTabIndex.value == widget.initialTabIndex
|
: false,
|
||||||
? _currentItemIndex.value == index
|
|
||||||
: false,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
itemScrollController: _itemScrollController[index],
|
itemScrollController: _itemScrollController[tabIndex],
|
||||||
separatorBuilder: (context, index) => const SizedBox(height: 2),
|
separatorBuilder: (context, index) => const SizedBox(height: 2),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -404,7 +398,7 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
|
|||||||
SmartDialog.showToast('切换到:$title');
|
SmartDialog.showToast('切换到:$title');
|
||||||
widget.onClose?.call();
|
widget.onClose?.call();
|
||||||
if (widget.showTitle == false) {
|
if (widget.showTitle == false) {
|
||||||
_currentItemIndex.value = index;
|
_currentItemIndex = index;
|
||||||
}
|
}
|
||||||
widget.changeFucCall(
|
widget.changeFucCall(
|
||||||
episode is bangumi.EpisodeItem ? episode.epId : null,
|
episode is bangumi.EpisodeItem ? episode.epId : null,
|
||||||
@@ -637,7 +631,7 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
|
|||||||
await Future.delayed(const Duration(milliseconds: 225));
|
await Future.delayed(const Duration(milliseconds: 225));
|
||||||
}
|
}
|
||||||
_itemScrollController[_currentTabIndex.value].scrollTo(
|
_itemScrollController[_currentTabIndex.value].scrollTo(
|
||||||
index: _currentItemIndex.value,
|
index: _currentItemIndex,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
);
|
);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user