This commit is contained in:
czz
2025-06-27 09:15:45 +08:00
parent 12c6a260c9
commit 943f5a778a
36 changed files with 1850 additions and 1355 deletions

View File

@@ -71,37 +71,76 @@ class AddressListPage extends GetView<AddressListController> {
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
// Obx(() {
// if (controller.model.addressList!.isEmpty) {
// // 如果地址列表为空,显示 EmptyMessageWidget
// return Expanded(child: NullDataWidget());
// } else {
// // 如果地址列表不为空,显示地址列表
// return Expanded(
// child: Container(
// width: bodysize!.maxWidth,
// height: bodysize!.maxHeight * 1,
// decoration: BoxDecoration(),
// child: Obx(() => ListView(
// shrinkWrap: true,
// scrollDirection: Axis.vertical,
// children: (controller.model.addressList!
// .asMap()
// .entries
// .map((e) => AddressModuleWidget(
// index: e.key,
// addressListController:
// controller,
// ))
// .toList() as List<Widget>)
// .divide(const SizedBox(height: 10))
// .addToEnd(const SizedBox(
// height:
// AppConstants.list_end_height)),
// )),
// ),
// );
// }
// }),
Obx(() {
if (controller.model.addressList!.isEmpty) {
// 如果地址列表为空,显示 EmptyMessageWidget
return Expanded(child: NullDataWidget());
} else {
// 如果地址列表不为空,显示地址列表
return Expanded(
child: Container(
width: bodysize!.maxWidth,
height: bodysize!.maxHeight * 1,
decoration: BoxDecoration(),
child: Obx(() => ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: (controller.model.addressList!
.asMap()
.entries
.map((e) => AddressModuleWidget(
index: e.key,
addressListController:
controller,
))
.toList() as List<Widget>)
.divide(const SizedBox(height: 10))
.addToEnd(const SizedBox(
height:
AppConstants.list_end_height)),
)),
),
);
}
final originList = controller.model.addressList ?? [];
// 拆出默认地址
final defaultItem = originList.firstWhere(
(e) => e["default"] == 1,
orElse: () => null,
);
// 其他非默认地址
final others =
originList.where((e) => e["default"] != 1).toList();
// 新的展示顺序列表(默认地址排前面)
final reorderedList = [
if (defaultItem != null) defaultItem,
...others,
];
return Expanded(
child: ListView(
shrinkWrap: true,
padding: EdgeInsets.zero,
children: reorderedList
.map((item) {
final realIndex =
originList.indexOf(item); // 保留原始 index
return AddressModuleWidget(
index: realIndex,
addressListController: controller,
);
})
.toList()
.divide(const SizedBox(height: 10))
.addToEnd(const SizedBox(
height: AppConstants.list_end_height)),
),
);
}),
Align(
alignment: AlignmentDirectional(0, 1),