Hide nonfunctional widgets

This commit is contained in:
Abdullah Alassaf
2024-12-15 02:22:11 +03:00
parent fc3f215dba
commit f81880a704
12 changed files with 735 additions and 920 deletions
@@ -38,10 +38,8 @@ class SettingProfilePage extends StatelessWidget {
final _bloc = BlocProvider.of<DeviceSettingBloc>(context);
return state is DeviceSettingLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
child:
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
@@ -57,18 +55,15 @@ class SettingProfilePage extends StatelessWidget {
child: SvgPicture.asset(
Assets.sosHomeIcon,
fit: BoxFit.fitHeight,
height:
MediaQuery.of(context).size.height * 0.13,
height: MediaQuery.of(context).size.height * 0.13,
))
: CircleAvatar(
radius: 55,
backgroundColor: ColorsManager.graysColor,
child: ClipOval(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: SvgPicture.asset(
@@ -76,10 +71,7 @@ class SettingProfilePage extends StatelessWidget {
? Assets.fourSceneIcon
: Assets.sixSceneIcon,
fit: BoxFit.contain,
height: MediaQuery.of(context)
.size
.height *
0.08,
height: MediaQuery.of(context).size.height * 0.08,
),
),
],
@@ -97,8 +89,7 @@ class SettingProfilePage extends StatelessWidget {
children: [
IntrinsicWidth(
child: ConstrainedBox(
constraints:
const BoxConstraints(maxWidth: 200),
constraints: const BoxConstraints(maxWidth: 200),
child: TextFormField(
maxLength: 30,
style: const TextStyle(
@@ -131,8 +122,7 @@ class SettingProfilePage extends StatelessWidget {
Assets.sosEditProfile,
color: Colors.grey,
fit: BoxFit.contain,
height: MediaQuery.of(context).size.height *
0.02,
height: MediaQuery.of(context).size.height * 0.02,
),
),
),
@@ -151,14 +141,14 @@ class SettingProfilePage extends StatelessWidget {
padding: const EdgeInsets.all(20),
child: InkWell(
onTap: () async {
bool val = await Navigator.of(context).push(
bool? val = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => LocationSettingPage(
space: spaces!.first,
deviceId: device?.uuid ?? '',
)),
);
if (val == true) {
if (val != null && val == true) {
_bloc.add(const DeviceSettingInitialInfo());
}
},
@@ -172,8 +162,7 @@ class SettingProfilePage extends StatelessWidget {
children: [
SizedBox(
child: BodyMedium(
text: _bloc
.deviceInfo.subspace.subspaceName,
text: _bloc.deviceInfo.subspace.subspaceName,
fontColor: ColorsManager.textGray,
),
),
@@ -40,10 +40,8 @@ class SettingsPage extends StatelessWidget {
return state is DeviceSettingLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
child:
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
)
: ListView(
children: [
@@ -71,31 +69,25 @@ class SettingsPage extends StatelessWidget {
children: [
const SizedBox(height: 20),
DefaultContainer(
borderRadius: const BorderRadius.all(
Radius.circular(30)),
borderRadius: const BorderRadius.all(Radius.circular(30)),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Padding(
padding:
const EdgeInsets.only(left: 90),
padding: const EdgeInsets.only(left: 90),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
child: Text(
_bloc.deviceInfo.name,
style: const TextStyle(
fontSize: 16,
fontWeight:
FontWeight.w700,
color: ColorsManager
.grayColor,
fontWeight: FontWeight.w700,
color: ColorsManager.grayColor,
),
overflow: TextOverflow
.ellipsis, // Adds ellipsis (...) when the text overflows.
@@ -106,10 +98,7 @@ class SettingsPage extends StatelessWidget {
height: 5,
),
BodySmall(
text: _bloc
.deviceInfo
.subspace
.subspaceName),
text: _bloc.deviceInfo.subspace.subspaceName),
],
),
),
@@ -136,13 +125,10 @@ class SettingsPage extends StatelessWidget {
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 40,
backgroundColor:
ColorsManager.backgroundColor,
backgroundColor: ColorsManager.backgroundColor,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
device!.type == "SOS"
? ClipOval(
@@ -153,20 +139,15 @@ class SettingsPage extends StatelessWidget {
),
)
: Padding(
padding: device!.type ==
"4S"
? const EdgeInsets.only(
top: 5)
: const EdgeInsets.only(
top: 0),
padding: device!.type == "4S"
? const EdgeInsets.only(top: 5)
: const EdgeInsets.only(top: 0),
child: SizedBox(
height: 70,
child: SvgPicture.asset(
device!.type == "4S"
? Assets
.fourSceneIcon
: Assets
.sixSceneIcon,
? Assets.fourSceneIcon
: Assets.sixSceneIcon,
fit: BoxFit.contain,
),
),
@@ -221,114 +202,114 @@ class SettingsPage extends StatelessWidget {
),
),
const SizedBox(height: 20),
const BodyMedium(
text: 'Device Offline Notification',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
DefaultContainer(
child: Column(
children: [
SettingWidget(
value: _bloc.enableAlarm,
onChanged: (p0) {
context
.read<DeviceSettingBloc>()
.add(ToggleEnableAlarmEvent(p0));
},
isNotification: true,
onTap: () {},
text: 'Offline Notification',
icon: Assets.notificationIcon,
),
],
),
),
const SizedBox(height: 20),
const BodyMedium(
text: 'Others',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
const SizedBox(height: 5),
DefaultContainer(
child: Column(
children: [
SettingWidget(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
ShareDevicePage(device: device!)),
);
},
text: 'Share Device',
icon: Assets.shareIcon,
),
// const Divider(
// color: ColorsManager.dividerColor,
// ),
// SettingWidget(
// onTap: () {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) =>
// FourSceneCreateGroup(
// device: device!)),
// );
// },
// text: 'Create Group',
// icon: Assets.createGroupIcon,
// ),
const Divider(
color: ColorsManager.dividerColor,
),
SettingWidget(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
FaqSettingPage(device: device!)),
);
},
text: 'Device FAQ',
icon: Assets.faqIcon,
),
const Divider(
color: ColorsManager.dividerColor,
),
SettingWidget(
onTapUpdate: () {
showDialog(
context: context,
builder: (context) {
return UpdateInfoDialog(
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: () {
Navigator.of(context).pop();
},
);
},
);
},
isUpdate: true,
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
const UpdatePageSetting()),
);
},
text: 'Device Update',
icon: Assets.updateIcon,
),
],
),
),
// const BodyMedium(
// text: 'Device Offline Notification',
// fontWeight: FontWeight.w700,
// fontSize: 12,
// fontColor: ColorsManager.grayColor,
// ),
// DefaultContainer(
// child: Column(
// children: [
// SettingWidget(
// value: _bloc.enableAlarm,
// onChanged: (p0) {
// context
// .read<DeviceSettingBloc>()
// .add(ToggleEnableAlarmEvent(p0));
// },
// isNotification: true,
// onTap: () {},
// text: 'Offline Notification',
// icon: Assets.notificationIcon,
// ),
// ],
// ),
// ),
// const SizedBox(height: 20),
// const BodyMedium(
// text: 'Others',
// fontWeight: FontWeight.w700,
// fontSize: 12,
// fontColor: ColorsManager.grayColor,
// ),
// const SizedBox(height: 5),
// DefaultContainer(
// child: Column(
// children: [
// SettingWidget(
// onTap: () {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) =>
// ShareDevicePage(device: device!)),
// );
// },
// text: 'Share Device',
// icon: Assets.shareIcon,
// ),
// // const Divider(
// // color: ColorsManager.dividerColor,
// // ),
// // SettingWidget(
// // onTap: () {
// // Navigator.of(context).push(
// // MaterialPageRoute(
// // builder: (context) =>
// // FourSceneCreateGroup(
// // device: device!)),
// // );
// // },
// // text: 'Create Group',
// // icon: Assets.createGroupIcon,
// // ),
// const Divider(
// color: ColorsManager.dividerColor,
// ),
// SettingWidget(
// onTap: () {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) =>
// FaqSettingPage(device: device!)),
// );
// },
// text: 'Device FAQ',
// icon: Assets.faqIcon,
// ),
// const Divider(
// color: ColorsManager.dividerColor,
// ),
// SettingWidget(
// onTapUpdate: () {
// showDialog(
// context: context,
// builder: (context) {
// return UpdateInfoDialog(
// cancelTab: () {
// Navigator.of(context).pop();
// },
// confirmTab: () {
// Navigator.of(context).pop();
// },
// );
// },
// );
// },
// isUpdate: true,
// onTap: () {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) =>
// const UpdatePageSetting()),
// );
// },
// text: 'Device Update',
// icon: Assets.updateIcon,
// ),
// ],
// ),
// ),
const SizedBox(height: 20),
InkWell(
onTap: () {
@@ -356,8 +337,7 @@ class SettingsPage extends StatelessWidget {
),
const SizedBox(height: 10),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () {
@@ -379,8 +359,7 @@ class SettingsPage extends StatelessWidget {
text: 'Disconnect Device',
fontWeight: FontWeight.w400,
fontSize: 15,
fontColor:
ColorsManager.textPrimaryColor,
fontColor: ColorsManager.textPrimaryColor,
),
),
const Icon(
@@ -391,8 +370,7 @@ class SettingsPage extends StatelessWidget {
),
const SizedBox(height: 20),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () {
@@ -404,20 +382,17 @@ class SettingsPage extends StatelessWidget {
Navigator.of(context).pop();
},
confirmTab: () {
_bloc.add(
DeleteDeviceEvent());
_bloc.add(DeleteDeviceEvent());
},
);
},
);
},
child: const BodyMedium(
text:
'Disconnect Device and Wipe Data',
text: 'Disconnect Device and Wipe Data',
fontWeight: FontWeight.w400,
fontSize: 15,
fontColor:
ColorsManager.textPrimaryColor,
fontColor: ColorsManager.textPrimaryColor,
),
),
const Icon(
@@ -1,6 +1,4 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/devices/view/widgets/popup_menu_widget.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
@@ -24,19 +22,19 @@ class DeviceAppbar extends StatelessWidget implements PreferredSizeWidget {
fontWeight: FontsManager.bold,
),
actions: [
IconButton(
onPressed: () {
showPopupMenu(context: context, items: [
PopupMenuItem(
onTap: () async {
HomeCubit.getInstance().updateDevice(deviceUuid);
},
value: 'Update',
child: const Text('Update'),
)
]);
},
icon: Icon(Icons.edit))
// IconButton(
// onPressed: () {
// showPopupMenu(context: context, items: [
// PopupMenuItem(
// onTap: () async {
// HomeCubit.getInstance().updateDevice(deviceUuid);
// },
// value: 'Update',
// child: const Text('Update'),
// )
// ]);
// },
// icon: Icon(Icons.edit))
],
);
}
@@ -8,9 +8,7 @@ import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/model/device_report_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.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 SosRecordsScreen extends StatefulWidget {
@@ -22,14 +20,13 @@ class SosRecordsScreen extends StatefulWidget {
}
class _SosRecordsScreenState extends State<SosRecordsScreen> {
int _selectedIndex = 0;
// int _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Records',
child: BlocProvider(
create: (context) =>
SosBloc(sosId: widget.sosId)..add(const ReportLogsInitial()),
create: (context) => SosBloc(sosId: widget.sosId)..add(const ReportLogsInitial()),
child: BlocBuilder<SosBloc, SosState>(
builder: (context, state) {
final waterSensorBloc = BlocProvider.of<SosBloc>(context);
@@ -37,15 +34,13 @@ class _SosRecordsScreenState extends State<SosRecordsScreen> {
if (state is LoadingNewSate) {
return const Center(
child: DefaultContainer(
width: 50, height: 50, child: CircularProgressIndicator()),
child: DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
);
} else if (state is UpdateState) {
for (var record in waterSensorBloc.recordGroups.data!) {
final DateTime eventDateTime =
DateTime.fromMillisecondsSinceEpoch(record.eventTime!);
final String formattedDate =
DateFormat('EEEE, dd/MM/yyyy').format(eventDateTime);
final String formattedDate = DateFormat('EEEE, dd/MM/yyyy').format(eventDateTime);
if (groupedRecords.containsKey(formattedDate)) {
groupedRecords[formattedDate]!.add(record);
} else {
@@ -58,63 +53,61 @@ class _SosRecordsScreenState extends State<SosRecordsScreen> {
length: 2,
child: Column(
children: [
Container(
width: MediaQuery.of(context).size.width,
decoration: const ShapeDecoration(
color: ColorsManager.onPrimaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(30)),
),
),
child: TabBar(
onTap: (value) {
setState(() {
_selectedIndex = value;
});
},
indicatorColor: Colors.white,
dividerHeight: 0,
indicatorSize: TabBarIndicatorSize.tab,
indicator: const ShapeDecoration(
color: ColorsManager.slidingBlueColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
),
),
tabs: [
Tab(
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
child: BodySmall(
text: 'Record',
style: context.bodySmall.copyWith(
color: _selectedIndex == 0
? Colors.white
: ColorsManager.blackColor,
fontSize: 12,
fontWeight: FontWeight.w400,
),
),
),
),
Tab(
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Text(
'Automation Log',
style: context.bodySmall.copyWith(
color: _selectedIndex == 1
? Colors.white
: ColorsManager.blackColor,
fontSize: 12,
fontWeight: FontWeight.w400,
),
),
),
),
],
),
),
// Container(
// width: MediaQuery.of(context).size.width,
// decoration: const ShapeDecoration(
// color: ColorsManager.onPrimaryColor,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(30)),
// ),
// ),
// child: TabBar(
// onTap: (value) {
// setState(() {
// _selectedIndex = value;
// });
// },
// indicatorColor: Colors.white,
// dividerHeight: 0,
// indicatorSize: TabBarIndicatorSize.tab,
// indicator: const ShapeDecoration(
// color: ColorsManager.slidingBlueColor,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(20)),
// ),
// ),
// tabs: [
// Tab(
// child: Container(
// padding: const EdgeInsets.symmetric(vertical: 10),
// child: BodySmall(
// text: 'Record',
// style: context.bodySmall.copyWith(
// color:
// _selectedIndex == 0 ? Colors.white : ColorsManager.blackColor,
// fontSize: 12,
// fontWeight: FontWeight.w400,
// ),
// ),
// ),
// ),
// Tab(
// child: Container(
// padding: const EdgeInsets.symmetric(vertical: 10),
// child: Text(
// 'Automation Log',
// style: context.bodySmall.copyWith(
// color:
// _selectedIndex == 1 ? Colors.white : ColorsManager.blackColor,
// fontSize: 12,
// fontWeight: FontWeight.w400,
// ),
// ),
// ),
// ),
// ],
// ),
// ),
Expanded(
child: TabBarView(
physics: const NeverScrollableScrollPhysics(),
@@ -129,14 +122,11 @@ class _SosRecordsScreenState extends State<SosRecordsScreen> {
: ListView.builder(
itemCount: groupedRecords.length,
itemBuilder: (context, index) {
final String date =
groupedRecords.keys.elementAt(index);
final List<DeviceEvent> recordsForDate =
groupedRecords[date]!;
final String date = groupedRecords.keys.elementAt(index);
final List<DeviceEvent> recordsForDate = groupedRecords[date]!;
return Column(
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(16.0),
@@ -152,49 +142,37 @@ class _SosRecordsScreenState extends State<SosRecordsScreen> {
DefaultContainer(
child: Column(
children: [
...recordsForDate
.asMap()
.entries
.map((entry) {
...recordsForDate.asMap().entries.map((entry) {
final int idx = entry.key;
final DeviceEvent record =
entry.value;
final DeviceEvent record = entry.value;
final DateTime eventDateTime =
DateTime
.fromMillisecondsSinceEpoch(
record.eventTime!);
DateTime.fromMillisecondsSinceEpoch(
record.eventTime!);
final String formattedTime =
DateFormat('HH:mm:ss')
.format(eventDateTime);
DateFormat('HH:mm:ss').format(eventDateTime);
return Column(
children: [
ListTile(
leading: SvgPicture.asset(
record.value == 'true'
? Assets
.leakDetectedIcon
: Assets
.leakNormalIcon,
? Assets.leakDetectedIcon
: Assets.leakNormalIcon,
height: 25,
width: 25,
),
title: const Text(
"SOS Alert Triggered",
style: const TextStyle(
fontWeight:
FontWeight.bold,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
subtitle:
Text(formattedTime),
subtitle: Text(formattedTime),
),
if (idx !=
recordsForDate.length - 1)
if (idx != recordsForDate.length - 1)
const Divider(
color: ColorsManager
.graysColor,
color: ColorsManager.graysColor,
),
],
);
@@ -8,9 +8,7 @@ import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_sta
import 'package:syncrow_app/features/devices/model/device_report_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.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 WaterLeakRecordsScreen extends StatefulWidget {
@@ -22,14 +20,13 @@ class WaterLeakRecordsScreen extends StatefulWidget {
}
class _WaterLeakRecordsScreenState extends State<WaterLeakRecordsScreen> {
int _selectedIndex = 0;
// int _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Records',
child: BlocProvider(
create: (context) =>
WaterLeakBloc(WLId: widget.WLId)..add(const ReportLogsInitial()),
create: (context) => WaterLeakBloc(WLId: widget.WLId)..add(const ReportLogsInitial()),
child: BlocBuilder<WaterLeakBloc, WaterLeakState>(
builder: (context, state) {
final waterSensorBloc = BlocProvider.of<WaterLeakBloc>(context);
@@ -37,15 +34,13 @@ class _WaterLeakRecordsScreenState extends State<WaterLeakRecordsScreen> {
if (state is WaterLeakLoadingState) {
return const Center(
child: DefaultContainer(
width: 50, height: 50, child: CircularProgressIndicator()),
child: DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
);
} else if (state is UpdateState) {
for (var record in waterSensorBloc.recordGroups.data!) {
final DateTime eventDateTime =
DateTime.fromMillisecondsSinceEpoch(record.eventTime!);
final String formattedDate =
DateFormat('EEEE, dd/MM/yyyy').format(eventDateTime);
final String formattedDate = DateFormat('EEEE, dd/MM/yyyy').format(eventDateTime);
if (groupedRecords.containsKey(formattedDate)) {
groupedRecords[formattedDate]!.add(record);
@@ -59,63 +54,63 @@ class _WaterLeakRecordsScreenState extends State<WaterLeakRecordsScreen> {
length: 2,
child: Column(
children: [
Container(
width: MediaQuery.of(context).size.width,
decoration: const ShapeDecoration(
color: ColorsManager.onPrimaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(30)),
),
),
child: TabBar(
onTap: (value) {
setState(() {
_selectedIndex = value;
});
},
indicatorColor: Colors.white,
dividerHeight: 0,
indicatorSize: TabBarIndicatorSize.tab,
indicator: const ShapeDecoration(
color: ColorsManager.slidingBlueColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
),
),
tabs: [
Tab(
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
child: BodySmall(
text: 'Record',
style: context.bodySmall.copyWith(
color: _selectedIndex == 0
? Colors.white
: ColorsManager.blackColor,
fontSize: 12,
fontWeight: FontWeight.w400,
),
),
),
),
Tab(
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Text(
'Automation Record',
style: context.bodySmall.copyWith(
color: _selectedIndex == 1
? Colors.white
: ColorsManager.blackColor,
fontSize: 12,
fontWeight: FontWeight.w400,
),
),
),
),
],
),
),
// Container(
// width: MediaQuery.of(context).size.width,
// decoration: const ShapeDecoration(
// color: ColorsManager.onPrimaryColor,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(30)),
// ),
// ),
// child: TabBar(
// onTap: (value) {
// setState(() {
// _selectedIndex = value;
// });
// },
// indicatorColor: Colors.white,
// dividerHeight: 0,
// indicatorSize: TabBarIndicatorSize.tab,
// indicator: const ShapeDecoration(
// color: ColorsManager.slidingBlueColor,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(20)),
// ),
// ),
// tabs: [
// Tab(
// child: Container(
// padding: const EdgeInsets.symmetric(vertical: 10),
// child: BodySmall(
// text: 'Record',
// style: context.bodySmall.copyWith(
// color: _selectedIndex == 0
// ? Colors.white
// : ColorsManager.blackColor,
// fontSize: 12,
// fontWeight: FontWeight.w400,
// ),
// ),
// ),
// ),
// Tab(
// child: Container(
// padding: const EdgeInsets.symmetric(vertical: 10),
// child: Text(
// 'Automation Record',
// style: context.bodySmall.copyWith(
// color: _selectedIndex == 1
// ? Colors.white
// : ColorsManager.blackColor,
// fontSize: 12,
// fontWeight: FontWeight.w400,
// ),
// ),
// ),
// ),
// ],
// ),
// ),
Expanded(
child: TabBarView(
physics: const NeverScrollableScrollPhysics(),
@@ -125,14 +120,11 @@ class _WaterLeakRecordsScreenState extends State<WaterLeakRecordsScreen> {
: ListView.builder(
itemCount: groupedRecords.length,
itemBuilder: (context, index) {
final String date =
groupedRecords.keys.elementAt(index);
final List<DeviceEvent> recordsForDate =
groupedRecords[date]!;
final String date = groupedRecords.keys.elementAt(index);
final List<DeviceEvent> recordsForDate = groupedRecords[date]!;
return Column(
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(16.0),
@@ -148,30 +140,22 @@ class _WaterLeakRecordsScreenState extends State<WaterLeakRecordsScreen> {
DefaultContainer(
child: Column(
children: [
...recordsForDate
.asMap()
.entries
.map((entry) {
...recordsForDate.asMap().entries.map((entry) {
final int idx = entry.key;
final DeviceEvent record =
entry.value;
final DeviceEvent record = entry.value;
final DateTime eventDateTime =
DateTime
.fromMillisecondsSinceEpoch(
record.eventTime!);
DateTime.fromMillisecondsSinceEpoch(
record.eventTime!);
final String formattedTime =
DateFormat('HH:mm:ss')
.format(eventDateTime);
DateFormat('HH:mm:ss').format(eventDateTime);
return Column(
children: [
ListTile(
leading: SvgPicture.asset(
record.value == 'true'
? Assets
.leakDetectedIcon
: Assets
.leakNormalIcon,
? Assets.leakDetectedIcon
: Assets.leakNormalIcon,
height: 25,
width: 25,
),
@@ -180,19 +164,15 @@ class _WaterLeakRecordsScreenState extends State<WaterLeakRecordsScreen> {
? "Leak Detected"
: "Normal",
style: const TextStyle(
fontWeight:
FontWeight.bold,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
subtitle:
Text('$formattedTime'),
subtitle: Text('$formattedTime'),
),
if (idx !=
recordsForDate.length - 1)
if (idx != recordsForDate.length - 1)
const Divider(
color: ColorsManager
.graysColor,
color: ColorsManager.graysColor,
),
],
);
@@ -207,8 +187,7 @@ class _WaterLeakRecordsScreenState extends State<WaterLeakRecordsScreen> {
Container(
height: 10,
width: 20,
child:
const Center(child: Text('No data available.')),
child: const Center(child: Text('No data available.')),
),
],
),