diff --git a/lib/main.dart b/lib/main.dart index d6128e4..ff3c6b0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,4 @@ +import 'package:chat/configs/app_colors.dart'; import 'package:chat/configs/themes.dart'; import 'package:chat/controllers/group_controller.dart'; import 'package:chat/controllers/moment_controller.dart'; @@ -8,11 +9,19 @@ import 'package:chat/services/auth_service.dart'; import 'package:chat/services/tabbar_service.dart'; import 'package:chat/services/tim_service.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; Future main() async { + /// 设置状态栏样式,透明 + SystemUiOverlayStyle style = const SystemUiOverlayStyle( + statusBarColor: AppColors.transparent, + systemNavigationBarColor: AppColors.nav, + ); + SystemChrome.setSystemUIOverlayStyle(style); + WidgetsFlutterBinding.ensureInitialized(); await GetStorage.init(); diff --git a/lib/routes/user_routes.dart b/lib/routes/user_routes.dart index 21d6603..db22d18 100644 --- a/lib/routes/user_routes.dart +++ b/lib/routes/user_routes.dart @@ -1,7 +1,12 @@ import 'package:chat/middleware/auth_middleware.dart'; import 'package:chat/views/contact/index/index_page.dart'; +import 'package:chat/views/user/info/avatar_page.dart'; +import 'package:chat/views/user/info/index_page.dart'; +import 'package:chat/views/user/info/nickname_page.dart'; import 'package:chat/views/user/qr_code/index_page.dart'; +import 'package:chat/views/user/safe/index_page.dart'; import 'package:chat/views/user/setting/index_page.dart'; +import 'package:chat/views/user/share/index_page.dart'; import 'package:get/get.dart'; abstract class UserRoutes { @@ -10,6 +15,10 @@ abstract class UserRoutes { static const String qrCode = '/user/qrCode'; static const String setting = '/user/setting'; static const String share = '/user/share'; + static const String safe = '/user/safe'; + static const String info = '/user/info'; + static const String infoNickname = '/user/info/nickname'; + static const String infoAvatar = '/user/info/avatar'; static GetPage router = GetPage( name: UserRoutes.index, @@ -18,6 +27,10 @@ abstract class UserRoutes { ], page: () => const ContactPage(), children: [ + GetPage( + name: '/share', + page: () => const UserSharePage(), + ), GetPage( name: '/qrCode', page: () => const UserQrCodePage(), @@ -26,6 +39,24 @@ abstract class UserRoutes { name: '/setting', page: () => const UserSettingPage(), ), + GetPage( + name: '/safe', + page: () => const UserSafePage(), + ), + GetPage( + name: '/info', + page: () => const UserInfoPage(), + children: [ + GetPage( + name: '/nickname', + page: () => const UserInfoNicknamePage(), + ), + GetPage( + name: '/avatar', + page: () => const UserInfoAvatarPage(), + ), + ], + ), ], ); } diff --git a/lib/services/auth_service.dart b/lib/services/auth_service.dart index 1ab152a..52577c4 100644 --- a/lib/services/auth_service.dart +++ b/lib/services/auth_service.dart @@ -71,7 +71,7 @@ class AuthService extends GetxService { } /// 退出登录 - void logout() async { + Future logout() async { await TencentImSDKPlugin.v2TIMManager.logout(); _box.remove('userSig'); _box.remove('userId'); diff --git a/lib/services/tim_service.dart b/lib/services/tim_service.dart index 10d66e3..47fd7c1 100644 --- a/lib/services/tim_service.dart +++ b/lib/services/tim_service.dart @@ -93,6 +93,7 @@ class TimService extends GetxService { if (loginResult.code != 0) { UiTools.toast(loginResult.desc); + await AuthService.to.logout(); } Get.put(TimConversationService()); diff --git a/lib/utils/im_tools.dart b/lib/utils/im_tools.dart index d04923b..91871c8 100644 --- a/lib/utils/im_tools.dart +++ b/lib/utils/im_tools.dart @@ -197,7 +197,7 @@ class ImTools { padding: const EdgeInsets.only( left: 16.0, ), - color: Colors.grey[200], + color: AppColors.page, alignment: Alignment.centerLeft, child: Text( tag, diff --git a/lib/views/home/index_page.dart b/lib/views/home/index_page.dart index 3119cbc..f84437e 100644 --- a/lib/views/home/index_page.dart +++ b/lib/views/home/index_page.dart @@ -50,7 +50,7 @@ class HomePage extends StatelessWidget { PreferredSizeWidget _appBar() { return AppBar( - title: const Text('聊聊'), + title: const Text('消息'), actions: [ IconButton( onPressed: () { diff --git a/lib/views/public/app_page.dart b/lib/views/public/app_page.dart index 572c211..75ef873 100644 --- a/lib/views/public/app_page.dart +++ b/lib/views/public/app_page.dart @@ -2,7 +2,7 @@ import 'package:chat/configs/app_colors.dart'; import 'package:chat/services/tabbar_service.dart'; import 'package:chat/views/contact/index/index_page.dart'; import 'package:chat/views/home/index_page.dart'; -import 'package:chat/views/user/index/user_page.dart'; +import 'package:chat/views/user/index/index_page.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:proste_indexed_stack/proste_indexed_stack.dart'; diff --git a/lib/views/user/index/index_page.dart b/lib/views/user/index/index_page.dart new file mode 100644 index 0000000..2e0ac26 --- /dev/null +++ b/lib/views/user/index/index_page.dart @@ -0,0 +1,80 @@ +import 'package:chat/configs/app_colors.dart'; +import 'package:chat/routes/user_routes.dart'; +import 'package:chat/views/home/widgets/action_item.dart'; +import 'package:chat/views/user/index/widgets/user_top_bar.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class UserPage extends StatefulWidget { + const UserPage({Key? key}) : super(key: key); + + @override + _UserPageState createState() => _UserPageState(); +} + +class _UserPageState extends State { + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + body: Column( + children: [ + const UserTopBar(), + const Divider( + height: 0, + color: AppColors.border, + ), + const SizedBox(height: 8), + const Divider( + height: 0, + color: AppColors.border, + ), + ActionItem( + '分享邀请', + onTap: () { + Get.toNamed(UserRoutes.share); + }, + ), + const Divider( + height: 0, + color: AppColors.border, + indent: 16, + ), + ActionItem( + '安全设置', + onTap: () { + Get.toNamed(UserRoutes.safe); + }, + ), + const Divider( + height: 0, + color: AppColors.border, + indent: 16, + ), + ActionItem( + '设置中心', + onTap: () { + Get.toNamed(UserRoutes.setting); + }, + ), + const Divider( + height: 0, + color: AppColors.border, + indent: 16, + ), + ActionItem( + '检查更新', + onTap: () { + Get.toNamed(UserRoutes.setting); + }, + ), + const Divider( + height: 0, + color: AppColors.border, + ), + ], + ), + ), + ); + } +} diff --git a/lib/views/user/index/user_page.dart b/lib/views/user/index/user_page.dart deleted file mode 100644 index 04f911a..0000000 --- a/lib/views/user/index/user_page.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:chat/routes/user_routes.dart'; -import 'package:chat/views/user/index/widgets/user_top_bar.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -class UserPage extends StatefulWidget { - const UserPage({Key? key}) : super(key: key); - - @override - _UserPageState createState() => _UserPageState(); -} - -class _UserPageState extends State { - @override - Widget build(BuildContext context) { - return SafeArea( - child: Scaffold( - body: Column( - children: [ - const UserTopBar(), - const SizedBox(height: 8), - ListTile( - onTap: () { - Get.toNamed(UserRoutes.share); - }, - title: const Text('分享邀请'), - ), - ListTile( - onTap: () { - Get.toNamed(UserRoutes.setting); - }, - title: const Text('设置中心'), - ), - const ListTile( - title: Text('检查更新'), - ), - ], - ), - ), - ); - } -} diff --git a/lib/views/user/index/widgets/user_top_bar.dart b/lib/views/user/index/widgets/user_top_bar.dart index d675eea..0d71c61 100644 --- a/lib/views/user/index/widgets/user_top_bar.dart +++ b/lib/views/user/index/widgets/user_top_bar.dart @@ -24,9 +24,14 @@ class UserTopBar extends StatelessWidget { return Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ - CustomAvatar( - _.userInfo.value.avatar, - size: 64, + InkWell( + onTap: () { + Get.toNamed(UserRoutes.info); + }, + child: CustomAvatar( + _.userInfo.value.avatar, + size: 64, + ), ), const SizedBox(width: 16), Column( diff --git a/lib/views/user/info/avatar_page.dart b/lib/views/user/info/avatar_page.dart new file mode 100644 index 0000000..c1ac02c --- /dev/null +++ b/lib/views/user/info/avatar_page.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class UserInfoAvatarPage extends StatefulWidget { + const UserInfoAvatarPage({Key? key}) : super(key: key); + + @override + State createState() => _UserInfoAvatarPageState(); +} + +class _UserInfoAvatarPageState extends State { + @override + Widget build(BuildContext context) { + return Container(); + } +} diff --git a/lib/views/user/info/index_page.dart b/lib/views/user/info/index_page.dart new file mode 100644 index 0000000..47f5618 --- /dev/null +++ b/lib/views/user/info/index_page.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class UserInfoPage extends StatefulWidget { + const UserInfoPage({Key? key}) : super(key: key); + + @override + State createState() => _UserInfoPageState(); +} + +class _UserInfoPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('用户资料'), + ), + ); + } +} diff --git a/lib/views/user/info/nickname_page.dart b/lib/views/user/info/nickname_page.dart new file mode 100644 index 0000000..55c7676 --- /dev/null +++ b/lib/views/user/info/nickname_page.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class UserInfoNicknamePage extends StatefulWidget { + const UserInfoNicknamePage({Key? key}) : super(key: key); + + @override + State createState() => _UserInfoNicknamePageState(); +} + +class _UserInfoNicknamePageState extends State { + @override + Widget build(BuildContext context) { + return Container(); + } +} diff --git a/lib/views/user/safe/index_page.dart b/lib/views/user/safe/index_page.dart new file mode 100644 index 0000000..ca72550 --- /dev/null +++ b/lib/views/user/safe/index_page.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class UserSafePage extends StatefulWidget { + const UserSafePage({Key? key}) : super(key: key); + + @override + State createState() => _UserSafePageState(); +} + +class _UserSafePageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('安全设置'), + ), + body: Container(), + ); + } +}