Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
movie_app_flutter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ernanda
movie_app_flutter
Commits
4dbe4b83
Commit
4dbe4b83
authored
Feb 16, 2022
by
valdi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
detail, rating, nav bottom
parent
aece6873
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
450 additions
and
242 deletions
+450
-242
config.dart
lib/config.dart
+5
-0
main.dart
lib/main.dart
+9
-173
main_page.dart
lib/main_page.dart
+116
-55
movie_detail_api.dart
lib/models/movie_detail_api.dart
+30
-0
movie_detail_arg.dart
lib/models/movie_detail_arg.dart
+6
-0
movie_detail.dart
lib/movie_detail.dart
+272
-1
pubspec.lock
pubspec.lock
+8
-0
pubspec.yaml
pubspec.yaml
+4
-13
No files found.
lib/config.dart
0 → 100644
View file @
4dbe4b83
import
'package:flutter/material.dart'
;
const
Color
backgroundColor
=
Color
.
fromRGBO
(
7
,
13
,
45
,
100
);
const
Color
textColor
=
Color
(
0xFFD2D3D8
);
const
String
apiKey
=
"0a9b845116028881ddaaec631f987469"
;
lib/main.dart
View file @
4dbe4b83
...
...
@@ -3,193 +3,29 @@ import 'dart:async';
import
'package:flutter/material.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:movie_app/main_page.dart'
;
import
'package:movie_app/movie_detail.dart'
;
void
main
(
)
{
runApp
(
const
MyApp
());
runApp
(
MyApp
());
}
class
MyApp
extends
StatefulWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
@override
_MyAppState
createState
()
=>
_MyAppState
();
}
class
_MyAppState
extends
State
<
MyApp
>
{
var
_Popular
=
[];
var
_nowPlaying
=
[];
void
GetPopular
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
"https://api.themoviedb.org/3/movie/popular?api_key=0a9b845116028881ddaaec631f987469&language=en-US&page=1"
));
var
jsonObject
=
jsonDecode
(
response
.
body
);
List
<
dynamic
>
listPopular
=
(
jsonObject
as
Map
<
String
,
dynamic
>)[
'results'
];
setState
(()
{
_Popular
=
listPopular
;
});
}
void
GetNowPlaying
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
"https://api.themoviedb.org/3/movie/now_playing?api_key=0a9b845116028881ddaaec631f987469&language=en-US&page=1"
));
var
jsonObject
=
jsonDecode
(
response
.
body
);
List
<
dynamic
>
listNowPlaying
=
(
jsonObject
as
Map
<
String
,
dynamic
>)[
'results'
];
setState
(()
{
_nowPlaying
=
listNowPlaying
;
});
}
@override
void
initState
()
{
// TODO: implement initState
super
.
initState
();
GetPopular
();
GetNowPlaying
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
home:
Scaffold
(
backgroundColor:
Color
.
fromRGBO
(
7
,
13
,
45
,
100
),
body:
Container
(
margin:
EdgeInsets
.
fromLTRB
(
15
,
40
,
15
,
30
),
child:
Column
(
children:
<
Widget
>[
Container
(
child:
TextFormField
(
textAlign:
TextAlign
.
left
,
style:
TextStyle
(
fontSize:
12.0
,
color:
Colors
.
white30
),
decoration:
InputDecoration
(
contentPadding:
new
EdgeInsets
.
symmetric
(
vertical:
0.0
),
prefixIcon:
Padding
(
padding:
EdgeInsets
.
all
(
0.0
),
child:
Icon
(
Icons
.
search
,
color:
Colors
.
grey
,
),
),
hintText:
"Search movie"
,
hintStyle:
TextStyle
(
fontSize:
12.0
,
height:
3
,
color:
Colors
.
white30
),
),
),
),
Container
(
child:
Container
(
margin:
EdgeInsets
.
fromLTRB
(
15
,
30
,
15
,
0
),
child:
Row
(
children:
<
Widget
>[
Text
(
"Popular"
,
style:
TextStyle
(
color:
Colors
.
white
),
),
],
),
),
),
Flexible
(
flex:
1
,
child:
new
ListView
(
children:
<
Widget
>[
new
Container
(
height:
265.0
,
child:
new
ListView
(
scrollDirection:
Axis
.
horizontal
,
children:
<
Widget
>[
for
(
int
i
=
0
;
i
<
_Popular
.
length
;
i
++)
CardPopular
(
"https://image.tmdb.org/t/p/w500"
+
_Popular
[
i
][
'poster_path'
],
_Popular
[
i
][
'title'
],
_Popular
[
i
][
'vote_average'
].
toString
()),
],
),
),
],
),
),
Container
(
child:
Container
(
margin:
EdgeInsets
.
fromLTRB
(
15
,
30
,
15
,
0
),
child:
Row
(
children:
[
Text
(
"Now Playing"
,
style:
TextStyle
(
color:
Colors
.
white
),
),
],
),
),
),
Flexible
(
flex:
1
,
child:
new
ListView
(
children:
<
Widget
>[
new
Container
(
height:
265.0
,
child:
new
ListView
(
scrollDirection:
Axis
.
horizontal
,
children:
<
Widget
>[
for
(
int
i
=
0
;
i
<
_nowPlaying
.
length
;
i
++)
CardPopular
(
"https://image.tmdb.org/t/p/w500"
+
_nowPlaying
[
i
][
'poster_path'
],
_nowPlaying
[
i
][
'title'
],
_nowPlaying
[
i
][
'vote_average'
].
toString
()),
],
),
),
],
),
),
],
),
),
),
debugShowCheckedModeBanner:
false
,
);
}
Widget
CardPopular
(
String
image
,
String
title
,
String
rating
)
{
return
GestureDetector
(
onTap:
()
{
print
(
"Test"
);
initialRoute:
'/'
,
routes:
{
'/'
:
(
context
)
=>
MainPage
(),
'/detail'
:
(
context
)
=>
MovieDetail
(
ModalRoute
.
of
(
context
)!.
settings
.
arguments
as
String
),
},
child:
Container
(
margin:
EdgeInsets
.
all
(
15.0
),
child:
new
ClipRRect
(
// borderRadius: new BorderRadius.circular(10.0),
child:
Column
(
children:
[
new
Image
(
image:
new
NetworkImage
(
image
),
height:
200.0
,
width:
120.0
,
fit:
BoxFit
.
cover
,
),
Container
(
width:
120
,
child:
Text
(
title
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
color:
Colors
.
white
,
overflow:
TextOverflow
.
ellipsis
),
),
),
Text
(
rating
,
style:
TextStyle
(
color:
Colors
.
white
),
),
],
),
),
),
debugShowCheckedModeBanner:
false
,
);
}
}
lib/main_page.dart
View file @
4dbe4b83
import
'dart:convert'
;
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:movie_app/config.dart'
;
import
'package:movie_app/main.dart'
;
class
MainPage
extends
StatefulWidget
{
...
...
@@ -49,27 +55,53 @@ class _MainPageState extends State<MainPage> {
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
home:
Scaffold
(
backgroundColor:
Color
.
fromRGBO
(
7
,
13
,
45
,
100
)
,
backgroundColor:
backgroundColor
,
body:
Container
(
margin:
EdgeInsets
.
fromLTRB
(
15
,
40
,
15
,
30
),
child:
Column
(
child:
ListView
(
children:
<
Widget
>[
Container
(
child:
TextFormField
(
textAlign:
TextAlign
.
left
,
style:
TextStyle
(
fontSize:
12.0
,
color:
Colors
.
white30
),
decoration:
InputDecoration
(
contentPadding:
new
EdgeInsets
.
symmetric
(
vertical:
0.0
),
prefixIcon:
Padding
(
padding:
EdgeInsets
.
all
(
0.0
),
Padding
(
padding:
const
EdgeInsets
.
all
(
10.0
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Text
(
"Hi, Bagus Rivaldi"
,
style:
TextStyle
(
color:
textColor
,
fontSize:
20
,
fontWeight:
FontWeight
.
w800
),
),
ClipRRect
(
child:
Icon
(
Icons
.
search
,
color:
Colors
.
grey
,
Icons
.
person
,
color:
textColor
,
size:
30
,
),
)
],
),
),
hintText:
"Search movie"
,
hintStyle:
TextStyle
(
fontSize:
12.0
,
height:
3
,
color:
Colors
.
white30
),
Align
(
alignment:
Alignment
.
center
,
child:
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
transparent
,
border:
Border
.
all
(
color:
Colors
.
grey
),
borderRadius:
BorderRadius
.
circular
(
20
)),
margin:
EdgeInsets
.
fromLTRB
(
10
,
30
,
10
,
30
),
padding:
EdgeInsets
.
fromLTRB
(
10
,
5
,
5
,
5
),
// ignore: prefer_const_constructors
child:
TextField
(
style:
TextStyle
(
color:
Color
(
0xFFD2D3D8
)),
decoration:
InputDecoration
(
border:
InputBorder
.
none
,
icon:
Icon
(
Icons
.
search
,
color:
Colors
.
white30
,
),
labelText:
"Search Movie"
,
labelStyle:
TextStyle
(
color:
Colors
.
white30
)),
),
),
),
...
...
@@ -82,77 +114,106 @@ class _MainPageState extends State<MainPage> {
"Popular"
,
style:
TextStyle
(
color:
Colors
.
white
),
),
Spacer
(),
Text
(
"See more"
,
style:
TextStyle
(
fontSize:
10
,
color:
Colors
.
white
,
fontWeight:
FontWeight
.
w500
),
),
],
),
),
),
Flexible
(
flex:
1
,
child:
new
ListView
(
children:
<
Widget
>[
new
Container
(
height:
265.0
,
child:
new
ListView
(
Container
(
margin:
EdgeInsets
.
fromLTRB
(
15
,
15
,
15
,
0
),
height:
300
,
child:
ListView
(
scrollDirection:
Axis
.
horizontal
,
children:
<
Widget
>
[
children:
[
for
(
int
i
=
0
;
i
<
_Popular
.
length
;
i
++)
CardPopular
(
"https://image.tmdb.org/t/p/w500"
+
_Popular
[
i
][
'poster_path'
],
_Popular
[
i
][
'title'
],
_Popular
[
i
][
'vote_average'
].
toString
()),
],
),
),
_Popular
[
i
][
'vote_average'
].
toString
(),
_Popular
[
i
][
'id'
].
toString
()),
],
),
),
Container
(
child:
Container
(
margin:
EdgeInsets
.
fromLTRB
(
15
,
3
0
,
15
,
0
),
margin:
EdgeInsets
.
fromLTRB
(
15
,
0
,
15
,
0
),
child:
Row
(
children:
[
Text
(
"Now Playing"
,
style:
TextStyle
(
color:
Colors
.
white
),
),
Spacer
(),
Text
(
"See more"
,
style:
TextStyle
(
fontSize:
10
,
color:
Colors
.
white
,
fontWeight:
FontWeight
.
w500
),
),
],
),
),
),
Flexible
(
flex:
1
,
child:
new
ListView
(
children:
<
Widget
>[
new
Container
(
height:
265.0
,
child:
new
ListView
(
Container
(
margin:
EdgeInsets
.
fromLTRB
(
15
,
15
,
15
,
0
),
height:
300
,
child:
ListView
(
scrollDirection:
Axis
.
horizontal
,
children:
<
Widget
>
[
children:
[
for
(
int
i
=
0
;
i
<
_nowPlaying
.
length
;
i
++)
CardPopular
(
"https://image.tmdb.org/t/p/w500"
+
_nowPlaying
[
i
][
'poster_path'
],
_nowPlaying
[
i
][
'title'
],
_nowPlaying
[
i
][
'vote_average'
].
toString
()),
_nowPlaying
[
i
][
'vote_average'
].
toString
(),
_nowPlaying
[
i
][
'id'
].
toString
()),
],
),
),
],
),
),
],
bottomNavigationBar:
BottomNavigationBar
(
items:
[
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
home
),
label:
'Home'
,
backgroundColor:
Colors
.
lightBlue
,
),
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
explore
),
label:
'Explore'
,
backgroundColor:
Colors
.
lightBlue
,
),
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
person
),
label:
'Account'
,
backgroundColor:
Colors
.
lightBlue
,
),
],
),
),
debugShowCheckedModeBanner:
false
,
);
}
Widget
CardPopular
(
String
image
,
String
title
,
String
rating
)
{
Widget
CardPopular
(
String
image
,
String
title
,
String
rating
,
String
id
)
{
return
GestureDetector
(
onTap:
()
{
print
(
"Test"
);
Navigator
.
pushNamed
(
context
,
'/detail'
,
arguments:
id
,
);
},
child:
Container
(
margin:
EdgeInsets
.
all
(
15.0
),
...
...
lib/models/movie_detail_api.dart
0 → 100644
View file @
4dbe4b83
class
movieDetail
{
final
String
title
;
final
String
poster_path
;
final
String
overview
;
final
double
vote_average
;
List
<
dynamic
>
genre
=
[];
movieDetail
(
this
.
title
,
this
.
poster_path
,
this
.
overview
,
this
.
vote_average
,
this
.
genre
);
factory
movieDetail
.
fromJson
(
dynamic
json
)
{
var
nameGenre
=
[];
for
(
int
i
=
0
;
i
<
json
[
'genres'
].
length
;
i
++)
{
print
(
json
[
'genres'
][
i
][
'name'
]);
var
genreName
=
''
;
if
(
json
[
'genres'
][
i
][
'name'
]
==
null
)
{
genreName
=
'Thriller'
;
}
else
{
genreName
=
json
[
'genres'
][
i
][
'name'
];
}
nameGenre
.
add
(
genreName
);
}
return
movieDetail
(
json
[
'title'
]
as
String
,
json
[
'poster_path'
]
as
String
,
json
[
'overview'
]
as
String
,
json
[
'vote_average'
]
as
double
,
nameGenre
as
List
<
dynamic
>);
}
}
lib/models/movie_detail_arg.dart
0 → 100644
View file @
4dbe4b83
class
ScreenArguments
{
final
String
id
;
final
String
image
;
ScreenArguments
(
this
.
id
,
this
.
image
);
}
lib/movie_detail.dart
View file @
4dbe4b83
This diff is collapsed.
Click to expand it.
pubspec.lock
View file @
4dbe4b83
...
...
@@ -69,6 +69,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_rating_bar:
dependency: "direct main"
description:
name: flutter_rating_bar
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
...
...
@@ -186,3 +193,4 @@ packages:
version: "2.1.1"
sdks:
dart: ">=2.16.1 <3.0.0"
flutter: ">=1.12.13+hotfix.5"
pubspec.yaml
View file @
4dbe4b83
...
...
@@ -27,19 +27,13 @@ environment:
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies
:
cupertino_icons
:
^1.0.2
flutter
:
sdk
:
flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons
:
^1.0.2
flutter_rating_bar
:
^4.0.0
http
:
^0.13.4
dev_dependencies
:
flutter_test
:
sdk
:
flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
...
...
@@ -47,10 +41,11 @@ dev_dependencies:
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints
:
^1.0.0
flutter_test
:
sdk
:
flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter
:
...
...
@@ -58,18 +53,14 @@ flutter:
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design
:
true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment