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,
|
||||
name: 'Light 1 CountDown',
|
||||
code: 'countdown_1',
|
||||
operationalValues: [],
|
||||
operationalValues: [
|
||||
StaticFunctionOperationHelper(icon: '', value: "12610"),
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
icon: Assets.assetsLightCountdown,
|
||||
name: 'Light 2 CountDown',
|
||||
code: 'countdown_1',
|
||||
operationalValues: [],
|
||||
operationalValues: [
|
||||
StaticFunctionOperationHelper(icon: '', value: "0"),
|
||||
],
|
||||
),
|
||||
SceneStaticFunction(
|
||||
icon: Assets.assetsLightCountdown,
|
||||
name: 'Light 3 CountDown',
|
||||
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/scene/helper/scene_helper.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_temperature_body.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'
|
||||
? AlertDialogTemperatureBody(
|
||||
index: index, functions: functions)
|
||||
: AlertDialogFunctionsOperationsBody(
|
||||
index: index, functions: functions),
|
||||
: functions[index].code.contains('countdown')
|
||||
? AlertDialogCountdown(
|
||||
durationValue: functions[index]
|
||||
.operationalValues
|
||||
.first
|
||||
.value)
|
||||
: AlertDialogFunctionsOperationsBody(
|
||||
index: index, functions: functions),
|
||||
title: functions[index].name,
|
||||
onConfirm: () {},
|
||||
);
|
||||
|
@ -1,19 +1,36 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class AlertDialogCountdown extends StatefulWidget {
|
||||
const AlertDialogCountdown({super.key});
|
||||
const AlertDialogCountdown({super.key, required this.durationValue});
|
||||
|
||||
final String durationValue;
|
||||
|
||||
@override
|
||||
State<AlertDialogCountdown> createState() => _AlertDialogCountdownState();
|
||||
}
|
||||
|
||||
class _AlertDialogCountdownState extends State<AlertDialogCountdown> {
|
||||
int durationInSeconds = 0;
|
||||
// Convert seconds to Duration.
|
||||
Duration get duration =>
|
||||
Duration(seconds: int.tryParse(widget.durationValue) ?? 0);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
|
||||
],
|
||||
return Container(
|
||||
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: [
|
||||
...widget.functions[widget.index].operationalValues.map(
|
||||
(operation) => SceneListTile(
|
||||
iconsSize: 22,
|
||||
iconsSize: 25,
|
||||
minLeadingWidth: 15,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
assetPath: operation.icon,
|
||||
|
@ -47,10 +47,10 @@ class SceneListTile extends StatelessWidget {
|
||||
width: iconsSize,
|
||||
child: SvgPicture.asset(
|
||||
assetPath ?? Assets.assetsImagesLogo,
|
||||
width: 20,
|
||||
height: assetHeight ?? 32,
|
||||
width: iconsSize,
|
||||
height: assetHeight ?? 35,
|
||||
alignment: Alignment.center,
|
||||
fit: BoxFit.fill,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
)
|
||||
: null),
|
||||
|
@ -42,6 +42,7 @@ dependencies:
|
||||
permission_handler: ^11.3.1
|
||||
pin_code_fields: ^8.0.1
|
||||
share_plus: ^9.0.0
|
||||
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Reference in New Issue
Block a user