/*
 * @Author       : WuWei
 * @LastEditors: ChenYaJin
 * @Date         : 2023-03-23 17:11:18
 * @LastEditTime: 2023-04-06 09:55:58
 * @Description  : Do not edit
 */

import 'package:app_package/app_package.dart';
import 'package:face_package/src/assets.gen.dart';
import 'package:face_package/src/models/cascade.dart';
import 'package:face_package/src/models/door_group.dart';
import 'package:face_package/src/view_models/private_add_store.dart';
import 'package:flutter/material.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

part 'components/form.dart';
part 'components/photo.dart';
part 'components/example.dart';

class AddPage extends StatelessWidget {
  const AddPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (providerContext) => PrivateAddStore(context, providerContext),
      child: Theme(
        data: Theme.of(context).copyWith(
          inputDecorationTheme: InputDecorationTheme(
            border: InputBorder.none,
            isCollapsed: false,
            isDense: false,
            contentPadding: EdgeInsets.symmetric(vertical: 11.pt),
          ),
        ),
        child: _PageView(),
      ),
      lazy: false,
    );
  }
}

class _PageView extends StatelessWidget {
  const _PageView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final colorScheme = WTheme.of(context).colorScheme;
    final store = Provider.of<PrivateAddStore>(context, listen: false);
    return Scaffold(
      appBar: WAppBar(
        brightness: Brightness.light,
        iconTheme: IconThemeData(
          color: colorScheme.mainTitle,
          size: 19.pt,
        ),
        backgroundColor: Colors.white,
        title: WisText('人脸添加',
            size: 19.pt, weight: FontWeight.w600, color: colorScheme.mainTitle),
      ),
      body: WisScrollView(
        slivers: [
          _FormComponent(),
          _PhotoComponent(),
          _ExampleComponent(),
          SliverToBoxAdapter(
            child: WLoadingButton(
              height: 44.pt,
              onPressed: () => store.submit(),
              margin: EdgeInsets.all(15.pt),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(25.pt),
              ),
              child: Text('确认添加'),
            ),
          ),
        ],
      ),
    );
  }
}
