更新日志铺路部分,dev中
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../widgets/trend_chart.dart';
|
||||
import '../widgets/battery_summary.dart';
|
||||
import '../widgets/battery_info_panel.dart';
|
||||
import '../widgets/charge_entry.dart';
|
||||
import '../widgets/charge_detail_page.dart';
|
||||
|
||||
/// 电池数据布局(含数据展示、趋势图、充电状态、电压温度面板)
|
||||
class BatteryDataLayout extends StatelessWidget {
|
||||
final String deviceModel;
|
||||
final double healthPercent;
|
||||
final int cycleCount;
|
||||
final double currentCap;
|
||||
final int designCap;
|
||||
final List<Map<String, dynamic>> trendData;
|
||||
final bool isCharging;
|
||||
final String chargeSummary;
|
||||
final double batteryVolt;
|
||||
final double batteryTemp;
|
||||
final double maxVolt;
|
||||
final double minVolt;
|
||||
final double maxTemp;
|
||||
final double minTemp;
|
||||
final String chargeType;
|
||||
final bool isWireless;
|
||||
final double chargePower;
|
||||
final double chargeVolt;
|
||||
final double chargeCurr;
|
||||
final int? wiredLevel;
|
||||
|
||||
const BatteryDataLayout({
|
||||
super.key,
|
||||
required this.deviceModel,
|
||||
required this.healthPercent,
|
||||
required this.cycleCount,
|
||||
required this.currentCap,
|
||||
required this.designCap,
|
||||
required this.trendData,
|
||||
required this.isCharging,
|
||||
required this.chargeSummary,
|
||||
required this.batteryVolt,
|
||||
required this.batteryTemp,
|
||||
required this.maxVolt,
|
||||
required this.minVolt,
|
||||
required this.maxTemp,
|
||||
required this.minTemp,
|
||||
required this.chargeType,
|
||||
required this.isWireless,
|
||||
required this.chargePower,
|
||||
required this.chargeVolt,
|
||||
required this.chargeCurr,
|
||||
this.wiredLevel,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
deviceModel,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
BatterySummary(
|
||||
healthPercent: healthPercent,
|
||||
cycleCount: cycleCount,
|
||||
currentCap: currentCap,
|
||||
designCap: designCap,
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
TrendChart(data: trendData, designCap: designCap),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 充电状态 + 信息面板(带进场动画)
|
||||
_buildChargeAndInfoPanel(context),
|
||||
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildChargeAndInfoPanel(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
// 充电状态入口(保持原有的透明度/位移动画由父级控制)
|
||||
ChargeEntry(
|
||||
summary: chargeSummary,
|
||||
isCharging: isCharging,
|
||||
onTap: () {
|
||||
if (isCharging) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChargeDetailPage(
|
||||
chargeType: chargeType,
|
||||
isWireless: isWireless,
|
||||
power: chargePower,
|
||||
volt: chargeVolt,
|
||||
curr: chargeCurr,
|
||||
wiredLevel: wiredLevel,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
BatteryInfoPanel(
|
||||
batteryVolt: batteryVolt,
|
||||
batteryTemp: batteryTemp,
|
||||
maxVolt: maxVolt,
|
||||
minVolt: minVolt,
|
||||
maxTemp: maxTemp,
|
||||
minTemp: minTemp,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 空状态布局(无数据时显示)
|
||||
class EmptyStateLayout extends StatelessWidget {
|
||||
const EmptyStateLayout({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.battery_unknown, size: 64, color: Colors.grey),
|
||||
SizedBox(height: 16),
|
||||
Text('暂无数据', style: TextStyle(fontSize: 18, color: Colors.grey)),
|
||||
Text('点击右上角刷新尝试', style: TextStyle(fontSize: 14, color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user