-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from SimCoderYoutube/lesson_8/search__for_users…
…_using_a_firestore_query [Add] search for users and profile abstraction
- Loading branch information
Showing
6 changed files
with
176 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class Feed extends StatefulWidget { | ||
Feed({Key key}) : super(key: key); | ||
|
||
@override | ||
FeedState createState() => FeedState(); | ||
} | ||
|
||
class FeedState extends State<Feed> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Text('feed'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:twitter/screens/main/profile/list.dart'; | ||
import 'package:twitter/services/user.dart'; | ||
|
||
class Search extends StatefulWidget { | ||
Search({Key key}) : super(key: key); | ||
|
||
@override | ||
_SearchState createState() => _SearchState(); | ||
} | ||
|
||
class _SearchState extends State<Search> { | ||
UserService _userService = UserService(); | ||
String search = ''; | ||
@override | ||
Widget build(BuildContext context) { | ||
return StreamProvider.value( | ||
value: _userService.queryByName(search), | ||
child: Column( | ||
children: [ | ||
Padding( | ||
padding: EdgeInsets.all(10), | ||
child: TextField( | ||
onChanged: (text) { | ||
setState(() { | ||
search = text; | ||
}); | ||
}, | ||
decoration: InputDecoration(hintText: 'Search...'), | ||
), | ||
), | ||
ListUsers() | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'dart:developer'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:twitter/models/user.dart'; | ||
|
||
class ListUsers extends StatefulWidget { | ||
ListUsers({Key key}) : super(key: key); | ||
|
||
@override | ||
_ListUsersState createState() => _ListUsersState(); | ||
} | ||
|
||
class _ListUsersState extends State<ListUsers> { | ||
@override | ||
Widget build(BuildContext context) { | ||
final users = Provider.of<List<UserModel>>(context) ?? []; | ||
|
||
return ListView.builder( | ||
shrinkWrap: true, | ||
itemCount: users.length, | ||
itemBuilder: (context, index) { | ||
final user = users[index]; | ||
return InkWell( | ||
onTap: () => | ||
Navigator.pushNamed(context, '/profile', arguments: user.id), | ||
child: Column( | ||
children: [ | ||
Padding( | ||
padding: EdgeInsets.all(10), | ||
child: Row(children: [ | ||
user.profileImageUrl != '' | ||
? CircleAvatar( | ||
radius: 20, | ||
backgroundImage: | ||
NetworkImage(user.profileImageUrl), | ||
) | ||
: Icon(Icons.person, size: 40), | ||
SizedBox(width: 10), | ||
Text(user.name) | ||
])), | ||
const Divider( | ||
thickness: 1, | ||
) | ||
], | ||
), | ||
); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters