power_clamp_issue&search_issue

This commit is contained in:
mohammad
2024-10-28 17:08:49 +03:00
parent d4d7ced585
commit 13f244ff19
7 changed files with 295 additions and 213 deletions
@@ -22,6 +22,8 @@ class PowerClampCard extends StatelessWidget {
final String? totalFactor;
final Widget? dateSwitcher;
final String? formattedDate;
final String? phaseType;
final String? energyConsumption;
final Function()? selectDateEvent;
final List<EnergyData>? chartData;
@@ -37,6 +39,7 @@ class PowerClampCard extends StatelessWidget {
this.totalCurrentGeneral,
this.totalFrequencyGeneral,
this.totalVoltage,
this.phaseType,
this.totalActive,
this.totalFrequency,
this.totalFactor,
@@ -53,8 +56,7 @@ class PowerClampCard extends StatelessWidget {
Widget build(BuildContext context) {
return DefaultContainer(
child: Padding(
padding:
const EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
padding: const EdgeInsets.only(left: 5, right: 5, top: 10, bottom: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
@@ -116,7 +118,7 @@ class PowerClampCard extends StatelessWidget {
PowerClampInfoCard(
iconPath: Assets.voltageIcon,
title: 'Voltage',
value: totalVoltage!,
value: '${double.parse(totalVoltage!) / 10}',
unit: ' V',
),
PowerClampInfoCard(
@@ -152,13 +154,15 @@ class PowerClampCard extends StatelessWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const BodyMedium(
text: 'Total consumption',
BodyMedium(
text: isGeneral == true
? 'Total consumption'
: phaseType!,
fontSize: 12,
fontWeight: FontWeight.w700,
),
Text(
dateTimeSelected !,
dateTimeSelected!,
style: const TextStyle(
fontSize: 8, fontWeight: FontWeight.w400),
),
@@ -55,7 +55,6 @@ class _PowerClampPageState extends State<PowerClampPage> {
child: BlocProvider(
create: (context) => PowerClampBloc(PCId: widget.device?.uuid ?? '')
..add(const PowerClampInitial()),
// ..add(const ReportLogsInitial(code: 'VoltageA')),
child: BlocBuilder<PowerClampBloc, PowerClampState>(
builder: (context, state) {
final blocProvider = context.read<PowerClampBloc>();
@@ -88,6 +87,7 @@ class _PowerClampPageState extends State<PowerClampPage> {
},
child: PageView(controller: _pageController, children: [
_buildPowerClampCard(
phaseType: '',
title: 'Total Energy \nConsumption',
phase: model.status.general,
isGeneral: true,
@@ -96,18 +96,21 @@ class _PowerClampPageState extends State<PowerClampPage> {
),
_buildPowerClampCard(
title: 'Phase A Energy \nConsumption',
phaseType: 'Phase A consumption',
phase: model.status.phaseA,
chartData: chartData,
blocProvider: blocProvider,
),
_buildPowerClampCard(
title: 'Phase B Energy \nConsumption',
phaseType: 'Phase B consumption',
phase: model.status.phaseB,
chartData: chartData,
blocProvider: blocProvider,
),
_buildPowerClampCard(
title: 'Phase C Energy \nConsumption',
phaseType: 'Phase C consumption',
phase: model.status.phaseC,
chartData: chartData,
blocProvider: blocProvider,
@@ -154,6 +157,7 @@ class _PowerClampPageState extends State<PowerClampPage> {
List<EnergyData> chartData, PowerClampBloc blocProvider) {
return [
_buildPowerClampCard(
phaseType: '',
title: 'Total Energy \nConsumption',
phase: model.status.general,
isGeneral: true,
@@ -161,18 +165,21 @@ class _PowerClampPageState extends State<PowerClampPage> {
blocProvider: blocProvider,
),
_buildPowerClampCard(
phaseType: 'Phase A consumption',
title: 'Phase A Energy \nConsumption',
phase: model.status.phaseA,
chartData: chartData,
blocProvider: blocProvider,
),
_buildPowerClampCard(
phaseType: 'Phase B consumption',
title: 'Phase B Energy \nConsumption',
phase: model.status.phaseB,
chartData: chartData,
blocProvider: blocProvider,
),
_buildPowerClampCard(
phaseType: 'Phase C consumption',
title: 'Phase C Energy \nConsumption',
phase: model.status.phaseC,
chartData: chartData,
@@ -183,15 +190,18 @@ class _PowerClampPageState extends State<PowerClampPage> {
Widget _buildPowerClampCard({
required String title,
required String phaseType,
required Phase phase,
bool isGeneral = false,
required List<EnergyData> chartData,
required PowerClampBloc blocProvider,
}) {
return PowerClampCard(
dateTimeSelected:blocProvider.formattedDate,
dateTimeSelected:
'${blocProvider.dateTime!.day}/${blocProvider.dateTime!.month}/${blocProvider.dateTime!.year} ${blocProvider.endChartDate}',
energyConsumption: _getValueOrNA(phase.dataPoints, isGeneral ? 0 : 5),
title: title,
phaseType: phaseType,
isGeneral: isGeneral,
dateSwitcher: blocProvider.dateSwitcher(),
formattedDate: blocProvider.formattedDate,
@@ -21,53 +21,50 @@ class PowerClampInfoCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Expanded(
child: Padding(
padding: const EdgeInsets.all(5.0),
child: DefaultContainer(
height: 55,
color: ColorsManager.grayBox,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: SvgPicture.asset(
iconPath,
fit: BoxFit.fill,
),
child: DefaultContainer(
height: 55,
color: ColorsManager.grayBox,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: SvgPicture.asset(
iconPath,
fit: BoxFit.contain,
),
Expanded(
flex: 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
BodyMedium(
fontWeight: FontWeight.w400,
fontSize: 8,
text: title,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
BodyMedium(
fontWeight: FontWeight.w700,
fontSize: 15,
text: value,
),
BodyMedium(
fontWeight: FontWeight.w700,
fontSize: 8,
text: unit,
),
],
),
],
),
)
],
),
),
Expanded(
flex: 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
BodyMedium(
fontWeight: FontWeight.w400,
fontSize: 8,
text: title,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
BodyMedium(
fontWeight: FontWeight.w700,
fontSize: 15,
text: value,
),
BodyMedium(
fontWeight: FontWeight.w700,
fontSize: 8,
text: unit,
),
],
),
],
),
)
],
),
),
);
@@ -67,21 +67,38 @@ class _RoomPageState extends State<RoomPage> {
),
),
),
Expanded(
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1.5,
),
padding: const EdgeInsets.only(top: 10),
itemCount: _filteredDevices.length,
itemBuilder: (context, index) {
return RoomPageSwitch(device: _filteredDevices[index]);
},
),
),
_filteredDevices.isNotEmpty
? Expanded(
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1.5,
),
padding: const EdgeInsets.only(top: 10),
itemCount: _filteredDevices.length,
itemBuilder: (context, index) {
return RoomPageSwitch(device: _filteredDevices[index]);
},
),
)
: const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: Text(
'No Results Found',
style: TextStyle(
color: ColorsManager.grayColor,
fontSize: 14,
fontWeight: FontWeight.w400),
)),
],
),
),
],
);
}
@@ -22,7 +22,6 @@ class RoomsSlider extends StatelessWidget {
onPageChanged: (index) {
HomeCubit.getInstance().roomSliderPageChanged(index);
},
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
@@ -45,15 +44,20 @@ class RoomsSlider extends StatelessWidget {
(room) => InkWell(
onTap: () {
HomeCubit.getInstance().roomSliderPageChanged(
HomeCubit.getInstance().selectedSpace!.rooms!.indexOf(room));
HomeCubit.getInstance()
.selectedSpace!
.rooms!
.indexOf(room));
},
child: TitleMedium(
text: room.name!,
style: context.titleMedium.copyWith(
fontSize: 25,
color: HomeCubit.getInstance().selectedRoom == room
? ColorsManager.textPrimaryColor
: ColorsManager.textPrimaryColor.withOpacity(.2),
color:
HomeCubit.getInstance().selectedRoom == room
? ColorsManager.textPrimaryColor
: ColorsManager.textPrimaryColor
.withOpacity(.2),
),
),
),
+160 -119
View File
@@ -35,7 +35,7 @@ class WizardPage extends StatelessWidget {
return StatefulBuilder(
builder: (context, setState) {
return ListView(
return Column(
children: [
if (groupsList.isNotEmpty)
TextFormField(
@@ -64,129 +64,170 @@ class WizardPage extends StatelessWidget {
),
),
),
GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1.5,
),
padding: const EdgeInsets.only(top: 10),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: _filteredGroups.length,
itemBuilder: (_, index) {
return GestureDetector(
onTap: () {
if (_filteredGroups[index].name == 'AC') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const ACsView()));
}
if (_filteredGroups[index].name == '3G') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const ThreeGangWizard()));
}
if (_filteredGroups[index].name == '2G') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const TwoGangWizard()));
}
if (_filteredGroups[index].name == '1G') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const OneGangWizard()));
}
if (_filteredGroups[index].name == 'WH') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const WHWizard()));
}
if (_filteredGroups[index].name == '1GT') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const OneTouchWizard()));
}
if (_filteredGroups[index].name == '2GT') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const TwoTouchWizard()));
}
if (_filteredGroups[index].name == '3GT') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const ThreeTouchWizard()));
}
if (_filteredGroups[index].name == 'GD') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const GarageWizard()));
}
if (_filteredGroups[index].name == 'CUR') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const CurtainsWizard()));
}
},
child: DefaultContainer(
padding: const EdgeInsets.all(15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
const SizedBox(
height: 10,
),
_filteredGroups.isNotEmpty
? Expanded(
child: ListView(
shrinkWrap: true,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SvgPicture.asset(
_filteredGroups[index].icon!,
fit: BoxFit.contain,
),
],
),
FittedBox(
fit: BoxFit.scaleDown,
child: BodyLarge(
text: _filteredGroups[index].name!,
style: context.bodyLarge.copyWith(
fontWeight: FontWeight.bold,
height: 0,
fontSize: 20,
color: Colors.grey,
),
GridView.builder(
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1.5,
),
),
padding: const EdgeInsets.only(top: 10),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: _filteredGroups.length,
itemBuilder: (_, index) {
return GestureDetector(
onTap: () {
if (_filteredGroups[index].name == 'AC') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const ACsView()));
}
if (_filteredGroups[index].name == '3G') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const ThreeGangWizard()));
}
if (_filteredGroups[index].name == '2G') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const TwoGangWizard()));
}
if (_filteredGroups[index].name == '1G') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const OneGangWizard()));
}
if (_filteredGroups[index].name == 'WH') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const WHWizard()));
}
if (_filteredGroups[index].name == '1GT') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const OneTouchWizard()));
}
if (_filteredGroups[index].name == '2GT') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const TwoTouchWizard()));
}
if (_filteredGroups[index].name == '3GT') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const ThreeTouchWizard()));
}
if (_filteredGroups[index].name == 'GD') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const GarageWizard()));
}
if (_filteredGroups[index].name == 'CUR') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const CurtainsWizard()));
}
},
child: DefaultContainer(
padding: const EdgeInsets.all(15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
SvgPicture.asset(
_filteredGroups[index].icon!,
fit: BoxFit.contain,
),
],
),
FittedBox(
fit: BoxFit.scaleDown,
child: BodyLarge(
text: _filteredGroups[index].name!,
style: context.bodyLarge.copyWith(
fontWeight: FontWeight.bold,
height: 0,
fontSize: 20,
color: Colors.grey,
),
),
),
],
),
),
);
},
)
],
),
)
: const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: Text(
'No Results Found',
style: TextStyle(
color: ColorsManager.grayColor,
fontSize: 14,
fontWeight: FontWeight.w400),
)),
],
),
),
);
},
),
],
);
},