添加选择头像

hmxc
小赖 4 years ago
parent accc292932
commit a6def9e502

@ -65,7 +65,7 @@ class _HomePageState extends State<HomePage> {
);
}
///
///
Widget _card(
String number,
String text,
@ -167,6 +167,11 @@ class _HomePageState extends State<HomePage> {
},
child: CircleAvatar(
radius: 36.w,
backgroundImage:
userProvider.userInfoModel.avatar == null
? null
: FileImage(
userProvider.userInfoModel.avatar),
backgroundColor: Colors.white,
child: userProvider.isSigned
? userProvider.userInfoModel.avatar == null
@ -195,7 +200,8 @@ class _HomePageState extends State<HomePage> {
child: Column(
children: [
SizedBox(height: 18.w),
Image.asset(R.ASSETS_HOME_IC_SEARCH_PNG,width:37.w,height:37.w),
Image.asset(R.ASSETS_HOME_IC_SEARCH_PNG,
width: 37.w, height: 37.w),
],
),
),
@ -296,8 +302,8 @@ class _HomePageState extends State<HomePage> {
children: [
_menuButton(
R.ASSETS_HOME_IC_POLICE_PNG, '一键报警', HomePage()),
_menuButton(
R.ASSETS_HOME_IC_VISITORS_PNG, '访客管理', VisitorManagerPage()),
_menuButton(R.ASSETS_HOME_IC_VISITORS_PNG, '访客管理',
VisitorManagerPage()),
_menuButton(
R.ASSETS_HOME_IC_SERVICE_PNG,
'报事报修',

@ -71,8 +71,15 @@ class _PersonalDrawState extends State<PersonalDraw> {
onPressed: () {},
child: CircleAvatar(
radius: 36.w,
backgroundColor: Colors.grey,
child: userProvider.isSigned ? null : null,
backgroundImage: userProvider.userInfoModel.avatar == null
? null
: FileImage(userProvider.userInfoModel.avatar),
backgroundColor: Colors.white,
child: userProvider.isSigned
? userProvider.userInfoModel.avatar == null
? Icon(Icons.person_outline)
: null
: Icon(Icons.person),
),
),
SizedBox(width: 24.w),

@ -1,8 +1,11 @@
import 'package:aku_community_manager/provider/user_provider.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/inner/pick_image.dart';
import 'package:flutter/material.dart';
import 'package:aku_community_manager/tools/screen_tool.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
class UserInfoPage extends StatefulWidget {
UserInfoPage({Key key}) : super(key: key);
@ -14,20 +17,35 @@ class UserInfoPage extends StatefulWidget {
class _UserInfoPageState extends State<UserInfoPage> {
@override
Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context);
return AkuScaffold(
title: '个人信息',
body: ListView(
padding: EdgeInsets.symmetric(vertical: 24.w),
children: [
AkuTile(
onTap: () {},
onTap: () {
akuPickImage().then((file) {
userProvider.setAvatar(file);
});
},
title: Text('头像'),
height: 168.w,
suffix: CircleAvatar(radius: 60.w),
suffix: CircleAvatar(
radius: 60.w,
backgroundColor: Colors.white,
backgroundImage: userProvider.userInfoModel.avatar == null
? null
: FileImage(userProvider.userInfoModel.avatar),
child: userProvider.userInfoModel.avatar == null
? Icon(Icons.person_outline)
: null,
),
),
AkuTile(
onTap: () {},
title: Text('昵称'),
suffix: Text(userProvider.userInfoModel.nickName),
),
AkuTile(
onTap: () {},

@ -0,0 +1,51 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
Future<File> akuPickImage() async {
return await showCupertinoModalPopup(
context: Get.context,
builder: (context) {
return CupertinoActionSheet(
title: Text('选择图片'),
actions: [
CupertinoActionSheetAction(
onPressed: () {
ImagePicker()
.getImage(
source: ImageSource.camera,
maxHeight: 600,
maxWidth: 600,
)
.then((file) {
Get.back(result: File(file.path));
});
},
child: Text('拍照'),
),
CupertinoActionSheetAction(
onPressed: () {
ImagePicker()
.getImage(
source: ImageSource.gallery,
maxHeight: 600,
maxWidth: 600,
)
.then((file) {
Get.back(result: File(file.path));
});
},
child: Text('相册'),
),
],
cancelButton: CupertinoButton(
child: Text('取消'),
onPressed: () => Get.back(),
),
);
},
);
}
Loading…
Cancel
Save