-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
835 additions
and
192 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
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,34 @@ | ||
import 'package:flutter/foundation.dart'; | ||
|
||
class Movie_model { | ||
late int id; | ||
late double populartiy; | ||
late String title; | ||
late String posterPath; | ||
late bool adult; | ||
late String backDropPath; | ||
late String overview; | ||
late String language; | ||
late double rating; | ||
late String date; | ||
Movie_model({ required this.id,required this.populartiy,required this.title,required this.posterPath,required this.adult,required this.backDropPath,required this.overview, | ||
required this.language,required this.rating ,required this.date}); | ||
factory Movie_model.fromMap(Map<String,dynamic> map) | ||
{ | ||
return Movie_model(id:map['id'],populartiy: map['popularity'],title: map['title'], posterPath: map['poster_path'], adult: map['adult'], backDropPath: map['backdrop_path'], overview: map['overview'], language: map['original_language'], rating: map['vote_average'], date: map['release_date']); | ||
} | ||
Map<String,dynamic> toMap(){ | ||
return { | ||
'id':id, | ||
'popularity':populartiy, | ||
'title':title, | ||
'poster_path':posterPath, | ||
'adult':adult, | ||
'backdrop_path':backDropPath, | ||
'overview':overview, | ||
'original_language':language, | ||
'vote_average':rating, | ||
'release_date':date | ||
}; | ||
} | ||
} |
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,133 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:google_fonts/google_fonts.dart'; | ||
import 'package:movie_app/services/Database%20helper.dart'; | ||
|
||
class fav_screen extends StatefulWidget { | ||
@override | ||
State<fav_screen> createState() => _fav_screenState(); | ||
} | ||
|
||
class _fav_screenState extends State<fav_screen> { | ||
@override | ||
void initState() { | ||
super.initState(); | ||
_loadFavorites(); | ||
Database_helper.instance.favoriteNotifier.addListener(_onFavoritesChanged); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
Database_helper.instance.favoriteNotifier | ||
.removeListener(_onFavoritesChanged); | ||
super.dispose(); | ||
} | ||
|
||
void _onFavoritesChanged() { | ||
if (mounted) { | ||
_loadFavorites(); | ||
} | ||
} | ||
|
||
Future<void> _loadFavorites() async { | ||
movies = | ||
await Database_helper.instance.getDataFromDatabase(Database_helper.db); | ||
if (mounted) { | ||
setState(() { | ||
movies = movies; | ||
}); | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
backgroundColor: Colors.black, | ||
appBar: AppBar( | ||
elevation: 0, | ||
backgroundColor: Colors.black, | ||
title: Text( | ||
"My List ", | ||
style: GoogleFonts.montserrat( | ||
fontSize: 22, | ||
fontWeight: FontWeight.bold, | ||
fontStyle: FontStyle.italic, | ||
color: Colors.white, | ||
), | ||
), | ||
), | ||
body: ListView.builder( | ||
itemCount: movies.length, | ||
itemBuilder: (context, index) => Padding( | ||
padding: const EdgeInsets.only(top: 10,bottom: 10,left: 7), | ||
child: Row( | ||
children: [ | ||
Expanded( | ||
child: Container( | ||
//margin: EdgeInsets.symmetric(horizontal: 5), | ||
decoration: BoxDecoration( | ||
color: Colors.white, | ||
borderRadius: BorderRadius.circular(15) | ||
), | ||
child: ClipRRect( | ||
borderRadius: BorderRadius.circular(15), | ||
child:Image.network( | ||
"https://image.tmdb.org/t/p/original/${movies[index]['image']}", | ||
height: 100, | ||
width: double.infinity, | ||
fit: BoxFit.cover,) , | ||
), | ||
), | ||
), | ||
Expanded( | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 12.0), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
movies[index]['title'], | ||
//overflow: TextOverflow.ellipsis, | ||
style: GoogleFonts.montserrat( | ||
fontSize: 15, | ||
fontWeight: FontWeight.bold, | ||
fontStyle: FontStyle.italic, | ||
color: Colors.white, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
IconButton( | ||
icon: Icon( | ||
Icons.delete, | ||
color: Colors.white, | ||
), | ||
onPressed: () async { | ||
await Database_helper.instance | ||
.deleteFromDatabase(movies[index]['id']); | ||
_loadFavorites(); | ||
}, | ||
), | ||
], | ||
)), | ||
), | ||
); | ||
} | ||
} | ||
// ListTile( | ||
// leading: Image.network("https://image.tmdb.org/t/p/original/${movies[index]['image']}",), | ||
// title: Text(movies[index]['title'],style: GoogleFonts.montserrat( | ||
// fontSize: 20, | ||
// fontWeight: FontWeight.bold, | ||
// fontStyle: FontStyle.italic, | ||
// color: Colors.white, | ||
// ),), | ||
// trailing: IconButton( | ||
// icon: Icon(Icons.delete,color: Colors.white,), | ||
// onPressed: () async{ | ||
// await Database_helper.instance.deleteFromDatabase(movies[index]['id']); | ||
// _loadFavorites(); | ||
// }, | ||
// ),),${movies[index]['image']} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.