构建初步的设备运行悬浮状态栏,已实现初步的的悬浮和开关功能。
优化了登录链条适配多种用户的登录操作
This commit is contained in:
@@ -8,6 +8,9 @@ import 'package:maibu_satabot_v2/core/router/route_paths.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/v2/device_list/presentation/float_bar/float_bar_controller.dart';
|
||||
|
||||
final sl = GetIt.instance;
|
||||
|
||||
/// 系统设置综合页面
|
||||
class SystemSettingsPage extends StatefulWidget {
|
||||
@@ -18,6 +21,17 @@ class SystemSettingsPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
/// 悬浮条开关状态
|
||||
bool _floatBarEnabled = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// 初始化时获取当前状态(使用静态属性)
|
||||
_floatBarEnabled = FloatBarController.isVisible;
|
||||
print('🔍 [设置页面] initState,初始状态: $_floatBarEnabled');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -45,6 +59,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
// Tab 设置
|
||||
_buildTabSettingsSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 悬浮条设置
|
||||
_buildFloatBarSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 语言设置
|
||||
_buildLanguageSection(),
|
||||
const SizedBox(height: 12),
|
||||
@@ -88,9 +105,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
if (state.runtimeType.toString() != 'TabConfigLoaded') {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
|
||||
final tabs = state.config.items;
|
||||
|
||||
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
@@ -164,14 +181,18 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
AppLocalizations.of(context).translate('my.chinese'),
|
||||
'zh',
|
||||
locale.languageCode == 'zh',
|
||||
() => context.read<LocaleCubit>().setLocale(const Locale('zh', 'CN')),
|
||||
() => context.read<LocaleCubit>().setLocale(
|
||||
const Locale('zh', 'CN'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildLanguageOption(
|
||||
AppLocalizations.of(context).translate('my.english'),
|
||||
'en',
|
||||
locale.languageCode == 'en',
|
||||
() => context.read<LocaleCubit>().setLocale(const Locale('en', 'US')),
|
||||
() => context.read<LocaleCubit>().setLocale(
|
||||
const Locale('en', 'US'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -182,16 +203,25 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLanguageOption(String label, String code, bool isSelected, VoidCallback onTap) {
|
||||
Widget _buildLanguageOption(
|
||||
String label,
|
||||
String code,
|
||||
bool isSelected,
|
||||
VoidCallback onTap,
|
||||
) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? const Color(0xFF165DFF).withOpacity(0.1) : Colors.transparent,
|
||||
color: isSelected
|
||||
? const Color(0xFF165DFF).withOpacity(0.1)
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: isSelected ? const Color(0xFF165DFF) : const Color(0xFFE5E6EB),
|
||||
color: isSelected
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFFE5E6EB),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
@@ -202,7 +232,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isSelected ? const Color(0xFF165DFF) : const Color(0xFF1D2129),
|
||||
color: isSelected
|
||||
? const Color(0xFF165DFF)
|
||||
: const Color(0xFF1D2129),
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
@@ -252,6 +284,94 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 悬浮条设置
|
||||
Widget _buildFloatBarSection() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'悬浮条设置',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildFloatBarSwitch(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 悬浮条开关
|
||||
Widget _buildFloatBarSwitch() {
|
||||
print(
|
||||
'🔍 [设置页面] _buildFloatBarSwitch 被调用,_floatBarEnabled: $_floatBarEnabled',
|
||||
);
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: const [
|
||||
Text(
|
||||
'显示悬浮条',
|
||||
style: TextStyle(fontSize: 14, color: Color(0xFF1D2129)),
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
'在Tab页面显示设备状态悬浮条',
|
||||
style: TextStyle(fontSize: 12, color: Color(0xFF8F959E)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: _floatBarEnabled,
|
||||
onChanged: (value) {
|
||||
print('🔍 [设置页面] 开关被点击,新值: $value,当前状态: $_floatBarEnabled');
|
||||
|
||||
// 🔥 立即更新本地状态
|
||||
setState(() {
|
||||
_floatBarEnabled = value;
|
||||
});
|
||||
print('🔍 [设置页面] 本地状态已更新为: $_floatBarEnabled');
|
||||
|
||||
// 🔥 使用静态方法设置新值
|
||||
FloatBarController.setVisible(value);
|
||||
print('🔍 [设置页面] setVisible 已调用完成');
|
||||
|
||||
// 显示提示
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(value ? '悬浮条已开启' : '悬浮条已关闭'),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
activeColor: const Color(0xFF165DFF),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示退出登录确认对话框
|
||||
void _showLogoutDialog(BuildContext context) {
|
||||
showDialog(
|
||||
|
||||
Reference in New Issue
Block a user