import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionEntity.dart';
import 'package:gmalpha_flutter/NewMessageModel/page/message_date.dart';
import 'package:gmalpha_flutter/res/value/ALColors.dart';

class AttentionListItem extends StatelessWidget {
  final Data item;
  AttentionListItem(this.item);

  Text myText(
    String text,
    Color color,
    double size,
    {int maxLines = 1, bool weight = false}
  ) {
    return Text(
      text,
      softWrap: true,
      maxLines: maxLines,
      overflow: TextOverflow.ellipsis,
      style: TextStyle(
        fontSize: size,
        color: color,
        height: 1.38,
        fontWeight: weight ? FontWeight.bold : FontWeight.normal
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      child: Card(
        elevation: 0.0,
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.only(top: 5.0, left: 16.0, right: 10.0),
              child: CircleAvatar(
                radius: 21.0,
                backgroundImage: NetworkImage(item.icon),
              ),
            ),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Container(
                    child: myText('${item.title}', ALColors.Color464646, 13.0, weight: true),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(top: 4.0),
                    child: myText('${item.content}', ALColors.Color666666, 13.0, maxLines: 2),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(top: 3.0),
                    child: myText(MessageDate(item.pushTime).diffTime(), ALColors.Color999999, 10.0)
                  )
                ],
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(top: 4.0, left: 12.0, right: 16.0),
              child: Container(
                width: 54.0,
                height: 29.0,
                child: OutlineButton(
                  padding: const EdgeInsets.only(left: 0.0, right: 0.0,),
                  borderSide: BorderSide(
                    color: ALColors.Color323232
                  ),
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.zero),
                  onPressed: () {
                    // todo 跳转到原生页面 详情页面
                  },
                  child: myText('详情', ALColors.Color323232, 13.0)
                ),
              )
            )
          ],
        ),
      ),
    );
  }
}
