|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/user_info.dart';
|
|
|
|
import 'package:huixiang/utils/font_weight.dart';
|
|
|
|
import 'package:huixiang/view_widget/custom_image.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:huixiang/view_widget/login_tips_dialog.dart';
|
|
|
|
import 'package:huixiang/view_widget/request_permission.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
|
|
|
class MineView extends StatefulWidget {
|
|
|
|
final UserInfo userInfo;
|
|
|
|
final GestureTapCallback toUserInfo;
|
|
|
|
final GestureTapCallback toIntegralPage;
|
|
|
|
|
|
|
|
MineView(this.userInfo, this.toUserInfo, this.toIntegralPage);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _MineView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MineView extends State<MineView> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(top: 28.w),
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
toScan();
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.all(8.h),
|
|
|
|
child: Image.asset(
|
|
|
|
"assets/image/icon_scan_qr_code.png",
|
|
|
|
width: 24.w,
|
|
|
|
height: 24.h,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pushNamed('/router/setting_page');
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.all(8.h),
|
|
|
|
margin: EdgeInsets.only(right: 12.w),
|
|
|
|
child: Image.asset(
|
|
|
|
"assets/image/icon_mine_setting.png",
|
|
|
|
width: 24.w,
|
|
|
|
height: 24.h,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
widget.toUserInfo();
|
|
|
|
},
|
|
|
|
child: mineView(),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 12.h,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
toScan() async {
|
|
|
|
if (await Permission.camera.isPermanentlyDenied) {
|
|
|
|
showCupertinoDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) {
|
|
|
|
return RequestPermission(
|
|
|
|
"assets/image/icon_camera_permission_tips.png",
|
|
|
|
S.of(context).ninxiangjiquanxianweikaiqi,
|
|
|
|
S.of(context).weilekaipaizhaoxuanzhetouxiang,
|
|
|
|
S.of(context).kaiqiquanxian,
|
|
|
|
(result) async {
|
|
|
|
if (result) {
|
|
|
|
await openAppSettings();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
heightRatioWithWidth: 0.82,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
} else if (await Permission.camera.isGranted) {
|
|
|
|
Navigator.of(context).pushNamed('/router/qr_scan');
|
|
|
|
} else {
|
|
|
|
await Permission.camera.request();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///我的信息部分
|
|
|
|
Widget mineView() {
|
|
|
|
return Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 16.w),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Stack(
|
|
|
|
children: [
|
|
|
|
MImage(
|
|
|
|
widget.userInfo == null ? "" : widget.userInfo.headimg,
|
|
|
|
isCircle: true,
|
|
|
|
width: 50,
|
|
|
|
height: 50,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
errorSrc: "assets/image/default_user.png",
|
|
|
|
fadeSrc: "assets/image/default_user.png",
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
bottom: 0,
|
|
|
|
right: 2.w,
|
|
|
|
child: Image.asset(
|
|
|
|
"assets/image/icon_mine_edit.png",
|
|
|
|
width: 17.w,
|
|
|
|
height: 17.w,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 10.w,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 1,
|
|
|
|
child: Container(
|
|
|
|
height: 50.h,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
widget.userInfo == null
|
|
|
|
? Text(
|
|
|
|
S.of(context).denglu,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16.sp,
|
|
|
|
fontWeight: MyFontWeight.medium,
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Row(
|
|
|
|
children: [
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
if (widget.userInfo == null) {
|
|
|
|
LoginTipsDialog().show(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
widget.userInfo == null
|
|
|
|
? S.of(context).denglu
|
|
|
|
: "${widget.userInfo.nickname}",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Image.asset(
|
|
|
|
"assets/image/icon_user.png",
|
|
|
|
width: 18.w,
|
|
|
|
height: 18.h,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
widget.userInfo == null
|
|
|
|
? Text(
|
|
|
|
S.of(context).weidengluxinxi,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: MyFontWeight.regular,
|
|
|
|
color: Color(0xFF2F2F2F),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Text(
|
|
|
|
widget.userInfo == null
|
|
|
|
? ""
|
|
|
|
: "NO.${widget.userInfo.vipNo}",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: MyFontWeight.regular,
|
|
|
|
color: Color(0xFF2F2F2F),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
widget.userInfo == null
|
|
|
|
? Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
height: 50.h,
|
|
|
|
child: Icon(
|
|
|
|
Icons.keyboard_arrow_right,
|
|
|
|
size: 20,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Container(
|
|
|
|
alignment: Alignment.bottomRight,
|
|
|
|
height: 50.h,
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
widget.toIntegralPage();
|
|
|
|
},
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
S.of(context).jifenxiangqing,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: MyFontWeight.semi_bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Icon(
|
|
|
|
Icons.keyboard_arrow_right,
|
|
|
|
size: 16,
|
|
|
|
color: Colors.black,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|