添加选择头像弹框

hmxc
小赖 4 years ago
parent a8bf223e3b
commit 4f167c2fd7

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/pages/personal/change_nick_name_page.dart';
import 'package:akuCommunity/pages/personal/update_tel_page.dart';
@ -8,6 +10,7 @@ import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart';
@ -52,6 +55,32 @@ class _UserProfilePageState extends State<UserProfilePage> {
);
}
_pickAvatar() async {
PickedFile file = await Get.bottomSheet(CupertinoActionSheet(
title: '选择头像'.text.isIntrinsic.make(),
actions: [
CupertinoDialogAction(
onPressed: () async => Get.back(
result: await ImagePicker().getImage(source: ImageSource.gallery),
),
child: '相册'.text.isIntrinsic.make(),
),
CupertinoDialogAction(
onPressed: () async => Get.back(
result: await ImagePicker().getImage(source: ImageSource.camera),
),
child: '相机'.text.isIntrinsic.make(),
),
],
cancelButton: CupertinoDialogAction(
onPressed: Get.back,
child: '取消'.text.isIntrinsic.make(),
),
));
if (file == null) return;
//TODO upload avatar.
}
@override
Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context);
@ -59,11 +88,7 @@ class _UserProfilePageState extends State<UserProfilePage> {
title: '个人资料',
body: ListView(
children: [
_buildTile(
'头像',
CircleAvatar(),
onPressed: () {},
),
_buildTile('头像', CircleAvatar(), onPressed: _pickAvatar),
_buildTile(
'姓名',
userProvider.userInfoModel.name.text.make(),

@ -389,6 +389,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.5"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.11"
flutter_redux:
dependency: "direct main"
description:
@ -518,6 +525,20 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.14"
image_picker:
dependency: "direct main"
description:
name: image_picker
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.7+21"
image_picker_platform_interface:
dependency: transitive
description:
name: image_picker_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
image_stack:
dependency: "direct main"
description:

@ -98,6 +98,8 @@ dependencies:
git:
url: http://192.168.2.201:8099/zhangmeng/random_character.git
image_picker: ^0.6.7+21
dev_dependencies:
flutter_test:
sdk: flutter

Loading…
Cancel
Save