import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../const/app_theme.dart';
import '../../const/colors.dart';
import '../../external/badges/badge.dart';
import '../../localization/language/languages.dart';
import '../../res/images/images.dart';
import '../../widgets/widgets_util.dart';

enum AppbarType {
  dashboard,
  courses,
  news,
  classroom,
  account,
  children,
  courses_detail,
  base,
  baseIpad,
  post,
  baseChild,
  submitAgain,
  dashbroadNotify,
  rightIcon
}

class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
  AppbarType type;
  String title;
  bool? onUpdate;
  late Function()? onContact;
  late Function()? onLike;
  late Function(String)? onFunction;
  late Function()? onActionBar;
  final callback;
  String? numberNotify;
  String? iconData;
  bool? centerText = false;

  CustomAppBar(
      {required this.type,
        required this.title,
        this.onContact,
        this.onLike,
        this.callback,
        this.onFunction,
        this.onActionBar,
        this.onUpdate,
        this.numberNotify,
        this.iconData,
        this.centerText = false});

  @override
  final Size preferredSize = Size.fromHeight(kMinInteractiveDimension);

  @override
  _CustomAppBarState createState() => _CustomAppBarState(
      onContact, onLike, onFunction, onActionBar, centerText);
}

class _CustomAppBarState extends State<CustomAppBar> {
  //Level? level;
  late Function()? onContact;
  late Function()? onLike;
  late Function(String)? onSearch;
  late Function()? onActionBar;
  late Function(String)? onFunction;
  late bool? onUpdate;
  bool isSearch = false;
  bool? centerText = false;
  TextEditingController _controller = TextEditingController();

  _CustomAppBarState(this.onContact, this.onLike, this.onSearch,
      this.onActionBar, this.centerText);

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    if (widget.type == AppbarType.dashboard) {
      return _buildDashBoard(context, onSearch!, widget.onUpdate);
    } else if (widget.type == AppbarType.courses) {
      return _buildNomarl();
    } else if (widget.type == AppbarType.news) {
      return _buildAppbarSocial(context, onContact!);
    } else if (widget.type == AppbarType.children) {
      return _buildChild();
    } else if (widget.type == AppbarType.courses_detail) {
      return _buildAppbarCoursesDetail(context, onSearch!, centerText ?? false);
    } else if (widget.type == AppbarType.base) {
      return _buildBaseToolbar(context, onSearch!);
    } else if (widget.type == AppbarType.post) {
      return _buildPostPage(onActionBar!, widget.numberNotify!);
    } else if (widget.type == AppbarType.baseChild) {
      return _buildBaseToolbarChild(context, onSearch!);
    } else if (widget.type == AppbarType.submitAgain) {
      return _buildSubmitImage(context, onContact!);
    } else if (widget.type == AppbarType.baseIpad) {
      return _buildBaseToolbarIPad(context, onSearch!);
    } else if (widget.type == AppbarType.dashbroadNotify) {
      return _buildDashBoardNoti(context, onSearch!, onActionBar!);
    } else if (widget.type == AppbarType.rightIcon) {
      return _appbarRightIcon(context, onSearch!,
          icon: widget.iconData,
          icon2: widget.numberNotify,
          onClick: onActionBar);
    }

    return Container(
      height: 0,
    );
  }

  Widget _buildChild() {
    return Container(
      width: double.infinity,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisSize: MainAxisSize.max,
        children: [
          Container(
            margin: EdgeInsets.all(4),
            child: Card(
              shadowColor: AppColors.primary_blue,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16.0),
              ),
              elevation: 2,
              child: Transform.rotate(
                angle: 180 * pi / 180,
                child: IconButton(
                  icon: Icon(Icons.play_arrow_rounded,
                      color: AppColors.primary_blue, size: 32),
                  onPressed: () {
                    Navigator.pop(context, widget.onUpdate);
                  },
                ),
              ),
            ),
          ),
          Expanded(
            child: Container(
              margin: EdgeInsets.only(right: 32),
              alignment: Alignment.center,
              child: NeoText(widget.title,
                  textStyle: AppTheme.textStyleLexendBold(
                      fontSize: 18,
                      color: AppColors.primary_blue,
                      overFlow: true),
                  maxLine: 2,
                  textAlign: TextAlign.center),
            ),
          ),
          SizedBox(
            width: 32,
          )
        ],
      ),
    );
  }

  Widget _buildPostPage(Function() onPost, String title) {
    return Container(
      width: double.infinity,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        mainAxisSize: MainAxisSize.max,
        children: [
          Container(
            margin: EdgeInsets.all(4),
            child: Card(
              shadowColor: AppColors.primary_blue,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16.0),
              ),
              elevation: 2,
              child: Transform.rotate(
                angle: 180 * pi / 180,
                child: IconButton(
                  icon: Icon(Icons.play_arrow_rounded,
                      color: AppColors.primary_blue, size: 32),
                  onPressed: () {
                    Navigator.pop(context, widget.onUpdate);
                  },
                ),
              ),
            ),
          ),
          Expanded(
            child: Container(
              alignment: Alignment.center,
              child: NeoText(widget.title,
                  textStyle: AppTheme.textStyleLexendBold(
                      fontSize: 18, color: AppColors.primary_blue)),
            ),
          ),
          TextButton(
            style: ButtonStyle(
                backgroundColor:
                MaterialStateProperty.all<Color>(AppColors.primary_blue),
                shape: MaterialStateProperty.all<RoundedRectangleBorder>(
                    RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(8.0),
                        side: BorderSide(color: AppColors.primary_blue)))),
            onPressed: () {
              onPost();
            },
            child: Padding(
              padding: const EdgeInsets.all(4.0),
              child: NeoText(title,
                  textStyle: AppTheme.textStyleLexendMedium(
                      fontSize: 16, color: AppColors.white)),
            ),
          ),
          SizedBox(
            width: 8,
          ),
        ],
      ),
    );
  }

  Widget _buildNomarl() {
    return Container(
      width: double.infinity,
      child: Row(
        children: [
          Padding(
            padding: const EdgeInsets.only(left: 8.0),
            child: NeoText(widget.title,
                textStyle: AppTheme.textStyleLexendBold(
                    fontSize: 18, color: AppColors.primary_blue)),
          ),
          Expanded(
              child: Stack(
                children: <Widget>[
                  Positioned(
                      right: 10,
                      child: IconButton(
                        icon: const ImageIcon(
                          AssetImage(Images.notify),
                          color: AppColors.grey,
                        ), onPressed: () {  },
                        // onPressed: () {
                        //   Navigator.push(
                        //       context,
                        //       MaterialPageRoute(
                        //           builder: (_) => NotificationPage()))
                        //       .then((value) {
                        //     if (value != null && value is bool && value) {}
                        //   });
                        // },
                      )),
                  Positioned(
                    right: 15,
                    top: 8,
                    child: Container(
                        padding: EdgeInsets.all(2),
                        decoration: BoxDecoration(
                            color: Colors.red,
                            borderRadius: BorderRadius.circular(6)),
                        constraints: BoxConstraints(
                          minWidth: 14,
                          minHeight: 14,
                        ),
                        child: NeoText('0',
                            textStyle: AppTheme.textStyleNormal(
                                fontSize: 8, color: AppColors.white),
                            textAlign: TextAlign.center)),
                  )
                ],
              )),
        ],
      ),
    );
  }

  Widget _buildDashBoard(
      BuildContext context, Function(String) onSearch, bool? showSearchBar) {
    return Container(
      width: double.infinity,
      height: 52,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Padding(
            padding: const EdgeInsets.only(left: 8.0, right: 8),
            child: Image.asset(Images.logoWhite, height: 42),
          ),
          SizedBox(
            width: 16,
          ),
          showSearchBar == null || showSearchBar == true
              ? Expanded(
            child: InkWell(
              onTap: () {
                onSearch('');
              },
              child: Container(
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(25)),
                  color: AppColors.white.withOpacity(0.2),
                ),
                height: 42,
                alignment: Alignment.centerLeft,
                child: Padding(
                  padding: const EdgeInsets.only(left: 16.0),
                  child: NeoText(Languages.of(context)!.search,
                      textStyle: AppTheme.textStyleLexendMedium(
                          fontSize: 16, color: AppColors.white)),
                ),
              ),
            ),
          )
              : SizedBox(),
          SizedBox(
            width: 24,
          )
        ],
      ),
    );
  }

  Widget _buildDashBoardNoti(
      BuildContext context, Function(String) onSearch, Function() onActionBar) {
    return Container(
      width: double.infinity,
      height: 52,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Padding(
            padding: const EdgeInsets.only(left: 8.0, right: 8),
            child: Image.asset(
              Images.logoWhite,
              height: 42,
            ),
          ),
          Expanded(
            child: InkWell(
              onTap: () {
                onSearch('');
              },
              child: Container(
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(25)),
                  color: AppColors.white.withOpacity(0.2),
                ),
                height: 42,
                alignment: Alignment.centerLeft,
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: NeoText(Languages.of(context)!.search,
                      textStyle: AppTheme.textStyleLexendMedium(
                          fontSize: 16, color: AppColors.white_primary)),
                ),
              ),
            ),
          ),
          InkWell(
            onTap: () {
              onActionBar();
            },
            child: Container(
              margin: EdgeInsets.only(left: 16, right: 16),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(25)),
                color: AppColors.white.withOpacity(0.2),
              ),
              height: 42,
              width: 42,
              alignment: Alignment.center,
              child: widget.numberNotify!.isEmpty
                  ? ImageIcon(
                AssetImage('${Images.notify}'),
                color: AppColors.white,
              )
                  : BadgeApp(
                badgeContent: NeoText(widget.numberNotify!,
                    textStyle: AppTheme.textStyleLexendMedium(
                        fontSize: 10, color: AppColors.white)),
                child: ImageIcon(
                  AssetImage('${Images.notify}'),
                  color: AppColors.white,
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _appbarRightIcon(BuildContext context, Function(String) onFunction,
      {String? icon, String? icon2, Function()? onClick}) {
    return Container(
      width: double.infinity,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Container(
            margin: EdgeInsets.all(4),
            child: Card(
              shadowColor: AppColors.primary_blue,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16.0),
              ),
              elevation: 2,
              child: Transform.rotate(
                angle: 180 * pi / 180,
                child: IconButton(
                  icon: Icon(Icons.play_arrow_rounded,
                      color: AppColors.primary_blue, size: 32),
                  onPressed: () {
                    Navigator.pop(context, widget.onUpdate);
                  },
                ),
              ),
            ),
          ),
          Expanded(
            child: NeoText(widget.title,
                textStyle: AppTheme.textStyleLexendBold(
                    fontSize: 18,
                    color: AppColors.primary_blue,
                    overFlow: true),
                maxLine: 2,
                textAlign: TextAlign.start),
          ),
          icon == null
              ? SizedBox()
              : Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              icon2 != null
                  ? Padding(
                padding: const EdgeInsets.only(
                  left: 8.0,
                ),
                child: IconButton(
                  icon: ImageIcon(
                    AssetImage(Images.icNote),
                    color: AppColors.primary_blue,
                  ),
                  onPressed: () {
                    onClick!();
                  },
                ),
              )
                  : SizedBox(),
              Padding(
                padding: const EdgeInsets.only(left: 8.0, right: 8),
                child: IconButton(
                  icon: ImageIcon(
                    AssetImage(icon),
                    color: AppColors.primary_blue,
                  ),
                  onPressed: () {
                    onFunction('');
                  },
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }

  Widget _buildBaseToolbar(BuildContext context, Function(String) onSearch) {
    // TextEditingController controller = TextEditingController();
    return Container(
      width: double.infinity,
      height: 52,
      decoration: BoxDecoration(
        image:
        DecorationImage(image: AssetImage(Images.tabBar), fit: BoxFit.fill),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Padding(
            padding: const EdgeInsets.only(left: 8.0),
            child: Image.asset(Images.logoWhite, height: 42),
          ),
          isSearch
              ? Container(
            child: Row(
              children: [
                Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(25)),
                    color: AppColors.white,
                  ),
                  width: MediaQuery.of(context).size.width - 160,
                  height: 38,
                  alignment: Alignment.centerLeft,
                  child: TextFormField(
                    onFieldSubmitted: (value) {
                      _controller = TextEditingController(text: value);
                    },
                    controller: _controller,
                    autocorrect: true,
                    style: TextStyle(color: AppColors.dark),
                    decoration: InputDecoration(
                        contentPadding: EdgeInsets.only(
                            left: 16, top: 0, bottom: 0, right: 16),
                        hintText: widget.title,
                        hintStyle: AppTheme.textStyleLexendLight(
                            fontSize: null,
                            color: AppColors.primary_grey),
                        filled: true,
                        fillColor: AppColors.white,
                        enabledBorder: OutlineInputBorder(
                          borderRadius:
                          BorderRadius.all(Radius.circular(25)),
                          borderSide: BorderSide(
                              color: AppColors.white, width: 1),
                        ),
                        focusedBorder: OutlineInputBorder(
                          borderRadius:
                          BorderRadius.all(Radius.circular(25)),
                          borderSide: BorderSide(color: AppColors.white),
                        ),
                        suffixIcon: _controller.text.length > 0
                            ? IconButton(
                          icon: ImageIcon(
                              AssetImage('${Images.clear}'),
                              size: 30),
                          onPressed: () {
                            onSearch('');
                            _controller.clear();
                            setState(() {});
                          },
                        )
                            : null),
                    onChanged: (text) =>
                    {onSearch(text), setState(() {})},
                  ),
                ),
                Container(
                  width: 30,
                  height: 30,
                  margin: EdgeInsets.only(left: 8, right: 16),
                  child: FloatingActionButton(
                    heroTag: 'close1',
                    elevation: 0,
                    backgroundColor: AppColors.grey,
                    child: Icon(Icons.close),
                    onPressed: () {
                      setState(() {
                        onSearch('');
                        _controller.clear();
                        isSearch = false;
                      });
                    },
                  ),
                ),
              ],
            ),
          )
              : Container(
            height: 30,
            width: 30,
            margin: EdgeInsets.only(right: 16),
            child: FloatingActionButton(
              heroTag: null,
              elevation: 0,
              backgroundColor: AppColors.grey,
              child: Icon(Icons.search),
              onPressed: () {
                setState(() {
                  isSearch = true;
                });
              },
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildBaseToolbarIPad(
      BuildContext context, Function(String) onSearch) {
    // TextEditingController controller = TextEditingController();
    return Container(
      width: double.infinity,
      height: 52,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Padding(
            padding: const EdgeInsets.only(left: 8.0),
            child: Image.asset(Images.logoWhite, height: 42),
          ),
          SizedBox(
            width: 24,
          ),
          Expanded(
              child: Container(
                height: 42,
                child: Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.all(Radius.circular(25)),
                    color: AppColors.white.withOpacity(0.2),
                  ),
                  alignment: Alignment.centerLeft,
                  child: TextFormField(
                    onFieldSubmitted: (value) {
                      _controller = TextEditingController(text: value);
                    },
                    controller: _controller,
                    autocorrect: true,
                    style: TextStyle(color: AppColors.white),
                    decoration: InputDecoration(
                        contentPadding:
                        EdgeInsets.only(left: 16, top: 0, bottom: 0, right: 16),
                        hintText: widget.title,
                        hintStyle: AppTheme.textStyleLexendLight(
                            fontSize: null, color: AppColors.primary_grey),
                        filled: true,
                        enabledBorder: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(25)),
                          borderSide: BorderSide(
                              color: AppColors.white.withOpacity(0.2), width: 0),
                        ),
                        focusedBorder: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(25)),
                          borderSide: BorderSide(color: AppColors.white),
                        ),
                        suffixIcon: _controller.text.length > 0
                            ? IconButton(
                          icon: Icon(
                            Icons.close,
                            color: AppColors.white,
                          ),
                          onPressed: () {
                            onSearch('');
                            _controller.clear();
                            setState(() {});
                          },
                        )
                            : null),
                    onChanged: (text) => {onSearch(text), setState(() {})},
                  ),
                ),
              )),
          SizedBox(
            width: 24,
          ),
        ],
      ),
    );
  }

  Widget _buildAppbarSocial(BuildContext context, Function() onContact) {
    return Container(
      width: double.infinity,
      height: 52,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Padding(
            padding: const EdgeInsets.only(left: 8.0),
            child: Image.asset(Images.logoWhite, height: 42),
          ),
          Container(
            width: 50,
            child: Stack(
              children: <Widget>[
                Positioned(
                    right: 10,
                    child: TextButton(
                      style: TextButton.styleFrom(
                          padding: EdgeInsets.zero,
                          minimumSize: Size(32, 32),
                          alignment: Alignment.centerLeft),
                      onPressed: () {
                        onContact();
                      },
                      child: ImageIcon(
                        AssetImage(Images.social),
                        color: AppColors.white,
                      ),
                    )),
                Positioned(
                  right: 24,
                  top: 12,
                  child: Container(
                    padding: EdgeInsets.all(2),
                    decoration: BoxDecoration(
                        color: Colors.red,
                        borderRadius: BorderRadius.circular(6)),
                    constraints: BoxConstraints(
                      minWidth: 8,
                      minHeight: 8,
                    ),
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget _buildAppbarCoursesDetail(
      BuildContext context, Function(String) onSearch, bool centerText) {
    // TextEditingController controller = TextEditingController();
    return Container(
      width: double.infinity,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Container(
            margin: EdgeInsets.all(4),
            width: 58,
            child: Card(
              shadowColor: AppColors.primary_blue,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16.0),
              ),
              elevation: 2,
              child: Transform.rotate(
                angle: 180 * pi / 180,
                child: IconButton(
                  icon: Icon(Icons.play_arrow_rounded,
                      color: AppColors.primary_blue, size: 32),
                  onPressed: () {
                    Navigator.pop(context, widget.onUpdate);
                  },
                ),
              ),
            ),
          ),
          Expanded(
            child: isSearch
                ? Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(Radius.circular(25)),
                color: AppColors.white,
              ),
              height: 48,
              alignment: Alignment.center,
              child: TextField(
                controller: _controller,
                autocorrect: true,
                inputFormatters: [FilteringTextInputFormatter.deny('  ')],
                style: TextStyle(color: AppColors.dark),
                decoration: InputDecoration(
                    contentPadding: EdgeInsets.only(
                        left: 16, top: 0, bottom: 0, right: 16),
                    hintText: Languages.of(context)!.searchLesson,
                    hintStyle: AppTheme.textStyleLexendLight(
                        fontSize: null, color: AppColors.primary_grey),
                    filled: true,
                    fillColor: AppColors.white,
                    enabledBorder: OutlineInputBorder(
                      borderRadius: BorderRadius.all(Radius.circular(25)),
                      borderSide:
                      BorderSide(color: AppColors.white, width: 1),
                    ),
                    focusedBorder: OutlineInputBorder(
                      borderRadius: BorderRadius.all(Radius.circular(25)),
                      borderSide: BorderSide(color: AppColors.white),
                    ),
                    suffixIcon: _controller.text.length > 0
                        ? IconButton(
                      icon: Icon(
                        Icons.close,
                        color: AppColors.grey,
                      ),
                      onPressed: () {
                        onSearch('');
                        _controller.clear();
                        setState(() {});
                      },
                    )
                        : null),
                onChanged: (text) => {onSearch(text), setState(() {})},
              ),
            )
                : centerText
                ? Center(
              child: NeoText(widget.title,
                  textStyle: AppTheme.textStyleLexendBold(
                      fontSize: 18, color: AppColors.primary_blue)),
            )
                : NeoText(widget.title,
                textStyle: AppTheme.textStyleLexendBold(
                    fontSize: 18, color: AppColors.primary_blue)),
          ),
          isSearch
              ? Container(
            width: 30,
            height: 30,
            margin: EdgeInsets.only(left: 8, right: 16),
            child: FloatingActionButton(
              heroTag: 'close2',
              elevation: 0,
              backgroundColor: AppColors.primary_blue,
              child: Icon(
                Icons.close,
                color: AppColors.white,
              ),
              onPressed: () {
                setState(() {
                  onSearch('');
                  isSearch = false;
                  _controller.clear();
                });
              },
            ),
          )
              : Container(
            height: 30,
            width: 30,
            margin: EdgeInsets.only(right: 16),
            child: FloatingActionButton(
              heroTag: 'search3',
              elevation: 0,
              backgroundColor: AppColors.primary_blue,
              child: Icon(Icons.search, color: AppColors.white),
              onPressed: () {
                setState(() {
                  isSearch = true;
                });
              },
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildBaseToolbarChild(
      BuildContext context, Function(String) onSearch) {
    return Container(
      width: double.infinity,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Container(
            margin: EdgeInsets.all(4),
            width: 58,
            child: Card(
              shadowColor: AppColors.primary_blue,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16.0),
              ),
              elevation: 2,
              child: Transform.rotate(
                angle: 180 * pi / 180,
                child: IconButton(
                  icon: Icon(Icons.play_arrow_rounded,
                      color: AppColors.primary_blue, size: 32),
                  onPressed: () {
                    Navigator.pop(context, widget.onUpdate);
                  },
                ),
              ),
            ),
          ),
          Expanded(
              child: Container(
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(25)),
                  color: AppColors.white,
                ),
                width: MediaQuery.of(context).size.width,
                height: 48,
                alignment: Alignment.center,
                margin: EdgeInsets.only(right: 30),
                child: TextFormField(
                  onFieldSubmitted: (value) {
                    _controller = TextEditingController(text: value);
                  },
                  controller: _controller,
                  autocorrect: true,
                  style: TextStyle(color: AppColors.dark),
                  decoration: InputDecoration(
                      contentPadding:
                      EdgeInsets.only(left: 16, top: 0, bottom: 0, right: 16),
                      hintText: widget.title,
                      hintStyle: AppTheme.textStyleLexendLight(
                          fontSize: null, color: AppColors.primary_grey),
                      filled: true,
                      fillColor: AppColors.white,
                      enabledBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(25)),
                        borderSide: BorderSide(color: AppColors.white, width: 1),
                      ),
                      focusedBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(25)),
                        borderSide: BorderSide(color: AppColors.white),
                      ),
                      suffixIcon: _controller.text.length > 0
                          ? IconButton(
                        icon: Icon(
                          Icons.close,
                          color: AppColors.lightGrey,
                        ),
                        onPressed: () {
                          onSearch('');
                          _controller.clear();
                          setState(() {});
                        },
                      )
                          : null),
                  onChanged: (text) => {
                    onSearch(text),
                    if (text.isEmpty)
                      {
                        _controller.clear(),
                      },
                    setState(() {})
                  },
                ),
              )),
        ],
      ),
    );
  }

  Widget _buildSubmitImage(BuildContext context, Function() onContact) {
    return Container(
      width: double.infinity,
      height: 52,
      decoration: BoxDecoration(
        image:
        DecorationImage(image: AssetImage(Images.tabBar), fit: BoxFit.fill),
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisSize: MainAxisSize.max,
        children: [
          IconButton(
            icon: Icon(Icons.arrow_back_sharp,
                color: AppColors.primary_blue, size: 24),
            onPressed: () {
              Navigator.pop(context, widget.onUpdate);
            },
          ),
          Expanded(
            child: Container(
              margin: EdgeInsets.only(right: 32),
              alignment: Alignment.center,
              child: NeoText(widget.title,
                  textStyle: AppTheme.textStyleLexendBold(
                      fontSize: 18,
                      color: AppColors.primary_blue,
                      overFlow: true),
                  maxLine: 2,
                  textAlign: TextAlign.center),
            ),
          ),
          Container(
              margin: EdgeInsets.only(right: 8),
              child: ElevatedButton(
                onPressed: () {
                  onContact();
                },
                child: NeoText(Languages.of(context)!.submitAgain,
                    textStyle: AppTheme.textStyleLexendMedium(
                        fontSize: 14, color: AppColors.white)),
                style: ElevatedButton.styleFrom(
                  primary: AppColors.primary,
                ),
              )),
        ],
      ),
    );
  }
}
