diff --git a/assets/agreement.pdf b/assets/agreement.pdf deleted file mode 100644 index 3d5eddd6..00000000 Binary files a/assets/agreement.pdf and /dev/null differ diff --git a/lib/const/resource.dart b/lib/const/resource.dart index 21e8e20f..ae65be93 100644 --- a/lib/const/resource.dart +++ b/lib/const/resource.dart @@ -1,8 +1,8 @@ /// Generate by [resource_generator](https://github.com/CaiJingLong/flutter_resource_generator) library. /// PLEASE DO NOT EDIT MANUALLY. class R { - /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/agreement.pdf) - static const String ASSETS_AGREEMENT_PDF = 'assets/agreement.pdf'; + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/.DS_Store) + static const String ASSETS__DS_STORE = 'assets/.DS_Store'; /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/example/QR_code.png) static const String ASSETS_EXAMPLE_QR_CODE_PNG = 'assets/example/QR_code.png'; diff --git a/lib/constants/api.dart b/lib/constants/api.dart index f7cb1efc..75122969 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -26,4 +26,10 @@ class _Login { class _User { ///用户资料 String get userProfile => '/user/personalData/findPersonalData'; + + ///设置用户性别 + String get setSex => '/user/personalData/updateSex'; + + ///设置用户生日 + String get setBirthday => '/user/personalData/updateBirthday'; } diff --git a/lib/main.dart b/lib/main.dart index d511e40c..b0588e88 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -53,10 +53,7 @@ class _MyAppState extends State { child: GetMaterialApp( title: '智慧社区', debugShowCheckedModeBanner: false, - theme: ThemeData( - primarySwatch: Colors.yellow, - visualDensity: VisualDensity.adaptivePlatformDensity, - ), + theme: ThemeData(primarySwatch: Colors.yellow), home: SplashPage(), //国际化支持 localizationsDelegates: [ diff --git a/lib/model/user/user_info_model.dart b/lib/model/user/user_info_model.dart index 6cd1c756..58c0131a 100644 --- a/lib/model/user/user_info_model.dart +++ b/lib/model/user/user_info_model.dart @@ -1,12 +1,31 @@ +import 'package:common_utils/common_utils.dart'; + class UserInfoModel { int id; List imgUrls; String name; String nickName; String tel; + + /// 性别 1.男 2.女 int sex; String birthday; + String get sexValue { + if (sex == null) return '未设置'; + if (sex == 1) return '男'; + if (sex == 2) return '女'; + return '未设置'; + } + + DateTime get birthdayDate => DateUtil.getDateTime(birthday); + String get birthdayValue { + if (TextUtil.isEmpty(birthday)) + return '未设置'; + else + return DateUtil.formatDate(birthdayDate, format: 'yyyy-MM-dd'); + } + UserInfoModel( {this.id, this.imgUrls, diff --git a/lib/pages/personal/personal_page.dart b/lib/pages/personal/personal_page.dart index ab927627..0605bc24 100644 --- a/lib/pages/personal/personal_page.dart +++ b/lib/pages/personal/personal_page.dart @@ -5,6 +5,7 @@ import 'package:akuCommunity/pages/life_pay/life_pay_page.dart'; import 'package:akuCommunity/pages/mine_car_page/mine_car_page.dart'; import 'package:akuCommunity/pages/mine_house_page/mine_house_page.dart'; import 'package:akuCommunity/pages/personal/order_page.dart'; +import 'package:akuCommunity/pages/personal/user_profile_page.dart'; import 'package:akuCommunity/pages/setting_page/settings_page.dart'; import 'package:akuCommunity/pages/sign/sign_in_page.dart'; import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart'; @@ -131,7 +132,10 @@ class _PersonalIndexState extends State ), InkWell( onTap: () { - if (!userProvider.isLogin) SignInPage().to(); + if (!userProvider.isLogin) + SignInPage().to(); + else + UserProfilePage().to(); }, child: Container( margin: EdgeInsets.only(left: 16.w), diff --git a/lib/pages/personal/user_profile_page.dart b/lib/pages/personal/user_profile_page.dart new file mode 100644 index 00000000..74b81b88 --- /dev/null +++ b/lib/pages/personal/user_profile_page.dart @@ -0,0 +1,176 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class UserProfilePage extends StatefulWidget { + UserProfilePage({Key key}) : super(key: key); + + @override + _UserProfilePageState createState() => _UserProfilePageState(); +} + +class _UserProfilePageState extends State { + int _sex = 1; + DateTime _birthday = DateTime.now(); + Widget _buildTile(String title, Widget suffix, {VoidCallback onPressed}) { + return MaterialButton( + color: Colors.white, + elevation: 0, + onPressed: onPressed, + height: 96.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + child: DefaultTextStyle( + style: TextStyle( + fontSize: 34.sp, + color: ktextPrimary, + ), + child: Row( + children: [ + 32.wb, + title.text.make(), + Spacer(), + suffix ?? SizedBox(), + 24.wb, + Icon( + CupertinoIcons.chevron_forward, + color: Color(0xFFDCDCDC), + size: 32.w, + ), + 16.wb, + ], + ), + ), + ); + } + + @override + Widget build(BuildContext context) { + final userProvider = Provider.of(context); + return BeeScaffold( + title: '个人资料', + body: ListView( + children: [ + _buildTile( + '头像', + CircleAvatar(), + onPressed: () {}, + ), + _buildTile( + '姓名', + userProvider.userInfoModel.name.text.make(), + onPressed: () {}, + ), + _buildTile( + '昵称', + userProvider.userInfoModel.nickName.text.make(), + onPressed: () {}, + ), + _buildTile( + '手机号', + TextUtil.hideNumber(userProvider.userInfoModel.tel).text.make(), + onPressed: () {}, + ), + _buildTile( + '性别', + userProvider.userInfoModel.sexValue.text.make(), + onPressed: () { + showCupertinoDialog( + context: context, + builder: (context) { + return CupertinoAlertDialog( + title: '请选择'.text.isIntrinsic.make(), + content: SizedBox( + child: CupertinoPicker( + itemExtent: 50, + onSelectedItemChanged: (index) { + _sex = index + 1; + }, + children: [ + '男'.text.isIntrinsic.make().centered(), + '女'.text.isIntrinsic.make().centered(), + ], + useMagnifier: true, + ), + height: 300.w, + ), + actions: [ + CupertinoDialogAction( + child: '取消'.text.isIntrinsic.make(), + onPressed: Get.back, + ), + CupertinoDialogAction( + child: '确定'.text.isIntrinsic.make(), + onPressed: () { + userProvider.setSex(_sex); + Get.back(); + }, + ), + ], + ); + }, + ); + }, + ), + _buildTile( + '出生日期', + userProvider.userInfoModel.birthdayValue.text.make(), + onPressed: () { + Get.dialog( + CupertinoAlertDialog( + title: '请选择'.text.isIntrinsic.make(), + content: SizedBox( + height: 340.w, + child: CupertinoTheme( + data: CupertinoThemeData( + textTheme: CupertinoTextThemeData( + dateTimePickerTextStyle: TextStyle( + fontSize: 30.sp, + color: Colors.black87, + ), + ), + ), + child: CupertinoDatePicker( + maximumYear: DateTime.now().year, + minimumYear: 1900, + mode: CupertinoDatePickerMode.date, + onDateTimeChanged: (date) { + _birthday = date; + }, + ), + ), + ), + actions: [ + CupertinoDialogAction( + child: '取消'.text.isIntrinsic.make(), + onPressed: Get.back, + ), + CupertinoDialogAction( + child: '确定'.text.isIntrinsic.make(), + onPressed: () { + userProvider.setBirthday(_birthday); + Get.back(); + }, + ), + ], + ), + ); + }, + ), + ].sepWidget( + separate: Divider( + indent: 104.w, + height: 1.w, + thickness: 1.w, + color: Color(0xFFEEEEEE), + )), + ), + ); + } +} diff --git a/lib/pages/setting_page/account_manager_page.dart b/lib/pages/setting_page/account_manager_page.dart index 8c1916c4..b631262d 100644 --- a/lib/pages/setting_page/account_manager_page.dart +++ b/lib/pages/setting_page/account_manager_page.dart @@ -28,7 +28,7 @@ class _AccountManagerPageState extends State { return CupertinoActionSheet( message: Text('注销当前账号'), actions: [ - CupertinoButton( + CupertinoDialogAction( child: Text( '确定', style: TextStyle( @@ -40,11 +40,9 @@ class _AccountManagerPageState extends State { }, ), ], - cancelButton: CupertinoButton( + cancelButton: CupertinoDialogAction( child: Text('取消'), - onPressed: () { - Get.back(); - }, + onPressed: Get.back, ), ); }, diff --git a/lib/pages/setting_page/settings_page.dart b/lib/pages/setting_page/settings_page.dart index 796f1e3a..80de4030 100644 --- a/lib/pages/setting_page/settings_page.dart +++ b/lib/pages/setting_page/settings_page.dart @@ -70,7 +70,7 @@ class _SettingsPageState extends State { return CupertinoActionSheet( message: Text('退出当前账号'), actions: [ - CupertinoButton( + CupertinoDialogAction( child: Text( '确定', style: TextStyle( @@ -83,7 +83,7 @@ class _SettingsPageState extends State { }, ), ], - cancelButton: CupertinoButton( + cancelButton: CupertinoDialogAction( child: Text('取消'), onPressed: () { Get.back(); diff --git a/lib/pages/sign/sign_in_page.dart b/lib/pages/sign/sign_in_page.dart index c53dad8e..2b657474 100644 --- a/lib/pages/sign/sign_in_page.dart +++ b/lib/pages/sign/sign_in_page.dart @@ -264,9 +264,7 @@ class _SignInPageState extends State { children: [ FlatButton( padding: EdgeInsets.zero, - onPressed: () { - ARoute.push(context, AgreementPage()); - }, + onPressed: AgreementPage().to, child: Text( '《小蜜蜂用户协议》', style: TextStyle( @@ -276,9 +274,7 @@ class _SignInPageState extends State { SizedBox(width: 15.w), FlatButton( padding: EdgeInsets.zero, - onPressed: () { - ARoute.push(context, PrivacyPage()); - }, + onPressed: PrivacyPage().to, child: Text( '《小蜜蜂隐私政策》', style: TextStyle( diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 7a42c583..9a524b41 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -1,7 +1,10 @@ +import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/user/user_info_model.dart'; import 'package:akuCommunity/pages/sign/sign_func.dart'; import 'package:akuCommunity/utils/hive_store.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; +import 'package:flustars/flustars.dart'; import 'package:flutter/material.dart'; class UserProvider extends ChangeNotifier { @@ -42,4 +45,28 @@ class UserProvider extends ChangeNotifier { UserInfoModel _userInfoModel; UserInfoModel get userInfoModel => _userInfoModel; + + Future setSex(int sex) async { + BaseModel baseModel = await NetUtil().post( + API.user.setSex, + params: {'sex': sex}, + showMessage: true, + ); + if (baseModel.status) { + _userInfoModel.sex = sex; + notifyListeners(); + } + } + + Future setBirthday(DateTime date) async { + BaseModel baseModel = await NetUtil().post( + API.user.setBirthday, + params: {'birthday': date.toIso8601String()}, + showMessage: true, + ); + if (baseModel.status) { + _userInfoModel.birthday = date.toIso8601String(); + notifyListeners(); + } + } }