import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:prime_chat/screens/components/Images.dart';

import 'SearchScreen.dart';
import 'components/RightClickPop.dart';

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

  @override
  State<StatefulWidget> createState() => _NewFriendScreenState();
}

class _NewFriendScreenState extends State<NewFriendScreen> {
  @override
  Widget build(BuildContext context) {
    return rightClickPop(
      child: buildScreen(context),
      context: context,
      canPop: true,
    );
  }

  buildScreen(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('新的朋友'),
        ),
        body: ListView.builder(
            itemCount: 1,
            itemBuilder: (context, index) {
              if (index == 0) return _buildHeader(context);
              return const Placeholder();
            }));
  }

  Widget _buildHeader(BuildContext context) {
    final theme = Theme.of(context);
    return Container(
      height: 60,
      color: theme.appBarTheme.backgroundColor,
      child: _buildSearchBar(context),
    );
  }

  _buildSearchBar(context) {
    final child = Container(
      margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
      padding: const EdgeInsets.all(5),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(6.0),
      ),
      child: Center(
          child: FittedBox(
              child: Row(
                children: const [
                  Icon(Icons.search, color: Colors.grey,),
                  Text(
                    "用户名",
                    style: TextStyle(color: Colors.grey),
                  )
                ],
              ))),
    );
    return GestureDetector(
      onTap: () =>
          Navigator.push(
              context,
              MaterialPageRoute(builder: (context) => const SearchScreen())),
      child: child,
    );
  }

  void _search(String value) {
    debugPrint("搜索好友 $value");
  }
}
