/*
 * @Author       : WuWei
 * @LastEditors  : WuWei
 * @Date         : 2023-03-13 17:15:13
 * @LastEditTime : 2023-11-08 11:05:23
 * @Description  : Do not edit
 */

part of '../index.dart';

class _CarListComponent extends StatelessWidget {
  const _CarListComponent({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<IndexStore>(context);
    final colorScheme = WTheme.of(context).colorScheme;
    final list = store.carList;

    return Column(
      children: <Widget>[
        WisScrollView(
          key: store.carScrollViewKey,
          onInit: () => store.getCarList(isLoad: false),
          onLoad: () => store.getCarList(isLoad: true),
          slivers: <Widget>[
            WSearch(
              isDark: true,
              backColor: Colors.white,
              moonlight: false,
              hintText: '请输入车牌号',
              onSubmitted: (value) => store.oncarSearchTrigger(value),
              onCancel: () => store.oncarSearchTrigger(''),
            ).asSliver(),
            SizedBox(height: 15.pt).asSliver(),
            WisSliverList.childBuilder(
              childCount: list.length,
              builder: (context, index) {
                final item = list[index];
                return WisCard(
                  onTap: () => store.route2Detail(item),
                  margin: EdgeInsets.fromLTRB(15.pt, 0, 15.pt, 10.pt),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: <Widget>[
                      Row(children: [
                        Container(
                          height: 20.pt,
                          width: 3.pt,
                          color: colorScheme.primary,
                        ),
                        Wisdom(
                          color: Colors.white,
                          padding: EdgeInsets.all(15.pt),
                          child: WisText(
                            '${item.assetName}',
                            size: 16.pt,
                            bold: true,
                            color: colorScheme.mainTitle,
                          ),
                        ),
                      ])
                    ],
                  ),
                );
              },
            ),
          ],
        ).asExpanded(),
      ],
    );
  }
}
