import 'package:fluent_ui/fluent_ui.dart';
import 'package:fluentui_system_icons/fluentui_system_icons.dart'
    as fluentui_system_icons;

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _selected = 0;

  @override
  Widget build(BuildContext context) {
    return MediaQuery.of(context).size.width > 640
        ? NavigationView(
            appBar: NavigationAppBar(title: Text('momo')),
            pane: NavigationPane(
                displayMode: PaneDisplayMode.auto,
                selected: _selected,
                leading: const Icon(
                    fluentui_system_icons.FluentIcons.backpack_12_filled),
                header: const Text("111"),
                onChanged: (idx) {
                  setState(() {
                    _selected = idx;
                  });
                },
                autoSuggestBox: const AutoSuggestBox(
                  placeholder: "查找",
                  trailingIcon: Center(
                    child: Icon(
                        fluentui_system_icons.FluentIcons.search_12_filled),
                  ),
                  items: [],
                ),
                items: [
                  PaneItem(
                      icon: const Icon(fluentui_system_icons
                          .FluentIcons.network_adapter_16_regular),
                      title: const Text('代理'),
                      // body: DeferredWidget
                      body: ScaffoldPage(
                        header: PageHeader(
                          title: Text("213"),
                        ),
                      )),
                  PaneItem(
                      icon: const Icon(fluentui_system_icons
                          .FluentIcons.settings_48_regular),
                      title: const Text('用户'),
                      body: ScaffoldPage(
                          header: const PageHeader(
                            title: Text("用户"),
                          ),
                          // bottomBar: BottomNavigationBarItem(),
                          // header: HeadingElement.h1(),
                          content: ListView.separated(
                              itemCount: 2,
                              itemBuilder: (context, index) {
                                return const Card(
                                    margin: EdgeInsets.fromLTRB(12, 0, 12, 0),
                                    padding: EdgeInsets.zero,
                                    child: ListTile(
                                        // tileColor:
                                        //     ButtonState.all(const Color(0xffeeeeee)),
                                        leading: Icon(fluentui_system_icons
                                            .FluentIcons
                                            .serial_port_24_regular),
                                        title: Text("端口"),
                                        trailing: SizedBox(
                                          width: 100,
                                          child: TextBox(
                                            placeholder: "端口",
                                          ),
                                        )));
                              },
                              separatorBuilder: (context, index) =>
                                  const SizedBox(
                                    height: 2,
                                  ))))
                ]),
          )
        : Container(
            color: Colors.white,
            child: ScaffoldPage(
              header: PageHeader(
                leading: IconButton(
                  icon: const Icon(fluentui_system_icons
                      .FluentIcons.arrow_hook_up_left_28_filled),
                  onPressed: () {},
                ),
                title: Text("用户"),
              ),
              content: Column(
                children: [
                  Expanded(
                    child: ListView(),
                  ),
                  BottomNavigation(
                    index: _selected,
                    onChanged: (idx) {
                      setState(() {
                        _selected = idx;
                      });
                    },
                    items: const [
                      BottomNavigationItem(
                          title: Text("相册"),
                          icon: Icon(fluentui_system_icons
                              .FluentIcons.fingerprint_48_regular)),
                      BottomNavigationItem(
                          title: Text("用户"),
                          icon: Icon(fluentui_system_icons
                              .FluentIcons.person_48_regular))
                    ],
                  )
                ],
              ),
            ),
          );
    // Column(
    //         children: [
    //           Expanded(
    //               child: ScaffoldPage(
    //             header: PageHeader(
    //               title: Text("用户"),
    //             ),
    //             content: Container(
    //               color: Colors.white,
    //             ),
    //           )),
    //           BottomNavigation(
    //             index: _selected,
    //             onChanged: (idx) {
    //               setState(() {
    //                 _selected = idx;
    //               });
    //             },
    //             items: const [
    //               BottomNavigationItem(
    //                   title: Text("相册"),
    //                   icon: Icon(fluentui_system_icons
    //                       .FluentIcons.fingerprint_48_regular)),
    //               BottomNavigationItem(
    //                   title: Text("用户"),
    //                   icon: Icon(
    //                       fluentui_system_icons.FluentIcons.person_48_regular))
    //             ],
    //           )
    //         ],
    //       );
  }
}
