mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 21:37:55 +00:00
add new flush sensor device to app
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/flush_sensor_bloc/flush_sensor_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_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/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class FlushPresenceRecords extends StatelessWidget {
|
||||
final String deviceId;
|
||||
final String code;
|
||||
final String title;
|
||||
const FlushPresenceRecords(
|
||||
{super.key, required this.deviceId, required this.code, required this.title});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
title: title,
|
||||
child: BlocProvider(
|
||||
create: (context) => FlushSensorBloc(deviceId: deviceId)
|
||||
..add(GetDeviceReportsEvent(deviceUuid: deviceId, code: code)),
|
||||
child: BlocBuilder<FlushSensorBloc, FlushSensorState>(builder: (context, state) {
|
||||
final Map<String, List<DeviceEvent>> groupedRecords = {};
|
||||
|
||||
if (state is LoadingInitialState) {
|
||||
return const Center(
|
||||
child: DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
);
|
||||
} else if (state is DeviceReportsState) {
|
||||
for (var record in state.deviceReport.data ?? []) {
|
||||
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)) {
|
||||
groupedRecords[formattedDate]!.add(record);
|
||||
} else {
|
||||
groupedRecords[formattedDate] = [record];
|
||||
}
|
||||
}
|
||||
}
|
||||
return groupedRecords.isEmpty
|
||||
? const Center(
|
||||
child: Text('No records found'),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: groupedRecords.length,
|
||||
itemBuilder: (context, index) {
|
||||
final String date = groupedRecords.keys.elementAt(index);
|
||||
final List<DeviceEvent> recordsForDate = groupedRecords[date]!;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 5, top: 10),
|
||||
child: Text(
|
||||
date,
|
||||
style: const TextStyle(
|
||||
color: ColorsManager.grayColor,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
DefaultContainer(
|
||||
child: Column(
|
||||
children: [
|
||||
...recordsForDate.asMap().entries.map((entry) {
|
||||
final int idx = entry.key;
|
||||
final DeviceEvent record = entry.value;
|
||||
final DateTime eventDateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(record.eventTime!);
|
||||
final String formattedTime =
|
||||
DateFormat('HH:mm:ss').format(eventDateTime);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
record.value == 'true'
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
color: record.value == 'true' ? Colors.blue : Colors.grey,
|
||||
),
|
||||
title: Text(
|
||||
record.value == 'true' ? "Opened" : "Closed",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
subtitle: Text('$formattedTime'),
|
||||
),
|
||||
),
|
||||
if (idx != recordsForDate.length - 1)
|
||||
const Divider(
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/flush_sensor_bloc/flush_sensor_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_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/flush_sensor_model.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/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/helpers/misc_string_helpers.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||
part "presence_indicator.dart";
|
||||
part "flush_sensor_options_list.dart";
|
||||
part 'flush_sensor_parameter_control_dialog.dart';
|
||||
|
||||
class FlushMountedInterface extends StatelessWidget {
|
||||
const FlushMountedInterface({super.key, required this.deviceModel});
|
||||
final DeviceModel deviceModel;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => FlushSensorBloc(deviceId: deviceModel.uuid ?? '')
|
||||
..add(InitialEvent()),
|
||||
child: BlocBuilder<FlushSensorBloc, FlushSensorState>(
|
||||
builder: (context, state) {
|
||||
final bloc = BlocProvider.of<FlushSensorBloc>(context);
|
||||
FlushSensorModel flushSensorModel = FlushSensorModel(
|
||||
presenceState: 'none',
|
||||
farDetection: 0,
|
||||
illuminance: 0,
|
||||
checkingResult: '',
|
||||
nearDetection: 0,
|
||||
noneDelay: 0,
|
||||
occurDistReduce: 0,
|
||||
presenceDelay: 0,
|
||||
sensiReduce: 0,
|
||||
sensitivity: 0);
|
||||
|
||||
if (state is UpdateState) {
|
||||
flushSensorModel = state.flushSensorModel;
|
||||
} else if (state is LoadingNewSate) {
|
||||
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(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
padding: const EdgeInsets.all(Constants.defaultPadding),
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
Assets.assetsImagesBackground,
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
opacity: 0.4,
|
||||
),
|
||||
),
|
||||
child: state is LoadingInitialState
|
||||
? const Center(
|
||||
child: RefreshProgressIndicator(),
|
||||
)
|
||||
: SafeArea(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
bloc.add(InitialEvent());
|
||||
},
|
||||
child: ListView(children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Column(children: [
|
||||
PresenceIndicator(
|
||||
state: flushSensorModel.presenceState,
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: FlushSensorOptionsList(
|
||||
bloc: bloc,
|
||||
flushSensorModel: flushSensorModel,
|
||||
deviceModel: deviceModel,
|
||||
),
|
||||
)
|
||||
]),
|
||||
),
|
||||
]),
|
||||
),
|
||||
))));
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class FlushSensorOption extends StatelessWidget {
|
||||
final String icon;
|
||||
final String label;
|
||||
final VoidCallback onTap;
|
||||
final String? sliderValue;
|
||||
final bool withArrow;
|
||||
|
||||
const FlushSensorOption({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.onTap,
|
||||
required this.withArrow,
|
||||
this.sliderValue = '',
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultContainer(
|
||||
margin: const EdgeInsets.only(bottom: 5),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 20),
|
||||
onTap: onTap,
|
||||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(icon),
|
||||
const SizedBox(width: 25),
|
||||
Expanded(
|
||||
child:
|
||||
Text(label, style: Theme.of(context).textTheme.bodyMedium)),
|
||||
Text(sliderValue!,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.grayTextColor,
|
||||
fontWeight: FontWeight.bold)),
|
||||
withArrow == true
|
||||
? const Icon(Icons.arrow_forward_ios,
|
||||
color: ColorsManager.grayTextColor, size: 15)
|
||||
: SizedBox(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
part of "flush_sensor_interface.dart";
|
||||
|
||||
class FlushSensorOptionsList extends StatelessWidget {
|
||||
final FlushSensorModel flushSensorModel;
|
||||
final DeviceModel deviceModel;
|
||||
final FlushSensorBloc bloc;
|
||||
const FlushSensorOptionsList(
|
||||
{super.key,
|
||||
required this.flushSensorModel,
|
||||
required this.bloc,
|
||||
required this.deviceModel});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
FlushSensorOption(
|
||||
withArrow: false,
|
||||
sliderValue: '${flushSensorModel.illuminance.toString()} Lux',
|
||||
icon: Assets.assetsIconsPresenceSensorAssetsIlluminanceValue,
|
||||
label: 'Illuminance Value',
|
||||
onTap: () {},
|
||||
),
|
||||
FlushSensorOption(
|
||||
withArrow: false,
|
||||
icon: Assets.assetsIconsPresenceSensorAssetsIlluminanceRecord,
|
||||
label: 'Presence Record',
|
||||
onTap: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => FlushPresenceRecords(
|
||||
deviceId: deviceModel.uuid!,
|
||||
code: FlushSensorModel.codePresenceState,
|
||||
title: 'Illuminance Record'),
|
||||
));
|
||||
}),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Text(
|
||||
'Configuration',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
FlushSensorOption(
|
||||
withArrow: true,
|
||||
sliderValue: flushSensorModel.sensitivity.toString(),
|
||||
icon: Assets.assetsSensitivityFunction,
|
||||
label: 'Sensitivity',
|
||||
onTap: () => _showParameterDialog(
|
||||
min: 0,
|
||||
max: 9,
|
||||
value: flushSensorModel.sensitivity.toDouble(),
|
||||
context: context,
|
||||
title: 'Sensitivity',
|
||||
controlCode: FlushSensorModel.codeSensitivity,
|
||||
step: 1.0,
|
||||
),
|
||||
),
|
||||
FlushSensorOption(
|
||||
withArrow: true,
|
||||
sliderValue: "${flushSensorModel.nearDetection / 100} m",
|
||||
icon: Assets.detectionDistanceIcon,
|
||||
label: 'Min Detection Distance',
|
||||
onTap: () => _showParameterDialog(
|
||||
min: 0.0,
|
||||
max: 9.5,
|
||||
value: flushSensorModel.nearDetection.toDouble() / 100,
|
||||
context: context,
|
||||
title: 'Min Detection Distance',
|
||||
controlCode: FlushSensorModel.codeNearDetection,
|
||||
step: 0.1,
|
||||
description: 'm',
|
||||
),
|
||||
),
|
||||
FlushSensorOption(
|
||||
withArrow: true,
|
||||
sliderValue: '${flushSensorModel.farDetection / 100} m',
|
||||
icon: Assets.detectionDistanceIcon,
|
||||
label: 'Max Detection Distance',
|
||||
onTap: () => _showParameterDialog(
|
||||
description: 'm',
|
||||
min: 0.0,
|
||||
max: 9.5,
|
||||
value: flushSensorModel.farDetection / 100,
|
||||
context: context,
|
||||
title: 'Max Detection Distance',
|
||||
controlCode: FlushSensorModel.codeFarDetection,
|
||||
step: 0.1),
|
||||
),
|
||||
FlushSensorOption(
|
||||
sliderValue: flushSensorModel.sensiReduce.toString(),
|
||||
withArrow: true,
|
||||
icon: Assets.triggerLevelIcon,
|
||||
label: 'Trigger Level',
|
||||
onTap: () => _showParameterDialog(
|
||||
min: 0,
|
||||
max: 3,
|
||||
value: flushSensorModel.sensiReduce.toDouble(),
|
||||
context: context,
|
||||
title: 'Trigger Level',
|
||||
controlCode: FlushSensorModel.codeSensiReduce,
|
||||
step: 1),
|
||||
),
|
||||
FlushSensorOption(
|
||||
sliderValue: flushSensorModel.occurDistReduce.toString(),
|
||||
withArrow: true,
|
||||
icon: Assets.indentLevelIcon,
|
||||
label: 'Indent Level',
|
||||
onTap: () => _showParameterDialog(
|
||||
min: 0,
|
||||
max: 3,
|
||||
value: flushSensorModel.occurDistReduce.toDouble(),
|
||||
context: context,
|
||||
title: 'Indent Level',
|
||||
controlCode: FlushSensorModel.codeOccurDistReduce,
|
||||
step: 1),
|
||||
),
|
||||
FlushSensorOption(
|
||||
sliderValue: '${flushSensorModel.presenceDelay / 10}',
|
||||
withArrow: true,
|
||||
icon: Assets.targetConfirmTimeIcon,
|
||||
label: 'Target Confirm Time',
|
||||
onTap: () => _showParameterDialog(
|
||||
min: 0.0,
|
||||
max: 0.5,
|
||||
value: flushSensorModel.presenceDelay.toDouble() / 10,
|
||||
context: context,
|
||||
title: 'Target Confirm Time',
|
||||
controlCode: FlushSensorModel.codePresenceDelay,
|
||||
step: 0.1),
|
||||
),
|
||||
FlushSensorOption(
|
||||
sliderValue: '${flushSensorModel.noneDelay.toDouble() / 10}',
|
||||
withArrow: true,
|
||||
icon: Assets.disappeDelayIcon,
|
||||
label: 'Disappe Delay',
|
||||
onTap: () => _showParameterDialog(
|
||||
min: 20,
|
||||
max: 300,
|
||||
value: flushSensorModel.noneDelay.toDouble() / 10,
|
||||
context: context,
|
||||
title: 'Disappe Delay',
|
||||
controlCode: FlushSensorModel.codeNoneDelay,
|
||||
step: 1),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _showParameterDialog({
|
||||
required double step,
|
||||
required BuildContext context,
|
||||
required String title,
|
||||
required String controlCode,
|
||||
required double min,
|
||||
required double max,
|
||||
required double value,
|
||||
String? description = '',
|
||||
}) async {
|
||||
var result = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return FlushParameterControlDialog(
|
||||
title: title,
|
||||
sensor: deviceModel,
|
||||
value: value,
|
||||
min: min,
|
||||
max: max,
|
||||
step: step,
|
||||
description: description);
|
||||
},
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
if (controlCode == FlushSensorModel.codeNearDetection ||
|
||||
controlCode == FlushSensorModel.codeFarDetection) {
|
||||
result = (result * 100).toInt();
|
||||
}
|
||||
if (controlCode == FlushSensorModel.codeNoneDelay) {
|
||||
result = (result * 10).toInt();
|
||||
}
|
||||
if (controlCode == FlushSensorModel.codePresenceDelay) {
|
||||
result = (result * 10).toInt();
|
||||
}
|
||||
bloc.add(
|
||||
ChangeValueEvent(value: result, code: controlCode),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
part of 'flush_sensor_interface.dart';
|
||||
|
||||
class FlushParameterControlDialog extends StatefulWidget {
|
||||
final String title;
|
||||
final String? description;
|
||||
final DeviceModel sensor;
|
||||
final double value;
|
||||
final double min;
|
||||
final double max;
|
||||
final double step;
|
||||
|
||||
const FlushParameterControlDialog({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.sensor,
|
||||
required this.value,
|
||||
required this.min,
|
||||
required this.max,
|
||||
required this.step,
|
||||
this.description = '',
|
||||
});
|
||||
|
||||
@override
|
||||
FlushParameterControlDialogState createState() =>
|
||||
FlushParameterControlDialogState();
|
||||
}
|
||||
|
||||
class FlushParameterControlDialogState
|
||||
extends State<FlushParameterControlDialog> {
|
||||
late double _value;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_value = widget.value;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final divisions = ((widget.max - widget.min) / widget.step).toInt();
|
||||
final decimalPlaces = widget.step % 1 == 0 ? 0 : 1;
|
||||
return Dialog(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
BodyMedium(
|
||||
text: widget.title,
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
fontWeight: FontsManager.extraBold,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 15,
|
||||
horizontal: 50,
|
||||
),
|
||||
child: Container(
|
||||
height: 1,
|
||||
width: double.infinity,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
),
|
||||
child: TitleMedium(
|
||||
text:
|
||||
"${_value.toStringAsFixed(decimalPlaces)} ${widget.description}",
|
||||
style: context.titleMedium.copyWith(
|
||||
color: Colors.black,
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_value = (_value - widget.step)
|
||||
.clamp(widget.min, widget.max);
|
||||
_value =
|
||||
double.parse(_value.toStringAsFixed(decimalPlaces));
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.remove, color: Colors.grey),
|
||||
),
|
||||
Flexible(
|
||||
child: Slider(
|
||||
value: _value,
|
||||
onChanged: (value) {
|
||||
final newValue =
|
||||
(value / widget.step).round() * widget.step;
|
||||
setState(() {
|
||||
_value = newValue.clamp(widget.min, widget.max);
|
||||
});
|
||||
},
|
||||
min: widget.min,
|
||||
max: widget.max,
|
||||
divisions: divisions,
|
||||
label: _value.toStringAsFixed(decimalPlaces),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_value = (_value + widget.step)
|
||||
.clamp(widget.min, widget.max);
|
||||
_value =
|
||||
double.parse(_value.toStringAsFixed(decimalPlaces));
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.add, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 1,
|
||||
width: double.infinity,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Center(
|
||||
child: BodyMedium(
|
||||
text: 'Cancel',
|
||||
style: context.bodyMedium
|
||||
.copyWith(color: ColorsManager.greyColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 50,
|
||||
width: 1,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (widget.sensor.isOnline == null) {
|
||||
CustomSnackBar.displaySnackBar('The device is offline');
|
||||
return;
|
||||
}
|
||||
if (!widget.sensor.isOnline!) {
|
||||
CustomSnackBar.displaySnackBar('The device is offline');
|
||||
return;
|
||||
}
|
||||
Navigator.pop(context, _value);
|
||||
},
|
||||
child: Center(
|
||||
child: BodyMedium(
|
||||
text: 'Confirm',
|
||||
style: context.bodyMedium.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
part of "flush_sensor_interface.dart";
|
||||
|
||||
class PresenceIndicator extends StatelessWidget {
|
||||
const PresenceIndicator({super.key, required this.state});
|
||||
final String state;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
state.toLowerCase() == 'motion'
|
||||
? Assets.assetsIconsPresenceSensorAssetsPresenceSensorMotion
|
||||
: Assets.assetsIconsPresenceSensorAssetsPresence,
|
||||
width: 100,
|
||||
height: 100,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
BodyMedium(
|
||||
text: StringHelpers.toTitleCase(state),
|
||||
style: context.bodyMedium.copyWith(fontWeight: FontsManager.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user