import 'dart:ui';

import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
import 'package:flutter/material.dart';

///
class DrawerItem extends StatefulWidget {
  final String title;
  final String subTitle;
  final icon;
  final Color textColor;
  final Color iconColor;
  final bool bottomLine;
  final bool sideArrow;
  final Widget count;
  final bool isImageIcon;
  final double fontHeight;
  final double letterSpacing;
  final double fontSize;
  final ProjectViewModel projectProvider;

  DrawerItem(this.title, this.icon,
      {this.fontSize, this.letterSpacing, this.textColor, this.iconColor, this.subTitle = '', this.bottomLine = true, this.count, this.sideArrow = false, this.isImageIcon = false, this.fontHeight, this.projectProvider});

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

class _DrawerItemState extends State<DrawerItem> {
  @override
  Widget build(BuildContext context) {
    return Container(
        decoration: widget.bottomLine == true
            ? BoxDecoration(
                border: Border(
                bottom: BorderSide(
                  //                   <--- left side
                  color: Colors.grey[200],
                  width: 1.0,
                ),
              ))
            : BoxDecoration(),
        child: Padding(
          padding: EdgeInsets.all(10),
          child: Row(
            children: <Widget>[
              Expanded(
                  flex: 1,
                  child: widget.isImageIcon == true
                      ? widget.icon
                      : Icon(
                          widget.icon,
                          color: widget.iconColor == null ? Theme.of(context).textTheme.bodyText1.color : widget.iconColor,
                          size: SizeConfig.imageSizeMultiplier * 5,
                        )),
              Expanded(
                  flex: 7,
                  child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
                    Row(
                      children: [
                        AppText(
                          widget.title,
                          fontWeight: FontWeight.w600,
                          fontSize: widget.fontSize,
                          height: widget.fontHeight,
                          letterSpacing: widget.letterSpacing,
                        ),
                        widget.count ?? SizedBox(),
                      ],
                    ),
                    widget.subTitle != ''
                        ? AppText(
                            widget.subTitle,
                            fontSize: SizeConfig.textMultiplier * 2.5,
                          )
                        : SizedBox(),
                  ])),
              widget.sideArrow == true ? Expanded(flex: 1, child: Icon(widget.projectProvider.isArabic ? Icons.keyboard_arrow_left : Icons.keyboard_arrow_right, color: Colors.black)) : Expanded(flex: 1, child: SizedBox()),
            ],
          ),
        ));
  }
}
