Advertisement
abimulya_

existing harga jual diskon

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