94 lines
2.6 KiB
Dart
94 lines
2.6 KiB
Dart
|
|
import 'dart:async';
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/appRouters.dart';
|
|
|
|
import '../login/login/entity/LoginEntity.dart';
|
|
import '../translations/trans_lib.dart';
|
|
import 'manager/client_manager.dart';
|
|
|
|
class BaseGetXController extends GetxController{
|
|
int currentTimeSeconds = 0;
|
|
|
|
bool currentPage = true;
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
Get.log('$runtimeType onReady');
|
|
currentPage = true;
|
|
}
|
|
|
|
@override
|
|
// TODO: implement onDelete
|
|
InternalFinalCallback<void> get onDelete => super.onDelete;
|
|
|
|
@override
|
|
// TODO: implement onStart
|
|
InternalFinalCallback<void> get onStart => super.onStart;
|
|
|
|
@override
|
|
void onInit() {
|
|
// TODO: implement onInit
|
|
Get.log('$runtimeType onInit ');
|
|
super.onInit();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
// TODO: implement onClose
|
|
super.onClose();
|
|
currentPage = false;
|
|
Get.log('onClose -----> $runtimeType');
|
|
}
|
|
|
|
operationFailedCallBack(e){
|
|
showOperationFailed();
|
|
}
|
|
|
|
Future delay({Duration? duration,Function? something}) => Future.delayed(duration ?? 500. milliseconds,something as FutureOr Function()?);
|
|
|
|
void showEasyLoading() => EasyLoading.show();
|
|
|
|
void dismissEasyLoading() => EasyLoading.dismiss();
|
|
|
|
void showToast(String status,{Function? something}) {
|
|
EasyLoading.showToast(status,duration: 2000.milliseconds);
|
|
if(something != null) {
|
|
delay(duration: 2100.milliseconds,something: something);
|
|
}
|
|
}
|
|
|
|
void showError(String status,{Function? something}) {
|
|
EasyLoading.showError(status,duration: 2000.milliseconds);
|
|
if(something != null) {
|
|
delay(duration: 2100.milliseconds,something: something);
|
|
}
|
|
}
|
|
|
|
void showSuccess(String status,{Function? something}) {
|
|
EasyLoading.showSuccess(status,duration: 1500.milliseconds);
|
|
if(something != null) {
|
|
delay(duration: 2000.milliseconds,something: something);
|
|
}
|
|
}
|
|
|
|
void showOperationSuccessful({String? status,Function? something}) => showSuccess( status ?? "成功",something: something);
|
|
void showOperationFailed({String? status, Function? something}) => showError( status ?? "失败",something: something);
|
|
|
|
void logOff() async {
|
|
await ClientManager().logOff();
|
|
Get.offAllNamed(Routers.starLockLoginPage);
|
|
}
|
|
|
|
// Future loginSuccess({LoginEntity? loginEntity, bool byToken = false}) async => ClientManager().loginSuccess(loginEntity: loginEntity,byToken: byToken);
|
|
}
|
|
|
|
|
|
///Extension_Int
|
|
extension Extension_Int on int {
|
|
bool get codeIsSuccessful => this == 0;
|
|
bool get msgCodeIsSuccessful => this == 1;
|
|
} |