基本完成APP的所有页面中的语言切换支持的开发和设计
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart';
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/widgets/common/commonFn.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -90,7 +91,7 @@ class ImmersionHeader extends StatelessWidget {
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// 3. 状态标签也紧跟其后
|
||||
_buildStatusTag(device.isOnline),
|
||||
_buildStatusTag(device.isOnline, context),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -121,7 +122,7 @@ class ImmersionHeader extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusTag(bool isOnline) {
|
||||
Widget _buildStatusTag(bool isOnline, BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
@@ -135,7 +136,11 @@ class ImmersionHeader extends StatelessWidget {
|
||||
children: [
|
||||
CircleAvatar(radius: 3, backgroundColor: isOnline ? Colors.green : Colors.grey),
|
||||
const SizedBox(width: 6),
|
||||
Text(isOnline ? "在线" : "离线", style: const TextStyle(fontSize: 12, color: Colors.black54)),
|
||||
Text(
|
||||
isOnline ? AppLocalizations.of(context).translate('home.device_online') : AppLocalizations.of(context).translate('home.device_offline'),
|
||||
style: const TextStyle(fontSize: 12, color: Colors.black54),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -199,7 +204,11 @@ class ImmersionHeader extends StatelessWidget {
|
||||
height: 5,
|
||||
decoration: BoxDecoration(color: Colors.grey[300], borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
const Text("切换设备", style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
Text(
|
||||
AppLocalizations.of(modalContext).translate('home.switch_device'),
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Container(height: 0.5, margin: const EdgeInsets.symmetric(horizontal: 20), color: Colors.grey.withOpacity(0.1)),
|
||||
|
||||
@@ -216,7 +225,7 @@ class ImmersionHeader extends StatelessWidget {
|
||||
children: [
|
||||
const CircularProgressIndicator(color: Colors.blue),
|
||||
const SizedBox(height: 16),
|
||||
Text("加载中...", style: TextStyle(color: Colors.grey[600])),
|
||||
Text(AppLocalizations.of(context).translate('home.loading'), style: TextStyle(color: Colors.grey[600])),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -224,13 +233,13 @@ class ImmersionHeader extends StatelessWidget {
|
||||
|
||||
// 2. 列表展示
|
||||
if (state.devices.isEmpty) {
|
||||
return const Center(
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.description_outlined, size: 60, color: Colors.grey),
|
||||
SizedBox(height: 16),
|
||||
Text('暂无设备', style: TextStyle(fontSize: 16, color: Colors.grey)),
|
||||
const Icon(Icons.description_outlined, size: 60, color: Colors.grey),
|
||||
const SizedBox(height: 16),
|
||||
Text(AppLocalizations.of(context).translate('home.no_devices'), style: const TextStyle(fontSize: 16, color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -288,7 +297,7 @@ class ImmersionHeader extends StatelessWidget {
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: Text(
|
||||
(device.deviceAlias?.trim() ?? '').isEmpty ? '未知设备' : device.deviceAlias!,
|
||||
(device.deviceAlias?.trim() ?? '').isEmpty ? AppLocalizations.of(context).translate('home.unknown_device') : device.deviceAlias!,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
// 关键属性:处理文本溢出
|
||||
maxLines: 2, // 最多显示2行
|
||||
@@ -299,7 +308,11 @@ class ImmersionHeader extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const Text("点击查看详情", style: TextStyle(color: Colors.grey, fontSize: 12)),
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('home.click_to_view'),
|
||||
style: const TextStyle(color: Colors.grey, fontSize: 12),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -319,8 +332,8 @@ class ImmersionHeader extends StatelessWidget {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
text: isSelected ? "使用中" : "切换",
|
||||
width: 80,
|
||||
text: isSelected ? AppLocalizations.of(context).translate('home.in_use') : AppLocalizations.of(context).translate('home.switch'),
|
||||
width: 90,
|
||||
height: 30,
|
||||
fontSize: 14,
|
||||
// 如果是当前设备,按钮颜色变灰
|
||||
@@ -333,8 +346,8 @@ class ImmersionHeader extends StatelessWidget {
|
||||
print("通过按钮进入详情,设备名称:$device");
|
||||
},
|
||||
|
||||
text: "详情",
|
||||
width: 80,
|
||||
text: AppLocalizations.of(context).translate('home.details'),
|
||||
width: 90,
|
||||
height: 30,
|
||||
fontSize: 14,
|
||||
backgroundColor: Colors.white,
|
||||
|
||||
Reference in New Issue
Block a user