import 'package:shimmer/shimmer.dart';
import 'package:flutter/material.dart';

class MessageNoticePageSkeleton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      padding: const EdgeInsets.only(left: 12.5, right: 12.5, top: 8, bottom: 20),
      itemBuilder: (context, index) {
        return Container(
          padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 12.5),
          margin: const EdgeInsets.only(bottom: 7.5),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(7.5),
            color: Colors.white,
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  // 头像
                  _shimmerWidget(width: 40, height: 40, radius: 30),
                  const SizedBox(width: 10),
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        _shimmerWidget(width: 140, height: 18),
                        const SizedBox(height: 5),
                        _shimmerWidget(height: 30, width: double.infinity),
                      ],
                    ),
                  )
                ],
              ),

            ],
          ),
        );
      },
      itemCount: 5,
    );
  }

  Widget _shimmerWidget({double width, double height, double radius = 0}) {
    return Shimmer.fromColors(
      baseColor: Colors.grey[300],
      highlightColor: Colors.grey[100],
      child: Container(
        width: width,
        height: height,
        decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(radius)),
      ),
    );
  }
}
