import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ride/controller/home/profile/feed_back_controller.dart';
import 'package:ride/views/widgets/my_scafold.dart';
import 'package:ride/views/widgets/mycircular.dart';

import '../../widgets/elevated_btn.dart';

class FeedBackPage extends StatelessWidget {
  FeedBackPage({super.key});
  FeedBackController feedBackController = Get.put(FeedBackController());
  @override
  Widget build(BuildContext context) {
    return MyScafolld(
      title: 'Feed Back'.tr,
      body: [
        Padding(
          padding: const EdgeInsets.all(26),
          child: Form(
            key: feedBackController.formKey,
            child: Column(
              children: [
                TextFormField(
                  controller: feedBackController.feedbackController,
                  decoration: const InputDecoration(
                    border: OutlineInputBorder(),
                    hintText: 'Enter your feedback here',
                    labelText: 'Feedback',
                  ),
                  validator: (value) {
                    if (value == null || value.isEmpty) {
                      return 'Please enter your feedback.';
                    }
                    return null;
                  },
                ),
                const SizedBox(height: 20),
                feedBackController.isLoading
                    ? const MyCircularProgressIndicator()
                    : MyElevatedButton(
                        onPressed: () {
                          if (feedBackController.formKey.currentState!
                              .validate()) {
                            feedBackController.addFeedBack();

                            // Clear the feedback form
                            feedBackController.formKey.currentState!.reset();
                          }
                        },
                        title: 'Submit Feedback'.tr,
                      ),
              ],
            ),
          ),
        ),
      ],
      isleading: true,
    );
  }
}
