Files
syncrow-web/lib/pages/routiens/widgets/routine_devices.dart
2024-11-18 01:13:28 +03:00

45 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/bloc/device_mgmt_bloc/device_managment_bloc.dart';
import 'package:syncrow_web/pages/routiens/widgets/dragable_card.dart';
class RoutineDevices extends StatelessWidget {
const RoutineDevices({
super.key,
});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => DeviceManagementBloc()
..add(
FetchDevices(),
),
child: BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
builder: (context, state) {
if (state is DeviceManagementLoaded) {
final deviceList = state.devices
.where((device) =>
device.productType == 'AC' ||
device.productType == '1G' ||
device.productType == '2G' ||
device.productType == '3G')
.toList();
return Wrap(
spacing: 10,
runSpacing: 10,
children: deviceList
.map((device) => DraggableCard(
imagePath: device.getDefaultIcon(device.productType),
title: device.name ?? '',
))
.toList(),
);
}
return const Center(child: CircularProgressIndicator());
},
),
);
}
}