|
|
@@ -8,6 +8,7 @@ import 'package:image_cropper/image_cropper.dart'; |
|
|
|
import 'package:image_picker/image_picker.dart'; |
|
|
|
import 'package:intl/intl.dart'; |
|
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
|
import 'package:zhiying_base_widget/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart'; |
|
|
|
import 'package:zhiying_base_widget/dialog/loading/loading.dart'; |
|
|
|
import 'package:zhiying_base_widget/pages/mine_detail_page/mine_detail_bloc.dart'; |
|
|
|
import 'package:zhiying_base_widget/pages/mine_detail_page/models/mine_detail_model.dart'; |
|
|
@@ -50,19 +51,19 @@ class _MineDetailPageState extends State<MineDetailPage> { |
|
|
|
backgroundColor: Colors.white, |
|
|
|
leading: Navigator.canPop(context) |
|
|
|
? GestureDetector( |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.zero, |
|
|
|
child: Icon( |
|
|
|
Icons.arrow_back_ios, |
|
|
|
size: 20, |
|
|
|
), |
|
|
|
), |
|
|
|
onTap: () { |
|
|
|
if (Navigator.canPop(context)) { |
|
|
|
Navigator.pop(context); |
|
|
|
} |
|
|
|
}, |
|
|
|
) |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.zero, |
|
|
|
child: Icon( |
|
|
|
Icons.arrow_back_ios, |
|
|
|
size: 20, |
|
|
|
), |
|
|
|
), |
|
|
|
onTap: () { |
|
|
|
if (Navigator.canPop(context)) { |
|
|
|
Navigator.pop(context); |
|
|
|
} |
|
|
|
}, |
|
|
|
) |
|
|
|
: Container(), |
|
|
|
middle: Text( |
|
|
|
'个人信息', |
|
|
@@ -207,10 +208,10 @@ class _MineDetailContainerState extends State<_MineDetailContainer> { |
|
|
|
onTap == null |
|
|
|
? Container() |
|
|
|
: Icon( |
|
|
|
Icons.arrow_forward_ios, |
|
|
|
size: 12, |
|
|
|
color: Color(0xff999999), |
|
|
|
) |
|
|
|
Icons.arrow_forward_ios, |
|
|
|
size: 12, |
|
|
|
color: Color(0xff999999), |
|
|
|
) |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
@@ -256,10 +257,10 @@ class _MineDetailContainerState extends State<_MineDetailContainer> { |
|
|
|
onTap == null |
|
|
|
? Container() |
|
|
|
: Icon( |
|
|
|
Icons.arrow_forward_ios, |
|
|
|
size: 12, |
|
|
|
color: Color(0xff999999), |
|
|
|
) |
|
|
|
Icons.arrow_forward_ios, |
|
|
|
size: 12, |
|
|
|
color: Color(0xff999999), |
|
|
|
) |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
@@ -277,14 +278,14 @@ class _MineDetailContainerState extends State<_MineDetailContainer> { |
|
|
|
} |
|
|
|
|
|
|
|
void _selectImage() async { |
|
|
|
var status = await Permission.photos.status; |
|
|
|
if (status != PermissionStatus.granted) { |
|
|
|
status = await Permission.photos.request(); |
|
|
|
} |
|
|
|
if (status == PermissionStatus.denied) { |
|
|
|
Fluttertoast.showToast(msg: '暂无权限,图片选择失败'); |
|
|
|
return null; |
|
|
|
} |
|
|
|
// var status = await Permission.photos.status; |
|
|
|
// if (status != PermissionStatus.granted) { |
|
|
|
// status = await Permission.photos.request(); |
|
|
|
// } |
|
|
|
// if (status == PermissionStatus.denied) { |
|
|
|
// Fluttertoast.showToast(msg: '暂无权限,图片选择失败'); |
|
|
|
// return null; |
|
|
|
// } |
|
|
|
|
|
|
|
final picker = ImagePicker(); |
|
|
|
PickedFile file; |
|
|
@@ -300,66 +301,80 @@ class _MineDetailContainerState extends State<_MineDetailContainer> { |
|
|
|
backgroundColor: Colors.transparent); |
|
|
|
if (index != null) { |
|
|
|
if (index == 0) { |
|
|
|
file = await picker.getImage(source: ImageSource.camera); |
|
|
|
if (!await Permission.camera.isGranted) { |
|
|
|
var result = await showDialog(context: context, child: NotificationSettingDialogNew([NotificationSettingDialogNew.cameraPermissModel])); |
|
|
|
} |
|
|
|
if (await Permission.camera.isGranted) { |
|
|
|
file = await picker.getImage(source: ImageSource.camera); |
|
|
|
} else { |
|
|
|
Fluttertoast.showToast(msg: '暂无权限,图片拍取失败'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
file = await picker.getImage(source: ImageSource.gallery); |
|
|
|
} |
|
|
|
if (!await Permission.storage.isGranted) { |
|
|
|
var result = await showDialog(context: context, child: NotificationSettingDialogNew([NotificationSettingDialogNew.storagePermissModel])); |
|
|
|
} |
|
|
|
if (await Permission.storage.isGranted) { |
|
|
|
file = await picker.getImage(source: ImageSource.gallery); |
|
|
|
} else { |
|
|
|
Fluttertoast.showToast(msg: '暂无权限,图片获取失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (file == null) return; |
|
|
|
File cropperFile = await ImageCropper.cropImage( |
|
|
|
sourcePath: file.path, |
|
|
|
aspectRatioPresets: [ |
|
|
|
CropAspectRatioPreset.square, |
|
|
|
], |
|
|
|
androidUiSettings: AndroidUiSettings( |
|
|
|
toolbarTitle: '图片剪裁', |
|
|
|
toolbarColor: HexColor.fromHex('#E52425'), |
|
|
|
toolbarWidgetColor: Colors.white, |
|
|
|
initAspectRatio: CropAspectRatioPreset.original, |
|
|
|
lockAspectRatio: true), |
|
|
|
iosUiSettings: IOSUiSettings(minimumAspectRatio: 1.0, aspectRatioLockEnabled: true)); |
|
|
|
if (cropperFile == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
Loading.show(context); |
|
|
|
File resultFile = await EncodeUtil.compressImage(context, file: cropperFile, size: 800); |
|
|
|
if (file == null) return; |
|
|
|
File cropperFile = await ImageCropper.cropImage( |
|
|
|
sourcePath: file.path, |
|
|
|
aspectRatioPresets: [ |
|
|
|
CropAspectRatioPreset.square, |
|
|
|
], |
|
|
|
androidUiSettings: AndroidUiSettings( |
|
|
|
toolbarTitle: '图片剪裁', |
|
|
|
toolbarColor: HexColor.fromHex('#E52425'), |
|
|
|
toolbarWidgetColor: Colors.white, |
|
|
|
initAspectRatio: CropAspectRatioPreset.original, |
|
|
|
lockAspectRatio: true), |
|
|
|
iosUiSettings: IOSUiSettings(minimumAspectRatio: 1.0, aspectRatioLockEnabled: true)); |
|
|
|
if (cropperFile == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
Loading.show(context); |
|
|
|
File resultFile = await EncodeUtil.compressImage(context, file: cropperFile, size: 800); |
|
|
|
|
|
|
|
_bloc.uploadAvatar(resultFile); |
|
|
|
_bloc.uploadAvatar(resultFile); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 选择性别 |
|
|
|
void _selectSex() async { |
|
|
|
int index = await showModalBottomSheet( |
|
|
|
context: context, |
|
|
|
builder: (context) { |
|
|
|
return ActionListAlert( |
|
|
|
title: '选择性别', |
|
|
|
actions: ['女', '男'], |
|
|
|
); |
|
|
|
}, |
|
|
|
isScrollControlled: false, |
|
|
|
backgroundColor: Colors.transparent); |
|
|
|
if (index != null) { |
|
|
|
print(index); |
|
|
|
_bloc.updateUser(gender: index == 0 ? '0' : '1'); |
|
|
|
// 选择性别 |
|
|
|
void _selectSex() async { |
|
|
|
int index = await showModalBottomSheet( |
|
|
|
context: context, |
|
|
|
builder: (context) { |
|
|
|
return ActionListAlert( |
|
|
|
title: '选择性别', |
|
|
|
actions: ['女', '男'], |
|
|
|
); |
|
|
|
}, |
|
|
|
isScrollControlled: false, |
|
|
|
backgroundColor: Colors.transparent); |
|
|
|
if (index != null) { |
|
|
|
print(index); |
|
|
|
_bloc.updateUser(gender: index == 0 ? '0' : '1'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void _selectBrithday() async { |
|
|
|
DateTime dateTime = await showModalBottomSheet( |
|
|
|
context: context, |
|
|
|
builder: (context) { |
|
|
|
return ActionDateAlert( |
|
|
|
title: '选择出生日期', |
|
|
|
maxTimeNew: "max", |
|
|
|
); |
|
|
|
}, |
|
|
|
isScrollControlled: false, |
|
|
|
backgroundColor: Colors.transparent); |
|
|
|
if (dateTime != null) { |
|
|
|
String timeStamp = (dateTime.millisecondsSinceEpoch / 1000).ceil().toString(); |
|
|
|
_bloc.updateUser(birthday: timeStamp); |
|
|
|
void _selectBrithday() async { |
|
|
|
DateTime dateTime = await showModalBottomSheet( |
|
|
|
context: context, |
|
|
|
builder: (context) { |
|
|
|
return ActionDateAlert( |
|
|
|
title: '选择出生日期', |
|
|
|
maxTimeNew: "max", |
|
|
|
); |
|
|
|
}, |
|
|
|
isScrollControlled: false, |
|
|
|
backgroundColor: Colors.transparent); |
|
|
|
if (dateTime != null) { |
|
|
|
String timeStamp = (dateTime.millisecondsSinceEpoch / 1000).ceil().toString(); |
|
|
|
_bloc.updateUser(birthday: timeStamp); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |