Untitled

mail@pastecode.io avatar
unknown
dart
a year ago
6.2 kB
1
Indexable
Never
import 'package:centro/app/modules/Common/MeetingRequest/widgets/attachments_tile.dart';
import 'package:centro/app/services/authentication/auth_manager.dart';
import 'package:centro/app/utilities/ui/widgets/background.dart';
import 'package:centro/app/utilities/ui/widgets/centro_button.dart';
import 'package:centro/app/utilities/ui/widgets/centro_textfield.dart';
import 'package:centro/app/utilities/ui/widgets/primary_appbar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../../utilities/constants/app_colors.dart';
import '../../../MC/widgets/mc_attachments_type_card.dart';
import '../controller/meeting_request_controller.dart';

class MeetingRequestView extends GetView<MeetingRequestController> {
  const MeetingRequestView({super.key});

  @override
  Widget build(BuildContext context) {
    return Background(
      child: Scaffold(
        bottomNavigationBar: Container(
            padding: const EdgeInsets.all(20),
            decoration: BoxDecoration(
              color: AppColors.white,
              boxShadow: [
                BoxShadow(
                  blurRadius: 10,
                  spreadRadius: 10,
                  color: AppColors.grey.withOpacity(0.1),
                ),
              ],
            ),
            child: CentroButton(
              isIconed: false, 
              text: 'send'.tr,
              onPressed: () async {
                if (controller.formKey.currentState!.validate()) {
                  await controller.apiService.addPendingMeeting(
                    controller.meetingTitleController.value.text,
                    controller.meetingDescriptionController.value.text,
                    controller.listOfAttachments,
                  );
                                    appTools.meetingSentSuccessfullyDialog(context);

                }
              },
              width: Get.width,
            )),
        appBar: PrimaryAppBar(
          showBackButton: true,
          showSearchButton: true,
          function: () {
            Get.back();
          },
        ),
        body: SingleChildScrollView(
          child: Padding(
            padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  'ask for meeting'.tr,
                  style: textTheme.headline5,
                ),
                const SizedBox(
                  height: 16,
                ),
                Form(
                  key: controller.formKey,
                  child: Column(
                    children: [
                      CentroTextField(
                        validator: (value) {
                          if (value!.isEmpty) {
                            return 'please add meeting name'.tr;
                          }
                          return null;
                        },
                        maxLines: 1,
                        controller: controller.meetingTitleController,
                        hintTxt: 'meeting name'.tr,
                      ),
                      const SizedBox(
                        height: 16,
                      ),
                      CentroTextField(
                        validator: (value) {
                          if (value!.isEmpty) {
                            return 'please add meeting reason'.tr;
                          }
                          return null;
                        },
                        maxLines: 8,
                        controller: controller.meetingDescriptionController,
                        hintTxt: 'meeting reason'.tr,
                      ),
                    ],
                  ),
                ),
                const SizedBox(
                  height: 16,
                ),
                Text(
                  'add file'.tr,
                  style: textTheme.headline6,
                ),
                const SizedBox(
                  height: 16,
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Expanded(
                      child: InkWell(
                          child: MCAttachmentsTypeCard(
                              fileType: 'PDF ملف', index: 0),
                          onTap: () {
                            controller.pickPDFfile();
                            controller.isFileAttached = true.obs;
                          }),
                    ),
                    const SizedBox(
                      width: 12,
                    ),
                    Expanded(
                      child: InkWell(
                          child: MCAttachmentsTypeCard(
                              fileType: 'PNG ملف', index: 1),
                          onTap: () {
                            controller.pickPNGfile();
                          }),
                    ),
                    const SizedBox(
                      width: 12,
                    ),
                    Expanded(
                      child: InkWell(
                        onTap: () => controller.pickMP3file(),
                        child: MCAttachmentsTypeCard(
                            fileType: 'MP3 ملف', index: 2),
                      ),
                    ),
                    const SizedBox(
                      width: 12,
                    ),
                    Expanded(
                      child: InkWell(
                        onTap: () => controller.pickAnyFile(),
                        child: MCAttachmentsTypeCard(
                            fileType: 'ارفاق ملف', index: 3),
                      ),
                    ),
                  ],
                ),
                const SizedBox(
                  height: 16,
                ),
                const AttachmentsTile()
              ],
            ),
          ),
        ),
      ),
    );
  }
}