delete packages
This commit is contained in:
@ -309,6 +309,22 @@ class _LogisticsState extends State<Logistics> {
|
|||||||
_activePackage = index;
|
_activePackage = index;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
onClose: () {
|
||||||
|
var curId =
|
||||||
|
_packages[index]["id"];
|
||||||
|
setState(() {
|
||||||
|
_activePackage =
|
||||||
|
_activePackage >= index
|
||||||
|
? _activePackage - 1
|
||||||
|
: _activePackage;
|
||||||
|
_packages = _packages
|
||||||
|
.where((el) =>
|
||||||
|
el["id"] != curId)
|
||||||
|
.toList();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
totalPackagesCount:
|
||||||
|
_packages.length,
|
||||||
isActive: _activePackage == index,
|
isActive: _activePackage == index,
|
||||||
package: _packages[index],
|
package: _packages[index],
|
||||||
index: index);
|
index: index);
|
||||||
@ -357,13 +373,17 @@ class PackageCard extends StatefulWidget {
|
|||||||
required this.package,
|
required this.package,
|
||||||
required this.index,
|
required this.index,
|
||||||
required this.onLogisticsChanged,
|
required this.onLogisticsChanged,
|
||||||
|
required this.totalPackagesCount,
|
||||||
|
required this.onClose,
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool isActive;
|
final bool isActive;
|
||||||
final Function() onTap;
|
final Function() onTap;
|
||||||
|
final Function() onClose;
|
||||||
final Map<String, dynamic> package;
|
final Map<String, dynamic> package;
|
||||||
final int index;
|
final int index;
|
||||||
final Function(String) onLogisticsChanged;
|
final Function(String) onLogisticsChanged;
|
||||||
|
final int totalPackagesCount;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PackageCard> createState() => _PackageCardState();
|
State<PackageCard> createState() => _PackageCardState();
|
||||||
@ -424,6 +444,24 @@ class _PackageCardState extends State<PackageCard> {
|
|||||||
top: 2,
|
top: 2,
|
||||||
child: Text("包裹${widget.index + 1}"),
|
child: Text("包裹${widget.index + 1}"),
|
||||||
),
|
),
|
||||||
|
widget.totalPackagesCount > 1
|
||||||
|
? Positioned(
|
||||||
|
top: 2,
|
||||||
|
right: 2,
|
||||||
|
child: SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: IconButton(
|
||||||
|
color: Colors.redAccent,
|
||||||
|
iconSize: 20,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
onPressed: widget.onClose,
|
||||||
|
),
|
||||||
|
))
|
||||||
|
: const SizedBox(
|
||||||
|
width: 0,
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user