Browse Source

fix : 返回被不确定的snackbar阻塞

dev
徐振升 2 weeks ago
parent
commit
f157925fa1
  1. 8
      lib/app/features/enterprise/presentation/controllers/enterprise_form_controller.dart
  2. 9
      lib/app/features/enterprise/presentation/controllers/enterprise_list_controller.dart
  3. 14
      lib/app/features/enterprise/presentation/pages/enterprise_list_page.dart

8
lib/app/features/enterprise/presentation/controllers/enterprise_form_controller.dart

@ -134,9 +134,8 @@ class EnterpriseFormController extends GetxController {
contactPhone: contactPhoneController.text, contactPhone: contactPhoneController.text,
majorHazardsDescription: hazardSourceController.text, majorHazardsDescription: hazardSourceController.text,
); );
Get.back(result: true); //
// [] Get.back(result: true, closeOverlays: true); //
Get.snackbar('成功', '企业信息已保存');
} catch (e) { } catch (e) {
// [] // []
Get.snackbar('错误', '保存失败,请稍后重试'); Get.snackbar('错误', '保存失败,请稍后重试');
@ -170,8 +169,7 @@ class EnterpriseFormController extends GetxController {
await editEnterpriseUsecase!(updatedEnterprise); await editEnterpriseUsecase!(updatedEnterprise);
// 4. // 4.
Get.back(result: true); Get.back(result: true, closeOverlays: true);
Get.snackbar('成功', '企业信息已更新');
} catch (e) { } catch (e) {
// 5. // 5.
Get.snackbar('错误', '更新失败,请稍后重试'); Get.snackbar('错误', '更新失败,请稍后重试');

9
lib/app/features/enterprise/presentation/controllers/enterprise_list_controller.dart

@ -55,11 +55,6 @@ class EnterpriseListController extends GetxController {
fetchEnterprises(); fetchEnterprises();
} }
void onItemTap(EnterpriseListItem item) {
//
navigateToEnterpriseInfoPage(item.enterprise);
}
void onSelectionChanged(Enterprise enterprise) { void onSelectionChanged(Enterprise enterprise) {
// //
// //
@ -92,7 +87,8 @@ class EnterpriseListController extends GetxController {
arguments: {'data': enterprise, 'mode': FormMode.edit}, arguments: {'data': enterprise, 'mode': FormMode.edit},
); );
if (result == true) { if (result == true) {
search(); // true search();
Get.snackbar('成功', '企业信息已更新');
} }
} }
@ -104,6 +100,7 @@ class EnterpriseListController extends GetxController {
); );
if (result == true) { if (result == true) {
search(); search();
Get.snackbar('成功', '企业信息已保存');
} }
} }

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

@ -222,7 +222,8 @@ class EnterpriseListPage extends GetView<EnterpriseListController> {
isSelected: isSelected, isSelected: isSelected,
// itemMode mode // itemMode mode
// --- [] controller --- // --- [] controller ---
onTap: () => controller.onItemTap(item), onTap: () =>
controller.navigateToEnterpriseInfoPage(item.enterprise),
// [] actions // [] actions
actions: Row( actions: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -231,9 +232,8 @@ class EnterpriseListPage extends GetView<EnterpriseListController> {
children: [ children: [
// //
TextButton.icon( TextButton.icon(
onPressed: () { onPressed: () =>
/* 编辑逻辑 */ controller.navigateToEditForm(item.enterprise),
},
icon: Icon( icon: Icon(
Icons.edit_outlined, Icons.edit_outlined,
size: 16.sp, size: 16.sp,
@ -257,9 +257,9 @@ class EnterpriseListPage extends GetView<EnterpriseListController> {
// () // ()
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () => controller.navigateToEnterpriseInfoPage(
/* 查看问题逻辑 */ item.enterprise,
}, ),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF42A5F5), backgroundColor: const Color(0xFF42A5F5),
foregroundColor: Colors.white, foregroundColor: Colors.white,

Loading…
Cancel
Save