This commit is contained in:
mohammad
2024-10-16 16:30:04 +03:00
parent e0dbbd67d1
commit ab66142568
4 changed files with 373 additions and 258 deletions
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/door_sensor_bloc/door_sensor_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/door_sensor_bloc/door_sensor_event.dart';
import 'package:syncrow_app/features/devices/bloc/door_sensor_bloc/door_sensor_state.dart';
@@ -61,139 +60,148 @@ class _PowerClampPageState extends State<PowerClampPage> {
onRefresh: () async {
doorSensorBloc.add(const DoorSensorInitial());
},
child: PageView.builder(
controller: _pageController,
onPageChanged: (int page) {
setState(() {
_currentPage = page;
});
},
itemBuilder: (context, index) {
return DefaultContainer(
child: Padding(
padding: const EdgeInsets.only(
left: 10, right: 10, top: 25, bottom: 20),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text('Energy usage'),
Row(
crossAxisAlignment:
CrossAxisAlignment.end,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
BodyLarge(
text: 'Total Energy \nConsumption',
fontSize: 20,
fontWeight: FontWeight.w700,
),
Row(
children: [
BodyLarge(
text: '8623.20 ',
fontSize: 20,
fontWeight: FontWeight.w700,
),
BodySmall(text: 'kWh')
],
),
],
),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
PowerClampInfoCard(
iconPath: Assets.powerActiveIcon,
title: 'Active',
value: '700',
unit: ' w',
),
PowerClampInfoCard(
iconPath: Assets.voltMeterIcon,
title: 'Current',
value: '3.06',
unit: ' A',
),
PowerClampInfoCard(
iconPath: Assets.frequencyIcon,
title: 'Frequency',
value: '50',
unit: ' Hz',
),
],
),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
BodyMedium(
text: 'Total consumption',
fontSize: 12,
fontWeight: FontWeight.w700,
),
Text(
'10/08/2024',
style: TextStyle(
child: Padding(
padding: EdgeInsets.only(top: 25),
child: PageView.builder(
controller: _pageController,
onPageChanged: (int page) {
setState(() {
_currentPage = page;
});
},
itemBuilder: (context, index) {
return DefaultContainer(
child: Padding(
padding: const EdgeInsets.only(
left: 10,
right: 10,
top: 25,
bottom: 20),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text('Energy usage'),
const Row(
crossAxisAlignment:
CrossAxisAlignment.end,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
BodyLarge(
text:
'Total Energy \nConsumption',
fontSize: 20,
fontWeight: FontWeight.w700,
),
Row(
children: [
BodyLarge(
text: '8623.20 ',
fontSize: 20,
fontWeight: FontWeight.w700,
),
BodySmall(text: 'kWh')
],
),
],
),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
PowerClampInfoCard(
iconPath: Assets.powerActiveIcon,
title: 'Active',
value: '700',
unit: ' w',
),
PowerClampInfoCard(
iconPath: Assets.voltMeterIcon,
title: 'Current',
value: '3.06',
unit: ' A',
),
PowerClampInfoCard(
iconPath: Assets.frequencyIcon,
title: 'Frequency',
value: '50',
unit: ' Hz',
),
],
),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
BodyMedium(
text: 'Total consumption',
fontSize: 12,
fontWeight: FontWeight.w700,
),
Text(
'10/08/2024',
style: TextStyle(
fontSize: 8,
fontWeight:
FontWeight.w400),
),
],
),
Row(
children: [
BodyMedium(
text: '1000.00 ',
fontSize: 12,
fontWeight:
FontWeight.w700),
BodyMedium(
text: 'kWh',
fontSize: 8,
fontWeight:
FontWeight.w400),
),
],
),
Row(
children: [
BodyMedium(
text: '1000.00 ',
fontSize: 12,
fontWeight: FontWeight.w700),
BodyMedium(
text: 'kWh',
fontSize: 8,
fontWeight: FontWeight.w700),
],
),
],
),
SizedBox(
height: 310,
child: EnergyConsumptionPage(
chartData: [
EnergyData('12:00 AM', 4.0),
EnergyData('01:00 AM', 3.5),
EnergyData('02:00 AM', 3.8),
EnergyData('03:00 AM', 3.2),
EnergyData('04:00 AM', 4.0),
EnergyData('05:00 AM', 3.4),
EnergyData('06:00 AM', 3.2),
EnergyData('07:00 AM', 3.5),
EnergyData('08:00 AM', 3.8),
EnergyData('09:00 AM', 3.6),
EnergyData('10:00 AM', 3.9),
EnergyData('11:00 AM', 4.0),
FontWeight.w700),
],
),
],
totalConsumption: 100.0,
date: '10/08/2024',
),
),
],
SizedBox(
height: 310,
child: EnergyConsumptionPage(
chartData: [
EnergyData('12:00 AM', 4.0),
EnergyData('01:00 AM', 3.5),
EnergyData('02:00 AM', 3.8),
EnergyData('03:00 AM', 3.2),
EnergyData('04:00 AM', 4.0),
EnergyData('05:00 AM', 3.4),
EnergyData('06:00 AM', 3.2),
EnergyData('07:00 AM', 3.5),
EnergyData('08:00 AM', 3.8),
EnergyData('09:00 AM', 3.6),
EnergyData('10:00 AM', 3.9),
EnergyData('11:00 AM', 4.0),
],
totalConsumption: 100.0,
date: '10/08/2024',
),
),
],
),
),
),
);
},
itemCount: _pageCount,
);
},
itemCount: _pageCount,
),
),
),
),
@@ -1,30 +1,88 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/model/room_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/room_page_switch.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class RoomPage extends StatelessWidget {
class RoomPage extends StatefulWidget {
const RoomPage({super.key, required this.room});
final RoomModel room;
@override
_RoomPageState createState() => _RoomPageState();
}
class _RoomPageState extends State<RoomPage> {
final TextEditingController _searchController = TextEditingController();
List<dynamic> _filteredDevices = [];
@override
void initState() {
super.initState();
_filteredDevices = widget.room.devices ?? [];
_searchController.addListener(_filterDevices);
}
@override
void dispose() {
_searchController.removeListener(_filterDevices);
_searchController.dispose();
super.dispose();
}
void _filterDevices() {
final query = _searchController.text.toLowerCase();
setState(() {
_filteredDevices = widget.room.devices!
.where((device) => device.type!.toLowerCase().contains(query))
.toList();
});
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1.5,
return Column(
children: [
if (widget.room.devices!.isNotEmpty)
TextFormField(
controller: _searchController,
decoration: InputDecoration(
hintText: 'Search',
hintStyle: const TextStyle(
color: ColorsManager.textGray,
fontSize: 16,
fontWeight: FontWeight.w400),
prefixIcon: Container(
padding: const EdgeInsets.all(5.0),
margin: const EdgeInsets.all(10.0),
child: SvgPicture.asset(
Assets.searchIcon,
fit: BoxFit.contain,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
),
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]);
},
),
),
padding: const EdgeInsets.only(top: 10),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: room.devices!.length,
itemBuilder: (context, index) {
return RoomPageSwitch(device: room.devices![index]);
},
),
],
);
}
}
+160 -113
View File
@@ -13,7 +13,9 @@ import 'package:syncrow_app/features/devices/view/widgets/two_touch/two_touch_wi
import 'package:syncrow_app/features/devices/view/widgets/water_heater/wh_wizard.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class WizardPage extends StatelessWidget {
final List<DevicesCategoryModel> groupsList;
@@ -21,126 +23,171 @@ class WizardPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1.5,
),
padding: const EdgeInsets.only(top: 10),
shrinkWrap: true,
itemCount: groupsList.length,
itemBuilder: (_, index) {
return GestureDetector(
onTap: () {
if (groupsList[index].name == 'AC') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const ACsView()));
}
if (groupsList[index].name == '3G') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const ThreeGangWizard()));
}
if (groupsList[index].name == '2G') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const TwoGangWizard()));
}
if (groupsList[index].name == '1G') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const OneGangWizard()));
}
if (groupsList[index].name == 'WH') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const WHWizard()));
}
final TextEditingController _searchController = TextEditingController();
List<DevicesCategoryModel> _filteredGroups = groupsList;
if (groupsList[index].name == '1GT') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const OneTouchWizard()));
}
void _filterGroups(String query) {
_filteredGroups = groupsList
.where((group) =>
group.name!.toLowerCase().contains(query.toLowerCase()))
.toList();
}
if (groupsList[index].name == '2GT') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const TwoTouchWizard()));
}
if (groupsList[index].name == '3GT') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const ThreeTouchWizard()));
}
if (groupsList[index].name == 'GD') {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
const GarageWizard()));
}
if (groupsList[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(
groupsList[index].icon!,
return StatefulBuilder(
builder: (context, setState) {
return ListView(
children: [
if (groupsList.isNotEmpty)
TextFormField(
controller: _searchController,
onChanged: (value) {
setState(() {
_filterGroups(value);
});
},
decoration: InputDecoration(
hintText: 'Search',
hintStyle: const TextStyle(
color: ColorsManager.textGray,
fontSize: 16,
fontWeight: FontWeight.w400),
prefixIcon: Container(
padding: const EdgeInsets.all(5.0),
margin: const EdgeInsets.all(10.0),
child: SvgPicture.asset(
Assets.searchIcon,
fit: BoxFit.contain,
),
// CustomSwitch(
],
),
FittedBox(
fit: BoxFit.scaleDown,
child: BodyLarge(
text: groupsList[index].name!,
style: context.bodyLarge.copyWith(
fontWeight: FontWeight.bold,
height: 0,
fontSize: 20,
color: Colors.grey,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
],
),
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,
),
),
),
],
),
),
);
},
),
),
],
);
},
);
+2
View File
@@ -1085,6 +1085,8 @@ class Assets {
static const String frequencyIcon = "assets/icons/frequency_icon.svg";
static const String voltMeterIcon = "assets/icons/volt_meter_icon.svg";
static const String powerActiveIcon = "assets/icons/power_active_icon.svg";
static const String searchIcon = "assets/icons/search_icon.svg";
//leakNormalIcon
}