Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
5.7 KiB

  1. import 'package:flutter/material.dart';
  2. import '/models/friends.dart';
  3. import '/views/main/friend_list_item.dart';
  4. import '/utils/storage/friends.dart';
  5. class FriendList extends StatefulWidget {
  6. const FriendList({Key? key}) : super(key: key);
  7. @override
  8. State<FriendList> createState() => _FriendListState();
  9. }
  10. class _FriendListState extends State<FriendList> {
  11. List<Friend> friends = [];
  12. @override
  13. void initState() {
  14. getFriends();
  15. super.initState();
  16. }
  17. Widget list() {
  18. if (friends.isEmpty) {
  19. return const Center(
  20. child: Text('No Friends'),
  21. );
  22. }
  23. return ListView.builder(
  24. itemCount: friends.length,
  25. shrinkWrap: true,
  26. padding: const EdgeInsets.only(top: 16),
  27. physics: const NeverScrollableScrollPhysics(),
  28. itemBuilder: (context, i) {
  29. return FriendListItem(
  30. id: friends[i].id,
  31. username: 'test',
  32. );
  33. },
  34. );
  35. }
  36. @override
  37. Widget build(BuildContext context) {
  38. return Scaffold(
  39. body: SingleChildScrollView(
  40. physics: const BouncingScrollPhysics(),
  41. child: Column(
  42. crossAxisAlignment: CrossAxisAlignment.start,
  43. children: <Widget>[
  44. SafeArea(
  45. child: Padding(
  46. padding: const EdgeInsets.only(left: 16,right: 16,top: 10),
  47. child: Row(
  48. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  49. children: <Widget>[
  50. const Text("Friends",style: TextStyle(fontSize: 32,fontWeight: FontWeight.bold),),
  51. Container(
  52. padding: const EdgeInsets.only(left: 8,right: 8,top: 2,bottom: 2),
  53. height: 30,
  54. decoration: BoxDecoration(
  55. borderRadius: BorderRadius.circular(30),
  56. color: Colors.pink[50],
  57. ),
  58. child: Row(
  59. children: const <Widget>[
  60. Icon(Icons.add,color: Colors.pink,size: 20,),
  61. SizedBox(width: 2,),
  62. Text("Add",style: TextStyle(fontSize: 14,fontWeight: FontWeight.bold),),
  63. ],
  64. ),
  65. )
  66. ],
  67. ),
  68. ),
  69. ),
  70. Padding(
  71. padding: const EdgeInsets.only(top: 16,left: 16,right: 16),
  72. child: TextField(
  73. decoration: InputDecoration(
  74. hintText: "Search...",
  75. hintStyle: TextStyle(color: Colors.grey.shade600),
  76. prefixIcon: Icon(Icons.search,color: Colors.grey.shade600, size: 20,),
  77. filled: true,
  78. fillColor: Colors.grey.shade100,
  79. contentPadding: const EdgeInsets.all(8),
  80. enabledBorder: OutlineInputBorder(
  81. borderRadius: BorderRadius.circular(20),
  82. borderSide: BorderSide(
  83. color: Colors.grey.shade100
  84. )
  85. ),
  86. ),
  87. ),
  88. ),
  89. Padding(
  90. padding: const EdgeInsets.only(top: 16,left: 16,right: 16),
  91. child: list(),
  92. ),
  93. ],
  94. ),
  95. ),
  96. );
  97. }
  98. }