6 Commits

Author SHA1 Message Date
dc006c2935 修复personal退出登录误弹登录过期弹窗 2026-10-10 10:12:11 +08:00
167229371f 帮助与反馈页面开发 2026-10-10 08:47:30 +08:00
208147cdf2 启动动画和登录页面的动画 2026-09-23 16:52:18 +08:00
b3a700491a 启动动画和登录页面的动画 2026-09-23 16:50:48 +08:00
d230279f4f 启动动画和登录页面的动画 2026-09-23 16:48:48 +08:00
32397f8899 AIR版的功能添加 2026-09-20 16:31:15 +08:00
12 changed files with 1230 additions and 244 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

@@ -40,12 +40,17 @@ class DioClient {
if (response.data is Map<String, dynamic>) { if (response.data is Map<String, dynamic>) {
final code = response.data['code']; final code = response.data['code'];
if (code == 401 || code == 403) { if (code == 401 || code == 403) {
print( // 🔥 仅在当前确实处于登录态时,才把 401 当作「登录过期」弹窗。
'>>> [DIO] 🚨🚨🚨 收到业务错误码 $code,触发 Token 过期处理!URL: ${response.requestOptions.uri},时间: ${DateTime.now()}', // 退出登录过程中 AppUserCubit.user 已被清为 null,此时残留/竞态请求
); // 返回的 401 不应再打扰用户(人已经在退出了),否则会误弹「登录已过期」。
try { if (sl<AppUserCubit>().state.user != null) {
sl<AuthCubit>().tokenExpired(); print(
} catch (ex) {} '>>> [DIO] 🚨🚨🚨 收到业务错误码 $code,触发 Token 过期处理!URL: ${response.requestOptions.uri},时间: ${DateTime.now()}',
);
try {
sl<AuthCubit>().tokenExpired();
} catch (ex) {}
}
} }
} }
return handler.next(response); return handler.next(response);
@@ -53,12 +58,15 @@ class DioClient {
onError: (DioException e, handler) async { onError: (DioException e, handler) async {
if (e.response?.statusCode == 401 || e.response?.statusCode == 403) { if (e.response?.statusCode == 401 || e.response?.statusCode == 403) {
print( // 🔥 同上:已退出登录(user==null)时不再触发过期弹窗
'>>> [DIO] 🚨🚨🚨 收到 HTTP ${e.response?.statusCode},触发 Token 过期处理!URL: ${e.requestOptions.uri},时间: ${DateTime.now()}', if (sl<AppUserCubit>().state.user != null) {
); print(
try { '>>> [DIO] 🚨🚨🚨 收到 HTTP ${e.response?.statusCode},触发 Token 过期处理!URL: ${e.requestOptions.uri},时间: ${DateTime.now()}',
sl<AuthCubit>().tokenExpired(); );
} catch (ex) {} try {
sl<AuthCubit>().tokenExpired();
} catch (ex) {}
}
} }
return handler.next(e); return handler.next(e);

View File

@@ -30,13 +30,19 @@ GoRouter createRouter(AuthCubit authCubit) {
return GoRouter( return GoRouter(
navigatorKey: navigatorKey, // 🔥 绑定全局 navigatorKey,使异地登录弹窗能获取 context navigatorKey: navigatorKey, // 🔥 绑定全局 navigatorKey,使异地登录弹窗能获取 context
initialLocation: RoutePaths.login, initialLocation: RoutePaths.splash,
refreshListenable: GoRouterRefreshStream(authCubit.stream), refreshListenable: GoRouterRefreshStream(authCubit.stream),
redirect: (context, state) { redirect: (context, state) {
final loggedIn = authCubit.state is AuthAuthenticated; final loggedIn = authCubit.state is AuthAuthenticated;
final onSplash = state.matchedLocation == RoutePaths.splash;
final loggingIn = state.matchedLocation == RoutePaths.login; final loggingIn = state.matchedLocation == RoutePaths.login;
final registering = state.matchedLocation == RoutePaths.register; final registering = state.matchedLocation == RoutePaths.register;
// 启动屏:交给 SplashPage 自己根据就绪信号跳转,路由层不干预
if (onSplash) {
return null;
}
// 如果未登录,只允许访问 login 和 register 页面 // 如果未登录,只允许访问 login 和 register 页面
if (!loggedIn && !loggingIn && !registering) { if (!loggedIn && !loggingIn && !registering) {
return RoutePaths.login; return RoutePaths.login;

View File

@@ -1,4 +1,7 @@
class RoutePaths { class RoutePaths {
/// 启动页(App 第一个路由)
static const splash = '/splash';
/// 账号相关页面 /// 账号相关页面
static const login = '/auth/login'; static const login = '/auth/login';
static const register = '/auth/register'; static const register = '/auth/register';

View File

@@ -18,19 +18,47 @@ class LoginPage extends StatefulWidget {
State<LoginPage> createState() => _LoginPageState(); State<LoginPage> createState() => _LoginPageState();
} }
class _LoginPageState extends State<LoginPage> { class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMixin {
final _userCtrl = TextEditingController(); final _userCtrl = TextEditingController();
final _pwdCtrl = TextEditingController(); final _pwdCtrl = TextEditingController();
bool _isAgreed = false; // 协议勾选状态 bool _isAgreed = false; // 协议勾选状态
bool _obscurePwd = true; // 密码可见性 bool _obscurePwd = true; // 密码可见性
// 进场动画控制器
late final AnimationController _entranceController;
@override
void initState() {
super.initState();
_entranceController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 900),
);
// 等首帧渲染 + 图片解码完成后再播放,避开启动初始化争抢导致的掉帧
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
Future.delayed(const Duration(milliseconds: 120), () {
if (mounted) _entranceController.forward();
});
});
}
@override @override
void dispose() { void dispose() {
_entranceController.dispose();
_userCtrl.dispose(); _userCtrl.dispose();
_pwdCtrl.dispose(); _pwdCtrl.dispose();
super.dispose(); super.dispose();
} }
/// 生成一个错峰区间的动画(0.0 ~ 1.0)
Animation<double> _interval(double begin, double end) {
return CurvedAnimation(
parent: _entranceController,
curve: Interval(begin, end, curve: Curves.easeOut),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@@ -64,130 +92,94 @@ class _LoginPageState extends State<LoginPage> {
// 顶部区域:图片 + 认证信息 + 标题(压缩空间) // 顶部区域:图片 + 认证信息 + 标题(压缩空间)
const SizedBox(height: 10), const SizedBox(height: 10),
// 顶部居中图片和认证信息 // ① 顶部居中图片和认证信息(缩放淡入)
Center( _Entrance(
child: Column( animation: _interval(0.00, 0.35),
children: [ scale: true,
Image.asset( child: Center(
'assets/images/huawei.png', child: Column(
width: 80, children: [
height: 80, Image.asset(
fit: BoxFit.contain, 'assets/images/huawei.png',
), width: 80,
const SizedBox(height: 6), height: 80,
Padding( fit: BoxFit.contain,
padding: const EdgeInsets.symmetric(horizontal: 20.0), ),
child: Text( const SizedBox(height: 6),
"通过华为云生态技术认证,请放心使用,证书编号C202605301", Padding(
textAlign: TextAlign.center, padding: const EdgeInsets.symmetric(horizontal: 20.0),
style: TextStyle( child: Text(
fontSize: 10, "通过华为云生态技术认证,请放心使用,证书编号C202605301",
color: context.appColors.textTertiary, textAlign: TextAlign.center,
height: 1.3, style: TextStyle(
fontSize: 10,
color: context.appColors.textTertiary,
height: 1.3,
),
), ),
), ),
), ],
],
),
),
const SizedBox(height: 16),
Text(
"账号登录",
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: context.appColors.textPrimary),
),
const SizedBox(height: 8),
Text("请填写以下信息以验证身份", style: TextStyle(fontSize: 15, color: context.appColors.textTertiary)),
const SizedBox(height: 24),
// 表单区域
// 账号输入框
_buildInputLabel("账号"),
TextField(
controller: _userCtrl,
style: TextStyle(fontSize: 14, color: context.appColors.textPrimary),
cursorColor: context.appColors.textPrimary,
decoration: _inputDecoration(hint: "请输入用户名"),
),
const SizedBox(height: 20),
// 密码输入框
_buildInputLabel("密码"),
TextField(
controller: _pwdCtrl,
obscureText: _obscurePwd,
style: TextStyle(fontSize: 14, color: context.appColors.textPrimary),
cursorColor: context.appColors.textPrimary,
decoration: _inputDecoration(
hint: "请输入密码",
suffixIcon: IconButton(
icon: Icon(_obscurePwd ? Icons.visibility_off_outlined : Icons.visibility_outlined, color: context.appColors.textTertiary, size: 20),
onPressed: () => setState(() => _obscurePwd = !_obscurePwd),
), ),
), ),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
// 协议勾选区域 // ② 标题区(上滑淡入)
_buildProtocolSection(), _Entrance(
animation: _interval(0.10, 0.45),
const SizedBox(height: 30), child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
// 底部区域:登录按钮 + 注册链接
SizedBox(
width: double.infinity,
child: BlocBuilder<LoginCubit, LoginState>(
builder: (context, state) {
bool isLoading = state is LoginLoading;
return CCPrimaryButton(
onPressed: isLoading
? null
: () {
if (!_isAgreed) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('请先阅读并同意用户协议'),
duration: Duration(seconds: 1),
),
);
return;
}
_handleLogin();
},
text: isLoading ? '登录中...' : '登 录',
);
},
),
),
const SizedBox(height: 16),
Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
"没有账号吗?", "账号登录",
style: TextStyle(fontSize: 14, color: context.appColors.textTertiary), style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: context.appColors.textPrimary),
), ),
InkWell( const SizedBox(height: 8),
onTap: () { Text("请填写以下信息以验证身份", style: TextStyle(fontSize: 15, color: context.appColors.textTertiary)),
debugPrint(' 点击了立即注册'); ],
debugPrint('👉 跳转路径: ${RoutePaths.register}'); ),
context.go(RoutePaths.register); ),
},
borderRadius: BorderRadius.circular(4), const SizedBox(height: 24),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), // ③ 表单区域
child: Text( // 账号输入框(上滑淡入)
"立即注册", _Entrance(
style: TextStyle( animation: _interval(0.20, 0.55),
fontSize: 14, child: Column(
color: context.appColors.textPrimary, crossAxisAlignment: CrossAxisAlignment.start,
fontWeight: FontWeight.bold, children: [
), _buildInputLabel("账号"),
TextField(
controller: _userCtrl,
style: TextStyle(fontSize: 14, color: context.appColors.textPrimary),
cursorColor: context.appColors.textPrimary,
decoration: _inputDecoration(hint: "请输入用户名"),
),
],
),
),
const SizedBox(height: 20),
// 密码输入框(上滑淡入)
_Entrance(
animation: _interval(0.28, 0.63),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildInputLabel("密码"),
TextField(
controller: _pwdCtrl,
obscureText: _obscurePwd,
style: TextStyle(fontSize: 14, color: context.appColors.textPrimary),
cursorColor: context.appColors.textPrimary,
decoration: _inputDecoration(
hint: "请输入密码",
suffixIcon: IconButton(
icon: Icon(_obscurePwd ? Icons.visibility_off_outlined : Icons.visibility_outlined, color: context.appColors.textTertiary, size: 20),
onPressed: () => setState(() => _obscurePwd = !_obscurePwd),
), ),
), ),
), ),
@@ -195,6 +187,83 @@ class _LoginPageState extends State<LoginPage> {
), ),
), ),
const SizedBox(height: 16),
// ④ 协议勾选区域(上滑淡入)
_Entrance(
animation: _interval(0.36, 0.71),
child: _buildProtocolSection(),
),
const SizedBox(height: 30),
// ⑤ 底部区域:登录按钮(上滑淡入)
_Entrance(
animation: _interval(0.45, 0.82),
child: SizedBox(
width: double.infinity,
child: BlocBuilder<LoginCubit, LoginState>(
builder: (context, state) {
bool isLoading = state is LoginLoading;
return CCPrimaryButton(
onPressed: isLoading
? null
: () {
if (!_isAgreed) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('请先阅读并同意用户协议'),
duration: Duration(seconds: 1),
),
);
return;
}
_handleLogin();
},
text: isLoading ? '登录中...' : '登 录',
);
},
),
),
),
const SizedBox(height: 16),
// 注册链接(上滑淡入,最后登场)
_Entrance(
animation: _interval(0.55, 0.95),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"没有账号吗?",
style: TextStyle(fontSize: 14, color: context.appColors.textTertiary),
),
InkWell(
onTap: () {
debugPrint(' 点击了立即注册');
debugPrint('👉 跳转路径: ${RoutePaths.register}');
context.go(RoutePaths.register);
},
borderRadius: BorderRadius.circular(4),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Text(
"立即注册",
style: TextStyle(
fontSize: 14,
color: context.appColors.textPrimary,
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
),
const SizedBox(height: 20), const SizedBox(height: 20),
], ],
), ),
@@ -320,3 +389,37 @@ class _LoginPageState extends State<LoginPage> {
); );
} }
} }
/// 进场动画包装组件:淡入 + 上滑(默认)或淡入 + 缩放(scale=true)
class _Entrance extends StatelessWidget {
const _Entrance({
required this.animation,
required this.child,
this.scale = false,
this.slideOffset = const Offset(0, 0.15),
});
final Animation<double> animation;
final Widget child;
final bool scale;
final Offset slideOffset;
@override
Widget build(BuildContext context) {
final curved = CurvedAnimation(parent: animation, curve: Curves.easeOutCubic);
if (scale) {
final scaleAnim = Tween<double>(begin: 0.85, end: 1.0).animate(curved);
return FadeTransition(
opacity: animation,
child: ScaleTransition(scale: scaleAnim, child: child),
);
}
final slideAnim = Tween<Offset>(begin: slideOffset, end: Offset.zero).animate(curved);
return FadeTransition(
opacity: animation,
child: SlideTransition(position: slideAnim, child: child),
);
}
}

View File

@@ -0,0 +1,114 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import '../../../../core/router/route_paths.dart';
import '../bloc/auth_cubit.dart';
import '../bloc/auth_state.dart';
/// 启动页:展示 App Logo 并循环播放「呼吸缩放」动画。
///
/// 该页面作为 App 的第一个路由,衔接原生启动屏(静态 Logo)。
/// 动画会一直循环,直到 [AuthCubit.appStarted] 完成、登录态确定
/// ([AuthAuthenticated] / [AuthUnauthenticated])这一「就绪信号」到来,
/// 才停止动画并跳转到首页或登录页。
class SplashPage extends StatefulWidget {
const SplashPage({super.key});
@override
State<SplashPage> createState() => _SplashPageState();
}
class _SplashPageState extends State<SplashPage>
with SingleTickerProviderStateMixin {
/// 呼吸动画控制器(循环往复)
late final AnimationController _breathController;
/// 就绪信号是否已到达
bool _ready = false;
/// 就绪后的目标登录态
AuthState? _resolvedState;
/// 防止重复跳转
bool _navigated = false;
@override
void initState() {
super.initState();
_breathController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 900),
)..repeat(reverse: true);
// 处理进入 splash 时登录态已经确定的情况(appStarted 先于首帧完成)
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _onReady(context.read<AuthCubit>().state);
});
}
@override
void dispose() {
_breathController.dispose();
super.dispose();
}
/// 记录就绪信号,并尝试跳转
void _onReady(AuthState state) {
if (state is AuthAuthenticated || state is AuthUnauthenticated) {
_resolvedState = state;
_ready = true;
_maybeNavigate();
}
// AuthInitial:尚未就绪,继续停留在启动页播放动画
}
/// 就绪信号到达即离开启动页,不额外增加打开时间
void _maybeNavigate() {
if (_navigated || !mounted) return;
if (!_ready || _resolvedState == null) return;
_navigated = true;
_breathController.stop();
if (_resolvedState is AuthAuthenticated) {
context.go(RoutePaths.home);
} else {
context.go(RoutePaths.login);
}
}
@override
Widget build(BuildContext context) {
return BlocListener<AuthCubit, AuthState>(
listenWhen: (prev, cur) =>
cur is AuthAuthenticated || cur is AuthUnauthenticated,
listener: (context, state) => _onReady(state),
child: Scaffold(
// 与原生启动屏白底保持一致,避免切换时闪色
backgroundColor: Colors.white,
body: Center(
child: AnimatedBuilder(
animation: _breathController,
builder: (context, child) {
// easeInOut 让呼吸更柔和;scale 从 1.0 起始以贴合原生屏尺寸
final t = Curves.easeInOut.transform(_breathController.value);
final scale = 1.0 - 0.22 * t; // 1.0 -> 0.78,幅度更大更明显
final opacity = 1.0 - 0.55 * t; // 1.0 -> 0.45
return Opacity(
opacity: opacity,
child: Transform.scale(scale: scale, child: child),
);
},
// 透明底应用图标,避免白底上出现浅灰"阴影"底块
child: Image.asset(
'assets/images/app_logo_gray_transparent.png',
width: 180,
height: 180,
fit: BoxFit.contain,
),
),
),
),
);
}
}

View File

@@ -3,10 +3,15 @@ import 'package:maibu_satabot_v2/core/router/route_paths.dart';
import 'package:maibu_satabot_v2/features/auth/presentation/pages/login_page.dart'; import 'package:maibu_satabot_v2/features/auth/presentation/pages/login_page.dart';
import '../pages/register_page.dart'; import '../pages/register_page.dart';
import '../pages/splash_page.dart';
class AuthRoutes { class AuthRoutes {
// 返回一个 List<RouteBase> // 返回一个 List<RouteBase>
static List<RouteBase> routes = [ static List<RouteBase> routes = [
GoRoute(
path: RoutePaths.splash,
builder: (context, state) => const SplashPage(),
),
GoRoute( GoRoute(
path: RoutePaths.login, path: RoutePaths.login,
builder: (context, state) => const LoginPage(), builder: (context, state) => const LoginPage(),

View File

@@ -20,7 +20,16 @@ class BleDeviceDetailPage extends StatefulWidget {
final BluetoothDevice device; final BluetoothDevice device;
final ScanResult? scanResult; final ScanResult? scanResult;
const BleDeviceDetailPage({super.key, required this.device, this.scanResult}); /// 后端设备长名称(如 MC700PLUS-CN-JS-1760408682847-0000002A-A9),
/// 由列表页跳转时传入;为空时回退到蓝牙广播名
final String? displayName;
const BleDeviceDetailPage({
super.key,
required this.device,
this.scanResult,
this.displayName,
});
@override @override
State<BleDeviceDetailPage> createState() => _BleDeviceDetailPageState(); State<BleDeviceDetailPage> createState() => _BleDeviceDetailPageState();
@@ -515,7 +524,9 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
final advData = widget.scanResult?.advertisementData; final advData = widget.scanResult?.advertisementData;
// 优先使用广告数据中的名称(含扫描响应),手机蓝牙列表也是这样显示的 // 优先使用广告数据中的名称(含扫描响应),手机蓝牙列表也是这样显示的
final name = final name =
_resolvedName ?? (widget.displayName?.isNotEmpty == true
? widget.displayName!
: _resolvedName) ??
(advData?.advName.isNotEmpty == true (advData?.advName.isNotEmpty == true
? advData!.advName ? advData!.advName
: (device.platformName.isNotEmpty : (device.platformName.isNotEmpty
@@ -603,14 +614,6 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
color: context.appColors.textPrimary, color: context.appColors.textPrimary,
), ),
), ),
const SizedBox(height: 4),
Text(
'${widget.device.remoteId}',
style: TextStyle(
fontSize: 12,
color: context.appColors.textTertiary,
),
),
], ],
), ),
), ),
@@ -621,7 +624,6 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
Divider(height: 1, color: context.appColors.divider), Divider(height: 1, color: context.appColors.divider),
const SizedBox(height: 12), const SizedBox(height: 12),
_buildInfoRow('设备名称', name), _buildInfoRow('设备名称', name),
_buildInfoRow('设备ID', '${widget.device.remoteId}'),
if (scanResult != null) ...[ if (scanResult != null) ...[
_buildInfoRow('信号强度', '${scanResult.rssi} dBm'), _buildInfoRow('信号强度', '${scanResult.rssi} dBm'),
_buildInfoRow( _buildInfoRow(
@@ -1237,7 +1239,7 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
'设备配置 (0x05)', '设备配置',
style: TextStyle( style: TextStyle(
fontSize: 15, fontSize: 15,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,

View File

@@ -74,6 +74,10 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
/// 当前缓存的 siteId,用于判断是否真的发生了变化 /// 当前缓存的 siteId,用于判断是否真的发生了变化
int? _currentSiteId; int? _currentSiteId;
/// 🔥 下拉刷新计数器:变更时联动重建"全部"标签下的机器人/无人机场内嵌列表,
/// 使其与统计卡片(DeviceStatusBloc)同步刷新,避免统计数字与实际卡片对不上
int _refreshTick = 0;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@@ -616,9 +620,16 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
return RefreshIndicator( return RefreshIndicator(
onRefresh: () async { onRefresh: () async {
// 🔥 同步刷新:统计卡片(DeviceStatusBloc) + 下方机器人列表(RobotListBloc)
// + 无人机场列表(DroneStationBloc)。三者数据源相互独立,只刷统计会导致
// 数字与实际卡片对不上,故用 _refreshTick 变更内嵌列表的 ValueKey 强制
// 重建对应 BlocProvider,使其重新拉取数据。
context.read<DeviceListBloc.DeviceStatusBloc>().add( context.read<DeviceListBloc.DeviceStatusBloc>().add(
const DeviceListEvent.DeviceStatusRefresh(), const DeviceListEvent.DeviceStatusRefresh(),
); );
if (state.selectedType == 'all') {
setState(() => _refreshTick++);
}
}, },
color: context.appColors.primary, color: context.appColors.primary,
child: ListView( child: ListView(
@@ -639,7 +650,7 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
_buildDroneStationList( _buildDroneStationList(
context, context,
embedded: true, embedded: true,
key: ValueKey('embedded_drone_station_$_currentSiteId'), key: ValueKey('embedded_drone_station_${_currentSiteId}_$_refreshTick'),
), ),
// 🔥 普通设备列表(仅类型 tab 生效,"全部"模式下 filteredByType 为空) // 🔥 普通设备列表(仅类型 tab 生效,"全部"模式下 filteredByType 为空)
...filteredDevices ...filteredDevices
@@ -674,7 +685,7 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
return BlocProvider( return BlocProvider(
// 🔥 电站切换时通过 key 变化强制重建 BlocProvider,重新用新 siteId 加载 // 🔥 电站切换时通过 key 变化强制重建 BlocProvider,重新用新 siteId 加载
key: ValueKey('embedded_robot_$siteId'), key: ValueKey('embedded_robot_${siteId}_$_refreshTick'),
create: (_) => create: (_) =>
sl<RobotListBloc>()..add(RobotListLoadData(siteId: siteId)), sl<RobotListBloc>()..add(RobotListLoadData(siteId: siteId)),
child: BlocConsumer<RobotListBloc, RobotListState>( child: BlocConsumer<RobotListBloc, RobotListState>(
@@ -757,7 +768,7 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
debugPrint('❌ [全部-EmbeddedRobotList] 未提取到时间戳'); debugPrint('❌ [全部-EmbeddedRobotList] 未提取到时间戳');
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar( const SnackBar(
content: Text('设备名称格式错误,无法提取时间戳'), content: Text('设备名称异常,暂时无法连接'),
duration: Duration(seconds: 2), duration: Duration(seconds: 2),
), ),
); );
@@ -967,12 +978,12 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
BuildContext context, BuildContext context,
DeviceListState.DeviceStatusLoaded state, DeviceListState.DeviceStatusLoaded state,
) { ) {
// 从实际设备列表计算统计数据(不再使用硬编码的假数据) // 从实际设备列表计算统计数据(设备状态仅有"在线/离线"两种,接口不会返回"异常",
// 故不再统计恒为 0 的"告警"项)
final devices = state.devices; final devices = state.devices;
final totalCount = devices.length; final totalCount = devices.length;
final onlineCount = devices.where((d) => d.status == '在线').length; final onlineCount = devices.where((d) => d.status == '在线').length;
final exceptionCount = devices.where((d) => d.status == '异常').length; final offlineCount = totalCount - onlineCount;
final offlineCount = totalCount - onlineCount - exceptionCount;
return Container( return Container(
margin: const EdgeInsets.symmetric(horizontal: 16.0), margin: const EdgeInsets.symmetric(horizontal: 16.0),
@@ -1008,15 +1019,6 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
textColor: context.appColors.success, textColor: context.appColors.success,
), ),
Container(width: 1, height: 40, color: context.appColors.divider), Container(width: 1, height: 40, color: context.appColors.divider),
_buildStatItem(
value: exceptionCount.toString(),
label: AppLocalizations.of(
context,
).translate('device_list_v2.alarm'),
dotColor: context.appColors.warning,
textColor: context.appColors.warning,
),
Container(width: 1, height: 40, color: context.appColors.divider),
_buildStatItem( _buildStatItem(
value: offlineCount.toString(), value: offlineCount.toString(),
label: AppLocalizations.of( label: AppLocalizations.of(
@@ -1356,7 +1358,10 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => BleDeviceDetailPage(device: connectedDevice), builder: (_) => BleDeviceDetailPage(
device: connectedDevice,
displayName: deviceName,
),
), ),
); );
return; return;
@@ -1418,7 +1423,10 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => BleDeviceDetailPage(device: device), builder: (_) => BleDeviceDetailPage(
device: device,
displayName: deviceName,
),
), ),
); );
} else { } else {
@@ -1449,7 +1457,7 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
dialogShown = true; dialogShown = true;
return AlertDialog( return AlertDialog(
title: const Text('未找到设备'), title: const Text('未找到设备'),
content: const Text('请确认机器已上线并打开蓝牙了'), content: const Text('暂未匹配到该设备,稍后重试'),
actions: [ actions: [
TextButton( TextButton(
onPressed: () { onPressed: () {
@@ -1495,7 +1503,10 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => BleDeviceDetailPage(device: result.device), builder: (_) => BleDeviceDetailPage(
device: result.device,
displayName: deviceName,
),
), ),
); );
break; break;

View File

@@ -669,7 +669,7 @@ class _RobotListViewState extends State<RobotListView> {
debugPrint('❌ [RobotListPage] 无法从设备名中提取时间戳: ${robot.name}'); debugPrint('❌ [RobotListPage] 无法从设备名中提取时间戳: ${robot.name}');
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text('设备名格式异常,无法进行蓝牙连接'), content: Text('设备名称异常,暂时无法连接'),
backgroundColor: context.appColors.warning, backgroundColor: context.appColors.warning,
), ),
); );
@@ -767,7 +767,10 @@ class _RobotListViewState extends State<RobotListView> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => BleDeviceDetailPage(device: connectedDevice), builder: (_) => BleDeviceDetailPage(
device: connectedDevice,
displayName: deviceName,
),
), ),
); );
return; return;
@@ -848,7 +851,10 @@ class _RobotListViewState extends State<RobotListView> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => BleDeviceDetailPage(device: device), builder: (_) => BleDeviceDetailPage(
device: device,
displayName: deviceName,
),
), ),
); );
} else { } else {
@@ -881,7 +887,7 @@ class _RobotListViewState extends State<RobotListView> {
dialogShown = true; dialogShown = true;
return AlertDialog( return AlertDialog(
title: const Text('未找到设备'), title: const Text('未找到设备'),
content: const Text('请确认机器已上线并打开蓝牙了'), content: const Text('暂未匹配到该设备,稍后重试'),
actions: [ actions: [
TextButton( TextButton(
onPressed: () { onPressed: () {
@@ -933,7 +939,10 @@ class _RobotListViewState extends State<RobotListView> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => BleDeviceDetailPage(device: dev!), builder: (_) => BleDeviceDetailPage(
device: dev!,
displayName: deviceName,
),
), ),
); );
break; break;

View File

@@ -0,0 +1,716 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
/// 帮助与反馈页面
class HelpFeedbackPage extends StatefulWidget {
const HelpFeedbackPage({super.key});
@override
State<HelpFeedbackPage> createState() => _HelpFeedbackPageState();
}
class _HelpFeedbackPageState extends State<HelpFeedbackPage>
with SingleTickerProviderStateMixin {
late TabController _tabController;
final TextEditingController _feedbackController = TextEditingController();
final TextEditingController _contactController = TextEditingController();
int _selectedFeedbackType = 0;
List<String> _selectedImages = [];
static const _feedbackTypes = [
{'icon': Icons.lightbulb_outline, 'label': '功能建议'},
{'icon': Icons.bug_report_outlined, 'label': 'Bug报告'},
{'icon': Icons.sentiment_dissatisfied_outlined, 'label': '体验问题'},
{'icon': Icons.more_horiz, 'label': '其他'},
];
static const _faqList = [
{
'category': '设备绑定',
'questions': [
{
'q': '扫码绑定失败怎么办?',
'a': '请检查设备是否已开机并处于待绑定状态,确保手机蓝牙已开启且网络正常。如仍无法绑定,请尝试重启设备后重新扫码。'
},
{
'q': '搜不到设备蓝牙信号?',
'a': '请确认设备已开机且蓝牙指示灯正常闪烁。尝试靠近设备(1米以内)后重新搜索。如多个设备同时绑定,请逐一操作。'
},
]
},
{
'category': '路径规划',
'questions': [
{
'q': '无法生成路径?',
'a': '请确保已绘制完整的作业区域(至少3个打点),并检查GPS信号是否良好。如果使用自动规划模式,请确认区域边界没有自相交。'
},
{
'q': '地图不显示或定位偏移?',
'a': '请检查手机GPS是否已开启,并授权App位置权限。在室内或信号较弱的区域可能出现定位偏移,建议到开阔区域使用。'
},
]
},
{
'category': '远程控制',
'questions': [
{
'q': '远程视频卡顿/连接超时?',
'a': '请检查手机和设备的网络连接是否稳定。建议在4G/Wi-Fi信号良好的环境下使用远程控制功能。如持续卡顿,可尝试降低视频分辨率。'
},
{
'q': '急停功能怎么使用?',
'a': '在远程控制页面,点击屏幕中央红色急停按钮即可立即停止设备运行。急停后需手动解除才能恢复操作。'
},
]
},
{
'category': '工单系统',
'questions': [
{
'q': '如何提交工单?',
'a': '在「工单」页面点击右下角「新建工单」按钮,选择工单类型,填写问题描述并上传相关图片后提交即可。'
},
{
'q': '工单状态怎么看?',
'a': '在「工单」页面可查看所有已提交的工单及其当前状态(待处理/处理中/已完成)。点击具体工单可查看详情和回复。'
},
]
},
{
'category': '账号问题',
'questions': [
{
'q': '忘记密码怎么办?',
'a': '在登录页面点击「忘记密码」,通过注册手机号验证后即可重置密码。'
},
{
'q': '换设备登录需要重新绑定?',
'a': '更换手机登录同一账号后,设备绑定关系不会丢失。但需要在新设备上重新搜索和连接设备。'
},
]
},
];
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
}
@override
void dispose() {
_tabController.dispose();
_feedbackController.dispose();
_contactController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light,
),
child: Scaffold(
backgroundColor: context.appColors.pageBackground,
appBar: AppBar(
elevation: 0,
leading: IconButton(
icon: Icon(Icons.arrow_back, color: context.appColors.textPrimary),
onPressed: () => Navigator.pop(context),
),
title: Text(
AppLocalizations.of(context).translate('my_v2.help_feedback'),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: context.appColors.textPrimary,
),
),
centerTitle: true,
bottom: TabBar(
controller: _tabController,
labelColor: const Color(0xFF165DFF),
unselectedLabelColor: context.appColors.textTertiary,
indicatorColor: const Color(0xFF165DFF),
indicatorSize: TabBarIndicatorSize.label,
tabs: const [
Tab(text: '常见问题'),
Tab(text: '意见反馈'),
],
),
),
body: TabBarView(
controller: _tabController,
children: [
_buildFAQTab(),
_buildFeedbackTab(),
],
),
),
);
}
// ==================== 常见问题 ====================
Widget _buildFAQTab() {
return ListView(
padding: const EdgeInsets.all(16),
children: [
..._faqList.map((category) => _buildFAQCategory(category)),
const SizedBox(height: 20),
_buildContactSection(),
],
);
}
Widget _buildFAQCategory(Map<String, dynamic> categoryData) {
final questions = categoryData['questions'] as List;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(top: 8, bottom: 8),
child: Text(
categoryData['category'] as String,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: context.appColors.textPrimary,
),
),
),
Container(
decoration: BoxDecoration(
color: context.appColors.cardBackground,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: context.appColors.cardShadow,
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Column(
children: questions.asMap().entries.map((entry) {
final index = entry.key;
final item = entry.value as Map<String, dynamic>;
final isLast = index == questions.length - 1;
return _buildFAQItem(
item['q'] as String,
item['a'] as String,
isLast,
);
}).toList(),
),
),
const SizedBox(height: 16),
],
);
}
Widget _buildFAQItem(String question, String answer, bool isLast) {
return Column(
children: [
ExpansionTile(
tilePadding: const EdgeInsets.symmetric(horizontal: 16),
childrenPadding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
shape: const Border(),
collapsedShape: const Border(),
title: Text(
question,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: context.appColors.textPrimary,
),
),
children: [
Text(
answer,
style: TextStyle(
fontSize: 13,
height: 1.6,
color: context.appColors.textSecondary,
),
),
],
),
if (!isLast)
Padding(
padding: const EdgeInsets.only(left: 48),
child: Divider(
height: 1,
thickness: 0.5,
color: context.appColors.divider,
),
),
],
);
}
// ==================== 联系客服 ====================
Widget _buildContactSection() {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: context.appColors.cardBackground,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: context.appColors.cardShadow,
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'联系客服',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: context.appColors.textPrimary,
),
),
const SizedBox(height: 16),
_buildContactItem(
Icons.phone_outlined,
'客服热线',
'400-000-0000',
onTap: () => _showPhoneDialog('400-000-0000'),
),
const Divider(height: 24),
_buildContactItem(
Icons.qr_code_2,
'企业微信',
'扫码添加客服微信',
onTap: () => debugPrint('显示企业微信二维码'),
),
],
),
);
}
Widget _buildContactItem(
IconData icon,
String title,
String subtitle, {
VoidCallback? onTap,
}) {
return GestureDetector(
onTap: onTap,
behavior: HitTestBehavior.opaque,
child: Row(
children: [
Icon(icon, size: 22, color: context.appColors.textSecondary),
const SizedBox(width: 12),
Expanded(
child: Text(
title,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: context.appColors.textPrimary,
),
),
),
Text(
subtitle,
style: TextStyle(
fontSize: 13,
color: context.appColors.textTertiary,
),
),
const SizedBox(width: 6),
Icon(
Icons.chevron_right,
color: context.appColors.textTertiary,
size: 20,
),
],
),
);
}
// ==================== 意见反馈 ====================
Widget _buildFeedbackTab() {
return ListView(
padding: const EdgeInsets.all(16),
children: [
// 反馈类型
_buildSectionCard(
title: '反馈类型',
child: Wrap(
spacing: 8,
runSpacing: 8,
children: _feedbackTypes.asMap().entries.map((entry) {
final index = entry.key;
final type = entry.value;
final isSelected = _selectedFeedbackType == index;
return GestureDetector(
onTap: () => setState(() => _selectedFeedbackType = index),
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 8,
),
decoration: BoxDecoration(
color: isSelected
? const Color(0xFF165DFF).withOpacity(0.1)
: context.appColors.fillBackground,
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: isSelected
? const Color(0xFF165DFF)
: Colors.transparent,
width: 1,
),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
type['icon'] as IconData,
size: 16,
color: isSelected
? const Color(0xFF165DFF)
: context.appColors.textSecondary,
),
const SizedBox(width: 6),
Text(
type['label'] as String,
style: TextStyle(
fontSize: 13,
color: isSelected
? const Color(0xFF165DFF)
: context.appColors.textSecondary,
fontWeight:
isSelected ? FontWeight.w600 : FontWeight.normal,
),
),
],
),
),
);
}).toList(),
),
),
const SizedBox(height: 16),
// 问题描述
_buildSectionCard(
title: '问题描述',
child: TextField(
controller: _feedbackController,
maxLines: 5,
maxLength: 500,
decoration: InputDecoration(
hintText: '请详细描述您遇到的问题或建议...',
hintStyle: TextStyle(
fontSize: 14,
color: context.appColors.textTertiary,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: context.appColors.divider),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: context.appColors.divider),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: const BorderSide(
color: Color(0xFF165DFF),
width: 1.5,
),
),
filled: true,
fillColor: context.appColors.fillBackground,
contentPadding: const EdgeInsets.all(12),
),
),
),
const SizedBox(height: 16),
// 添加截图
_buildSectionCard(
title: '添加截图 (${_selectedImages.length}/6)',
child: Wrap(
spacing: 8,
runSpacing: 8,
children: [
..._selectedImages.asMap().entries.map((entry) {
return _buildImageItem(entry.key, entry.value);
}),
if (_selectedImages.length < 6) _buildAddImageButton(),
],
),
),
const SizedBox(height: 16),
// 联系方式
_buildSectionCard(
title: '联系方式(选填)',
child: TextField(
controller: _contactController,
decoration: InputDecoration(
hintText: '手机号/微信号,方便我们回访',
hintStyle: TextStyle(
fontSize: 14,
color: context.appColors.textTertiary,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: context.appColors.divider),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(color: context.appColors.divider),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: const BorderSide(
color: Color(0xFF165DFF),
width: 1.5,
),
),
filled: true,
fillColor: context.appColors.fillBackground,
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 14,
),
prefixIcon: const Icon(
Icons.phone_outlined,
size: 20,
color: Color(0xFF86909C),
),
),
),
),
const SizedBox(height: 24),
// 提交按钮
SizedBox(
width: double.infinity,
height: 48,
child: ElevatedButton(
onPressed: _submitFeedback,
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF165DFF),
foregroundColor: Colors.white,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: const Text(
'提交反馈',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
),
),
),
const SizedBox(height: 32),
],
);
}
Widget _buildSectionCard({
required String title,
required Widget child,
}) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: context.appColors.cardBackground,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: context.appColors.cardShadow,
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: context.appColors.textPrimary,
),
),
const SizedBox(height: 12),
child,
],
),
);
}
Widget _buildImageItem(int index, String path) {
return Stack(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.file(
File(path),
width: 80,
height: 80,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) => Container(
width: 80,
height: 80,
color: context.appColors.fillBackground,
child: Icon(
Icons.broken_image_outlined,
color: context.appColors.textTertiary,
),
),
),
),
Positioned(
top: 2,
right: 2,
child: GestureDetector(
onTap: () => setState(() => _selectedImages.removeAt(index)),
child: Container(
padding: const EdgeInsets.all(2),
decoration: const BoxDecoration(
color: Colors.black54,
shape: BoxShape.circle,
),
child: const Icon(
Icons.close,
size: 14,
color: Colors.white,
),
),
),
),
],
);
}
Widget _buildAddImageButton() {
return GestureDetector(
onTap: _pickImage,
child: Container(
width: 80,
height: 80,
decoration: BoxDecoration(
color: context.appColors.fillBackground,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: context.appColors.divider,
width: 1,
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.add_photo_alternate_outlined,
size: 28,
color: context.appColors.textTertiary,
),
const SizedBox(height: 4),
Text(
'添加截图',
style: TextStyle(
fontSize: 11,
color: context.appColors.textTertiary,
),
),
],
),
),
);
}
// ==================== 交互方法 ====================
void _showPhoneDialog(String phoneNumber) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('客服热线'),
content: SelectableText(
phoneNumber,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('关闭'),
),
TextButton(
onPressed: () {
Clipboard.setData(ClipboardData(text: phoneNumber));
Navigator.pop(context);
ScaffoldMessenger.of(this.context).showSnackBar(
const SnackBar(content: Text('号码已复制')),
);
},
child: const Text('复制号码'),
),
],
),
);
}
void _pickImage() {
// 占位:接入 image_picker 后实现
debugPrint('选择图片');
setState(() {
_selectedImages.add('placeholder_${_selectedImages.length}');
});
}
void _submitFeedback() {
if (_feedbackController.text.trim().isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('请输入问题描述'),
backgroundColor: Color(0xFFF53F3F),
),
);
return;
}
// TODO: 调用后端接口提交反馈
debugPrint('提交反馈: type=${_feedbackTypes[_selectedFeedbackType]['label']}, '
'content=${_feedbackController.text}, '
'images=${_selectedImages.length}, '
'contact=${_contactController.text}');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text('反馈已提交,感谢您的支持!'),
backgroundColor: context.appColors.success,
),
);
// 重置表单
_feedbackController.clear();
_contactController.clear();
setState(() {
_selectedFeedbackType = 0;
_selectedImages.clear();
});
}
}

View File

@@ -19,6 +19,7 @@ import 'package:maibu_satabot_v2/features/v2/my/presentation/widgets/quick_actio
import 'package:maibu_satabot_v2/features/v2/my/presentation/widgets/menu_item_card.dart'; import 'package:maibu_satabot_v2/features/v2/my/presentation/widgets/menu_item_card.dart';
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/system_settings_page.dart'; import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/system_settings_page.dart';
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/profile_detail_page.dart'; import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/profile_detail_page.dart';
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/help_feedback_page.dart';
/// 我的页面(100% 还原设计稿) /// 我的页面(100% 还原设计稿)
class MyPage extends StatelessWidget { class MyPage extends StatelessWidget {
@@ -75,90 +76,91 @@ class _MyPageContent extends StatelessWidget {
return SingleChildScrollView( return SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
// 用户信息卡片(延伸到状态栏) // 用户信息卡片(延伸到状态栏)
UserProfileCard( UserProfileCard(
name: userName, name: userName,
role: userRole, role: userRole,
avatar: user?.avatar, avatar: user?.avatar,
onTap: () { onTap: () {
// 跳转到个人信息详情页 // 跳转到个人信息详情页
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const ProfileDetailPage(), builder: (context) => const ProfileDetailPage(),
), ),
);
},
),
// 快捷入口卡片(负margin向上重叠)
Transform.translate(
offset: const Offset(0, -15),
child: QuickActionCard(
onMessageTap: () {
debugPrint('我的消息');
},
onFavoriteTap: () {
debugPrint('我的收藏');
},
onWorkOrderTap: () {
debugPrint('我的工单');
},
),
),
// 菜单列表(白色卡片)
Container(
margin: const EdgeInsets.only(
top: 15,
left: 16,
right: 16,
bottom: 16,
),
decoration: BoxDecoration(
color: context.appColors.cardBackground,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: context.appColors.cardShadow,
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero,
// 末尾追加退出登录,占据“关于我们”原来的位置
itemCount: state.menuItems.length + 1,
itemBuilder: (context, index) {
// 退出登录(列表最后一项,在可滚动区域内避免底部溢出)
if (index == state.menuItems.length) {
return _buildLogoutButton(context);
}
final item = state.menuItems[index];
// 🔥 夜间模式开关值以全局 ThemeCubit 状态为准
final displayItem = item.id == 'night_mode'
? item.copyWith(switchValue: isDarkMode)
: item;
return MenuItemCard(
item: displayItem,
onTap: () => _handleMenuItemTap(context, cubit, item),
onSwitchChanged: item.hasSwitch
? (value) {
// 更新菜单 UI 状态
cubit.toggleNightMode(value);
// 🔥 真正切换全局主题
context
.read<ThemeCubit>()
.toggleDarkMode(value);
}
: null,
); );
}, },
), ),
), // 快捷入口卡片(负margin向上重叠)
], Transform.translate(
offset: const Offset(0, -15),
child: QuickActionCard(
onMessageTap: () {
debugPrint('我的消息');
},
onFavoriteTap: () {
debugPrint('我的收藏');
},
onWorkOrderTap: () {
debugPrint('我的工单');
},
),
),
// 菜单列表(白色卡片)
Container(
margin: const EdgeInsets.only(
top: 15,
left: 16,
right: 16,
bottom: 16,
),
decoration: BoxDecoration(
color: context.appColors.cardBackground,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: context.appColors.cardShadow,
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero,
// 末尾追加退出登录,占据“关于我们”原来的位置
itemCount: state.menuItems.length + 1,
itemBuilder: (context, index) {
// 退出登录(列表最后一项,在可滚动区域内避免底部溢出)
if (index == state.menuItems.length) {
return _buildLogoutButton(context);
}
final item = state.menuItems[index];
// 🔥 夜间模式开关值以全局 ThemeCubit 状态为准
final displayItem = item.id == 'night_mode'
? item.copyWith(switchValue: isDarkMode)
: item;
return MenuItemCard(
item: displayItem,
onTap: () =>
_handleMenuItemTap(context, cubit, item),
onSwitchChanged: item.hasSwitch
? (value) {
// 更新菜单 UI 状态
cubit.toggleNightMode(value);
// 🔥 真正切换全局主题
context.read<ThemeCubit>().toggleDarkMode(
value,
);
}
: null,
);
},
),
),
],
), ),
); );
} }
@@ -196,6 +198,13 @@ class _MyPageContent extends StatelessWidget {
MaterialPageRoute(builder: (context) => const SystemSettingsPage()), MaterialPageRoute(builder: (context) => const SystemSettingsPage()),
); );
break; break;
case 'help_feedback':
// 跳转到帮助与反馈页面
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const HelpFeedbackPage()),
);
break;
default: default:
debugPrint('点击菜单: ${item.title}'); debugPrint('点击菜单: ${item.title}');
// TODO: 根据 ID 跳转到对应页面 // TODO: 根据 ID 跳转到对应页面