import 'package:flutter/material.dart';
import 'package:liftmanager/res/colors.dart';
import 'package:liftmanager/res/gaps.dart';
import 'package:liftmanager/utils/image_utils.dart';

class SelectWorker extends StatelessWidget {
  const SelectWorker({
    Key key,
    this.onTap,
    this.onClick,
    @required this.avatar,
    @required this.title,
    @required this.isChecked,
    this.isCheckbox=false, //
  }) : super(key: key);

  final GestureTapCallback onTap;
  final Function onClick;
  final String avatar;
  final String title;
  final bool isChecked;

  final bool isCheckbox;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Container(
        padding: const EdgeInsets.only(left: 15),
        constraints:
            BoxConstraints(maxHeight: double.infinity, minHeight: 55.0),
        width: double.infinity,
        decoration: BoxDecoration(
            color: Colors.white,
            border: Border(
              bottom: Divider.createBorderSide(context, width: 0.6),
            )),
        child: Row(
          children: <Widget>[
            Offstage(
                offstage: isCheckbox,
                child: Checkbox(
                  activeColor: Colours.app_main,
                  tristate: false,
                  value: isChecked,
                  onChanged: onClick,
                )),
            CircleAvatar(
                radius: 18.5,
                backgroundColor: Colors.transparent,
                backgroundImage: ImageUtils.getImageProvider(avatar,
                    holderImg: 'icon_avatar')),
            Gaps.hGap8,
            Expanded(
              flex: 1,
              child: Padding(
                padding: const EdgeInsets.only(right: 5.0),
                child: Text(title),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
