73 lines
1.6 KiB
Dart
73 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:starwork_flutter/common/constant/app_toast_messages.dart';
|
|
import 'package:starwork_flutter/common/widgets/custom_dialog_widget.dart';
|
|
|
|
class BaseController extends GetxController {
|
|
void showToast(String message) {
|
|
EasyLoading.showToast(message);
|
|
}
|
|
|
|
void showFunctionNotOpen() {
|
|
EasyLoading.showToast('功能未开放'.tr);
|
|
}
|
|
|
|
void showLoading() {
|
|
if (EasyLoading.isShow) {
|
|
return;
|
|
}
|
|
EasyLoading.show(status: AppToastMessages.loading);
|
|
}
|
|
|
|
void hideLoading() {
|
|
EasyLoading.dismiss();
|
|
}
|
|
|
|
void showSuccess({String message = '操作成功'}) {
|
|
EasyLoading.showSuccess(message.tr);
|
|
}
|
|
|
|
void showUpdateSuccess() {
|
|
EasyLoading.showSuccess('修改成功'.tr);
|
|
}
|
|
|
|
void showError({String message = '操作失败'}) {
|
|
EasyLoading.showError(message.tr);
|
|
}
|
|
|
|
void showCustomDialog(
|
|
{required String title, required Widget content, required VoidCallback onConfirm, String? confirmText}) {
|
|
Get.dialog(
|
|
CustomDialogWidget(
|
|
title: title,
|
|
content: content,
|
|
onConfirm: onConfirm,
|
|
confirmText: confirmText,
|
|
),
|
|
barrierDismissible: false, // 点击遮罩是否关闭
|
|
useSafeArea: true, // 推荐保持默认
|
|
);
|
|
}
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
if (EasyLoading.isShow) {
|
|
EasyLoading.dismiss();
|
|
}
|
|
super.onClose();
|
|
}
|
|
|
|
}
|