import 'package:fcs/domain/entities/user.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/user_search/user_serach.dart';
import 'package:flutter/material.dart';

class UserListRow extends StatefulWidget {
  final CallbackUserSelect callbackUserSelect;
  final User user;
  const UserListRow({this.user, this.callbackUserSelect});

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

class _UserListRowState extends State<UserListRow> {
  final double dotSize = 15.0;
  User user;
  @override
  void initState() {
    super.initState();
    this.user = widget.user;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 15, right: 15),
      child: Card(
        elevation: 10,
        color: Colors.white,
        child: InkWell(
          onTap: () {
            Navigator.pop(context);
            if (widget.callbackUserSelect != null)
              widget.callbackUserSelect(widget.user);
          },
          child: Row(
            children: <Widget>[
              Expanded(
                child: new Padding(
                  padding: const EdgeInsets.symmetric(vertical: 16.0),
                  child: new Row(
                    children: <Widget>[
                      new Padding(
                          padding: new EdgeInsets.symmetric(
                              horizontal: 32.0 - dotSize / 2),
                          child: Icon(
                            Icons.perm_identity,
                            color: primaryColor,
                            size: 50,
                          )),
                      new Expanded(
                        child: new Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            new Text(
                              user.name == null ? '' : user.name,
                              style: new TextStyle(
                                  fontSize: 15.0, color: Colors.black),
                            ),
                            new Text(
                              user.fcsID == null ? "" : user.fcsID,
                              style: new TextStyle(
                                  fontSize: 13.0, color: Colors.grey),
                            ),
                            new Text(
                              user.phoneNumber == null ? "" : user.phoneNumber,
                              style: new TextStyle(
                                  fontSize: 13.0, color: Colors.grey),
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
