多角色的配置适配

This commit is contained in:
2026-09-14 12:35:20 +08:00
parent 3547f80383
commit a1e01da241
11 changed files with 333 additions and 187 deletions

View File

@@ -73,7 +73,8 @@ class _MyPageContent extends StatelessWidget {
final userName = user?.nickname ?? user?.username ?? '未知用户';
final userRole = user?.email ?? user?.phone ?? '未设置';
return Column(
return SingleChildScrollView(
child: Column(
children: [
// 用户信息卡片(延伸到状态栏)
UserProfileCard(
@@ -124,11 +125,9 @@ class _MyPageContent extends StatelessWidget {
),
],
),
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.5,
),
child: ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero,
// 末尾追加退出登录,占据“关于我们”原来的位置
itemCount: state.menuItems.length + 1,
@@ -160,6 +159,7 @@ class _MyPageContent extends StatelessWidget {
),
),
],
),
);
}

View File

@@ -10,6 +10,8 @@ import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
import 'package:maibu_satabot_v2/core/storage/user_storage.dart';
import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart';
import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart';
import 'package:maibu_satabot_v2/features/main_container/domain/tab_config.dart';
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/float_bar/cubit/float_bar_setting_cubit.dart';
import 'package:maibu_satabot_v2/core/update/update_cubit.dart';
import 'package:maibu_satabot_v2/core/update/update_state.dart';
@@ -146,6 +148,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
/// Tab 设置
Widget _buildTabSettingsSection() {
// 🔥 个人角色(roleKey == 'personal'):Tab 设置只列出「设备 + 我的」,且开关常开锁定
final roleKey = context.watch<AppUserCubit>().state.user?.roleKey;
final isPersonal = roleKey == TabConfig.personalRoleKey;
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
@@ -177,7 +182,7 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
return const Center(child: CircularProgressIndicator());
}
final tabs = state.config.items;
final tabs = state.config.settingItemsForRole(roleKey);
return ListView.builder(
shrinkWrap: true,
@@ -199,10 +204,13 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
),
),
Switch(
value: tab.isEnabled,
onChanged: (value) {
context.read<TabConfigCubit>().toggleTab(tab.id);
},
// 个人角色:设备/我的 强制常开且不可关闭
value: isPersonal ? true : tab.isEnabled,
onChanged: isPersonal
? null
: (value) {
context.read<TabConfigCubit>().toggleTab(tab.id);
},
activeColor: const Color(0xFF165DFF),
),
],