diff --git a/lib/mock_models/users/user_info_model.dart b/lib/mock_models/users/user_info_model.dart index 945e711..f5d41d2 100644 --- a/lib/mock_models/users/user_info_model.dart +++ b/lib/mock_models/users/user_info_model.dart @@ -1,4 +1,8 @@ class UserInfoModel { String nickName; String avatarPath; + UserInfoModel({ + this.nickName, + this.avatarPath, + }); } diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index b29b8a1..e9d6db5 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -1,18 +1,29 @@ +import 'package:aku_community_manager/const/resource.dart'; +import 'package:aku_community_manager/mock_models/users/user_info_model.dart'; import 'package:flutter/material.dart'; + //登录状态管理 -class UserProvider extends ChangeNotifier{ +class UserProvider extends ChangeNotifier { + bool _isSigned = false; - - bool _isSigned=false; ///用户是否登陆 - get isSigned=>_isSigned; + get isSigned => _isSigned; ///设置用户登陆 - setisSigned (bool state){ - _isSigned=state; - notifyListeners(); + setisSigned(bool state) { + _isSigned = state; + notifyListeners(); } + UserInfoModel _userInfoModel = UserInfoModel( + nickName: '李大海', + avatarPath: R.ASSETS_STATIC_TEMP_F3_WEBP, + ); + + UserInfoModel get userInfoModel => _userInfoModel; - -} \ No newline at end of file + setNickName(String name) { + _userInfoModel.nickName = name; + notifyListeners(); + } +} diff --git a/lib/ui/settings/settings_page.dart b/lib/ui/settings/settings_page.dart index d2d5458..543d634 100644 --- a/lib/ui/settings/settings_page.dart +++ b/lib/ui/settings/settings_page.dart @@ -1,11 +1,17 @@ +import 'package:aku_community_manager/provider/user_provider.dart'; +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/home/home_page.dart'; import 'package:aku_community_manager/ui/settings/setting_feedback_page.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_ui/common_widgets/aku_material_button.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.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 SettingsPage extends StatefulWidget { SettingsPage({Key key}) : super(key: key); @@ -17,6 +23,7 @@ class SettingsPage extends StatefulWidget { class _SettingsPageState extends State { @override Widget build(BuildContext context) { + final userProvider = Provider.of(context); return AkuScaffold( title: '设置', body: ListView( @@ -49,6 +56,20 @@ class _SettingsPageState extends State { arrow: true, onTap: () => BotToast.showText(text: '缓存清理完成'), ), + AkuBox.h(320), + userProvider.isSigned + ? Padding( + padding: EdgeInsets.symmetric(horizontal: 64.w), + child: AkuMaterialButton( + color: AppStyle.primaryColor, + onPressed: () { + userProvider.setisSigned(false); + Get.offAll(HomePage()); + }, + child: Text('退出登录'), + ), + ) + : SizedBox(), ], ), );