细节修改

This commit is contained in:
Seven Tsui 2025-09-20 11:21:32 +08:00
parent a777aca121
commit 4f0c1f6f73
2 changed files with 52 additions and 26 deletions

View File

@ -507,11 +507,7 @@ class _SearchResultPageState extends State<SearchResultPage> with SingleTickerPr
),
);
}
//
//
//
//
Widget _buildVideoItem(Map<String, dynamic> video) {
return GestureDetector(
onTap: () {
@ -687,7 +683,6 @@ class _SearchResultPageState extends State<SearchResultPage> with SingleTickerPr
return Container();
}
// Tab
Widget _buildProductTab() {
if (_productResults.isEmpty && !_isLoading) {
@ -712,7 +707,7 @@ class _SearchResultPageState extends State<SearchResultPage> with SingleTickerPr
crossAxisCount: 2,
crossAxisSpacing: 8,
mainAxisSpacing: 8,
childAspectRatio: 0.55,
childAspectRatio: 0.65, //
),
itemCount: _productResults.length,
itemBuilder: (context, index) {
@ -783,46 +778,68 @@ class _SearchResultPageState extends State<SearchResultPage> with SingleTickerPr
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// - 100%
// - 使AspectRatio保持固定宽高比
ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(_itemCornerRadius),
topRight: Radius.circular(_itemCornerRadius),
),
child: AspectRatio(
aspectRatio: 0.8, //
child: Container(
width: double.infinity,
color: Colors.grey[200],
child: product['pic'] != null
child: product['pic'] != null && product['pic'].toString().isNotEmpty
? Image.network(
product['pic'].toString(),
fit: BoxFit.cover,
)
: SizedBox(
height: 110,
width: double.infinity,
height: double.infinity,
errorBuilder: (context, error, stackTrace) {
return Container(
color: Colors.grey[200],
child: const Center(
child: Icon(Icons.shopping_bag, color: Colors.grey, size: 32),
child: Icon(
Icons.shopping_bag,
color: Colors.grey,
size: 32,
),
),
);
},
)
: Container(
color: Colors.grey[200],
child: const Center(
child: Icon(
Icons.shopping_bag,
color: Colors.grey,
size: 32,
),
),
),
),
// -
),
),
//
Expanded(
child: Padding(
padding: const EdgeInsets.all(6),
padding: const EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end, //
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
//
Text(
product['name']?.toString() ?? '未知商品',
style: const TextStyle(
fontSize: 11,
fontWeight: FontWeight.w500,
height: 1.2,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
//
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@ -835,7 +852,7 @@ class _SearchResultPageState extends State<SearchResultPage> with SingleTickerPr
),
),
Text(
'已售 ${product['sales']?.toString() ?? '0'}',
'已售 ${Utils.graceNumber(product['sales'] ?? 0)}',
style: const TextStyle(
fontSize: 9,
color: Colors.grey,

View File

@ -113,7 +113,16 @@ class Utils {
}
//
static String graceNumber(int number) {
static String graceNumber(dynamic value) {
int number;
if (value is int) {
number = value;
} else if (value is String) {
number = int.tryParse(value) ?? 0;
} else {
number = 0;
}
if (number == 0) return "0";
if (number < 1000) {