Browse Source

fix : 没有企业、问题时无法下拉刷新

dev
徐振升 2 months ago
parent
commit
a25bf1ef1b
  1. 43
      lib/app/features/enterprise/presentation/pages/enterprise_list_page.dart
  2. 44
      lib/app/features/problem/presentation/pages/problem_list_page.dart

43
lib/app/features/enterprise/presentation/pages/enterprise_list_page.dart

@ -180,15 +180,27 @@ class EnterpriseListPage extends GetView<EnterpriseListController> {
/// ///
Widget _buildEnterpriseList() { Widget _buildEnterpriseList() {
// 使 Obx controller Rx // 使
return Obx(() { return RefreshIndicator(
// onRefresh: () async => controller.loadAndSyncEnterprises(),
if (controller.isLoading.value) { child: Obx(() {
// 3.
if (controller.isLoading.value && controller.enterpriseList.isEmpty) {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
} }
//
// 4. ListView
if (controller.enterpriseList.isEmpty) { if (controller.enterpriseList.isEmpty) {
return Center( // 使 ListView AlwaysScrollableScrollPhysics
return ListView(
// [!!!] ListView 使
physics: const AlwaysScrollableScrollPhysics(),
children: [
//
SizedBox(
// Expanded
height: Get.height * 0.5, //
child: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@ -200,17 +212,19 @@ class EnterpriseListPage extends GetView<EnterpriseListController> {
SizedBox(height: 16.h), SizedBox(height: 16.h),
Text( Text(
'没有找到相关企业', '没有找到相关企业',
style: TextStyle(fontSize: 16.sp, color: Colors.grey[600]), style: TextStyle(
fontSize: 16.sp,
color: Colors.grey[600],
),
), ),
], ],
), ),
),
),
],
); );
} }
return ListView.builder(
// 使
return RefreshIndicator(
onRefresh: () async => controller.loadAndSyncEnterprises(),
child: ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
itemCount: controller.enterpriseList.length, itemCount: controller.enterpriseList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -296,8 +310,9 @@ class EnterpriseListPage extends GetView<EnterpriseListController> {
), ),
); );
}, },
),
); );
}); }),
);
// });
} }
} }

44
lib/app/features/problem/presentation/pages/problem_list_page.dart

@ -273,15 +273,27 @@ class ProblemListPage extends GetView<ProblemListController> {
/// ///
Widget _buildEnterpriseList() { Widget _buildEnterpriseList() {
// 使 Obx controller Rx // 使
return Obx(() { return RefreshIndicator(
// onRefresh: () async => controller.loadAndSyncProblems(),
if (controller.isLoading.value) { child: Obx(() {
// 3.
if (controller.isLoading.value && controller.enterpriseList.isEmpty) {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
} }
//
if (controller.problemList.isEmpty) { // 4. ListView
return Center( if (controller.enterpriseList.isEmpty) {
// 使 ListView AlwaysScrollableScrollPhysics
return ListView(
// [!!!] ListView 使
physics: const AlwaysScrollableScrollPhysics(),
children: [
//
SizedBox(
// Expanded
height: Get.height * 0.5, //
child: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
@ -293,17 +305,20 @@ class ProblemListPage extends GetView<ProblemListController> {
SizedBox(height: 16.h), SizedBox(height: 16.h),
Text( Text(
'没有找到相关问题', '没有找到相关问题',
style: TextStyle(fontSize: 16.sp, color: Colors.grey[600]), style: TextStyle(
fontSize: 16.sp,
color: Colors.grey[600],
),
), ),
], ],
), ),
),
),
],
); );
} }
// 使 return ListView.builder(
return RefreshIndicator(
onRefresh: () async => controller.loadAndSyncProblems(),
child: ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
itemCount: controller.problemList.length, itemCount: controller.problemList.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
@ -388,8 +403,9 @@ class ProblemListPage extends GetView<ProblemListController> {
), ),
); );
}, },
),
); );
}); }),
);
// });
} }
} }

Loading…
Cancel
Save