mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-21 17:46:24 +08:00
refa query follow up
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/dynamic/dynamics_type.dart';
|
||||
import 'package:PiliPlus/models/common/dynamic/up_panel_position.dart';
|
||||
import 'package:PiliPlus/models/dynamics/up.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/controller.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/widgets/up_panel.dart';
|
||||
import 'package:PiliPlus/pages/dynamics_create/view.dart';
|
||||
import 'package:PiliPlus/pages/dynamics_tab/view.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart' hide DraggableScrollableSheet;
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -52,29 +52,6 @@ class _DynamicsPageState extends State<DynamicsPage>
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (Pref.dynamicsShowAllFollowedUp) {
|
||||
_dynamicsController.scrollController.addListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
void listener() {
|
||||
if (_dynamicsController.scrollController.position.pixels >=
|
||||
_dynamicsController.scrollController.position.maxScrollExtent - 300) {
|
||||
EasyThrottle.throttle('following', const Duration(seconds: 1), () {
|
||||
_dynamicsController.queryFollowing2();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_dynamicsController.scrollController.removeListener(listener);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget upPanelPart(ThemeData theme) {
|
||||
bool isTop = upPanelPosition == UpPanelPosition.top;
|
||||
bool needBg = upPanelPosition.index > 1;
|
||||
@@ -84,25 +61,28 @@ class _DynamicsPageState extends State<DynamicsPage>
|
||||
child: SizedBox(
|
||||
width: isTop ? null : 64,
|
||||
height: isTop ? 76 : null,
|
||||
child: Obx(
|
||||
() {
|
||||
final upData = _dynamicsController.upData.value;
|
||||
if (upData.upList == null && upData.liveUsers == null) {
|
||||
return const SizedBox.shrink();
|
||||
} else if (upData.errMsg != null) {
|
||||
return Center(
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: _dynamicsController.queryFollowUp,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return UpPanel(dynamicsController: _dynamicsController);
|
||||
}
|
||||
child: Obx(() => _buildUpPanel(_dynamicsController.upState.value)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUpPanel(LoadingState<FollowUpModel> upState) {
|
||||
return switch (upState) {
|
||||
Loading() => const SizedBox.shrink(),
|
||||
Success<FollowUpModel>() => UpPanel(
|
||||
dynamicsController: _dynamicsController,
|
||||
),
|
||||
Error() => Center(
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
_dynamicsController
|
||||
..upState.value = LoadingState<FollowUpModel>.loading()
|
||||
..queryFollowUp();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user