Untitled

 avatar
unknown
plain_text
2 years ago
12 kB
4
Indexable
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tailorx/src/view/edit_order/edit_order_controller.dart';

import '../../../custom_widgets/button_primary.dart';
import '../../../custom_widgets/text_field_input.dart';
import '../../../custom_widgets/text_widget.dart';
import '../../../utils/colors.dart';
import '../../invoice/widget/invoce_text_data_widget.dart';
import '../models/order_drop_down_data_response.dart';

class EditOrderContentsView extends StatelessWidget {
  final EditOrderController editOrderController;

  const EditOrderContentsView({Key? key, required this.editOrderController})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          const SizedBox(
            height: 10,
          ),
          Expanded(
            child: SingleChildScrollView(
              scrollDirection: Axis.vertical,
              physics: const AlwaysScrollableScrollPhysics(),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  const SizedBox(
                    height: 30,
                  ),
                  Row(
                    children: const [
                      Expanded(
                        flex: 1,
                        child: InvoiceTextDataWidget(
                            title: "Net Amount: ", desc: "5"),
                      ),
                      Expanded(
                        flex: 1,
                        child: InvoiceTextDataWidget(
                            title: "Balance: ", desc: "55 SAR"),
                      )
                    ],
                  ),
                  const SizedBox(
                    height: 15,
                  ),
                  Row(
                    children: [
                      Expanded(
                        flex: 1,
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.stretch,
                          children: [
                            const CustomTextWidget(
                              text: "Discount",
                              textSize: 14,
                              color: AppColors.textLight,
                            ),
                            const SizedBox(
                              height: 5,
                            ),
                            TextFieldInput(
                              label: "Discount",
                              textEditingController:
                                  editOrderController.discountController,
                              textInputType: TextInputType.number,
                            ),
                          ],
                        ),
                      ),
                      const SizedBox(
                        width: 8,
                      ),
                      Expanded(
                        flex: 1,
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.stretch,
                          children: [
                            const CustomTextWidget(
                              text: "Previous Balance",
                              textSize: 14,
                              color: AppColors.textLight,
                            ),
                            const SizedBox(
                              height: 5,
                            ),
                            TextFieldInput(
                              label: "P/B",
                              textEditingController:
                                  editOrderController.previousBalanceController,
                              textInputType: TextInputType.number,
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                  const SizedBox(
                    height: 15,
                  ),
                  const CustomTextWidget(
                    text: "Payment Mode",
                    textSize: 14,
                    color: AppColors.textLight,
                  ),
                  const SizedBox(
                    height: 5,
                  ),
                  SizedBox(
                    height: 55.0,
                    child: InputDecorator(
                      decoration:
                          const InputDecoration(border: OutlineInputBorder()),
                      child: DropdownButtonHideUnderline(
                        child: Obx(
                          () => DropdownButton(
                            isDense: true,
                            isExpanded: true,
                            hint: const Text(
                              "Select",
                            ),
                            value: editOrderController
                                        .selectedPaymentValue.value ==
                                    ""
                                ? null
                                : editOrderController
                                    .selectedPaymentValue.value,
                            items: ['Cash', 'Credit Card', "Transfer"]
                                .map((String value) {
                              return DropdownMenuItem(
                                value: value,
                                child: Text(value),
                              );
                            }).toList(),
                            onChanged: (newValue) {
                              editOrderController
                                  .setPaymentValue(newValue.toString());
                            },
                          ),
                        ),
                      ),
                    ),
                  ),
                  const SizedBox(
                    height: 15,
                  ),
                  const CustomTextWidget(
                    text: "Master",
                    textSize: 14,
                    color: AppColors.textLight,
                  ),
                  const SizedBox(
                    height: 5,
                  ),
                  SizedBox(
                    height: 55.0,
                    child: InputDecorator(
                      decoration:
                          const InputDecoration(border: OutlineInputBorder()),
                      child: DropdownButtonHideUnderline(
                        child: Obx(
                          () => DropdownButton(
                            isDense: true,
                            isExpanded: true,
                            hint: const Text(
                              "Select",
                            ),
                            value: editOrderController
                                        .selectedMasterValue.value ==
                                    ""
                                ? null
                                : editOrderController.selectedMasterValue.value,
                            items: editOrderController.masters.map((OrderDropDownData value) {
                              return DropdownMenuItem(
                                value: value.accountName,
                                child: Text(value.accountName!),
                              );
                            }).toList(),
                            onChanged: (newValue) {
                              editOrderController
                                  .setMasterValue(newValue.toString());
                            },
                          ),
                        ),
                      ),
                    ),
                  ),
                  const SizedBox(
                    height: 15,
                  ),
                  const CustomTextWidget(
                    text: "Select Tailor",
                    textSize: 14,
                    color: AppColors.textLight,
                  ),
                  const SizedBox(
                    height: 5,
                  ),
                  SizedBox(
                    height: 55.0,
                    child: InputDecorator(
                      decoration:
                          const InputDecoration(border: OutlineInputBorder()),
                      child: DropdownButtonHideUnderline(
                        child: Obx(
                          () => DropdownButton(
                            isDense: true,
                            isExpanded: true,
                            hint: const Text(
                              "Select",
                            ),
                            value: editOrderController
                                        .selectedTailorValue.value ==
                                    ""
                                ? null
                                : editOrderController.selectedTailorValue.value,
                            items: editOrderController.tailors
                                .map((OrderDropDownData value) {
                              return DropdownMenuItem(
                                value: value.accountName!,
                                child: Text(value.accountName!),
                              );
                            }).toList(),
                            onChanged: (newValue) {
                              editOrderController
                                  .setTailorValue(newValue.toString());
                            },
                          ),
                        ),
                      ),
                    ),
                  ),
                  const SizedBox(
                    height: 15,
                  ),
                  const CustomTextWidget(
                    text: "Status",
                    textSize: 14,
                    color: AppColors.textLight,
                  ),
                  const SizedBox(
                    height: 5,
                  ),
                  SizedBox(
                    height: 55.0,
                    child: InputDecorator(
                      decoration:
                          const InputDecoration(border: OutlineInputBorder()),
                      child: DropdownButtonHideUnderline(
                        child: Obx(
                          () => DropdownButton(
                            isDense: true,
                            isExpanded: true,
                            hint: const Text(
                              "Select",
                            ),
                            value: editOrderController
                                        .selectedStatusValue.value ==
                                    ""
                                ? null
                                : editOrderController.selectedStatusValue.value,
                            items: ['Booking', 'Ready', "Delivered", "Canceled"]
                                .map((String value) {
                              return DropdownMenuItem(
                                value: value,
                                child: Text(value),
                              );
                            }).toList(),
                            onChanged: (newValue) {
                              editOrderController
                                  .setStatusValue(newValue.toString());
                            },
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
          ButtonPrimary(
            text: "Update Order",
            function: editOrderController.updateTheOrder,
            
          ),
        ],
      ),
    );
  }
}
Editor is loading...