/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2021-03-30 14:48:50
 * @LastEditTime : 2023-04-07 15:29:49
 * @FilePath     : /wisdom-huiguanjia-app/oa_package/lib/src/pages/detail/components/actionDialog.dart
 * @Description  : Do not edit
 */
part of '../view.dart';

class _RejectDialogComponent extends StatefulWidget {
  _RejectDialogComponent({
    Key? key,
    this.type,
    this.typeText,
    this.id,
    this.audit,
  }) : super(key: key);
  final String? type;
  final String? typeText;
  final String? id;
  final bool? audit;
  static show(BuildContext context, type, typeText, id, audit) async {
    await showDialog(
      barrierDismissible: false,
      context: context,
      builder: (context) {
        return _RejectDialogComponent(
          type: type,
          typeText: typeText,
          id: id,
          audit: audit,
        );
      },
    );
  }

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

class __RejectDialogComponentState extends State<_RejectDialogComponent> {
  final formKey = GlobalKey<FormState>();

  String content = "";

  changeParams(String value) {
    content = value;
  }

  @override
  Widget build(BuildContext context) {
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    return Provider<DetailStore>(
      create: (_) => DetailStore(context),
      child: WisForm(
        autovalidateMode: AutovalidateMode.always,
        formKey: formKey,
        child: WisDialog(
          shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.all(Radius.circular(20.0))),
          content: Builder(
            builder: (context) {
              // var height = MediaQuery.of(context).size.height;
              var width = MediaQuery.of(context).size.width;
              return Container(
                width: width - 64,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    TextFormField(
                      minLines: 3,
                      maxLines: 3,
                      maxLength: 256,
                      onChanged: (v) => changeParams(v),
                      validator: (v) {
                        return v == '' && widget.audit != null && !widget.audit!
                            ? '${widget.typeText}原因不可为空'
                            : null;
                      },
                    ),
                    SizedBox(height: 10.pt),
                    WLoadingButton(
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(20.pt),
                      ),
                      onPressed: () => DetailStore(context).onTaskAction(
                          content,
                          widget.type,
                          widget.typeText,
                          widget.id,
                          widget.audit),
                      color: colorScheme.primary,
                      height: 44.pt,
                      child: Text('${widget.typeText}'),
                    )
                  ],
                ),
              );
            },
          ),
          title: Text('${widget.typeText}原因'),
          contentPadding: EdgeInsets.all(15.pt),
        ),
      ),
    );
  }
}
