pageview backwarding bug fixed
This commit is contained in:
parent
085ee82c4b
commit
e5bae19f14
|
|
@ -44,7 +44,9 @@ class _NewsDetailsState extends State<NewsDetails> {
|
|||
builder: (context, state) => Stack(
|
||||
children: [
|
||||
if (state.news.isNotEmpty)
|
||||
DidvanPageView(
|
||||
IgnorePointer(
|
||||
ignoring: state.isFetchingNewItem,
|
||||
child: DidvanPageView(
|
||||
isRadar: false,
|
||||
initialIndex: state.initialIndex,
|
||||
onPageChanged: _onPageChnaged,
|
||||
|
|
@ -52,6 +54,7 @@ class _NewsDetailsState extends State<NewsDetails> {
|
|||
items: state.news,
|
||||
currentIndex: state.currentIndex,
|
||||
),
|
||||
),
|
||||
if (state.news.isNotEmpty)
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class NewsDetailsState extends CoreProvier {
|
|||
late final NewsRequestArgs args;
|
||||
late Timer _trackingTimer;
|
||||
int _trackingTimerCounter = 0;
|
||||
bool isFetchingNewItem = false;
|
||||
final List<int> relatedQueue = [];
|
||||
|
||||
int _currentIndex = 0;
|
||||
|
|
@ -25,6 +26,9 @@ class NewsDetailsState extends CoreProvier {
|
|||
Future<void> getNewsDetails(int id, {bool? isForward}) async {
|
||||
if (isForward == null) {
|
||||
appState = AppState.busy;
|
||||
} else {
|
||||
isFetchingNewItem = true;
|
||||
notifyListeners();
|
||||
}
|
||||
final service = RequestService(RequestHelper.newsDetails(id, args));
|
||||
await service.httpGet();
|
||||
|
|
@ -67,6 +71,7 @@ class NewsDetailsState extends CoreProvier {
|
|||
}
|
||||
_currentIndex--;
|
||||
}
|
||||
isFetchingNewItem = false;
|
||||
appState = AppState.idle;
|
||||
return;
|
||||
}
|
||||
|
|
@ -97,8 +102,11 @@ class NewsDetailsState extends CoreProvier {
|
|||
Future<void> getRelatedContents() async {
|
||||
if (currentNews.relatedContents.isNotEmpty) return;
|
||||
relatedQueue.add(currentNews.id);
|
||||
final service = RequestService(
|
||||
RequestHelper.tag(currentNews.tags.map((tag) => tag.id).toList()));
|
||||
final service = RequestService(RequestHelper.tag(
|
||||
ids: currentNews.tags.map((tag) => tag.id).toList(),
|
||||
itemId: currentNews.id,
|
||||
type: 'news',
|
||||
));
|
||||
await service.httpGet();
|
||||
if (service.isSuccess) {
|
||||
final relateds = service.result['contents'];
|
||||
|
|
|
|||
|
|
@ -44,7 +44,9 @@ class _RadarDetailsState extends State<RadarDetails> {
|
|||
builder: (context, state) => Stack(
|
||||
children: [
|
||||
if (state.radars.isNotEmpty)
|
||||
DidvanPageView(
|
||||
IgnorePointer(
|
||||
ignoring: state.isFetchingNewItem,
|
||||
child: DidvanPageView(
|
||||
isRadar: true,
|
||||
initialIndex: state.initialIndex,
|
||||
onPageChanged: _onPageChanged,
|
||||
|
|
@ -52,6 +54,7 @@ class _RadarDetailsState extends State<RadarDetails> {
|
|||
items: state.radars,
|
||||
currentIndex: state.currentIndex,
|
||||
),
|
||||
),
|
||||
if (state.radars.isNotEmpty)
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class RadarDetailsState extends CoreProvier {
|
|||
int _trackingTimerCounter = 0;
|
||||
late final int initialIndex;
|
||||
late final RadarRequestArgs args;
|
||||
bool isFetchingNewItem = false;
|
||||
final List<int> relatedQueue = [];
|
||||
|
||||
int _currentIndex = 0;
|
||||
|
|
@ -31,6 +32,9 @@ class RadarDetailsState extends CoreProvier {
|
|||
Future<void> getRadarDetails(int id, {bool? isForward}) async {
|
||||
if (isForward == null) {
|
||||
appState = AppState.busy;
|
||||
} else {
|
||||
isFetchingNewItem = true;
|
||||
notifyListeners();
|
||||
}
|
||||
final service = RequestService(RequestHelper.radarDetails(id, args));
|
||||
await service.httpGet();
|
||||
|
|
@ -76,6 +80,7 @@ class RadarDetailsState extends CoreProvier {
|
|||
}
|
||||
_currentIndex--;
|
||||
}
|
||||
isFetchingNewItem = false;
|
||||
appState = AppState.idle;
|
||||
return;
|
||||
}
|
||||
|
|
@ -88,8 +93,11 @@ class RadarDetailsState extends CoreProvier {
|
|||
Future<void> getRelatedContents() async {
|
||||
if (currentRadar.relatedContents.isNotEmpty) return;
|
||||
relatedQueue.add(currentRadar.id);
|
||||
final service = RequestService(
|
||||
RequestHelper.tag(currentRadar.tags.map((tag) => tag.id).toList()));
|
||||
final service = RequestService(RequestHelper.tag(
|
||||
ids: currentRadar.tags.map((tag) => tag.id).toList(),
|
||||
itemId: currentRadar.id,
|
||||
type: 'news',
|
||||
));
|
||||
await service.httpGet();
|
||||
if (service.isSuccess) {
|
||||
final relateds = service.result['contents'];
|
||||
|
|
|
|||
Loading…
Reference in New Issue