mod: 本地缓存字段修改、登录状态
This commit is contained in:
@ -11,16 +11,17 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
late TabController tabController;
|
||||
late List tabsCtrList;
|
||||
late List<Widget> tabsPageList;
|
||||
Box user = GStrorage.user;
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
RxBool userLogin = false.obs;
|
||||
RxString userFace = ''.obs;
|
||||
var userInfo;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
userLogin.value = user.get(UserBoxKey.userLogin) ?? false;
|
||||
userFace.value = user.get(UserBoxKey.userFace) ?? '';
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
userLogin.value = userInfo != null;
|
||||
userFace.value = userInfo != null ? userInfo.face : '';
|
||||
|
||||
// 进行tabs配置
|
||||
tabs = tabsConfig;
|
||||
@ -48,7 +49,8 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
|
||||
// 更新登录状态
|
||||
void updateLoginStatus(val) {
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
userLogin.value = val ?? false;
|
||||
userFace.value = user.get(UserBoxKey.userFace) ?? '';
|
||||
userFace.value = userInfo != null ? userInfo.face : '';
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,14 @@ import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/pages/mine/view.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
Box user = GStrorage.user;
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
|
||||
class HomeAppBar extends StatelessWidget {
|
||||
const HomeAppBar({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var userInfo = userInfoCache.get('userInfoCache');
|
||||
return SliverAppBar(
|
||||
// forceElevated: true,
|
||||
scrolledUnderElevation: 0,
|
||||
@ -55,7 +56,7 @@ class HomeAppBar extends StatelessWidget {
|
||||
const SizedBox(width: 6),
|
||||
|
||||
/// TODO
|
||||
if (user.get(UserBoxKey.userLogin)) ...[
|
||||
if (userInfo != null) ...[
|
||||
GestureDetector(
|
||||
onTap: () => showModalBottomSheet(
|
||||
context: context,
|
||||
@ -70,7 +71,7 @@ class HomeAppBar extends StatelessWidget {
|
||||
type: 'avatar',
|
||||
width: 32,
|
||||
height: 32,
|
||||
src: user.get(UserBoxKey.userMid),
|
||||
src: userInfo.face,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
|
Reference in New Issue
Block a user