Ways to like a movie either tapping the 'Heart' icon or Double tapping the banner
toggleLike() {
liked = !liked;
if (liked) {
movieService.onMovieLiked(widget.movie);
} else {
movieService.onMovieRemoveLiked(widget.movie);
}
}
toggleDislike() {
disliked = !disliked;
if (disliked) {
movieService.onMovieDisliked(widget.movie);
} else {
movieService.onMovieRemoveDisliked(widget.movie);
}
}
Each Genre takes you to a variety of movies to chose from belonging to that particular Genre, as shown in video. The user can then select movies they like and dislike accordingly.
class GenreMoviesScreen extends StatefulWidget {
final String genre;
const GenreMoviesScreen({Key key, @required this.genre})
: super(key: key);
@override
_GenreMoviesScreenState createState() => _GenreMoviesScreenState();
}
class _GenreMoviesScreenState extends State<GenreMoviesScreen> {
List<Widget> movieList = [];
@override
Widget build(BuildContext context) {
final genreMovieListService = GenreMoviesListService(genre: widget.genre);
return StreamBuilder<List<Movie>>(
stream: genreMovieListService.movies,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Container(
child: Center(
child: CircularProgressIndicator(),
),
);
}
snapshot.data.forEach((movie) {
movieList.add(MovieTile(movie: movie));
});
return Scaffold(
appBar: AppBar(
title: Text(widget.genre),
),
body: ListView(
children: movieList,
)
);
});
}
}
Keep track of movies you like and dislike, and edit them at any time from the 'My Movies' page.
class LikedMovieTile extends StatelessWidget {
final String movieName;
final String posterURL;
final String movieId;
const LikedMovieTile({Key key, this.movieName, this.posterURL, this.movieId})
: super(key: key);
@override
Widget build(BuildContext context) {
return ListTile(
onLongPress: () => MovieService().onMovieRemoveLikedViaUid(movieId),
contentPadding: EdgeInsets.fromLTRB(40, 10, 20, 10),
leading: Image(
image: NetworkImage(posterURL ?? ''),
fit: BoxFit.cover,
),
title: Text(movieName),
trailing: Icon(
FontAwesomeIcons.solidHeart,
color: Colors.redAccent,
),
);
}
Widget disLikedMovieTile(
{String movieName, String posterURL, String movieId}) {
return ListTile(
onLongPress: () => MovieService().onMovieRemoveDislikedViaUid(movieId),
contentPadding: EdgeInsets.fromLTRB(40, 10, 20, 10),
leading: Image(
image: NetworkImage(posterURL ?? ''),
fit: BoxFit.cover,
),
title: Text(movieName),
trailing: Icon(
FontAwesomeIcons.solidThumbsDown,
color: Colors.blue,
),
);
}
}
The unique feature of this chat, is that messages are sent in real time as they are being typed. Unlike the normal messenger when one has to wait in anticipation of what the 'Typing...' bears.
Working shown in DEMO
Future<Stream<QuerySnapshot>> getChatRoomMessages(chatRoomId) async {
return FirebaseFirestore.instance
.collection("chatrooms")
.doc(chatRoomId)
.collection("chats")
.orderBy("ts", descending: true)
.snapshots();
}
Future<Stream<QuerySnapshot>> getChatRooms() async {
String myUsername = await SharedPreferenceHelper().getUserName();
return FirebaseFirestore.instance
.collection("chatrooms")
.orderBy("lastMessageSendTs", descending: true)
.where("users", arrayContains: myUsername)
.snapshots();
}
The primary feature of the app. Upon pressing the "Match" button, both user are shown the common movies they like and a percentage of how much their preferences match. This is calculated by:
[(no. Common liked movies) / (greater count of liked movies)] *100
Future<double> getMatchPercentage(String username1, String username2) async {
List<LikedMovie> commonLikedMovies = [];
String user1uid, user2uid;
double matchPercentage = 0;
QuerySnapshot user1Snapshot =
await userCollection.where('username', isEqualTo: username1).get();
QuerySnapshot user2Snapshot =
await userCollection.where('username', isEqualTo: username2).get();
user1uid = user1Snapshot.docs[0].id;
user2uid = user2Snapshot.docs[0].id;
QuerySnapshot user1LikedMoviesSnapshot =
await userCollection.doc(user1uid).collection('likedMovies').get();
QuerySnapshot user2LikedMoviesSnapshot =
await userCollection.doc(user2uid).collection('likedMovies').get();
List<LikedMovie> user1LikedMovies =
MovieService().likedMoviesFromSnapshot(user1LikedMoviesSnapshot);
List<LikedMovie> user2LikedMovies =
MovieService().likedMoviesFromSnapshot(user2LikedMoviesSnapshot);
user1LikedMovies.forEach((user1movie) {
user2LikedMovies.forEach((user2movie) {
if (user1movie.movieName == user2movie.movieName) {
commonLikedMovies.add(user2movie);
}
});
});
if (user1LikedMovies.length > user2LikedMovies.length)
return matchPercentage =
(commonLikedMovies.length / user1LikedMovies.length) * 100;
else
return matchPercentage =
(commonLikedMovies.length / user2LikedMovies.length) * 100;
}