Commit 34e710d5 authored by akari's avatar akari

feat: 添加出厂设置页

parent d89810d0
import 'package:equatable/equatable.dart';
class FactorySettingItem extends Equatable {
const FactorySettingItem({
required this.label,
required this.value,
});
final String label;
final String value;
@override
List<Object?> get props => [label, value];
}
class FactorySettingGroup extends Equatable {
const FactorySettingGroup({
required this.title,
required this.items,
});
final String title;
final List<FactorySettingItem> items;
@override
List<Object?> get props => [title, items];
}
class FactorySettingsIndexState extends Equatable {
const FactorySettingsIndexState();
const FactorySettingsIndexState({
this.warningText = '非专业人员请勿更改设备各项参数!',
this.leftGroups = const [
FactorySettingGroup(
title: '温度范围设定(℃)',
items: [
FactorySettingItem(label: '温度设定上限:', value: '34'),
FactorySettingItem(label: '温度设定下限:', value: '17'),
],
),
FactorySettingGroup(
title: '氧浓度范围设定(%)',
items: [
FactorySettingItem(label: '氧浓度设定上限:', value: '34'),
FactorySettingItem(label: '氧浓度设定下限:', value: '17'),
],
),
FactorySettingGroup(
title: '湿度范围设定(%)',
items: [
FactorySettingItem(label: '湿度设定上限:', value: '34'),
FactorySettingItem(label: '湿度设定下限:', value: '17'),
],
),
],
this.timeLimitGroup = const FactorySettingGroup(
title: '时间上限设定(分钟)',
items: [
FactorySettingItem(label: 'UV时间设定上限:', value: '34'),
FactorySettingItem(label: '红外时间设定上限:', value: '17'),
FactorySettingItem(label: '雾化时间设定上限:', value: '17'),
],
),
});
final String warningText;
final List<FactorySettingGroup> leftGroups;
final FactorySettingGroup timeLimitGroup;
@override
List<Object?> get props => [];
List<Object?> get props => [
warningText,
leftGroups,
timeLimitGroup,
];
}
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../widgets/settings_panel_frame.dart';
import '../cubit/factory_settings_index_cubit.dart';
import '../cubit/factory_settings_index_state.dart';
class FactorySettingsPanel extends StatelessWidget {
const FactorySettingsPanel({super.key});
......@@ -10,17 +13,277 @@ class FactorySettingsPanel extends StatelessWidget {
Widget build(BuildContext context) {
return SettingsPanelFrame(
backgroundAsset: settingsAssetPanelMain,
padding: EdgeInsets.all(42.w),
child: Align(
alignment: Alignment.topLeft,
child: Text(
'出厂设置',
padding: EdgeInsets.fromLTRB(42.w, 34.h, 42.w, 42.h),
child: BlocBuilder<FactorySettingsIndexCubit, FactorySettingsIndexState>(
builder: (context, state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_WarningBanner(text: state.warningText),
SizedBox(height: 44.h),
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: _FactorySettingsColumn(
groups: state.leftGroups,
),
),
Container(
width: 1.w,
margin: EdgeInsets.symmetric(horizontal: 42.w),
color: const Color(0xFF3A9BD2).withValues(alpha: 0.42),
),
Expanded(
child: _FactoryActionColumn(
group: state.timeLimitGroup,
),
),
],
),
),
],
);
},
),
);
}
}
class _WarningBanner extends StatelessWidget {
const _WarningBanner({required this.text});
final String text;
@override
Widget build(BuildContext context) {
return Container(
height: 62.h,
alignment: Alignment.center,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.white.withValues(alpha: 0.02),
const Color(0xFF6A3C23).withValues(alpha: 0.72),
Colors.white.withValues(alpha: 0.02),
],
),
),
child: Text(
text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white,
fontSize: 30.sp,
fontWeight: FontWeight.w800,
),
),
);
}
}
class _FactorySettingsColumn extends StatelessWidget {
const _FactorySettingsColumn({required this.groups});
final List<FactorySettingGroup> groups;
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
physics: const ClampingScrollPhysics(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
for (final group in groups) ...[
_FactorySettingGroupView(group: group),
SizedBox(height: 28.h),
],
],
),
);
}
}
class _FactoryActionColumn extends StatelessWidget {
const _FactoryActionColumn({required this.group});
final FactorySettingGroup group;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_FactorySettingGroupView(group: group),
const Spacer(),
Center(
child: Column(
children: [
const _WideFactoryButton(text: '设备校准'),
SizedBox(height: 28.h),
const _WideFactoryButton(text: '初始化设置'),
],
),
),
SizedBox(height: 64.h),
Row(
children: [
const Expanded(child: _FactoryButton(text: '撤销')),
SizedBox(width: 34.w),
const Expanded(child: _FactoryButton(text: '应用更改')),
],
),
],
);
}
}
class _FactorySettingGroupView extends StatelessWidget {
const _FactorySettingGroupView({required this.group});
final FactorySettingGroup group;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
group.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white,
fontSize: 34.sp,
fontSize: 26.sp,
fontWeight: FontWeight.w800,
),
),
SizedBox(height: 24.h),
for (final item in group.items) ...[
_FactorySettingRow(item: item),
SizedBox(height: 18.h),
],
],
);
}
}
class _FactorySettingRow extends StatelessWidget {
const _FactorySettingRow({required this.item});
final FactorySettingItem item;
@override
Widget build(BuildContext context) {
return Row(
children: [
Expanded(
child: Text(
item.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white,
fontSize: 21.sp,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 16.w),
_ValueBox(value: item.value),
],
);
}
}
class _ValueBox extends StatelessWidget {
const _ValueBox({required this.value});
final String value;
@override
Widget build(BuildContext context) {
return Container(
width: 104.w,
height: 48.h,
alignment: Alignment.center,
decoration: BoxDecoration(
color: const Color(0xFF14253A).withValues(alpha: 0.86),
borderRadius: BorderRadius.circular(8.r),
border: Border.all(color: const Color(0xFF68CFFF), width: 1.w),
),
child: Text(
value,
style: TextStyle(
color: Colors.white,
fontSize: 25.sp,
fontWeight: FontWeight.w800,
),
),
);
}
}
class _WideFactoryButton extends StatelessWidget {
const _WideFactoryButton({required this.text});
final String text;
@override
Widget build(BuildContext context) {
return SizedBox(
width: 360.w,
height: 70.h,
child: _FactoryButton(text: text),
);
}
}
class _FactoryButton extends StatelessWidget {
const _FactoryButton({required this.text});
final String text;
@override
Widget build(BuildContext context) {
return Container(
height: 70.h,
padding: EdgeInsets.symmetric(horizontal: 28.w),
decoration: settingsButtonDecoration(active: true),
child: Row(
children: [
Text(
'《《',
style: TextStyle(
color: const Color(0xFF67C9F5).withValues(alpha: 0.72),
fontSize: 25.sp,
fontWeight: FontWeight.w700,
),
),
Expanded(
child: Text(
text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 25.sp,
fontWeight: FontWeight.w800,
),
),
),
Text(
'》》',
style: TextStyle(
color: const Color(0xFF67C9F5).withValues(alpha: 0.72),
fontSize: 25.sp,
fontWeight: FontWeight.w700,
),
),
],
),
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment