重写avatar

hmxc
小赖 4 years ago
parent 5d65480cd5
commit 0be5099251

@ -56,6 +56,11 @@ class UserProvider extends ChangeNotifier {
return USER_INFO.UserInfoModel.fromJson(model.data); return USER_INFO.UserInfoModel.fromJson(model.data);
} }
logout() {
_isLogin = false;
notifyListeners();
}
bool _isSigned = false; bool _isSigned = false;
/// ///

@ -11,14 +11,8 @@ class AgreementPage extends StatelessWidget {
title: '服务协议', title: '服务协议',
body: SingleChildScrollView( body: SingleChildScrollView(
padding: EdgeInsets.all(16.w), padding: EdgeInsets.all(16.w),
child: Column( child: Text(
children: [ '''
Text(
'《服务协议》',
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 35.w),
),
Text(
'''
使APP 使APP
使APP使 使APP使
@ -217,11 +211,9 @@ class AgreementPage extends StatelessWidget {
20201021 20201021
''', ''',
style: TextStyle( style: TextStyle(
fontSize: 30.w, fontSize: 30.w,
), ),
),
],
), ),
), ),
); );

@ -23,6 +23,7 @@ import 'package:aku_community_manager/ui/sub_pages/visitor_manager/visitor_manag
import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_and_fix_page.dart'; import 'package:aku_community_manager/ui/sub_pages/business_and_fix/business_and_fix_page.dart';
import 'package:aku_community_manager/ui/tool_pages/scan_page.dart'; import 'package:aku_community_manager/ui/tool_pages/scan_page.dart';
import 'package:aku_community_manager/ui/tool_pages/warning/warning_page.dart'; import 'package:aku_community_manager/ui/tool_pages/warning/warning_page.dart';
import 'package:aku_community_manager/ui/widgets/app_widgets/aku_avatar.dart';
import 'package:aku_ui/aku_ui.dart'; import 'package:aku_ui/aku_ui.dart';
import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart';
import 'package:carousel_slider/carousel_slider.dart'; import 'package:carousel_slider/carousel_slider.dart';
@ -187,14 +188,7 @@ class _HomePageState extends State<HomePage> {
onTap: () { onTap: () {
Scaffold.of(context).openDrawer(); Scaffold.of(context).openDrawer();
}, },
child: userProvider.isLogin child: AkuAvatar(),
? FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_WEBP,
image: API.image(userProvider
.profileModel.firstImg?.url ??
''),
)
: Icon(Icons.person),
); );
}, },
), ),
@ -450,7 +444,7 @@ class _HomePageState extends State<HomePage> {
), ),
SizedBox(height: 16.w), SizedBox(height: 16.w),
// //
!userProvider.isSigned !userProvider.isLogin
? SizedBox() ? SizedBox()
: Row( : Row(
children: [ children: [
@ -489,7 +483,7 @@ class _HomePageState extends State<HomePage> {
), ),
SizedBox(height: 16.w), SizedBox(height: 16.w),
// //
!userProvider.isSigned !userProvider.isLogin
? SizedBox() ? SizedBox()
: Container( : Container(
height: 480.w, height: 480.w,
@ -520,7 +514,7 @@ class _HomePageState extends State<HomePage> {
), ),
SizedBox(height: 24.w), SizedBox(height: 24.w),
// //
!userProvider.isSigned !userProvider.isLogin
? SizedBox() ? SizedBox()
: Container( : Container(
width: double.infinity, width: double.infinity,

@ -5,6 +5,7 @@ import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/ui/login/login_page.dart'; import 'package:aku_community_manager/ui/login/login_page.dart';
import 'package:aku_community_manager/ui/settings/settings_page.dart'; import 'package:aku_community_manager/ui/settings/settings_page.dart';
import 'package:aku_community_manager/ui/settings/user_info_page.dart'; import 'package:aku_community_manager/ui/settings/user_info_page.dart';
import 'package:aku_community_manager/ui/widgets/app_widgets/aku_avatar.dart';
import 'package:aku_ui/common_widgets/aku_button.dart'; import 'package:aku_ui/common_widgets/aku_button.dart';
import 'package:aku_ui/common_widgets/aku_round_button.dart'; import 'package:aku_ui/common_widgets/aku_round_button.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -73,21 +74,7 @@ class _PersonalDrawState extends State<PersonalDraw> {
children: [ children: [
SizedBox(width: 32.w), SizedBox(width: 32.w),
// //
Material( AkuAvatar(),
borderRadius: BorderRadius.circular(36.w),
clipBehavior: Clip.antiAlias,
color: Colors.grey,
child: userProvider.isLogin
? FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_WEBP,
image: API.image(
userProvider.profileModel.firstImg?.url ?? '',
),
height: 72.w,
width: 72.w,
)
: Icon(Icons.person),
),
SizedBox(width: 24.w), SizedBox(width: 24.w),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -131,7 +118,7 @@ class _PersonalDrawState extends State<PersonalDraw> {
R.ASSETS_USER_IC_PERSON_PNG, R.ASSETS_USER_IC_PERSON_PNG,
'个人信息', '个人信息',
onPressed: () { onPressed: () {
userProvider.isSigned userProvider.isLogin
? Get.to(UserInfoPage()) ? Get.to(UserInfoPage())
: Get.to(LoginPage()); : Get.to(LoginPage());
}, },

@ -76,14 +76,14 @@ class _SettingsPageState extends State<SettingsPage> {
onTap: () => Get.to(AgreementPage()), onTap: () => Get.to(AgreementPage()),
), ),
AkuBox.h(320), AkuBox.h(320),
userProvider.isSigned userProvider.isLogin
? Padding( ? Padding(
padding: EdgeInsets.symmetric(horizontal: 64.w), padding: EdgeInsets.symmetric(horizontal: 64.w),
child: AkuMaterialButton( child: AkuMaterialButton(
radius: 8.w, radius: 8.w,
color: AppStyle.primaryColor, color: AppStyle.primaryColor,
onPressed: () { onPressed: () {
userProvider.setisSigned(false); userProvider.logout();
Get.offAll(HomePage()); Get.offAll(HomePage());
}, },
child: Text( child: Text(

@ -1,6 +1,7 @@
import 'package:aku_community_manager/const/resource.dart'; import 'package:aku_community_manager/const/resource.dart';
import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/provider/user_provider.dart';
import 'package:aku_community_manager/ui/widgets/app_widgets/aku_avatar.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_tile.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_tile.dart';
import 'package:aku_community_manager/ui/widgets/inner/pick_image.dart'; import 'package:aku_community_manager/ui/widgets/inner/pick_image.dart';
@ -33,21 +34,7 @@ class _UserInfoPageState extends State<UserInfoPage> {
}, },
title: Text('头像'), title: Text('头像'),
height: 168.w, height: 168.w,
suffix: Material( suffix: AkuAvatar(),
color: Colors.grey,
borderRadius: BorderRadius.circular(36.w),
clipBehavior: Clip.antiAlias,
child: userProvider.isLogin
? FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_WEBP,
image: API.image(
userProvider.profileModel.firstImg?.url ?? '',
),
height: 72.w,
width: 72.w,
)
: Icon(Icons.person),
),
), ),
AkuTile( AkuTile(
onTap: () {}, onTap: () {},

@ -0,0 +1,29 @@
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/const/resource.dart';
import 'package:aku_community_manager/provider/user_provider.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class AkuAvatar extends StatelessWidget {
final double size;
AkuAvatar({Key key, this.size}) : super(key: key);
@override
Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context);
return userProvider.isLogin
? Material(
color: Colors.grey,
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_WEBP,
image: API.image(userProvider.profileModel.firstImg?.url ?? ''),
height: size ?? 72.w,
width: size ?? 72.w,
),
)
: CircleAvatar(
child: Icon(Icons.person),
);
}
}
Loading…
Cancel
Save