mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-10 15:17:21 +00:00
Add flush sensor icon to assets and enhancement code
This commit is contained in:
22
assets/icons/flush_icon.svg
Normal file
22
assets/icons/flush_icon.svg
Normal file
@ -0,0 +1,22 @@
|
||||
<svg width="38" height="40" viewBox="0 0 38 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M19 0C18.3528 0 17.8281 0.524531 17.8281 1.17188V5.85938C17.8281 6.50656 18.3528 7.03125 19 7.03125C19.6472 7.03125 20.1719 6.50656 20.1719 5.85938V1.17188C20.1719 0.524531 19.6472 0 19 0Z" fill="#596C76"/>
|
||||
<path d="M20.1719 5.85938V1.17188C20.1719 0.524531 19.6472 0 19 0V7.03125C19.6472 7.03125 20.1719 6.50656 20.1719 5.85938Z" fill="#3B4A51"/>
|
||||
<path d="M30.7188 4.6875H19H7.28125C5.34266 4.6875 3.76562 6.26453 3.76562 8.20312V13.0469C3.76562 14.9855 5.34266 16.5625 7.28125 16.5625H19H30.7188C32.6573 16.5625 34.2344 14.9855 34.2344 13.0469V8.20312C34.2344 6.26453 32.6573 4.6875 30.7188 4.6875Z" fill="#596C76"/>
|
||||
<path d="M34.2344 13.0469V8.20312C34.2344 6.26453 32.6573 4.6875 30.7188 4.6875H19V16.5625H30.7188C32.6573 16.5625 34.2344 14.9855 34.2344 13.0469Z" fill="#3B4A51"/>
|
||||
<path d="M28.375 0H19H9.625C8.97727 0 8.45312 0.524141 8.45312 1.17188C8.45312 1.81961 8.97727 2.34375 9.625 2.34375H19H28.375C29.0227 2.34375 29.5469 1.81961 29.5469 1.17188C29.5469 0.524141 29.0227 0 28.375 0Z" fill="#596C76"/>
|
||||
<path d="M29.5469 1.17188C29.5469 0.524141 29.0227 0 28.375 0H19V2.34375H28.375C29.0227 2.34375 29.5469 1.81961 29.5469 1.17188Z" fill="#3B4A51"/>
|
||||
<path d="M19 35.3125C24.5046 35.3125 29.6315 33.1096 33.4344 29.1087C33.8808 28.6395 33.8613 27.8979 33.3933 27.4516C32.9229 27.0053 32.1825 27.0247 31.7361 27.4928C28.3796 31.0244 23.8557 32.9688 19 32.9688C14.1443 32.9688 9.62037 31.0244 6.26388 27.4928C5.81873 27.0247 5.07716 27.0053 4.60677 27.4516C4.13873 27.8979 4.11927 28.6395 4.5656 29.1087C8.36841 33.1096 13.4954 35.3125 19 35.3125Z" fill="#D5E8FE"/>
|
||||
<path d="M19 30.6253C23.0203 30.6253 26.8152 29.0677 29.6853 26.2399C30.1465 25.7867 30.1511 25.044 29.6967 24.5828C29.2447 24.1227 28.5031 24.1182 28.0396 24.5714C25.6112 26.9632 22.4001 28.2816 19 28.2816C15.5999 28.2816 12.3887 26.9632 9.96031 24.5714C9.49679 24.1148 8.75523 24.1217 8.3032 24.5828C7.8489 25.044 7.85343 25.7867 8.31461 26.2399C11.1848 29.0677 14.9797 30.6253 19 30.6253Z" fill="#D5E8FE"/>
|
||||
<path d="M19 25.9377C21.5223 25.9377 23.9667 25.0291 25.8813 23.3788C26.3712 22.9554 26.4261 22.2161 26.0037 21.7252C25.578 21.233 24.8399 21.1816 24.3501 21.6027C22.8612 22.8868 20.9305 23.5287 19 23.5287C17.0695 23.5287 15.1387 22.8867 13.6499 21.6027C13.1578 21.1816 12.4185 21.2331 11.9962 21.7252C11.574 22.2161 11.6289 22.9554 12.1187 23.3788C14.0333 25.0291 16.4777 25.9377 19 25.9377Z" fill="#D5E8FE"/>
|
||||
<path d="M16.1687 20.52C17.0316 20.9973 18.0112 21.2502 19 21.2502C19.9887 21.2502 20.9683 20.9973 21.8312 20.52C22.3977 20.2064 22.6026 19.4934 22.289 18.927C21.9754 18.3605 21.259 18.1545 20.6959 18.4692C20.1798 18.7553 19.5898 18.8984 18.9999 18.8984C18.41 18.8984 17.82 18.7553 17.3039 18.4692C16.7386 18.1545 16.0233 18.3605 15.7109 18.927C15.3974 19.4935 15.6023 20.2065 16.1687 20.52Z" fill="#D5E8FE"/>
|
||||
<path d="M37.0897 30.324C36.6113 29.8903 35.8709 29.92 35.4337 30.3984C31.2177 35.0104 25.2279 37.6563 19 37.6563C12.7721 37.6563 6.78226 35.0104 2.56624 30.3985C2.12906 29.9201 1.38867 29.8904 0.910306 30.3241C0.433119 30.7613 0.399916 31.5017 0.835931 31.98C5.49593 37.0772 12.1164 40 19 40C25.8836 40 32.5041 37.0772 37.1641 31.98C37.6001 31.5017 37.5669 30.7612 37.0897 30.324Z" fill="#D5E8FE"/>
|
||||
<path d="M37.0897 30.324C36.6113 29.8903 35.8709 29.92 35.4338 30.3984C31.2177 35.0104 25.2279 37.6563 19 37.6563V40C25.8836 40 32.5041 37.0772 37.1641 31.98C37.6001 31.5017 37.5669 30.7612 37.0897 30.324Z" fill="#B5DBFF"/>
|
||||
<path d="M33.3932 27.4516C32.9228 27.0053 32.1824 27.0247 31.7361 27.4928C28.3796 31.0244 23.8557 32.9688 19 32.9688V35.3125C24.5046 35.3125 29.6316 33.1096 33.4345 29.1087C33.8808 28.6395 33.8613 27.8979 33.3932 27.4516Z" fill="#B5DBFF"/>
|
||||
<path d="M29.6968 24.5826C29.2448 24.1225 28.5032 24.118 28.0397 24.5712C25.6113 26.963 22.4001 28.2813 19 28.2813V30.6251C23.0203 30.6251 26.8152 29.0675 29.6853 26.2397C30.1466 25.7865 30.1511 25.0438 29.6968 24.5826Z" fill="#B5DBFF"/>
|
||||
<path d="M26.0038 21.7252C25.578 21.233 24.8399 21.1816 24.3501 21.6027C22.8612 22.8868 20.9305 23.5287 19 23.5287V25.9377C21.5223 25.9377 23.9667 25.0291 25.8813 23.3788C26.3712 22.9554 26.4261 22.2161 26.0038 21.7252Z" fill="#B5DBFF"/>
|
||||
<path d="M22.2891 18.927C21.9755 18.3605 21.2591 18.1545 20.696 18.4692C20.1799 18.7553 19.5899 18.8984 19 18.8984V21.2501C19.9887 21.2501 20.9684 20.9972 21.8312 20.5199C22.3977 20.2064 22.6026 19.4934 22.2891 18.927Z" fill="#B5DBFF"/>
|
||||
<path d="M14.3125 11.7969C14.9597 11.7969 15.4844 11.2722 15.4844 10.625C15.4844 9.97779 14.9597 9.45312 14.3125 9.45312C13.6653 9.45312 13.1406 9.97779 13.1406 10.625C13.1406 11.2722 13.6653 11.7969 14.3125 11.7969Z" fill="#EDF5FF"/>
|
||||
<path d="M23.6875 11.7969C24.3347 11.7969 24.8594 11.2722 24.8594 10.625C24.8594 9.97779 24.3347 9.45312 23.6875 9.45312C23.0403 9.45312 22.5156 9.97779 22.5156 10.625C22.5156 11.2722 23.0403 11.7969 23.6875 11.7969Z" fill="#51FAFF"/>
|
||||
<path d="M19 11.7969C19.6472 11.7969 20.1719 11.2722 20.1719 10.625C20.1719 9.97779 19.6472 9.45312 19 9.45312C18.3528 9.45312 17.8281 9.97779 17.8281 10.625C17.8281 11.2722 18.3528 11.7969 19 11.7969Z" fill="#EDF5FF"/>
|
||||
<path d="M20.1719 10.625C20.1719 9.97766 19.6472 9.45312 19 9.45312V11.7969C19.6472 11.7969 20.1719 11.2722 20.1719 10.625Z" fill="#D5E8FE"/>
|
||||
</svg>
|
After Width: | Height: | Size: 5.2 KiB |
@ -5,6 +5,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/flush_sensor_bloc/flush_sensor_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/flush_sensor_bloc/flush_sensor_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_info_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/flush_sensor_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
@ -15,17 +16,17 @@ class FlushSensorBloc extends Bloc<FlushSensorEvent, FlushSensorState> {
|
||||
late DeviceModel deviceModel;
|
||||
late FlushSensorModel deviceStatus;
|
||||
|
||||
FlushSensorBloc({required this.deviceId}) : super(InitialState()) {
|
||||
on<InitialEvent>(_fetchFlushSensorStatus);
|
||||
on<ChangeIndicatorEvent>(_changeIndicator);
|
||||
on<ChangeValueEvent>(_changeValue);
|
||||
on<WallSensorUpdatedEvent>(_flushSensorUpdated);
|
||||
on<GetDeviceReportsEvent>(_getDeviceReports);
|
||||
FlushSensorBloc({required this.deviceId}) : super(FlushSensorInitialState()) {
|
||||
on<FlushSensorInitialEvent>(_fetchFlushSensorStatus);
|
||||
on<FlushSensorChangeIndicatorEvent>(_changeIndicator);
|
||||
on<FlushSensorChangeValueEvent>(_changeValue);
|
||||
on<FlushSensorUpdatedEvent>(_flushSensorUpdated);
|
||||
on<FlushSensorGetDeviceReportsEvent>(_getDeviceReports);
|
||||
}
|
||||
|
||||
void _fetchFlushSensorStatus(
|
||||
InitialEvent event, Emitter<FlushSensorState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
FlushSensorInitialEvent event, Emitter<FlushSensorState> emit) async {
|
||||
emit(FlushSensorLoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(deviceId);
|
||||
List<StatusModel> statusModelList = [];
|
||||
@ -33,10 +34,10 @@ class FlushSensorBloc extends Bloc<FlushSensorEvent, FlushSensorState> {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
}
|
||||
deviceStatus = FlushSensorModel.fromJson(statusModelList);
|
||||
emit(UpdateState(flushSensorModel: deviceStatus));
|
||||
emit(FlushSensorUpdateState(flushSensorModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
emit(FlushSensorFailedState(error: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -60,7 +61,7 @@ class FlushSensorBloc extends Bloc<FlushSensorEvent, FlushSensorState> {
|
||||
});
|
||||
deviceStatus = FlushSensorModel.fromJson(statusList);
|
||||
if (!isClosed) {
|
||||
add(WallSensorUpdatedEvent());
|
||||
add(FlushSensorUpdatedEvent());
|
||||
}
|
||||
});
|
||||
} catch (_) {
|
||||
@ -79,51 +80,53 @@ class FlushSensorBloc extends Bloc<FlushSensorEvent, FlushSensorState> {
|
||||
}
|
||||
|
||||
_flushSensorUpdated(
|
||||
WallSensorUpdatedEvent event, Emitter<FlushSensorState> emit) {
|
||||
emit(UpdateState(flushSensorModel: deviceStatus));
|
||||
FlushSensorUpdatedEvent event, Emitter<FlushSensorState> emit) {
|
||||
emit(FlushSensorUpdateState(flushSensorModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _changeIndicator(
|
||||
ChangeIndicatorEvent event, Emitter<FlushSensorState> emit) async {
|
||||
emit(LoadingNewSate(flushSensorModel: deviceStatus));
|
||||
void _changeIndicator(FlushSensorChangeIndicatorEvent event,
|
||||
Emitter<FlushSensorState> emit) async {
|
||||
emit(FlushSensorLoadingNewSate(flushSensorModel: deviceStatus));
|
||||
try {
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: deviceId, code: 'indicator', value: !event.value),
|
||||
deviceId);
|
||||
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
emit(FlushSensorFailedState(error: e.toString()));
|
||||
return;
|
||||
}
|
||||
emit(UpdateState(flushSensorModel: deviceStatus));
|
||||
emit(FlushSensorUpdateState(flushSensorModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _changeValue(
|
||||
ChangeValueEvent event, Emitter<FlushSensorState> emit) async {
|
||||
emit(LoadingNewSate(flushSensorModel: deviceStatus));
|
||||
FlushSensorChangeValueEvent event, Emitter<FlushSensorState> emit) async {
|
||||
emit(FlushSensorLoadingNewSate(flushSensorModel: deviceStatus));
|
||||
try {
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: deviceId, code: event.code, value: event.value),
|
||||
deviceId);
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
emit(FlushSensorFailedState(error: e.toString()));
|
||||
return;
|
||||
}
|
||||
emit(UpdateState(flushSensorModel: deviceStatus));
|
||||
emit(FlushSensorUpdateState(flushSensorModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _getDeviceReports(
|
||||
GetDeviceReportsEvent event, Emitter<FlushSensorState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
void _getDeviceReports(FlushSensorGetDeviceReportsEvent event,
|
||||
Emitter<FlushSensorState> emit) async {
|
||||
emit(FlushSensorLoadingInitialState());
|
||||
try {
|
||||
await DevicesAPI.getDeviceReports(deviceId, event.code).then((value) {
|
||||
emit(DeviceReportsState(deviceReport: value, code: event.code));
|
||||
emit(FlushSensorDeviceReportsState(
|
||||
deviceReport: value, code: event.code));
|
||||
});
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
emit(FlushSensorFailedState(error: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,33 +7,35 @@ abstract class FlushSensorEvent extends Equatable {
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class LoadingEvent extends FlushSensorEvent {}
|
||||
class FlushSensorLoadingEvent extends FlushSensorEvent {}
|
||||
|
||||
class InitialEvent extends FlushSensorEvent {}
|
||||
class FlushSensorInitialEvent extends FlushSensorEvent {}
|
||||
|
||||
class WallSensorUpdatedEvent extends FlushSensorEvent {}
|
||||
class FlushSensorInitialDeviseInfo extends FlushSensorEvent {}
|
||||
|
||||
class ChangeIndicatorEvent extends FlushSensorEvent {
|
||||
class FlushSensorUpdatedEvent extends FlushSensorEvent {}
|
||||
|
||||
class FlushSensorChangeIndicatorEvent extends FlushSensorEvent {
|
||||
final bool value;
|
||||
const ChangeIndicatorEvent({required this.value});
|
||||
const FlushSensorChangeIndicatorEvent({required this.value});
|
||||
|
||||
@override
|
||||
List<Object> get props => [value];
|
||||
}
|
||||
|
||||
class ChangeValueEvent extends FlushSensorEvent {
|
||||
class FlushSensorChangeValueEvent extends FlushSensorEvent {
|
||||
final dynamic value;
|
||||
final String code;
|
||||
const ChangeValueEvent({required this.value, required this.code});
|
||||
const FlushSensorChangeValueEvent({required this.value, required this.code});
|
||||
|
||||
@override
|
||||
List<Object> get props => [value, code];
|
||||
}
|
||||
|
||||
class GetDeviceReportsEvent extends FlushSensorEvent {
|
||||
class FlushSensorGetDeviceReportsEvent extends FlushSensorEvent {
|
||||
final String deviceUuid;
|
||||
final String code;
|
||||
const GetDeviceReportsEvent({
|
||||
const FlushSensorGetDeviceReportsEvent({
|
||||
required this.deviceUuid,
|
||||
required this.code,
|
||||
});
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_info_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_report_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/flush_sensor_model.dart';
|
||||
|
||||
@ -9,37 +10,43 @@ class FlushSensorState extends Equatable {
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class InitialState extends FlushSensorState {}
|
||||
class FlushSensorInitialState extends FlushSensorState {}
|
||||
|
||||
class LoadingInitialState extends FlushSensorState {}
|
||||
class FlushSensorLoadingInitialState extends FlushSensorState {}
|
||||
|
||||
class UpdateState extends FlushSensorState {
|
||||
class FlushSensorUpdateState extends FlushSensorState {
|
||||
final FlushSensorModel flushSensorModel;
|
||||
const UpdateState({required this.flushSensorModel});
|
||||
const FlushSensorUpdateState({required this.flushSensorModel});
|
||||
|
||||
@override
|
||||
List<Object> get props => [flushSensorModel];
|
||||
}
|
||||
|
||||
class LoadingNewSate extends FlushSensorState {
|
||||
class FlushSensorLoadingNewSate extends FlushSensorState {
|
||||
final FlushSensorModel flushSensorModel;
|
||||
const LoadingNewSate({required this.flushSensorModel});
|
||||
const FlushSensorLoadingNewSate({required this.flushSensorModel});
|
||||
|
||||
@override
|
||||
List<Object> get props => [flushSensorModel];
|
||||
}
|
||||
|
||||
class FailedState extends FlushSensorState {
|
||||
class FlushSensorFailedState extends FlushSensorState {
|
||||
final String error;
|
||||
|
||||
const FailedState({required this.error});
|
||||
const FlushSensorFailedState({required this.error});
|
||||
|
||||
@override
|
||||
List<Object> get props => [error];
|
||||
}
|
||||
|
||||
class DeviceReportsState extends FlushSensorState {
|
||||
class FlushSensorDeviceReportsState extends FlushSensorState {
|
||||
final DeviceReport deviceReport;
|
||||
final String code;
|
||||
const DeviceReportsState({required this.deviceReport, required this.code});
|
||||
const FlushSensorDeviceReportsState(
|
||||
{required this.deviceReport, required this.code});
|
||||
}
|
||||
|
||||
class FlushSensorLoadingDeviceInfo extends FlushSensorState {
|
||||
final DeviceInfoModel? deviceInfo;
|
||||
const FlushSensorLoadingDeviceInfo({this.deviceInfo});
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class DeviceModel {
|
||||
} else if (type == DeviceType.SOS) {
|
||||
tempIcon = Assets.sosHomeIcon;
|
||||
} else if (type == DeviceType.FlushMountedSensor) {
|
||||
tempIcon = Assets.sosHomeIcon;
|
||||
tempIcon = Assets.flushIcon;
|
||||
} else {
|
||||
tempIcon = Assets.assetsIconsLogo;
|
||||
}
|
||||
|
@ -15,7 +15,10 @@ class FlushPresenceRecords extends StatelessWidget {
|
||||
final String code;
|
||||
final String title;
|
||||
const FlushPresenceRecords(
|
||||
{super.key, required this.deviceId, required this.code, required this.title});
|
||||
{super.key,
|
||||
required this.deviceId,
|
||||
required this.code,
|
||||
required this.title});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -23,18 +26,23 @@ class FlushPresenceRecords extends StatelessWidget {
|
||||
title: title,
|
||||
child: BlocProvider(
|
||||
create: (context) => FlushSensorBloc(deviceId: deviceId)
|
||||
..add(GetDeviceReportsEvent(deviceUuid: deviceId, code: code)),
|
||||
child: BlocBuilder<FlushSensorBloc, FlushSensorState>(builder: (context, state) {
|
||||
..add(FlushSensorGetDeviceReportsEvent(
|
||||
deviceUuid: deviceId, code: code)),
|
||||
child: BlocBuilder<FlushSensorBloc, FlushSensorState>(
|
||||
builder: (context, state) {
|
||||
final Map<String, List<DeviceEvent>> groupedRecords = {};
|
||||
|
||||
if (state is LoadingInitialState) {
|
||||
if (state is FlushSensorLoadingInitialState) {
|
||||
return const Center(
|
||||
child: DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
child: DefaultContainer(
|
||||
width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
);
|
||||
} else if (state is DeviceReportsState) {
|
||||
} else if (state is FlushSensorDeviceReportsState) {
|
||||
for (var record in state.deviceReport.data ?? []) {
|
||||
final DateTime eventDateTime = DateTime.fromMillisecondsSinceEpoch(record.eventTime!);
|
||||
final String formattedDate = DateFormat('EEEE, dd/MM/yyyy').format(eventDateTime);
|
||||
final DateTime eventDateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(record.eventTime!);
|
||||
final String formattedDate =
|
||||
DateFormat('EEEE, dd/MM/yyyy').format(eventDateTime);
|
||||
|
||||
// Group by formatted date
|
||||
if (groupedRecords.containsKey(formattedDate)) {
|
||||
@ -52,7 +60,8 @@ class FlushPresenceRecords extends StatelessWidget {
|
||||
itemCount: groupedRecords.length,
|
||||
itemBuilder: (context, index) {
|
||||
final String date = groupedRecords.keys.elementAt(index);
|
||||
final List<DeviceEvent> recordsForDate = groupedRecords[date]!;
|
||||
final List<DeviceEvent> recordsForDate =
|
||||
groupedRecords[date]!;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -75,9 +84,11 @@ class FlushPresenceRecords extends StatelessWidget {
|
||||
final int idx = entry.key;
|
||||
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: [
|
||||
@ -87,10 +98,14 @@ class FlushPresenceRecords extends StatelessWidget {
|
||||
record.value == 'true'
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: record.value == 'true' ? Colors.blue : Colors.grey,
|
||||
color: record.value == 'true'
|
||||
? Colors.blue
|
||||
: Colors.grey,
|
||||
),
|
||||
title: Text(
|
||||
record.value == 'true' ? "Opened" : "Closed",
|
||||
record.value == 'true'
|
||||
? "Opened"
|
||||
: "Closed",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
|
@ -8,9 +8,11 @@ import 'package:syncrow_app/features/devices/bloc/flush_sensor_bloc/flush_sensor
|
||||
import 'package:syncrow_app/features/devices/bloc/flush_sensor_bloc/flush_sensor_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/flush_sensor_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/device_settings/settings_page.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/device_appbar.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/flush_sensor/flush_persence_records.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/flush_sensor/flush_sensor_option.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
@ -31,7 +33,7 @@ class FlushMountedInterface extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => FlushSensorBloc(deviceId: deviceModel.uuid ?? '')
|
||||
..add(InitialEvent()),
|
||||
..add(FlushSensorInitialEvent()),
|
||||
child: BlocBuilder<FlushSensorBloc, FlushSensorState>(
|
||||
builder: (context, state) {
|
||||
final bloc = BlocProvider.of<FlushSensorBloc>(context);
|
||||
@ -47,28 +49,23 @@ class FlushMountedInterface extends StatelessWidget {
|
||||
sensiReduce: 0,
|
||||
sensitivity: 0);
|
||||
|
||||
if (state is UpdateState) {
|
||||
if (state is FlushSensorUpdateState) {
|
||||
flushSensorModel = state.flushSensorModel;
|
||||
} else if (state is LoadingNewSate) {
|
||||
} else if (state is FlushSensorLoadingNewSate) {
|
||||
flushSensorModel = state.flushSensorModel;
|
||||
}
|
||||
|
||||
return AnnotatedRegion(
|
||||
value: SystemUiOverlayStyle(
|
||||
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: ColorsManager.backgroundColor,
|
||||
extendBodyBehindAppBar: true,
|
||||
extendBody: true,
|
||||
appBar: DeviceAppbar(
|
||||
deviceName: deviceModel.name!,
|
||||
deviceUuid: deviceModel.uuid!,
|
||||
),
|
||||
body: Container(
|
||||
child: DefaultScaffold(
|
||||
title: deviceModel.name!,
|
||||
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
padding: const EdgeInsets.all(Constants.defaultPadding),
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
@ -78,14 +75,14 @@ class FlushMountedInterface extends StatelessWidget {
|
||||
opacity: 0.4,
|
||||
),
|
||||
),
|
||||
child: state is LoadingInitialState
|
||||
child: state is FlushSensorLoadingInitialState
|
||||
? const Center(
|
||||
child: RefreshProgressIndicator(),
|
||||
)
|
||||
: SafeArea(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
bloc.add(InitialEvent());
|
||||
bloc.add(FlushSensorInitialEvent());
|
||||
},
|
||||
child: ListView(children: [
|
||||
SizedBox(
|
||||
|
@ -186,7 +186,7 @@ class FlushSensorOptionsList extends StatelessWidget {
|
||||
result = (result * 10).toInt();
|
||||
}
|
||||
bloc.add(
|
||||
ChangeValueEvent(value: result, code: controlCode),
|
||||
FlushSensorChangeValueEvent(value: result, code: controlCode),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -153,14 +153,10 @@ class FlushParameterControlDialogState
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (widget.sensor.isOnline == null) {
|
||||
if (widget.sensor.isOnline == null || !widget.sensor.isOnline!) {
|
||||
CustomSnackBar.displaySnackBar('The device is offline');
|
||||
return;
|
||||
}
|
||||
if (!widget.sensor.isOnline!) {
|
||||
CustomSnackBar.displaySnackBar('The device is offline');
|
||||
return;
|
||||
}
|
||||
}
|
||||
Navigator.pop(context, _value);
|
||||
},
|
||||
child: Center(
|
||||
|
@ -1155,4 +1155,5 @@ class Assets {
|
||||
static const String targetConfirmTimeIcon =
|
||||
'assets/icons/target_confirm_time_icon.svg';
|
||||
static const String disappeDelayIcon = 'assets/icons/disappe_delay_icon.svg';
|
||||
static const String flushIcon = 'assets/icons/flush_icon.svg';
|
||||
}
|
||||
|
Reference in New Issue
Block a user