46 lines
1.4 KiB
Dart
46 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:miaoji_zhang/shared/theme/app_theme.dart';
|
|
import 'package:miaoji_zhang/shared/widgets/app_icons.dart';
|
|
|
|
/// P24 离线状态:顶部提示条 + AI 入口/tab 控制
|
|
class OfflineBar extends StatelessWidget {
|
|
const OfflineBar({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
|
color: AppTheme.orange,
|
|
child: Row(
|
|
children: [
|
|
AppIcons.icon(AppIcons.offline, size: 16, color: Colors.white),
|
|
const SizedBox(width: 8),
|
|
const Expanded(
|
|
child: Text(
|
|
'当前无网络 · AI 功能暂不可用 · 手动记账正常',
|
|
style: TextStyle(fontSize: 10.5, color: Colors.white),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 检测是否有网络连接(简化版:同时 ping 后端)
|
|
class ConnectivityChecker {
|
|
static bool _lastKnown = true;
|
|
|
|
static bool get isOnline => _lastKnown;
|
|
|
|
static Future<bool> check() async {
|
|
// 简化实现:future 如果需要真正的网络检测,用 connectivity_plus 包
|
|
// 当前返回上次已知状态
|
|
return _lastKnown;
|
|
}
|
|
|
|
static void setOffline() => _lastKnown = false;
|
|
static void setOnline() => _lastKnown = true;
|
|
}
|