Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
Movie-app
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
Dio Maulana
Movie-app
Commits
0b4af86c
Commit
0b4af86c
authored
Feb 16, 2022
by
Dio Maulana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
detail done
parent
bc917573
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
256 additions
and
73 deletions
+256
-73
main.dart
lib/main.dart
+17
-1
movie_detail_api.dart
lib/models/movie_detail_api.dart
+30
-0
movie_detail_arg.dart
lib/models/movie_detail_arg.dart
+6
-0
terserah.dart
lib/models/terserah.dart
+57
-0
main_page.dart
lib/pages/main_page.dart
+5
-0
movie_detail.dart
lib/pages/movie_detail.dart
+132
-66
pubspec.lock
pubspec.lock
+8
-0
pubspec.yaml
pubspec.yaml
+1
-6
No files found.
lib/main.dart
View file @
0b4af86c
...
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
...
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import
'package:movie_app/pages/main_page.dart'
;
import
'package:movie_app/pages/main_page.dart'
;
import
'package:movie_app/pages/movie_detail.dart'
;
import
'package:movie_app/pages/movie_detail.dart'
;
import
'models/movie_detail_arg.dart'
;
void
main
(
)
{
void
main
(
)
{
runApp
(
MyApp
());
runApp
(
MyApp
());
}
}
...
@@ -15,10 +17,24 @@ class _MyAppState extends State<MyApp> {
...
@@ -15,10 +17,24 @@ class _MyAppState extends State<MyApp> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
return
MaterialApp
(
// onGenerateRoute: (settings) {
// if (settings.name == '/detail') {
// final args = settings.arguments.toString();
// return PageRouteBuilder(
// settings: settings,
// pageBuilder: (_, __, ___) => detailMovie(args),
// transitionsBuilder: (_, a, __, c) => FadeTransition(
// opacity: a,
// child: c,
// ));
// }
// },
initialRoute:
'/'
,
initialRoute:
'/'
,
routes:
{
routes:
{
'/'
:
(
context
)
=>
MainPages
(),
'/'
:
(
context
)
=>
MainPages
(),
'/detail'
:
(
context
)
=>
detailMovie
(),
'/detail'
:
(
context
)
=>
detailMovie
(
// ModalRoute.of(context)!.settings.arguments as ScreenArguments),
ModalRoute
.
of
(
context
)!.
settings
.
arguments
as
String
),
},
},
);
);
}
}
...
...
lib/models/movie_detail_api.dart
0 → 100644
View file @
0b4af86c
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 @
0b4af86c
class
ScreenArguments
{
final
String
id
;
final
String
image
;
ScreenArguments
(
this
.
id
,
this
.
image
);
}
lib/models/terserah.dart
0 → 100644
View file @
0b4af86c
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
MyApp
());
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
static
const
String
_title
=
'Flutter Code Sample'
;
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
_title
,
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
_title
)),
body:
const
MyStatelessWidget
(),
),
);
}
}
class
MyStatelessWidget
extends
StatelessWidget
{
const
MyStatelessWidget
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
Center
(
child:
ElevatedButton
(
child:
const
Text
(
'showModalBottomSheet'
),
onPressed:
()
{
showModalBottomSheet
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
{
return
Container
(
height:
200
,
color:
Colors
.
amber
,
child:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
const
Text
(
'Modal BottomSheet'
),
ElevatedButton
(
child:
const
Text
(
'Close BottomSheet'
),
onPressed:
()
=>
Navigator
.
pop
(
context
),
)
],
),
),
);
},
);
},
),
);
}
}
lib/pages/main_page.dart
View file @
0b4af86c
...
@@ -6,6 +6,7 @@ import 'package:http/http.dart' as http;
...
@@ -6,6 +6,7 @@ import 'package:http/http.dart' as http;
import
'package:movie_app/pages/movie_detail.dart'
;
import
'package:movie_app/pages/movie_detail.dart'
;
import
'../config.dart'
;
import
'../config.dart'
;
// import '../models/movie_detail_arg.dart';
class
MainPages
extends
StatefulWidget
{
class
MainPages
extends
StatefulWidget
{
@override
@override
...
@@ -219,6 +220,10 @@ class _MainPagesState extends State<MainPages> {
...
@@ -219,6 +220,10 @@ class _MainPagesState extends State<MainPages> {
Navigator
.
pushNamed
(
Navigator
.
pushNamed
(
context
,
context
,
'/detail'
,
'/detail'
,
// arguments: ScreenArguments(
// id,
// image,
// ),
arguments:
id
,
arguments:
id
,
);
);
},
},
...
...
lib/pages/movie_detail.dart
View file @
0b4af86c
...
@@ -2,35 +2,36 @@ import 'dart:convert';
...
@@ -2,35 +2,36 @@ import 'dart:convert';
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_rating_bar/flutter_rating_bar.dart'
;
import
'package:movie_app/config.dart'
;
import
'package:movie_app/config.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:http/http.dart'
as
http
;
class
detailMovie
extends
StatefulWidget
{
import
'../models/movie_detail_api.dart'
;
String
id
;
detailMovie
(
this
.
id
);
class
detailMovie
extends
StatefulWidget
{
// ScreenArguments arg;
// detailMovie(this.arg);
String
id
;
detailMovie
(
this
.
id
,
{
Key
?
key
})
:
super
(
key:
key
);
@override
@override
_detailMovieState
createState
()
=>
_detailMovieState
();
_detailMovieState
createState
()
=>
_detailMovieState
();
}
}
class
_detailMovieState
extends
State
<
detailMovie
>
{
class
_detailMovieState
extends
State
<
detailMovie
>
{
@override
double
rating
=
0
;
Widget
build
(
BuildContext
context
)
{
movieDetail
?
_movieDetail
;
final
arguments
=
ModalRoute
.
of
(
context
)!.
settings
.
arguments
as
String
;
void
getDetailMovie
(
String
apiKey
,
String
movieId
)
async
{
var
_populars
;
void
getPopularData
(
String
apiKey
,
String
arguments
)
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
var
response
=
await
http
.
get
(
Uri
.
parse
(
"https://api.themoviedb.org/3/movie/"
+
"https://api.themoviedb.org/3/movie/"
+
arguments
+
movieId
+
"?api_key="
+
"?api_key="
+
apiKey
+
apiKey
+
"&language=en-US"
));
"&language=en-US"
));
var
jsonObject
=
jsonDecode
(
response
.
body
);
var
json
=
jsonDecode
(
response
.
body
);
setState
(()
{
setState
(()
{
_populars
=
jsonObject
;
_movieDetail
=
movieDetail
.
fromJson
(
json
)
;
});
});
}
}
...
@@ -38,10 +39,12 @@ class _detailMovieState extends State<detailMovie> {
...
@@ -38,10 +39,12 @@ class _detailMovieState extends State<detailMovie> {
void
initState
()
{
void
initState
()
{
// TODO: implement initState
// TODO: implement initState
super
.
initState
();
super
.
initState
();
getPopularData
(
apiKey
,
arguments
);
getDetailMovie
(
apiKey
,
widget
.
id
);
}
}
print
(
_populars
);
@override
Widget
build
(
BuildContext
context
)
{
// print(apiKey);
return
Scaffold
(
return
Scaffold
(
backgroundColor:
backgroundColor
,
backgroundColor:
backgroundColor
,
body:
Stack
(
body:
Stack
(
...
@@ -91,9 +94,14 @@ class _detailMovieState extends State<detailMovie> {
...
@@ -91,9 +94,14 @@ class _detailMovieState extends State<detailMovie> {
color:
Colors
.
transparent
,
color:
Colors
.
transparent
,
child:
ClipRRect
(
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
40
),
borderRadius:
BorderRadius
.
circular
(
40
),
child:
Image
(
child:
_movieDetail
==
null
?
SizedBox
(
width:
10
,
)
:
Image
(
image:
NetworkImage
(
image:
NetworkImage
(
"https://cdn.dribbble.com/users/6881751/screenshots/15130805/media/abdbb24b44fe7217de410073d279dc25.png"
),
"https://image.tmdb.org/t/p/w500"
+
_movieDetail
!.
poster_path
),
fit:
BoxFit
.
cover
,
fit:
BoxFit
.
cover
,
height:
500
,
height:
500
,
width:
300
,
width:
300
,
...
@@ -108,7 +116,7 @@ class _detailMovieState extends State<detailMovie> {
...
@@ -108,7 +116,7 @@ class _detailMovieState extends State<detailMovie> {
margin:
EdgeInsets
.
only
(
top:
10
),
margin:
EdgeInsets
.
only
(
top:
10
),
width:
300
,
width:
300
,
child:
Text
(
child:
Text
(
_
populars
!=
null
?
_populars
[
'title'
]
:
''
,
_
movieDetail
==
null
?
''
:
_movieDetail
!.
title
,
textAlign:
TextAlign
.
start
,
textAlign:
TextAlign
.
start
,
style:
TextStyle
(
style:
TextStyle
(
fontSize:
25
,
fontSize:
25
,
...
@@ -128,7 +136,9 @@ class _detailMovieState extends State<detailMovie> {
...
@@ -128,7 +136,9 @@ class _detailMovieState extends State<detailMovie> {
fontWeight:
FontWeight
.
w400
),
fontWeight:
FontWeight
.
w400
),
),
),
Text
(
Text
(
'4.8 '
,
_movieDetail
==
null
?
''
:
_movieDetail
!.
vote_average
.
toString
(),
style:
TextStyle
(
style:
TextStyle
(
fontSize:
15
,
fontSize:
15
,
color:
textColor
,
color:
textColor
,
...
@@ -143,32 +153,31 @@ class _detailMovieState extends State<detailMovie> {
...
@@ -143,32 +153,31 @@ class _detailMovieState extends State<detailMovie> {
),
),
Container
(
Container
(
margin:
EdgeInsets
.
fromLTRB
(
50
,
0
,
30
,
10
),
margin:
EdgeInsets
.
fromLTRB
(
50
,
0
,
30
,
10
),
child:
Row
(
height:
50
,
children:
[
child:
_movieDetail
==
null
RaisedButton
(
?
SizedBox
(
width:
1
,
)
:
ListView
(
scrollDirection:
Axis
.
horizontal
,
children:
_movieDetail
!.
genre
.
map
(
(
e
)
=>
Container
(
margin:
EdgeInsets
.
only
(
left:
5
),
child:
RaisedButton
(
shape:
RoundedRectangleBorder
(
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
25
)),
borderRadius:
BorderRadius
.
circular
(
25
)),
color:
Color
(
0xFF05104f
),
color:
Color
(
0xFF05104f
),
child:
Text
(
child:
Text
(
"Crime"
,
e
,
style:
TextStyle
(
color:
textColor
),
style:
TextStyle
(
color:
textColor
),
),
),
onPressed:
()
{},
onPressed:
()
{},
),
),
SizedBox
(
width:
10
,
),
RaisedButton
(
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
25
)),
color:
Color
(
0xFF05104f
),
child:
Text
(
"Thriler"
,
style:
TextStyle
(
color:
textColor
),
),
onPressed:
()
{},
),
),
],
)
.
toList
(),
),
),
),
),
Container
(
Container
(
...
@@ -186,19 +195,76 @@ class _detailMovieState extends State<detailMovie> {
...
@@ -186,19 +195,76 @@ class _detailMovieState extends State<detailMovie> {
Container
(
Container
(
margin:
EdgeInsets
.
fromLTRB
(
50
,
30
,
30
,
10
),
margin:
EdgeInsets
.
fromLTRB
(
50
,
30
,
30
,
10
),
child:
Text
(
child:
Text
(
"ini isi sssssssssssssssssssssa aslaskasa kasmdasldka sdasdkjasd asdkasa sdapsdasd as dapsdjasd asdasld asd["
,
_movieDetail
==
null
?
''
:
_movieDetail
!.
overview
,
textAlign:
TextAlign
.
start
,
textAlign:
TextAlign
.
start
,
style:
TextStyle
(
style:
TextStyle
(
color:
textColor
,
color:
textColor
,
fontSize:
15
,
fontSize:
15
,
fontWeight:
FontWeight
.
w300
),
fontWeight:
FontWeight
.
w400
),
))
)),
],
SizedBox
(
height:
35
,
)
)
],
],
)
)
],
],
),
),
Align
(
alignment:
Alignment
.
bottomCenter
,
child:
RaisedButton
(
child:
Text
(
'Rate This Movie'
),
color:
Colors
.
yellow
,
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
25
)),
onPressed:
()
{
showModalBottomSheet
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
{
return
Container
(
height:
200
,
color:
Color
(
0xFF05104f
),
child:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
Text
(
"Rate this movie "
,
style:
TextStyle
(
color:
textColor
),
),
SizedBox
(
height:
10
,
),
RatingBar
.
builder
(
minRating:
1
,
itemSize:
46
,
itemPadding:
EdgeInsets
.
symmetric
(
horizontal:
5
),
itemBuilder:
(
context
,
_
)
=>
Icon
(
Icons
.
star
,
color:
Colors
.
yellow
),
updateOnDrag:
true
,
onRatingUpdate:
(
rating
)
=>
setState
(()
{
this
.
rating
=
rating
;
}),
),
RaisedButton
(
child:
Text
(
"Submit"
),
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
25
)),
color:
Colors
.
yellow
,
onPressed:
()
{
print
(
"You rate this movie :
$rating
"
);
})
],
),
),
);
},
);
}))
],
),
);
);
}
}
}
}
pubspec.lock
View file @
0b4af86c
...
@@ -69,6 +69,13 @@ packages:
...
@@ -69,6 +69,13 @@ packages:
url: "https://pub.dartlang.org"
url: "https://pub.dartlang.org"
source: hosted
source: hosted
version: "1.0.4"
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:
flutter_test:
dependency: "direct dev"
dependency: "direct dev"
description: flutter
description: flutter
...
@@ -186,3 +193,4 @@ packages:
...
@@ -186,3 +193,4 @@ packages:
version: "2.1.1"
version: "2.1.1"
sdks:
sdks:
dart: ">=2.16.0 <3.0.0"
dart: ">=2.16.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5"
pubspec.yaml
View file @
0b4af86c
...
@@ -30,15 +30,10 @@ dependencies:
...
@@ -30,15 +30,10 @@ dependencies:
cupertino_icons
:
^1.0.2
cupertino_icons
:
^1.0.2
flutter
:
flutter
:
sdk
:
flutter
sdk
:
flutter
flutter_rating_bar
:
^4.0.0
http
:
^0.13.4
http
:
^0.13.4
dev_dependencies
:
dev_dependencies
:
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints
:
^1.0.0
flutter_lints
:
^1.0.0
flutter_test
:
flutter_test
:
sdk
:
flutter
sdk
:
flutter
...
...
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