mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-26 08:54:55 +00:00
connect device dropdown to bloc.
This commit is contained in:
@ -1,4 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/models/analytics_device.dart';
|
||||||
|
import 'package:syncrow_web/pages/analytics/modules/analytics/blocs/analytics_devices/analytics_devices_bloc.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
@ -7,6 +10,8 @@ class PowerClampEnergyDataDeviceDropdown extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return BlocBuilder<AnalyticsDevicesBloc, AnalyticsDevicesState>(
|
||||||
|
builder: (context, state) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
@ -15,8 +20,8 @@ class PowerClampEnergyDataDeviceDropdown extends StatelessWidget {
|
|||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: DropdownButton<String>(
|
child: DropdownButton<AnalyticsDevice?>(
|
||||||
value: 'Device 1',
|
value: state.selectedDevice,
|
||||||
isDense: true,
|
isDense: true,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
dropdownColor: ColorsManager.whiteColors,
|
dropdownColor: ColorsManager.whiteColors,
|
||||||
@ -34,22 +39,22 @@ class PowerClampEnergyDataDeviceDropdown extends StatelessWidget {
|
|||||||
horizontal: 20,
|
horizontal: 20,
|
||||||
vertical: 2,
|
vertical: 2,
|
||||||
),
|
),
|
||||||
items: [
|
items: state.devices.map((e) {
|
||||||
for (var i = 1; i < 10; i++)
|
return DropdownMenuItem(
|
||||||
DropdownMenuItem(
|
value: e,
|
||||||
value: 'Device $i',
|
child: Text(e.uuid),
|
||||||
child: Text(
|
);
|
||||||
'Device $i',
|
}).toList(),
|
||||||
style: context.textTheme.labelSmall?.copyWith(
|
onChanged: (value) {
|
||||||
color: ColorsManager.textPrimaryColor,
|
if (value case final AnalyticsDevice device) {
|
||||||
fontWeight: FontWeight.w700,
|
context.read<AnalyticsDevicesBloc>().add(
|
||||||
fontSize: 14,
|
SelectAnalyticsDeviceEvent(device),
|
||||||
),
|
);
|
||||||
),
|
}
|
||||||
),
|
},
|
||||||
],
|
|
||||||
onChanged: (value) {},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user