Advertisement
abimulya_

Harga jual diskon

Apr 11th, 2025
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 4.91 KB | None | 0 0
  1. Column(
  2.   crossAxisAlignment: CrossAxisAlignment.start,
  3.   mainAxisSize: MainAxisSize.min,
  4.   children: [
  5.     Row(
  6.       crossAxisAlignment: CrossAxisAlignment.center,
  7.       children: [
  8.         SizedBox(
  9.           width: 100.w,
  10.           child: Text(
  11.             'Harga Jual',
  12.             style: context.textTheme.titleSmall!
  13.                 .copyWith(
  14.                     color: AccurateColor.black50),
  15.           ),
  16.         ),
  17.         Expanded(
  18.           child: Row(
  19.             children: [
  20.               Expanded(
  21.                 flex: 7,
  22.                 child: OneFormComponentNumeric(
  23.                   formCtr: _sellingPriceCtr,
  24.                   focusNode: _sellingPriceNode,
  25.                   isUseOutlineBorder: true,
  26.                   maxLines: 1,
  27.                   textInputType: const TextInputType
  28.                       .numberWithOptions(),
  29.                   hintText: 'Rp.0',
  30.                   inputFormatter: [
  31.                     RupiahInputFormatter()
  32.                   ],
  33.                   onChanged: (p0) {
  34.                     _hitCalculateDetail();
  35.                     return;
  36.                   },
  37.                 ),
  38.               ),
  39.               SizedBox(width: 8.w),
  40.               Container(
  41.                 alignment: Alignment.centerRight,
  42.                 child: GestureDetector(
  43.                   onTap: () {
  44.                     context
  45.                         .read<
  46.                             ProductStockSalePriceHistoryCubit>()
  47.                         .getSalePriceHistory(
  48.                           id: item.itemId!,
  49.                           customerId:
  50.                               _customerChoosenData
  51.                                   .id!,
  52.                         );
  53.                   },
  54.                   child: Icon(
  55.                     Icons.restore,
  56.                     color:
  57.                         AccurateColor.blueAccurate,
  58.                     size: 27.r,
  59.                   ),
  60.                 ),
  61.               ),
  62.             ],
  63.           ),
  64.         ),
  65.       ],
  66.     ),
  67.     SizedBox(height: 4.h),
  68.     Row(
  69.       crossAxisAlignment: CrossAxisAlignment.center,
  70.       children: [
  71.         SizedBox(
  72.           width: 100.w,
  73.           child: Text(
  74.             'Diskon',
  75.             style: context.textTheme.titleSmall!,
  76.           ),
  77.         ),
  78.         Expanded(
  79.           child: Row(
  80.             children: [
  81.               Expanded(
  82.                 flex: 1,
  83.                 child: OneFormComponentNumeric(
  84.                   formCtr: _discountPercentCtr,
  85.                   focusNode: _discountPercentNode,
  86.                   isUseOutlineBorder: true,
  87.                   maxLines: 1,
  88.                   textInputType: const TextInputType
  89.                       .numberWithOptions(
  90.                     decimal: true,
  91.                     signed: true,
  92.                   ),
  93.                   hintText: '0%',
  94.                   inputFormatter: [
  95.                     PercentageInputFormatter()
  96.                   ],
  97.                   onChanged: (_) => int.parse(
  98.                             _discountPercentCtr.text
  99.                                 .replaceAll(
  100.                                     '%', ''),
  101.                           ) <=
  102.                           100
  103.                       ? _hitCalculateDetail()
  104.                       : null,
  105.                   validator: (value) {
  106.                     if (value != null &&
  107.                         value.isNotEmpty) {
  108.                       if (int.parse(
  109.                               value.replaceAll(
  110.                                   '%', '')) >
  111.                           100) {
  112.                         return 'Maksimal diskon 100%';
  113.                       }
  114.                     }
  115.                     return null;
  116.                   },
  117.                 ),
  118.               ),
  119.               SizedBox(width: 8.w),
  120.               Expanded(
  121.                 flex: 2,
  122.                 child: OneFormComponentNumeric(
  123.                   formCtr: _discountRupiahCtr,
  124.                   focusNode: _discountRupiahNode,
  125.                   isUseOutlineBorder: true,
  126.                   maxLines: 1,
  127.                   textInputType: const TextInputType
  128.                       .numberWithOptions(),
  129.                   hintText: 'Rp.0',
  130.                   inputFormatter: [
  131.                     RupiahInputFormatter()
  132.                   ],
  133.                   onChanged: (_) {
  134.                     _discountPercentCtr.clear();
  135.                     _hitCalculateDetail();
  136.                     return null;
  137.                   },
  138.                   validator: (value) {
  139.                     if (rupiahToDouble(value!) >
  140.                         rupiahToDouble(
  141.                             _totalPrice.value)) {
  142.                       return 'Diskon melebihi total';
  143.                     }
  144.                     return null;
  145.                   },
  146.                 ),
  147.               ),
  148.             ],
  149.           ),
  150.         ),
  151.       ],
  152.     ),
  153.   ],
  154. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement