mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 10:14:55 +00:00
fixed device type counts
This commit is contained in:
@ -10,8 +10,10 @@ import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
class AddDeviceWidget extends StatefulWidget {
|
||||
final List<ProductModel>? products;
|
||||
final ValueChanged<Map<String, int>>? onProductsSelected;
|
||||
final Map<String, int>? initialSelectedProducts;
|
||||
|
||||
const AddDeviceWidget({super.key, this.products, this.onProductsSelected});
|
||||
const AddDeviceWidget(
|
||||
{super.key, this.products, this.initialSelectedProducts, this.onProductsSelected});
|
||||
|
||||
@override
|
||||
_AddDeviceWidgetState createState() => _AddDeviceWidgetState();
|
||||
@ -25,11 +27,9 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_scrollController = ScrollController();
|
||||
|
||||
if (widget.products != null) {
|
||||
for (var product in widget.products!) {
|
||||
productCounts[product.uuid] = 0;
|
||||
}
|
||||
print(widget.initialSelectedProducts);
|
||||
if (widget.initialSelectedProducts != null && widget.initialSelectedProducts!.isNotEmpty) {
|
||||
productCounts = widget.initialSelectedProducts!;
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ class _AddDeviceWidgetState extends State<AddDeviceWidget> {
|
||||
const SizedBox(height: 8),
|
||||
// The custom counter widget aligned at the bottom
|
||||
CounterWidget(
|
||||
initialCount: 0,
|
||||
initialCount: productCounts[deviceType!.uuid] ?? 0,
|
||||
onCountChanged: (newCount) {
|
||||
setState(() {
|
||||
if (newCount > 0) {
|
||||
|
||||
Reference in New Issue
Block a user