/*
 * @Author       : WuWei
 * @Date         : 2023-02-13 14:20:02
 * @LastEditTime: 2023-04-03 15:42:17
 * @Description  : Do not edit
 */
// import 'package:app_package/src/stores/push.dart';
import 'package:app_package/src/view_models/message_index_store.dart';
import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';
import 'dart:convert' as convert;

class ListComponent extends StatelessWidget {
  const ListComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<MessageIndexStore>(context);
    final style = WTheme.of(context);
    final colorScheme = style.colorScheme;
    // final pushGlobalStore = GetIt.I.get<PushGlobalStore>();
    return WisSliverList.childBuilder(
      childCount: store.list.length,
      padding: EdgeInsets.symmetric(horizontal: 15.pt, vertical: 10.pt),
      interval: 10.pt,
      // itemExtent: 160.pt,
      itemExtent: 120.pt,
      builder: (_, i) {
        var item = store.list[i];
        return WisCard(
          onTap: () => {
            if (item.canJump == true)
              {
                // pushGlobalStore.jumpByType(
                //   item.businessType,
                //   {
                //     'communityId': item.communityId,
                //     ...convert.jsonDecode(item.routeParameter!)
                //   },
                //   false,
                // ),
              }
            else
              {
                WToastUtil.show('该消息不可跳转'),
              }
          },
          child: Stack(
            children: <Widget>[
              Wisdom.column(
                padding: EdgeInsets.all(15.pt),
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: <Widget>[
                  WisText.title(
                    '${item.title ?? ''}',
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                  WisText(
                    '${item.createAt ?? ''}',
                    color: colorScheme.minor,
                  ),
                  WisText(
                    '${item.message ?? ''}',
                    maxLines: 2,
                    overflow: TextOverflow.ellipsis,
                  ),
                  // Divider(),
                  // Row(
                  //   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  //   children: <Widget>[
                  //     WisText('详情', color: colorScheme.primary),
                  //     Icon(FaIcons.angle_right, color: colorScheme.primary),
                  //   ],
                  // ),
                ],
              ),

              ///已读未读
              // Positioned(
              //   top: 0,
              //   right: 21.pt,
              //   child: Wisdom(
              //     color: colorScheme.primary,
              //     padding: EdgeInsets.symmetric(
              //       vertical: 3.pt,
              //       horizontal: 10.pt,
              //     ),
              //     borderRadius: BorderRadius.only(
              //       bottomRight: Radius.circular(5.pt),
              //       bottomLeft: Radius.circular(5.pt),
              //     ),
              //     child: WisText.white(
              //       '已读',
              //       size: 13.pt,
              //     ),
              //   ),
              // ),
            ],
          ),
        );
      },
    );
  }
}
