2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/domain/entities/setting.dart';
|
|
|
|
|
import 'package:fcs/domain/entities/user.dart';
|
2020-09-04 15:30:10 +06:30
|
|
|
import 'package:flutter/foundation.dart';
|
2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/helpers/api_helper.dart';
|
2020-09-04 15:30:10 +06:30
|
|
|
|
|
|
|
|
import 'main_model.dart';
|
|
|
|
|
|
|
|
|
|
abstract class BaseModel extends ChangeNotifier {
|
2021-09-10 15:15:20 +06:30
|
|
|
User? user;
|
|
|
|
|
Setting? setting;
|
|
|
|
|
MainModel? mainModel;
|
2020-09-04 15:30:10 +06:30
|
|
|
|
|
|
|
|
void initUser(User user) async {
|
|
|
|
|
this.user = user;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-22 03:52:48 +06:30
|
|
|
void privilegeChanged() {}
|
|
|
|
|
|
2021-09-10 15:15:20 +06:30
|
|
|
void initSetting(Setting? setting) async {
|
2020-09-04 15:30:10 +06:30
|
|
|
this.setting = setting;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-13 02:38:16 +06:30
|
|
|
void notify() {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-22 03:52:48 +06:30
|
|
|
void logout() {}
|
2020-09-04 15:30:10 +06:30
|
|
|
|
|
|
|
|
// request makes http request
|
|
|
|
|
// if token is null
|
|
|
|
|
dynamic request(
|
|
|
|
|
String path,
|
|
|
|
|
method, {
|
|
|
|
|
dynamic payload,
|
2021-09-10 15:15:20 +06:30
|
|
|
required String token,
|
|
|
|
|
String? url,
|
2020-09-04 15:30:10 +06:30
|
|
|
}) async {
|
|
|
|
|
return await requestAPI(path, method,
|
|
|
|
|
payload: payload, token: token, url: url);
|
|
|
|
|
}
|
|
|
|
|
}
|