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:movie_app/pages/main_page.dart';
import 'package:movie_app/pages/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();
}
......@@ -15,6 +14,12 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
@override
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:http/http.dart' as http;
import 'package:movie_app/pages/movie_detail.dart';
class MainPages extends StatefulWidget {
const MainPages({Key? key}) : super(key: key);
import '../config.dart';
class MainPages extends StatefulWidget {
@override
_MainPagesState createState() => _MainPagesState();
}
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
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Color(0xFF212121),
body: Stack(
children: [
ListView(
children: [
Align(
alignment: Alignment.center,
child: Container(
decoration: BoxDecoration(
color: Colors.transparent,
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(20)),
margin: EdgeInsets.fromLTRB(30, 150, 10, 30),
padding: EdgeInsets.fromLTRB(10, 5, 5, 5),
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
icon: Icon(
Icons.search,
color: Colors.white30,
),
labelText: "Search Movie",
labelStyle: TextStyle(color: Colors.white30)),
return Scaffold(
backgroundColor: backgroundColor,
body: Stack(
children: [
ListView(
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),
),
),
),
Container(
margin: EdgeInsets.fromLTRB(30, 10, 10, 30),
child: Row(
children: [
Text(
"Popular",
style: TextStyle(
fontSize: 20,
color: Colors.white,
fontWeight: FontWeight.w700),
ClipRRect(
child: Icon(
Icons.person,
color: textColor,
size: 30,
),
Spacer(),
Text(
"See More",
style: TextStyle(
fontSize: 10,
color: Colors.white24,
fontWeight: FontWeight.w500),
),
],
),
)
],
),
// Align(
// alignment: Alignment.centerLeft,
// child: Container(
// margin: EdgeInsets.fromLTRB(30, 10, 10, 30),
// 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(
scrollDirection: Axis.horizontal,
children: [
Container(
margin: EdgeInsets.fromLTRB(5, 10, 10, 0),
child: Column(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(12),
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: EdgeInsets.fromLTRB(5, 10, 10, 0),
child: Column(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(12),
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,)
],
)
],
),
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: textColor),
decoration: InputDecoration(
border: InputBorder.none,
icon: Icon(
Icons.search,
color: Colors.white30,
),
labelText: "Search Movie",
labelStyle: TextStyle(color: Colors.white30)),
),
),
),
Container(
margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Row(
children: [
Text(
"Popular",
style: titleText,
),
Spacer(),
Text("See More", style: litleText),
],
),
),
isLoading
? Container(
margin: defaultCardPading,
height: 400,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
for (int i = 0; i < 5; i++)
Center(
child: Container(
width: 120,
height: 120,
child: CircularProgressIndicator())),
],
),
Container(
margin: EdgeInsets.fromLTRB(5, 10, 10, 0),
child: Column(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(12),
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(
margin: EdgeInsets.fromLTRB(5, 10, 10, 0),
child: Column(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(12),
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,
child: Row(
children: [
Text(
"Up coming",
style: titleText,
),
Spacer(),
Text(
"See More",
style: litleText,
),
],
),
),
isLoading
? Container(
margin: defaultCardPading,
height: 400,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
for (int i = 0; i < 5; i++)
Center(
child: Container(
width: 120,
height: 120,
child: CircularProgressIndicator())),
],
),
Container(
margin: EdgeInsets.fromLTRB(5, 10, 10, 0),
child: Column(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(12),
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: EdgeInsets.fromLTRB(10, 10, 10, 0),
height: 400,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
for (int i = 0; i < _upComing.length; i++)
popularCard(
context,
"https://image.tmdb.org/t/p/w500" +
_upComing[i]['poster_path'],
_upComing[i]['title'],
_upComing[i]['vote_average'].toString(),
_upComing[i]['id'].toString()),
],
),
],
),
),
],
)
],
)),
),
],
)
],
));
}
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(
children: [
Material(
elevation: 10,
borderRadius: BorderRadius.circular(45),
color: Colors.transparent,
child: ClipRRect(
borderRadius: BorderRadius.circular(45),
child: Image(
image: NetworkImage(image),
fit: BoxFit.cover,
width: 200,
height: 300,
),
),
),
SizedBox(
height: 10,
),
Container(
width: 200,
child: Text(
title,
textAlign: TextAlign.center,
maxLines: 1,
style: TextStyle(
fontSize: 14,
color: Colors.white,
fontWeight: FontWeight.w900,
overflow: TextOverflow.ellipsis),
),
),
SizedBox(
height: 5,
),
Row(
children: [
Text(
rating,
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,
)
],
)
],
),
),
);
}
}
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:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description:
......@@ -81,6 +74,20 @@ packages:
description: flutter
source: sdk
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:
dependency: transitive
description:
......@@ -178,4 +185,4 @@ packages:
source: hosted
version: "2.1.1"
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
version: 1.0.0+1
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.
# To automatically upgrade your package dependencies to the latest versions
......@@ -27,18 +27,12 @@ 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
carousel_slider: ^2.3.1
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
......@@ -46,10 +40,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:
......@@ -57,18 +52,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
......
......@@ -13,7 +13,7 @@ import 'package:movie_app/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
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