|
|
@@ -15,19 +15,23 @@ class AccountRepository {
|
|
|
final ACCOUNT_TOKEN = 'account_token';
|
|
|
final ACCOUNT_PHONE = 'account_phone';
|
|
|
|
|
|
- String? token;
|
|
|
- String? phone;
|
|
|
+ String? _token;
|
|
|
+ String? _phone;
|
|
|
final isLogin = false.obs;
|
|
|
|
|
|
AccountRepository._() {
|
|
|
debugPrint('AccountRepository init');
|
|
|
- token = KVUtil.getString(ACCOUNT_TOKEN, null);
|
|
|
- phone = KVUtil.getString(ACCOUNT_PHONE, null);
|
|
|
- if (token != null && token!.isNotEmpty) {
|
|
|
+ _token = KVUtil.getString(ACCOUNT_TOKEN, null);
|
|
|
+ _phone = KVUtil.getString(ACCOUNT_PHONE, null);
|
|
|
+ if (_token != null && _token!.isNotEmpty) {
|
|
|
isLogin.value = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ String? get phone => _phone;
|
|
|
+
|
|
|
+ String? get token => _token;
|
|
|
+
|
|
|
Future<void> getVerificationCode(String phone) {
|
|
|
return atmobApi
|
|
|
.getVerificationCode(VerificationCodeRequest(phone))
|
|
|
@@ -46,16 +50,16 @@ class AccountRepository {
|
|
|
}
|
|
|
|
|
|
void onLoginSuccess(String phone, String? token) {
|
|
|
- this.token = token;
|
|
|
- this.phone = phone;
|
|
|
+ this._token = token;
|
|
|
+ this._phone = phone;
|
|
|
KVUtil.putString(ACCOUNT_TOKEN, token);
|
|
|
KVUtil.putString(ACCOUNT_PHONE, phone);
|
|
|
isLogin.value = true;
|
|
|
}
|
|
|
|
|
|
void logout() {
|
|
|
- token = null;
|
|
|
- phone = null;
|
|
|
+ _phone = null;
|
|
|
+ _phone = null;
|
|
|
KVUtil.putString(ACCOUNT_TOKEN, null);
|
|
|
KVUtil.putString(ACCOUNT_PHONE, null);
|
|
|
isLogin.value = false;
|