import 'dart:ui';

import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-preview.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class LakumWidget extends StatefulWidget {
  final OrderPreviewViewModel model;


  LakumWidget(this.model);

  @override
  _LakumWidgetState createState() => _LakumWidgetState();
}

class _LakumWidgetState extends State<LakumWidget> {
  TextEditingController _pointsController = new TextEditingController();
  bool useLakumWidgets = false;

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectProvider = Provider.of(context);
    _pointsController.text = widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount.toString();

    return Container(
      color: Colors.white,
      padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
      child: Row(
        children: [
          Row(
            children: [
              SizedBox(
                height: 24.0,
                width: 24.0,
                child: Checkbox(
                  activeColor: CustomColors.green,
                  value: useLakumWidgets,
                  onChanged: (bool value) {
                    setState(() {
                      useLakumWidgets = value;
                      print(useLakumWidgets);
//                      if (value){
//                      //  isChecked;
//                        OrderPreviewPage.isChecked = true;
//                        print(value);
//                      }else{
//                        OrderPreviewPage.isChecked = false;
//                      }
                      setState(() {
                      });
                    });
                  },
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(left: 8.0, right: 8.0),
                child: Text(
                    TranslationBase.of(context).useLakumPoints +
                        " (${widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalance.toString() + " " + TranslationBase.of(context).points})",
                    style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.w600, letterSpacing: -0.56)),
              ),
            ],
          ),
          Expanded(
            child: Container(
              decoration: BoxDecoration(color: Color(0x99ffffff)),
              padding: const EdgeInsets.symmetric(horizontal: 8),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Container(
                    decoration: BoxDecoration(color: Color(0x99ffffff)),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Texts(
                          "${TranslationBase.of(context).availableBalance}",
                          fontSize: 12,
                          fontWeight: FontWeight.bold,
                        ),
                        Text(
                          "${TranslationBase.of(context).sar + " " + widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount.toString()}",
                            style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.w600, letterSpacing: -0.56)
                        ),
                      ],
                    ),
                  ),
                ],
              ),
              // child: Row(
              //   mainAxisAlignment: MainAxisAlignment.end,
              //   children: [
              //     Texts(
              //       "${TranslationBase.of(context).riyal}",
              //       fontSize: 12,
              //       fontWeight: FontWeight.bold,
              //     ),
              //     Container(
              //       margin: projectProvider.isArabic ? EdgeInsets.only(right: 4) : EdgeInsets.only(left: 4),
              //       width: 60,
              //       height: 50,
              //       child: TextField(
              //         decoration: InputDecoration(
              //           border: OutlineInputBorder(
              //             borderSide: BorderSide(color: Colors.black, width: 0.2),
              //             gapPadding: 0,
              //             borderRadius: projectProvider.isArabic
              //                 ? BorderRadius.only(topRight: Radius.circular(8), bottomRight: Radius.circular(8))
              //                 : BorderRadius.only(topLeft: Radius.circular(8), bottomLeft: Radius.circular(8)),
              //           ),
              //           disabledBorder: OutlineInputBorder(
              //             borderSide: BorderSide(color: Colors.black, width: 0.4),
              //             gapPadding: 0,
              //             borderRadius: BorderRadius.only(topLeft: Radius.circular(8), bottomLeft: Radius.circular(8)),
              //           ),
              //         ),
              //         controller: _pointsController,
              //         keyboardType: TextInputType.number,
              //         style: TextStyle(
              //           fontSize: 14,
              //           color: widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount > 0 ? Colors.black : Colors.grey,
              //         ),
              //         enabled: widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount == 0 ? false : true,
              //         onChanged: (val) {
              //           var value = int.tryParse(val);
              //           if (value != null && value <= widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount) {
              //             widget.model.paymentCheckoutData.usedLakumPoints = value;
              //           } else {
              //             widget.model.paymentCheckoutData.usedLakumPoints = 0;
              //           }
              //           _pointsController.text = "${widget.model.paymentCheckoutData.usedLakumPoints}";
              //         },
              //       ),
              //     ),
              //     Container(
              //       height: 50,
              //       padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
              //       decoration: new BoxDecoration(
              //         color: Color(0xff3666E0),
              //         shape: BoxShape.rectangle,
              //         borderRadius: projectProvider.isArabic
              //             ? BorderRadius.only(topLeft: Radius.circular(6), bottomLeft: Radius.circular(6))
              //             : BorderRadius.only(topRight: Radius.circular(6), bottomRight: Radius.circular(6)),
              //         border: Border.fromBorderSide(BorderSide(
              //           color: Color(0xff3666E0),
              //           width: 0.8,
              //         )),
              //       ),
              //       child: Texts(
              //         "${TranslationBase.of(context).use}",
              //         fontSize: 12,
              //         color: Colors.white,
              //         fontWeight: FontWeight.bold,
              //       ),
              //     ),
              //   ],
              // ),
            ),
          ),
//          useLakumWidgets ?
//          Row(
//            mainAxisAlignment: MainAxisAlignment.spaceBetween,
//            children: [
//              Texts(
//                "${TranslationBase.of(context).lakum}",
//                fontSize: 14,
//                color: Colors.black,
//                fontWeight: FontWeight.w500,
//              ),
//              Texts(
//                "${TranslationBase.of(context).sar} ${(widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalance).toStringAsFixed(2)}",
//                fontSize: 14,
//                color: Colors.black,
//                fontWeight: FontWeight.w500,
//              ),
//            ],
//          )
//              :Container()
        ],
      ),
    );
  }
}
