NewFriendScreen.dart 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_svg/flutter_svg.dart';
  4. import 'package:prime_chat/screens/components/Images.dart';
  5. import 'SearchScreen.dart';
  6. import 'components/RightClickPop.dart';
  7. class NewFriendScreen extends StatefulWidget {
  8. const NewFriendScreen({Key? key}) : super(key: key);
  9. @override
  10. State<StatefulWidget> createState() => _NewFriendScreenState();
  11. }
  12. class _NewFriendScreenState extends State<NewFriendScreen> {
  13. @override
  14. Widget build(BuildContext context) {
  15. return rightClickPop(
  16. child: buildScreen(context),
  17. context: context,
  18. canPop: true,
  19. );
  20. }
  21. buildScreen(BuildContext context) {
  22. return Scaffold(
  23. appBar: AppBar(
  24. title: const Text('新的朋友'),
  25. ),
  26. body: ListView.builder(
  27. itemCount: 1,
  28. itemBuilder: (context, index) {
  29. if (index == 0) return _buildHeader(context);
  30. return const Placeholder();
  31. }));
  32. }
  33. Widget _buildHeader(BuildContext context) {
  34. final theme = Theme.of(context);
  35. return Container(
  36. height: 60,
  37. color: theme.appBarTheme.backgroundColor,
  38. child: _buildSearchBar(context),
  39. );
  40. }
  41. _buildSearchBar(context) {
  42. final child = Container(
  43. margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
  44. padding: const EdgeInsets.all(5),
  45. decoration: BoxDecoration(
  46. color: Colors.white,
  47. borderRadius: BorderRadius.circular(6.0),
  48. ),
  49. child: Center(
  50. child: FittedBox(
  51. child: Row(
  52. children: const [
  53. Icon(Icons.search, color: Colors.grey,),
  54. Text(
  55. "用户名",
  56. style: TextStyle(color: Colors.grey),
  57. )
  58. ],
  59. ))),
  60. );
  61. return GestureDetector(
  62. onTap: () =>
  63. Navigator.push(
  64. context,
  65. MaterialPageRoute(builder: (context) => const SearchScreen())),
  66. child: child,
  67. );
  68. }
  69. void _search(String value) {
  70. debugPrint("搜索好友 $value");
  71. }
  72. }