/*
 * @Author: WuWei
 * @Date: 2020-06-16 15:24:21
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2023-03-31 10:45:25
 * @Description:
 */

import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';
import '../../components/block_clipper.dart';
import '../../components/info_item.dart';
import '../../view_models/car_detail_store.dart';
// import '../../view_models/search_index_store.dart';

part 'components/topinfo_card.dart';
part 'components/resident.dart';
part 'components/park.dart';

class CarDetailPage extends StatelessWidget {
  const CarDetailPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (_) => SearchCarDetailStore(context),
      child: _PageView(),
      lazy: false,
    );
  }
}

class _PageView extends StatefulWidget {
  _PageView({Key? key}) : super(key: key);

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

class _PageViewState extends State<_PageView> {
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    final store = Provider.of<SearchCarDetailStore>(context);
    return Scaffold(
      appBar: WAppBar(
        brightness: Brightness.dark,
        iconTheme: IconThemeData(
          color: Colors.white,
          size: 19.pt,
        ),
        title: Text('车辆信息'),
      ),
      body: WisScrollView(
        key: store.scorllViewKey,
        onInit: () => store.getCarDetail(
          id: store.args['id'],
        ),
        slivers: <Widget>[
          _TopInfoCard(),
          _CarResident(),
          _CarPark(),
        ],
      ),
    );
  }
}
