import 'package:diplomaticquarterapp/pages/MyAppointments/models/AskDocRequestTypeModel.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart';

import 'custom_radio.dart';

class AskDocDialog extends StatefulWidget {

  List<AskDocRequestType> requestData;

  static int selectedParameterCode = 0;

  AskDocDialog({@required this.requestData});

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

class _AskDocDialogState extends State<AskDocDialog> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Dialog(
        shape:
            RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
        child: Container(
          height: MediaQuery.of(context).size.height * 0.77,
          width: 450.0,
          child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisSize: MainAxisSize.max,
              children: <Widget>[
                Container(
                  margin: EdgeInsets.all(20.0),
                  child: Text(TranslationBase.of(context).requestType,
                      style: TextStyle(
                          fontSize: 20.0,
                          fontWeight: FontWeight.bold,
                          fontFamily: "Open-Sans-Bold")),
                ),
                Container(
                  transform: Matrix4.translationValues(0.0, -30.0, 0.0),
                  child: CustomRadio(requestData: widget.requestData),
                ),
                Container(
                  width: MediaQuery.of(context).size.width,
                  height: 40.0,
                  margin: EdgeInsets.only(left: 30.0, top: 0.0, right: 30.0),
                  child: RaisedButton(
                    shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(10.0),
                        side: BorderSide(color: Colors.blue)),
                    color: Colors.blue,
                    elevation: 0,
                    onPressed: () {
                      if(AskDocDialog.selectedParameterCode != 0)
                        Navigator.pop(context, AskDocDialog.selectedParameterCode);
                      else
                        AppToast.showErrorToast(message: "Please select request type to continue");
                    },
                    child: Text(TranslationBase.of(context).confirm,
                        style: TextStyle(
                            color: Colors.white,
                            fontWeight: FontWeight.bold,
                            fontFamily: 'Open-Sans-Bold')),
                  ),
                ),
                Container(
                  width: MediaQuery.of(context).size.width,
                  margin: EdgeInsets.only(left: 100.0, top: 20.0, right: 100.0),
                  child: OutlineButton(
                    shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(10.0)),
                    color: Colors.red,
                    borderSide: BorderSide(color: Colors.red),
                    highlightColor: Colors.red,
                    highlightedBorderColor: Colors.red,
                    onPressed: () {
                      Navigator.pop(context, null);
                    },
                    child: Text(TranslationBase.of(context).cancel_nocaps,
                        style: TextStyle(
                            color: Colors.red,
                            fontWeight: FontWeight.bold,
                            fontFamily: 'Open-Sans-Bold')),
                  ),
                ),
              ]),
        ),
      ),
    );
  }
}
