/*
 * @Author       : WuWei
 * @LastEditors: ChenYaJin
 * @Date         : 2022-11-02 10:26:39
 * @LastEditTime: 2023-03-28 14:59:26
 * @Description  : Do not edit
 */
import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:wisdom_cli/wisdom_cli.dart';
import 'store.dart';
import 'view.dart';
part 'index.g.dart';

///路由传递的参数
@JsonSerializable()
class IndexPageArguments {
  final String? appBarTitle;
  IndexPageArguments({this.appBarTitle});
  factory IndexPageArguments.fromJson(Map<String, dynamic> json) {
    return _$IndexPageArgumentsFromJson(json);
  }
  factory IndexPageArguments.fromRouteArguments(BuildContext context) {
    return _$IndexPageArgumentsFromJson(
      (ModalRoute.of(context)?.settings.arguments ?? new Map<String, dynamic>())
          as Map<String, dynamic>,
    );
  }
  Map<String, dynamic> toJson() => _$IndexPageArgumentsToJson(this);
}

class IndexPage extends StatelessWidget {
  const IndexPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => IndexPageStore(context)),
      ],
      child: _PageView(),
    );
  }
}

class _PageView extends StatefulWidget {
  _PageView({Key? key}) : super(key: key);
  @override
  _PageViewState createState() => _PageViewState();
}

class _PageViewState extends State<_PageView>
    with SingleTickerProviderStateMixin {
  IndexPageStore get store => Provider.of(context, listen: true);

  @override
  Widget build(BuildContext context) {
    return IndexPageView();
  }
}
