Commit fca140a3 authored by Dio Maulana's avatar Dio Maulana

home page done

parent 517cf4ad
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
\ No newline at end of file
import 'package:flutter/material.dart';
const String apiKey = "7bd732568db90a2ce0b095777844cdb9"; // apikey tmbd
const Color backgroundColor = Color(0xFF070D2D);
const Color textColor = Color(0xFFD2D3D8);
const TextStyle litleText =
TextStyle(fontSize: 10, color: textColor, fontWeight: FontWeight.w500);
const TextStyle titleText =
TextStyle(fontSize: 20, color: textColor, fontWeight: FontWeight.w700);
const EdgeInsets defaultCardPading = EdgeInsets.fromLTRB(0, 10, 0, 0);
import 'package:flutter/material.dart'; 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';
void main() { void main() {
runApp(const MyApp()); runApp(MyApp());
} }
class MyApp extends StatefulWidget { class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override @override
_MyAppState createState() => _MyAppState(); _MyAppState createState() => _MyAppState();
} }
...@@ -15,6 +14,12 @@ class MyApp extends StatefulWidget { ...@@ -15,6 +14,12 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MainPages(); return MaterialApp(
initialRoute: '/',
routes: {
'/': (context) => MainPages(),
'/detail': (context) => detailMovie(),
},
);
} }
} }
import 'dart:convert';
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:movie_app/pages/movie_detail.dart';
class MainPages extends StatefulWidget { import '../config.dart';
const MainPages({Key? key}) : super(key: key);
class MainPages extends StatefulWidget {
@override @override
_MainPagesState createState() => _MainPagesState(); _MainPagesState createState() => _MainPagesState();
} }
class _MainPagesState extends State<MainPages> { class _MainPagesState extends State<MainPages> {
int _selectedIndex = 0; var _populars = [];
var _upComing = [];
bool isLoading = true;
void getPopularData(String apiKey) async {
var response = await http.get(Uri.parse(
"https://api.themoviedb.org/3/movie/popular?api_key=" +
apiKey +
"&language=en-US&page=1"));
var jsonObject = jsonDecode(response.body);
List<dynamic> listPopular = (jsonObject as Map<String, dynamic>)['results'];
setState(() {
_populars = listPopular;
isLoading = false;
});
}
void getUpComingData(String apiKey) async {
var response = await http.get(Uri.parse(
"https://api.themoviedb.org/3/movie/upcoming?api_key=" +
apiKey +
"&language=en-US&page=1"));
var jsonObject = jsonDecode(response.body);
List<dynamic> listUpComing =
(jsonObject as Map<String, dynamic>)['results'];
setState(() {
_upComing = listUpComing;
isLoading = false;
});
}
@override
void initState() {
// TODO: implement initState
super.initState();
getPopularData(apiKey);
getUpComingData(apiKey);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return Scaffold(
home: Scaffold( backgroundColor: backgroundColor,
backgroundColor: Color(0xFF212121),
body: Stack( body: Stack(
children: [ children: [
ListView( ListView(
children: [ children: [
Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Hi, Dio Maulana",
style: TextStyle(
color: textColor,
fontSize: 20,
fontWeight: FontWeight.w800),
),
ClipRRect(
child: Icon(
Icons.person,
color: textColor,
size: 30,
),
)
],
),
),
Align( Align(
alignment: Alignment.center, alignment: Alignment.center,
child: Container( child: Container(
...@@ -25,9 +92,11 @@ class _MainPagesState extends State<MainPages> { ...@@ -25,9 +92,11 @@ class _MainPagesState extends State<MainPages> {
color: Colors.transparent, color: Colors.transparent,
border: Border.all(color: Colors.grey), border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(20)), borderRadius: BorderRadius.circular(20)),
margin: EdgeInsets.fromLTRB(30, 150, 10, 30), margin: EdgeInsets.fromLTRB(10, 30, 10, 30),
padding: EdgeInsets.fromLTRB(10, 5, 5, 5), padding: EdgeInsets.fromLTRB(10, 5, 5, 5),
// ignore: prefer_const_constructors
child: TextField( child: TextField(
style: TextStyle(color: textColor),
decoration: InputDecoration( decoration: InputDecoration(
border: InputBorder.none, border: InputBorder.none,
icon: Icon( icon: Icon(
...@@ -40,227 +109,180 @@ class _MainPagesState extends State<MainPages> { ...@@ -40,227 +109,180 @@ class _MainPagesState extends State<MainPages> {
), ),
), ),
Container( Container(
margin: EdgeInsets.fromLTRB(30, 10, 10, 30), margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row( child: Row(
children: [ children: [
Text( Text(
"Popular", "Popular",
style: TextStyle( style: titleText,
fontSize: 20,
color: Colors.white,
fontWeight: FontWeight.w700),
), ),
Spacer(), Spacer(),
Text( Text("See More", style: litleText),
"See More",
style: TextStyle(
fontSize: 10,
color: Colors.white24,
fontWeight: FontWeight.w500),
),
], ],
), ),
), ),
// Align( isLoading
// alignment: Alignment.centerLeft, ? Container(
// child: Container( margin: defaultCardPading,
// margin: EdgeInsets.fromLTRB(30, 10, 10, 30), height: 400,
// width: 200,
// height: 300,
// padding: EdgeInsets.all(3),
// child: ClipRRect(
// borderRadius: BorderRadius.circular(35),
// child: Image(
// image: NetworkImage(
// "https://repository-images.githubusercontent.com/31792824/fb7e5700-6ccc-11e9-83fe-f602e1e1a9f1"),
// fit: BoxFit.cover,
// ),
// ),
// ),
// )
Container(
margin: EdgeInsets.fromLTRB(30, 10, 10, 0),
height: 300,
child: ListView( child: ListView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
children: [ children: [
Container( for (int i = 0; i < 5; i++)
margin: EdgeInsets.fromLTRB(5, 10, 10, 0), Center(
child: Column( child: Container(
children: [ width: 120,
ClipRRect( height: 120,
borderRadius: BorderRadius.circular(12), child: CircularProgressIndicator())),
child: Image(
image: NetworkImage(
"https://e1.pngegg.com/pngimages/513/361/png-clipart-render-naruto-naruto-uzumaki-illustration.png"),
fit: BoxFit.cover,
width: 100,
height: 200,
),
),
SizedBox(
height: 10,
),
Text("Naruto Shippuden", style: TextStyle(fontSize: 12, color: Colors.white, fontWeight: FontWeight.w700),),
SizedBox(
height: 5,
),
Row(
children: [
Text("3.5", maxLines: 1,textAlign: TextAlign.center, style: TextStyle(color: Colors.grey, fontSize: 12, fontWeight: FontWeight.w500),),
SizedBox(
width: 5,
),
Icon(Icons.star, color: Colors.yellow, size: 14,)
], ],
),
) )
: Container(
margin: defaultCardPading,
height: 400,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
for (int i = 0; i < _populars.length; i++)
popularCard(
context,
"https://image.tmdb.org/t/p/w500" +
_populars[i]['poster_path'],
_populars[i]['title'],
_populars[i]['vote_average'].toString(),
_populars[i]['id'].toString()),
], ],
), ),
), ),
Container( Container(
margin: EdgeInsets.fromLTRB(5, 10, 10, 0), margin: defaultCardPading,
child: Column( child: Row(
children: [ children: [
ClipRRect( Text(
borderRadius: BorderRadius.circular(12), "Up coming",
child: Image( style: titleText,
image: NetworkImage(
"https://e1.pngegg.com/pngimages/513/361/png-clipart-render-naruto-naruto-uzumaki-illustration.png"),
fit: BoxFit.cover,
width: 100,
height: 200,
), ),
Spacer(),
Text(
"See More",
style: litleText,
), ),
SizedBox( ],
height: 10,
), ),
Text("Naruto Shippuden", style: TextStyle(fontSize: 12, color: Colors.white, fontWeight: FontWeight.w700),),
SizedBox(
height: 5,
), ),
Row( isLoading
? Container(
margin: defaultCardPading,
height: 400,
child: ListView(
scrollDirection: Axis.horizontal,
children: [ children: [
Text("3.5", maxLines: 1,textAlign: TextAlign.center, style: TextStyle(color: Colors.grey, fontSize: 12, fontWeight: FontWeight.w500),), for (int i = 0; i < 5; i++)
SizedBox( Center(
width: 5, child: Container(
), width: 120,
Icon(Icons.star, color: Colors.yellow, size: 14,) height: 120,
], child: CircularProgressIndicator())),
)
], ],
), ),
), )
Container( : Container(
margin: EdgeInsets.fromLTRB(5, 10, 10, 0), margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Column( height: 400,
child: ListView(
scrollDirection: Axis.horizontal,
children: [ children: [
ClipRRect( for (int i = 0; i < _upComing.length; i++)
borderRadius: BorderRadius.circular(12), popularCard(
child: Image( context,
image: NetworkImage( "https://image.tmdb.org/t/p/w500" +
"https://e1.pngegg.com/pngimages/513/361/png-clipart-render-naruto-naruto-uzumaki-illustration.png"), _upComing[i]['poster_path'],
fit: BoxFit.cover, _upComing[i]['title'],
width: 100, _upComing[i]['vote_average'].toString(),
height: 200, _upComing[i]['id'].toString()),
), ],
),
SizedBox(
height: 10,
),
Text("Naruto Shippuden", style: TextStyle(fontSize: 12, color: Colors.white, fontWeight: FontWeight.w700),),
SizedBox(
height: 5,
), ),
Row(
children: [
Text("3.5", maxLines: 1,textAlign: TextAlign.center, style: TextStyle(color: Colors.grey, fontSize: 12, fontWeight: FontWeight.w500),),
SizedBox(
width: 5,
), ),
Icon(Icons.star, color: Colors.yellow, size: 14,)
], ],
) )
], ],
), ));
), }
Container(
margin: EdgeInsets.fromLTRB(5, 10, 10, 0), Widget popularCard(BuildContext context, String image, String title,
String rating, String id) {
return GestureDetector(
onTap: () {
// Navigator.push(context, MaterialPageRoute(builder: (context) {
// return detailMovie();
// }));
Navigator.pushNamed(
context,
'/detail',
arguments: id,
);
},
child: Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Column( child: Column(
children: [ children: [
ClipRRect( Material(
borderRadius: BorderRadius.circular(12), elevation: 10,
borderRadius: BorderRadius.circular(45),
color: Colors.transparent,
child: ClipRRect(
borderRadius: BorderRadius.circular(45),
child: Image( child: Image(
image: NetworkImage( image: NetworkImage(image),
"https://e1.pngegg.com/pngimages/513/361/png-clipart-render-naruto-naruto-uzumaki-illustration.png"),
fit: BoxFit.cover, fit: BoxFit.cover,
width: 100, width: 200,
height: 200, height: 300,
), ),
), ),
SizedBox(
height: 10,
),
Text("Naruto Shippuden", style: TextStyle(fontSize: 12, color: Colors.white, fontWeight: FontWeight.w700),),
SizedBox(
height: 5,
), ),
Row(
children: [
Text("3.5", maxLines: 1,textAlign: TextAlign.center, style: TextStyle(color: Colors.grey, fontSize: 12, fontWeight: FontWeight.w500),),
SizedBox( SizedBox(
width: 5, height: 10,
),
Icon(Icons.star, color: Colors.yellow, size: 14,)
],
)
],
),
), ),
Container( Container(
margin: EdgeInsets.fromLTRB(5, 10, 10, 0), width: 200,
child: Column( child: Text(
children: [ title,
ClipRRect( textAlign: TextAlign.center,
borderRadius: BorderRadius.circular(12), maxLines: 1,
child: Image( style: TextStyle(
image: NetworkImage( fontSize: 14,
"https://e1.pngegg.com/pngimages/513/361/png-clipart-render-naruto-naruto-uzumaki-illustration.png"), color: Colors.white,
fit: BoxFit.cover, fontWeight: FontWeight.w900,
width: 100, overflow: TextOverflow.ellipsis),
height: 200,
),
), ),
SizedBox(
height: 10,
), ),
Text("Naruto Shippuden", style: TextStyle(fontSize: 12, color: Colors.white, fontWeight: FontWeight.w700),),
SizedBox( SizedBox(
height: 5, height: 5,
), ),
Row( Row(
children: [ children: [
Text("3.5", maxLines: 1,textAlign: TextAlign.center, style: TextStyle(color: Colors.grey, fontSize: 12, fontWeight: FontWeight.w500),), Text(
rating,
maxLines: 1,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.grey,
fontSize: 12,
fontWeight: FontWeight.w500),
),
SizedBox( SizedBox(
width: 5, width: 5,
), ),
Icon(Icons.star, color: Colors.yellow, size: 14,) Icon(
], Icons.star,
color: Colors.yellow,
size: 14,
) )
], ],
), )
),
], ],
), ),
), ),
],
)
],
)),
); );
} }
} }
import 'dart:convert';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:movie_app/config.dart';
import 'package:http/http.dart' as http;
class detailMovie extends StatefulWidget {
@override
_detailMovieState createState() => _detailMovieState();
}
class _detailMovieState extends State<detailMovie> {
@override
Widget build(BuildContext context) {
final arguments = ModalRoute.of(context)!.settings.arguments as String;
var _populars = [];
void getPopularData(String apiKey, String arguments) async {
var response = await http.get(Uri.parse(
"https://api.themoviedb.org/3/movie/" +
arguments +
"?api_key=" +
apiKey +
"&language=en-US"));
var jsonObject = jsonDecode(response.body);
List<dynamic> listPopular = (jsonObject as Map<String, dynamic>)[''];
setState(() {
_populars = listPopular;
});
}
@override
void initState() {
// TODO: implement initState
super.initState();
getPopularData(apiKey, arguments);
}
print(_populars);
return Scaffold(
backgroundColor: backgroundColor,
body: Stack(
children: [
ListView(
children: [
Container(
margin: EdgeInsets.fromLTRB(20, 20, 20, 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () {
Navigator.pop(
context,
);
},
child: Icon(
Icons.arrow_back_ios_new,
color: textColor,
),
),
Text(
"Detail Movies",
style: TextStyle(
color: textColor,
fontSize: 20,
fontWeight: FontWeight.w800),
),
Icon(
Icons.bookmark_border_outlined,
color: textColor,
),
],
),
),
Center(
child: Container(
height: 500,
width: 300,
decoration:
BoxDecoration(borderRadius: BorderRadius.circular(40)),
margin: EdgeInsets.fromLTRB(30, 30, 30, 10),
child: Material(
elevation: 10,
borderRadius: BorderRadius.circular(40),
color: Colors.transparent,
child: ClipRRect(
borderRadius: BorderRadius.circular(40),
child: Image(
image: NetworkImage(
"https://cdn.dribbble.com/users/6881751/screenshots/15130805/media/abdbb24b44fe7217de410073d279dc25.png"),
fit: BoxFit.cover,
height: 500,
width: 300,
),
),
),
),
),
Column(
children: [
Container(
margin: EdgeInsets.only(top: 10),
width: 300,
child: Text(
arguments,
textAlign: TextAlign.start,
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w700,
color: textColor),
),
),
Container(
margin: EdgeInsets.fromLTRB(50, 30, 30, 10),
child: Row(
children: [
Text(
'Director: Dio Maulana | ',
style: TextStyle(
fontSize: 15,
color: textColor,
fontWeight: FontWeight.w400),
),
Text(
'4.8 ',
style: TextStyle(
fontSize: 15,
color: textColor,
fontWeight: FontWeight.w400),
),
Icon(
Icons.star,
color: Colors.yellow,
)
],
),
),
Container(
margin: EdgeInsets.fromLTRB(50, 0, 30, 10),
child: Row(
children: [
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25)),
color: Color(0xFF05104f),
child: Text(
"Crime",
style: TextStyle(color: textColor),
),
onPressed: () {},
),
SizedBox(
width: 10,
),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25)),
color: Color(0xFF05104f),
child: Text(
"Thriler",
style: TextStyle(color: textColor),
),
onPressed: () {},
),
],
),
),
Container(
margin: EdgeInsets.only(top: 10),
width: 300,
child: Text(
"Synopsis",
textAlign: TextAlign.start,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: textColor),
),
),
Container(
margin: EdgeInsets.fromLTRB(50, 30, 30, 10),
child: Text(
"ini isi sssssssssssssssssssssa aslaskasa kasmdasldka sdasdkjasd asdkasa sdapsdasd as dapsdjasd asdasld asd[",
textAlign: TextAlign.start,
style: TextStyle(
color: textColor,
fontSize: 15,
fontWeight: FontWeight.w300),
))
],
)
],
)
],
),
);
}
}
...@@ -15,13 +15,6 @@ packages: ...@@ -15,13 +15,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
carousel_slider:
dependency: "direct main"
description:
name: carousel_slider
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.4"
characters: characters:
dependency: transitive dependency: transitive
description: description:
...@@ -81,6 +74,20 @@ packages: ...@@ -81,6 +74,20 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
http:
dependency: "direct main"
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.4"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
lints: lints:
dependency: transitive dependency: transitive
description: description:
...@@ -178,4 +185,4 @@ packages: ...@@ -178,4 +185,4 @@ packages:
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
sdks: sdks:
dart: ">=2.16.1 <3.0.0" dart: ">=2.16.0 <3.0.0"
...@@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev ...@@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ">=2.16.1 <3.0.0" sdk: ">=2.16.0 <3.0.0"
# Dependencies specify other packages that your package needs in order to work. # Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions # To automatically upgrade your package dependencies to the latest versions
...@@ -27,18 +27,12 @@ environment: ...@@ -27,18 +27,12 @@ environment:
# the latest version available on pub.dev. To see which dependencies have newer # the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`. # versions available, run `flutter pub outdated`.
dependencies: dependencies:
cupertino_icons: ^1.0.2
flutter: flutter:
sdk: flutter sdk: flutter
http: ^0.13.4
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
carousel_slider: ^2.3.1
dev_dependencies: dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to # The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is # encourage good coding practices. The lint set provided by the package is
...@@ -46,10 +40,11 @@ dev_dependencies: ...@@ -46,10 +40,11 @@ dev_dependencies:
# package. See that file for information about deactivating specific lint # package. See that file for information about deactivating specific lint
# rules and activating additional ones. # rules and activating additional ones.
flutter_lints: ^1.0.0 flutter_lints: ^1.0.0
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter. # The following section is specific to Flutter.
flutter: flutter:
...@@ -57,18 +52,14 @@ flutter: ...@@ -57,18 +52,14 @@ flutter:
# included with your application, so that you can use the icons in # included with your application, so that you can use the icons in
# the material Icons class. # the material Icons class.
uses-material-design: true uses-material-design: true
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
# assets: # assets:
# - images/a_dot_burr.jpeg # - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg # - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware. # https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see # For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages # https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here, # To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a # 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 # "family" key with the font family name, and a "fonts" key with a
......
...@@ -13,7 +13,7 @@ import 'package:movie_app/main.dart'; ...@@ -13,7 +13,7 @@ import 'package:movie_app/main.dart';
void main() { void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async { testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame. // Build our app and trigger a frame.
await tester.pumpWidget(const MyApp()); await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0. // Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget); expect(find.text('0'), findsOneWidget);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment