mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 12:54:55 +00:00
connected the realtime feature to the occupancy side bar, but with a mock id.
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/realtime_device_changes/realtime_device_changes_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/fetch_energy_management_data_helper.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/helpers/fetch_energy_management_data_helper.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/occupancy/blocs/occupancy/occupancy_bloc.dart';
|
import 'package:syncrow_web/pages/analytics/modules/occupancy/blocs/occupancy/occupancy_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/params/get_occupancy_param.dart';
|
import 'package:syncrow_web/pages/analytics/params/get_occupancy_param.dart';
|
||||||
@ -21,5 +22,11 @@ abstract final class FetchOccupancyDataHelper {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
context.read<RealtimeDeviceChangesBloc>()
|
||||||
|
..add(const RealtimeDeviceChangesClosed())
|
||||||
|
..add(
|
||||||
|
const RealtimeDeviceChangesStarted('14fe6e7e-47af-4a07-ae0a-7c4a26ef8135'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/models/power_clamp_energy_status.dart';
|
import 'package:syncrow_web/pages/analytics/models/power_clamp_energy_status.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/blocs/realtime_device_changes/realtime_device_changes_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/power_clamp_energy_data_device_dropdown.dart';
|
||||||
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/power_clamp_energy_status_widget.dart';
|
import 'package:syncrow_web/pages/analytics/modules/energy_management/widgets/power_clamp_energy_status_widget.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
@ -12,6 +16,8 @@ class OccupancyEndSideBar extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return BlocBuilder<RealtimeDeviceChangesBloc, RealtimeDeviceChangesState>(
|
||||||
|
builder: (context, state) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: subSectionContainerDecoration.copyWith(
|
decoration: subSectionContainerDecoration.copyWith(
|
||||||
borderRadius: BorderRadius.circular(30),
|
borderRadius: BorderRadius.circular(30),
|
||||||
@ -43,35 +49,55 @@ class OccupancyEndSideBar extends StatelessWidget {
|
|||||||
const SizedBox(height: 50),
|
const SizedBox(height: 50),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: MediaQuery.sizeOf(context).height * 0.2,
|
height: MediaQuery.sizeOf(context).height * 0.2,
|
||||||
child: const Expanded(
|
|
||||||
child: PowerClampEnergyStatusWidget(
|
child: PowerClampEnergyStatusWidget(
|
||||||
status: [
|
status: [
|
||||||
PowerClampEnergyStatus(
|
PowerClampEnergyStatus(
|
||||||
iconPath: Assets.presenceState,
|
iconPath: Assets.presenceState,
|
||||||
title: 'Presence Status',
|
title: 'Presence Status',
|
||||||
value: 'Presence',
|
value: _valueFromCode(
|
||||||
|
'presence_state',
|
||||||
|
state.deviceStatusList,
|
||||||
|
),
|
||||||
unit: '',
|
unit: '',
|
||||||
),
|
),
|
||||||
PowerClampEnergyStatus(
|
PowerClampEnergyStatus(
|
||||||
iconPath: Assets.presenceTimeIcon,
|
iconPath: Assets.presenceTimeIcon,
|
||||||
title: 'Presence Time',
|
title: 'Presence Time',
|
||||||
value: '15 Mins',
|
value:
|
||||||
|
'${_valueFromCode('none_body_time', state.deviceStatusList)} Min',
|
||||||
unit: '',
|
unit: '',
|
||||||
),
|
),
|
||||||
PowerClampEnergyStatus(
|
PowerClampEnergyStatus(
|
||||||
iconPath: Assets.currentDistanceIcon,
|
iconPath: Assets.currentDistanceIcon,
|
||||||
title: 'Detection Distance',
|
title: 'Detection Distance',
|
||||||
value: '1.5M',
|
value:
|
||||||
|
'${_valueFromCode('space_move_val', state.deviceStatusList)} M',
|
||||||
unit: '',
|
unit: '',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _valueFromCode(
|
||||||
|
String code,
|
||||||
|
List<Status> status, {
|
||||||
|
String? defaultValue,
|
||||||
|
}) {
|
||||||
|
final value = status
|
||||||
|
.firstWhere(
|
||||||
|
(e) => e.code == code,
|
||||||
|
orElse: () => Status(code: '--', value: '--'),
|
||||||
|
)
|
||||||
|
.value
|
||||||
|
.toString();
|
||||||
|
return value == 'null' ? defaultValue ?? '--' : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildHeader(BuildContext context) {
|
Widget _buildHeader(BuildContext context) {
|
||||||
@ -98,8 +124,7 @@ class OccupancyEndSideBar extends StatelessWidget {
|
|||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
// child: PowerClampEnergyDataDeviceDropdown(),
|
child: PowerClampEnergyDataDeviceDropdown(),
|
||||||
child: Placeholder(fallbackHeight: 30),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class FirebaseRealtimeDeviceService implements RealtimeDeviceService {
|
|||||||
|
|
||||||
return Status(
|
return Status(
|
||||||
code: status['code']?.toString() ?? '',
|
code: status['code']?.toString() ?? '',
|
||||||
value: num.tryParse(status['value']?.toString() ?? '0'),
|
value: status['value']?.toString() ?? '',
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user