mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00
push countdown widget
This commit is contained in:
@ -1,58 +0,0 @@
|
|||||||
class FunctionsEntity {
|
|
||||||
final String productUuid;
|
|
||||||
final String productType;
|
|
||||||
final List<DeviceFunction> functions;
|
|
||||||
|
|
||||||
FunctionsEntity({
|
|
||||||
required this.productUuid,
|
|
||||||
required this.productType,
|
|
||||||
required this.functions,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory FunctionsEntity.fromJson(Map<String, dynamic> json) =>
|
|
||||||
FunctionsEntity(
|
|
||||||
productUuid: json["productUuid"],
|
|
||||||
productType: json["productType"],
|
|
||||||
functions: List<DeviceFunction>.from(
|
|
||||||
json["functions"].map((x) => DeviceFunction.fromJson(x)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"productUuid": productUuid,
|
|
||||||
"productType": productType,
|
|
||||||
"functions": List<dynamic>.from(functions.map((x) => x.toJson())),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class DeviceFunction {
|
|
||||||
final String code;
|
|
||||||
final String values;
|
|
||||||
final String dataType;
|
|
||||||
|
|
||||||
DeviceFunction({
|
|
||||||
required this.code,
|
|
||||||
required this.values,
|
|
||||||
required this.dataType,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory DeviceFunction.fromJson(Map<String, dynamic> json) => DeviceFunction(
|
|
||||||
code: _formatCode(json["code"]),
|
|
||||||
values: json["values"],
|
|
||||||
dataType: json["dataType"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"code": code,
|
|
||||||
"values": values,
|
|
||||||
"dataType": dataType,
|
|
||||||
};
|
|
||||||
|
|
||||||
static String _formatCode(String originalCode) {
|
|
||||||
return originalCode
|
|
||||||
.replaceAll('_', ' ')
|
|
||||||
.split(' ')
|
|
||||||
.map((word) => word[0].toUpperCase() + word.substring(1))
|
|
||||||
.join(' ');
|
|
||||||
}
|
|
||||||
}
|
|
@ -149,19 +149,25 @@ List<SceneStaticFunction> threeGangFunctions(List<FunctionModel> functions) {
|
|||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
name: 'Light 1 CountDown',
|
name: 'Light 1 CountDown',
|
||||||
code: 'countdown_1',
|
code: 'countdown_1',
|
||||||
operationalValues: [],
|
operationalValues: [
|
||||||
|
StaticFunctionOperationHelper(icon: '', value: "12610"),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
name: 'Light 2 CountDown',
|
name: 'Light 2 CountDown',
|
||||||
code: 'countdown_1',
|
code: 'countdown_1',
|
||||||
operationalValues: [],
|
operationalValues: [
|
||||||
|
StaticFunctionOperationHelper(icon: '', value: "0"),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
name: 'Light 3 CountDown',
|
name: 'Light 3 CountDown',
|
||||||
code: 'countdown_1',
|
code: 'countdown_1',
|
||||||
operationalValues: [],
|
operationalValues: [
|
||||||
|
StaticFunctionOperationHelper(icon: '', value: "0"),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/scene/helper/scene_helper.dart';
|
import 'package:syncrow_app/features/scene/helper/scene_helper.dart';
|
||||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||||
|
import 'package:syncrow_app/features/scene/widgets/alert_dialog_countdown.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/alert_dialog_functions_body.dart';
|
import 'package:syncrow_app/features/scene/widgets/alert_dialog_functions_body.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/alert_dialog_temperature_body.dart';
|
import 'package:syncrow_app/features/scene/widgets/alert_dialog_temperature_body.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||||
@ -102,8 +103,14 @@ class DeviceFunctionsView extends StatelessWidget with SceneHelper {
|
|||||||
alertBody: functions[index].code == 'temp_set'
|
alertBody: functions[index].code == 'temp_set'
|
||||||
? AlertDialogTemperatureBody(
|
? AlertDialogTemperatureBody(
|
||||||
index: index, functions: functions)
|
index: index, functions: functions)
|
||||||
: AlertDialogFunctionsOperationsBody(
|
: functions[index].code.contains('countdown')
|
||||||
index: index, functions: functions),
|
? AlertDialogCountdown(
|
||||||
|
durationValue: functions[index]
|
||||||
|
.operationalValues
|
||||||
|
.first
|
||||||
|
.value)
|
||||||
|
: AlertDialogFunctionsOperationsBody(
|
||||||
|
index: index, functions: functions),
|
||||||
title: functions[index].name,
|
title: functions[index].name,
|
||||||
onConfirm: () {},
|
onConfirm: () {},
|
||||||
);
|
);
|
||||||
|
@ -1,19 +1,36 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
|
||||||
class AlertDialogCountdown extends StatefulWidget {
|
class AlertDialogCountdown extends StatefulWidget {
|
||||||
const AlertDialogCountdown({super.key});
|
const AlertDialogCountdown({super.key, required this.durationValue});
|
||||||
|
|
||||||
|
final String durationValue;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AlertDialogCountdown> createState() => _AlertDialogCountdownState();
|
State<AlertDialogCountdown> createState() => _AlertDialogCountdownState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AlertDialogCountdownState extends State<AlertDialogCountdown> {
|
class _AlertDialogCountdownState extends State<AlertDialogCountdown> {
|
||||||
|
int durationInSeconds = 0;
|
||||||
|
// Convert seconds to Duration.
|
||||||
|
Duration get duration =>
|
||||||
|
Duration(seconds: int.tryParse(widget.durationValue) ?? 0);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Row(
|
return Container(
|
||||||
children: [
|
height: 120,
|
||||||
|
color: Colors.white,
|
||||||
],
|
child: CupertinoTimerPicker(
|
||||||
|
itemExtent: 120,
|
||||||
|
mode: CupertinoTimerPickerMode.hm,
|
||||||
|
initialTimerDuration: duration,
|
||||||
|
onTimerDurationChanged: (newDuration) {
|
||||||
|
setState(() {
|
||||||
|
durationInSeconds = newDuration.inSeconds;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class _AlertDialogFunctionsOperationsBodyState
|
|||||||
children: [
|
children: [
|
||||||
...widget.functions[widget.index].operationalValues.map(
|
...widget.functions[widget.index].operationalValues.map(
|
||||||
(operation) => SceneListTile(
|
(operation) => SceneListTile(
|
||||||
iconsSize: 22,
|
iconsSize: 25,
|
||||||
minLeadingWidth: 15,
|
minLeadingWidth: 15,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
assetPath: operation.icon,
|
assetPath: operation.icon,
|
||||||
|
@ -47,10 +47,10 @@ class SceneListTile extends StatelessWidget {
|
|||||||
width: iconsSize,
|
width: iconsSize,
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
assetPath ?? Assets.assetsImagesLogo,
|
assetPath ?? Assets.assetsImagesLogo,
|
||||||
width: 20,
|
width: iconsSize,
|
||||||
height: assetHeight ?? 32,
|
height: assetHeight ?? 35,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.contain,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: null),
|
: null),
|
||||||
|
@ -42,6 +42,7 @@ dependencies:
|
|||||||
permission_handler: ^11.3.1
|
permission_handler: ^11.3.1
|
||||||
pin_code_fields: ^8.0.1
|
pin_code_fields: ^8.0.1
|
||||||
share_plus: ^9.0.0
|
share_plus: ^9.0.0
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Reference in New Issue
Block a user