2025-08-01 01:40:33 +07:00
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
|
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
|
|
|
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
|
|
|
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
|
|
|
|
import 'package:enaklo_pos/core/constants/variables.dart';
|
|
|
|
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
|
|
|
|
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
|
|
|
|
import 'package:enaklo_pos/data/models/response/product_response_model.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
class DetailProductDialog extends StatelessWidget {
|
|
|
|
|
final Product product;
|
|
|
|
|
const DetailProductDialog({super.key, required this.product});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return CustomModalDialog(
|
|
|
|
|
title: "Detail Produk",
|
|
|
|
|
maxWidth: context.deviceWidth * 0.5,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
ClipRRect(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
child: CachedNetworkImage(
|
2025-08-03 00:35:00 +07:00
|
|
|
imageUrl: product.name!.contains('http')
|
|
|
|
|
? product.name!
|
|
|
|
|
: '${Variables.baseUrl}/${product.name}',
|
2025-08-01 01:40:33 +07:00
|
|
|
fit: BoxFit.cover,
|
2025-08-01 14:17:11 +07:00
|
|
|
width: 120,
|
|
|
|
|
height: 120,
|
2025-08-01 01:40:33 +07:00
|
|
|
errorWidget: (context, url, error) => Container(
|
|
|
|
|
width: 120,
|
|
|
|
|
height: 120,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: AppColors.grey.withOpacity(0.1),
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
),
|
|
|
|
|
child: const Icon(
|
|
|
|
|
Icons.image_outlined,
|
|
|
|
|
color: AppColors.grey,
|
|
|
|
|
size: 40,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SpaceWidth(16),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
child: _buildStatus(),
|
|
|
|
|
),
|
|
|
|
|
const SpaceHeight(8),
|
|
|
|
|
Text(
|
|
|
|
|
product.name ?? "-",
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (product.description != null &&
|
|
|
|
|
product.description!.isNotEmpty)
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 4.0),
|
|
|
|
|
child: Text(
|
|
|
|
|
product.description!,
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: AppColors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SpaceHeight(16),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
_buildItem(
|
2025-08-03 00:35:00 +07:00
|
|
|
"-",
|
2025-08-01 01:40:33 +07:00
|
|
|
"Kategori",
|
|
|
|
|
),
|
2025-08-03 00:35:00 +07:00
|
|
|
// _buildItem(
|
|
|
|
|
// "${product.stock}",
|
|
|
|
|
// "Stok",
|
|
|
|
|
// valueColor: product.stock! < 50
|
|
|
|
|
// ? AppColors.red
|
|
|
|
|
// : product.stock! < 100
|
|
|
|
|
// ? Colors.yellow
|
|
|
|
|
// : AppColors.green,
|
|
|
|
|
// ),
|
2025-08-01 01:40:33 +07:00
|
|
|
_buildItem(
|
2025-08-03 00:35:00 +07:00
|
|
|
(product.price ?? 0).toString().currencyFormatRpV2,
|
2025-08-01 01:40:33 +07:00
|
|
|
"Harga",
|
|
|
|
|
valueColor: AppColors.primary,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Column _buildItem(String value, String label,
|
|
|
|
|
{Color valueColor = AppColors.black}) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
label,
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SpaceHeight(4),
|
|
|
|
|
Text(
|
|
|
|
|
value,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: valueColor,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Container _buildStatus() {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
|
|
|
decoration: BoxDecoration(
|
2025-08-03 00:35:00 +07:00
|
|
|
color: product.isActive == true ? AppColors.green : AppColors.red,
|
2025-08-01 01:40:33 +07:00
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
2025-08-03 00:35:00 +07:00
|
|
|
product.isActive == true ? 'Aktif' : 'Tidak Aktif',
|
2025-08-01 01:40:33 +07:00
|
|
|
style: const TextStyle(
|
|
|
|
|
color: Colors.white, fontSize: 12, fontWeight: FontWeight.w700),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|