mirror of
https://github.com/SyncrowIOT/web.git
synced 2026-10-25 13:47:56 +00:00
finished ac devices
This commit is contained in:
@@ -43,95 +43,70 @@ class DraggableCard extends StatelessWidget {
|
||||
BuildContext context, List<DeviceFunctionData> deviceFunctions) {
|
||||
return Card(
|
||||
color: ColorsManager.whiteColors,
|
||||
child: SizedBox(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
width: 90,
|
||||
height: deviceFunctions.isEmpty ? 123 : null,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 123,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
height: 50,
|
||||
width: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.CircleImageBackground,
|
||||
borderRadius: BorderRadius.circular(90),
|
||||
border: Border.all(
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: imagePath.contains('.svg')
|
||||
? SvgPicture.asset(
|
||||
imagePath,
|
||||
)
|
||||
: Image.network(imagePath),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||
child: Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
height: 50,
|
||||
width: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.CircleImageBackground,
|
||||
borderRadius: BorderRadius.circular(90),
|
||||
border: Border.all(
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: imagePath.contains('.svg')
|
||||
? SvgPicture.asset(
|
||||
imagePath,
|
||||
)
|
||||
: Image.network(imagePath),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||
child: Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (deviceFunctions.isNotEmpty) ...[
|
||||
const Divider(height: 1),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 4),
|
||||
itemCount: deviceFunctions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final function = deviceFunctions[index];
|
||||
return Row(
|
||||
if (deviceFunctions.isNotEmpty)
|
||||
// const Divider(height: 1),
|
||||
...deviceFunctions.map((function) => Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${function.operationName}: ${function.valueDescription}',
|
||||
'${function.operationName}: ${function.value}',
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
fontSize: 9,
|
||||
color: ColorsManager.textGray,
|
||||
height: 1.2,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
context.read<RoutineBloc>().add(
|
||||
RemoveFunction(function),
|
||||
);
|
||||
},
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(2),
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
size: 12,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -9,9 +9,6 @@ class RoutineDevices extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Get the RoutineBloc instance from the parent
|
||||
final routineBloc = context.read<RoutineBloc>();
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => DeviceManagementBloc()..add(FetchDevices()),
|
||||
child: BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
|
||||
@@ -26,32 +23,28 @@ class RoutineDevices extends StatelessWidget {
|
||||
.toList();
|
||||
|
||||
// Provide the RoutineBloc to the child widgets
|
||||
return BlocProvider.value(
|
||||
value: routineBloc,
|
||||
child: BlocBuilder<RoutineBloc, RoutineState>(
|
||||
builder: (context, routineState) {
|
||||
return Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: deviceList.asMap().entries.map((entry) {
|
||||
final device = entry.value;
|
||||
return DraggableCard(
|
||||
imagePath: device.getDefaultIcon(device.productType),
|
||||
title: device.name ?? '',
|
||||
deviceData: {
|
||||
'key': UniqueKey().toString(),
|
||||
'imagePath':
|
||||
device.getDefaultIcon(device.productType),
|
||||
'title': device.name ?? '',
|
||||
'deviceId': device.uuid,
|
||||
'productType': device.productType,
|
||||
'functions': device.functions,
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||
builder: (context, routineState) {
|
||||
return Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: deviceList.asMap().entries.map((entry) {
|
||||
final device = entry.value;
|
||||
return DraggableCard(
|
||||
imagePath: device.getDefaultIcon(device.productType),
|
||||
title: device.name ?? '',
|
||||
deviceData: {
|
||||
'device': device,
|
||||
'imagePath': device.getDefaultIcon(device.productType),
|
||||
'title': device.name ?? '',
|
||||
'deviceId': device.uuid,
|
||||
'productType': device.productType,
|
||||
'functions': device.functions,
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
|
||||
@@ -30,7 +30,7 @@ class ThenContainer extends StatelessWidget {
|
||||
runSpacing: 8,
|
||||
children: state.thenItems
|
||||
.map((item) => DraggableCard(
|
||||
key: Key(item['key']!),
|
||||
// key: Key(item['key']!),
|
||||
imagePath: item['imagePath']!,
|
||||
title: item['title']!,
|
||||
deviceData: item,
|
||||
@@ -45,6 +45,18 @@ class ThenContainer extends StatelessWidget {
|
||||
onAccept: (data) async {
|
||||
final result =
|
||||
await DeviceDialogHelper.showDeviceDialog(context, data);
|
||||
// if (result != null) {
|
||||
// for (var function in routineBloc.state.selectedFunctions) {
|
||||
// routineBloc.add(AddToThenContainer(
|
||||
// {
|
||||
// 'item': function,
|
||||
// 'imagePath': data['imagePath'],
|
||||
// 'title': data['name'],
|
||||
|
||||
// }
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer(data));
|
||||
} else if (!['AC', '1G', '2G', '3G']
|
||||
|
||||
Reference in New Issue
Block a user