Skip to content

Commit 1e61e22

Browse files
committed
Fixed some bugs in displaying movie images
1 parent 1be6b8e commit 1e61e22

File tree

6 files changed

+44
-30
lines changed

6 files changed

+44
-30
lines changed

README.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,2 @@
1-
# megaflixz
1+
# Megaflixz
22

3-
A new Flutter project.
4-
5-
## Getting Started
6-
7-
This project is a starting point for a Flutter application.
8-
9-
A few resources to get you started if this is your first Flutter project:
10-
11-
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12-
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13-
14-
For help getting started with Flutter, view our
15-
[online documentation](https://flutter.dev/docs), which offers tutorials,
16-
samples, guidance on mobile development, and a full API reference.

lib/models/movie.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ class MovieModel {
2222
});
2323

2424
factory MovieModel.fromJson(Map<String, dynamic> parsedJson) {
25+
print(parsedJson['original_title']);
26+
print(parsedJson['poster_path']);
27+
2528
return MovieModel(
2629
title: parsedJson['original_title'],
2730
overview: parsedJson['overview'],
28-
imgPath: parsedJson['poster_path']);
31+
imgPath:
32+
parsedJson['poster_path'] ?? '/q719jXXEzOoYaps6babgKnONONX.jpg');
2933
}
3034
}

lib/screens/homepage.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class _HomePageState extends State<HomePage> {
3232
padding: EdgeInsets.all(16.0),
3333
itemCount: moviesLists.length,
3434
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
35-
mainAxisSpacing: 15,
35+
mainAxisSpacing: 5,
3636
crossAxisSpacing: 15,
3737
crossAxisCount: 2,
38-
childAspectRatio: 8 / 12),
38+
childAspectRatio: 7.5 / 12),
3939
itemBuilder: (BuildContext context, int index) {
4040
return MovieCard(movieModel: moviesLists[index]);
4141
});

lib/screens/movie_display.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ class _MovieDisplayState extends State<MovieDisplay> {
2828
body: FutureBuilder(
2929
future: MovieGenre(genreId: widget.genreid).getData(),
3030
builder: (BuildContext context, AsyncSnapshot snapshot) {
31-
if (!snapshot.hasData) return Center(child: CircularProgressIndicator());
31+
if (!snapshot.hasData)
32+
return Center(child: CircularProgressIndicator());
3233
moviesLists = snapshot.data.movieList;
3334
return GridView.builder(
3435
padding: EdgeInsets.all(16.0),
3536
itemCount: moviesLists.length,
3637
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
37-
mainAxisSpacing: 15,
38+
mainAxisSpacing: 5,
3839
crossAxisSpacing: 15,
3940
crossAxisCount: 2,
40-
childAspectRatio: 8 / 12),
41+
childAspectRatio: 7.5 / 12),
4142
itemBuilder: (BuildContext context, int index) {
4243
return MovieCard(movieModel: moviesLists[index]);
4344
});

lib/screens/widgets/drawer.dart

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:megaflixz/data/genre_api.dart';
33
import 'package:megaflixz/models/genres.dart';
4+
import 'package:megaflixz/screens/homepage.dart';
45
import 'package:megaflixz/screens/movie_display.dart';
56

67
class DrawerWid extends StatefulWidget {
@@ -23,7 +24,27 @@ class _DrawerWidState extends State<DrawerWid> {
2324
'GENRES',
2425
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22),
2526
),
26-
SizedBox(height: 30),
27+
GestureDetector(
28+
onTap: () {
29+
Navigator.of(context)
30+
.push(MaterialPageRoute(builder: (ctxt) => HomePage()));
31+
},
32+
child: Column(
33+
children: [
34+
SizedBox(height: 30),
35+
Text(
36+
'Trending',
37+
style: TextStyle(fontSize: 16),
38+
),
39+
SizedBox(height: 20),
40+
Divider(
41+
thickness: 1,
42+
indent: 20,
43+
endIndent: 20,
44+
),
45+
],
46+
),
47+
),
2748
Expanded(
2849
child: FutureBuilder(
2950
future: GenreApi().getData(),
@@ -38,6 +59,7 @@ class _DrawerWidState extends State<DrawerWid> {
3859
itemCount: genre.length,
3960
itemBuilder: (context, index) {
4061
return GestureDetector(
62+
behavior: HitTestBehavior.opaque,
4163
onTap: () {
4264
Navigator.of(context).push(MaterialPageRoute(
4365
builder: (ctxt) => MovieDisplay(

lib/screens/widgets/movie_card.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ class MovieCard extends StatelessWidget {
1313
Widget build(BuildContext context) {
1414
return Container(
1515
// padding: EdgeInsets.all(16.0),
16-
// height: 200,
17-
decoration: BoxDecoration(
18-
// color: Colors.orange,
19-
borderRadius: BorderRadius.circular(16.0),
20-
),
16+
// height: 300,
17+
// decoration: BoxDecoration(
18+
// // color: Colors.orange,
19+
// borderRadius: BorderRadius.circular(16.0),
20+
// ),
2121
child: Column(
2222
children: [
2323
ClipRRect(
@@ -29,13 +29,14 @@ class MovieCard extends StatelessWidget {
2929
),
3030
),
3131
Padding(
32-
padding: const EdgeInsets.symmetric(horizontal: 16),
32+
padding: const EdgeInsets.fromLTRB(10.0, 4.0, 0, 0),
3333
child: Text(
3434
movieModel.title,
35+
maxLines: 2,
3536
overflow: TextOverflow.ellipsis,
36-
style: TextStyle(fontSize: 12),
37+
style: TextStyle(fontSize: 14),
3738
),
38-
)
39+
),
3940
],
4041
),
4142
);

0 commit comments

Comments
 (0)