Browse Source

个人信息刷新

ff_new
w-R 3 years ago
parent
commit
e823db7b27
  1. 2
      lib/community/community_view/community_dynamic.dart
  2. 39
      lib/mine/mine_page.dart

2
lib/community/community_view/community_dynamic.dart

@ -335,6 +335,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
child: MImage( child: MImage(
subjectInfo.images[0], subjectInfo.images[0],
fit: BoxFit.cover, fit: BoxFit.cover,
radius: BorderRadius.circular(2),
width: MediaQuery.of(context).size.width / 1.5, width: MediaQuery.of(context).size.width / 1.5,
height: MediaQuery.of(context).size.width / 1.5, height: MediaQuery.of(context).size.width / 1.5,
errorSrc: "assets/image/default_2_1.png", errorSrc: "assets/image/default_2_1.png",
@ -365,6 +366,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
subjectInfo.images[position], subjectInfo.images[position],
fit: BoxFit.cover, fit: BoxFit.cover,
aspectRatio: 1, aspectRatio: 1,
radius: BorderRadius.circular(1),
errorSrc: "assets/image/default_2_1.png", errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png", fadeSrc: "assets/image/default_2_1.png",
), ),

39
lib/mine/mine_page.dart

@ -7,9 +7,7 @@ import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/main.dart'; import 'package:huixiang/main.dart';
import 'package:huixiang/mine/mine_view/mine_order.dart'; import 'package:huixiang/mine/mine_view/mine_order.dart';
import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/comunity_comment.dart';
import 'package:huixiang/retrofit/data/rank.dart'; import 'package:huixiang/retrofit/data/rank.dart';
import 'package:huixiang/retrofit/data/sign_info.dart';
import 'package:huixiang/retrofit/data/social_info.dart'; import 'package:huixiang/retrofit/data/social_info.dart';
import 'package:huixiang/retrofit/data/user_info.dart'; import 'package:huixiang/retrofit/data/user_info.dart';
import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart';
@ -34,7 +32,7 @@ class MinePage extends StatefulWidget {
} }
} }
class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin { class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin ,WidgetsBindingObserver{
ApiService apiService; ApiService apiService;
UserInfo userInfo; UserInfo userInfo;
List<Rank> ranks = []; List<Rank> ranks = [];
@ -55,12 +53,31 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
if (_refreshController != null) _refreshController.dispose(); if (_refreshController != null)
_refreshController.dispose();
WidgetsBinding.instance.removeObserver(this); //
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
print("-didChangeAppLifecycleState-" + state.toString());
switch (state) {
case AppLifecycleState.inactive: //
break;
case AppLifecycleState.resumed: //
querySocialInfo();
break;
case AppLifecycleState.paused: //
break;
case AppLifecycleState.detached: // APP结束时调用
break;
}
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance.addObserver(this);
querySocialInfo(); querySocialInfo();
eventBus.on<EventType>().listen((event) { eventBus.on<EventType>().listen((event) {
@ -117,6 +134,11 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
EasyLoading.dismiss(); EasyLoading.dismiss();
} }
_onRefresh(){
queryUserInfo();
querySocialInfo();
}
///(//) ///(//)
querySocialInfo() async { querySocialInfo() async {
SharedPreferences value = await SharedPreferences.getInstance(); SharedPreferences value = await SharedPreferences.getInstance();
@ -128,9 +150,12 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
); );
BaseData<SocialInfo> baseData = BaseData<SocialInfo> baseData =
await apiService.socialInfo().catchError((onError) {}); await apiService.socialInfo().catchError((onError) {
_refreshController.refreshFailed();
});
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
infoNumber = baseData.data; infoNumber = baseData.data;
_refreshController.refreshCompleted();
} }
EasyLoading.dismiss(); EasyLoading.dismiss();
} }
@ -150,7 +175,9 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
header: MyHeader(), header: MyHeader(),
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
onRefresh: () { onRefresh: () {
setState(() {}); setState(() {
_onRefresh();
});
}, },
child: SingleChildScrollView( child: SingleChildScrollView(
child: Container( child: Container(

Loading…
Cancel
Save