|
|
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:injectable/injectable.dart';
|
|
|
import 'package:keyboard/base/base_controller.dart';
|
|
|
+import 'package:keyboard/data/repository/account_repository.dart';
|
|
|
import 'package:keyboard/data/repository/characters_repository.dart';
|
|
|
import 'package:keyboard/dialog/character_details_dialog.dart';
|
|
|
import 'package:keyboard/module/character/character_controller.dart';
|
|
|
@@ -27,7 +28,14 @@ class CharacterGroupContentController extends BaseController {
|
|
|
Get.find<CharacterController>().currentCharacterGroupInfo;
|
|
|
final CharactersRepository charactersRepository;
|
|
|
|
|
|
- CharacterGroupContentController(this.charactersRepository);
|
|
|
+ final AccountRepository accountRepository;
|
|
|
+
|
|
|
+ bool get isLogin => accountRepository.isLogin.value;
|
|
|
+
|
|
|
+ CharacterGroupContentController(
|
|
|
+ this.charactersRepository,
|
|
|
+ this.accountRepository,
|
|
|
+ );
|
|
|
|
|
|
RxList<CharacterInfo> characterList = <CharacterInfo>[].obs;
|
|
|
RxInt currentListCount = 0.obs;
|
|
|
@@ -102,6 +110,10 @@ class CharacterGroupContentController extends BaseController {
|
|
|
|
|
|
void itemButtonClick(CharacterInfo characterInfo) {
|
|
|
AtmobLog.d(tag, 'characterInfo ${characterInfo.toJson()} ');
|
|
|
+ if (isLogin == false) {
|
|
|
+ ToastUtil.show('请先登录~');
|
|
|
+ return;
|
|
|
+ }
|
|
|
CharacterDetailsDialog.show(
|
|
|
characterInfo: characterInfo,
|
|
|
clickCallback: () {
|
|
|
@@ -130,10 +142,13 @@ class CharacterGroupContentController extends BaseController {
|
|
|
|
|
|
ToastUtil.show('添加成功~');
|
|
|
} catch (error) {
|
|
|
- if (error is ServerErrorException && error.code == 1005) {
|
|
|
- StorePage.start();
|
|
|
-
|
|
|
- ErrorHandler.toastError(error);
|
|
|
+ if (error is ServerErrorException) {
|
|
|
+ if (error.code == 1005) {
|
|
|
+ StorePage.start();
|
|
|
+ ToastUtil.show(error.message);
|
|
|
+ } else {
|
|
|
+ ToastUtil.show(error.message);
|
|
|
+ }
|
|
|
} else {
|
|
|
ErrorHandler.toastError(error);
|
|
|
}
|
|
|
@@ -156,9 +171,12 @@ class CharacterGroupContentController extends BaseController {
|
|
|
ToastUtil.show('解锁成功~');
|
|
|
})
|
|
|
.catchError((error) {
|
|
|
- if (error is ServerErrorException && error.code == 1005) {
|
|
|
- ToastUtil.show('请开通会员解锁权益~');
|
|
|
- StorePage.start();
|
|
|
+ if (error is ServerErrorException) {
|
|
|
+ if (error.code == 1005) {
|
|
|
+ ToastUtil.show('请开通会员解锁权益~');
|
|
|
+ StorePage.start();
|
|
|
+ }
|
|
|
+ ToastUtil.show(error.message);
|
|
|
} else {
|
|
|
ErrorHandler.toastError(error);
|
|
|
}
|