Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sudah dengan rooting #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
21 changes: 21 additions & 0 deletions pokemon-reactif/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
2,138 changes: 2,138 additions & 0 deletions pokemon-reactif/README.md

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions pokemon-reactif/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "pokemon-reactif",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.16.2",
"material-ui": "^0.18.7",
"material-ui-icons": "^1.0.0-alpha.19",
"materialize-css": "^0.100.1",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-router-dom": "^4.1.2",
"react-scripts": "1.0.10",
"react-tap-event-plugin": "^2.0.1",
"semantic-ui-css": "^2.2.11"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Binary file added pokemon-reactif/public/favicon.ico
Binary file not shown.
13 changes: 13 additions & 0 deletions pokemon-reactif/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<title>React App</title>
</head>
<body>
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions pokemon-reactif/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
8 changes: 8 additions & 0 deletions pokemon-reactif/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.App {
text-align: center;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
50 changes: 50 additions & 0 deletions pokemon-reactif/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { Component } from 'react';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
//import Header from './components/Header';
import {BrowserRouter as Router, Switch, Route} from 'react-router-dom'
import {Link} from 'react-router-dom'
import Beranda from './components/Beranda';
import Category from './components/Category';
import './App.css';

const styles = {
navigation: {
backgroundColor: '#5b569e'
},
logo: {
paddingLeft: 50
},
navbarMenu: {
paddingRight: 10
}
}

class App extends Component {
render() {
return (
<Router>
<MuiThemeProvider>
<div id="app">
<div className="navbar-fixed">
<nav style={styles.navigation}>
<div className="nav-wrapper">
<a className="brand-logo left" style={styles.logo}><i className="large material-icons">chrome_reader_mode</i>TNWnews</a>
<ul id="nav-mobile" className="right hide-on-med-and-down" style={styles.navbarMenu}>
<li><Link to="/Home">Beranda</Link></li>
<li><Link to="/Category">Category</Link></li>
</ul>
</div>
</nav>
</div>
<Switch>
<Route path="/Home" component={Beranda} />
<Route path="/Category" component={Category} />
</Switch>
</div>
</MuiThemeProvider>
</Router>
);
}
}

export default App;
8 changes: 8 additions & 0 deletions pokemon-reactif/src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});
59 changes: 59 additions & 0 deletions pokemon-reactif/src/components/Beranda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, { Component } from 'react';
import axios from 'axios'

const styles = {
container: {
paddingTop: 40
}
}

export default class People extends Component {
constructor () {
super()
this.state = {
articles: []
}
}

componentDidMount () {
this.getNews()
}

getNews () {
axios.get('https://newsapi.org/v1/articles?source=the-next-web&sortBy=latest&apiKey=beb2f163c5bb43e38c5ae0e00d06ec8f')
.then((response) => {
this.setState({
articles: response.data.articles
})
})
.catch((err) => {
console.log(err)
})
}

render () {
return (
<div className="container" style={styles.container}>
<div className="row">
{this.state.articles.map((article, index) => {
return <div key={index} className="col s12 m6 l4">
<div className="card z-depth-3">
<div className="card-image waves-effect waves-block waves-light">
<img className="activator" src={article.urlToImage} alt="..."/>
<span className="card-title activator gray-text text-darken-4">{article.author}</span>
</div>
<div className="card-content">
<span className="card-title activator gray-text text-darken-4">{article.title}</span>
<p>{article.description}</p>
</div>
<div className="card-action">
<a href={article.url} className="waves-effect waves-light btn blue">Get Read</a>
</div>
</div>
</div>
})}
</div>
</div>
)
}
}
108 changes: 108 additions & 0 deletions pokemon-reactif/src/components/Category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import React, { Component }from 'react'
import axios from 'axios'
import FontIcon from 'material-ui/FontIcon'
import { BottomNavigation, BottomNavigationItem } from 'material-ui/BottomNavigation'
import Paper from 'material-ui/Paper'

const popularIcon = <FontIcon className="material-icons">line_weight</FontIcon>
const topIcon = <FontIcon className="material-icons">movie_filter</FontIcon>
const latestIcon = <FontIcon className="material-icons">extension</FontIcon>

class Category extends Component {
constructor () {
super()
this.state = {
articles: [],
category: 'bbc-news',
selectedIndex: 1
}
}

componentDidMount () {
this.getArticles()
}

getArticles () {
let category = this.state.category
axios.get(` https://newsapi.org/v1/articles?source=${category}&sortBy=top&apiKey=beb2f163c5bb43e38c5ae0e00d06ec8f`)
.then((response) => {
this.setState({
articles: response.data.articles
})
})
.catch((err) => {
console.log(err)
})
}

selectCategory (value) {
if(value === 0){
this.setState({
category: 'abc-news-au',
selectedIndex: value
})
} else if(value === 1) {
this.setState({
category: 'al-jazeera-english',
selectedIndex: value
})
} else {
this.setState({
category: 'bloomberg',
selectedIndex: value
})
}
this.getArticles()
}

render () {
return (
<div>
<div className="container">
<div className="row">
{this.state.articles.map((article, index) => {
return <div key={index} className="col s12 m6 l4">
<div className="card z-depth-3">
<div className="card-image waves-effect waves-block waves-light">
<img className="activator" src={article.urlToImage} alt="..."/>
<span className="card-title activator gray-text text-darken-4">{article.author}</span>
</div>
<div className="card-content">
<span className="card-title activator gray-text text-darken-4">{article.title}</span>
<p>{article.description}</p>
</div>
<div className="card-action">
<a href={article.url} className="waves-effect waves-light btn blue">Get Read</a>
</div>
</div>
</div>
})}
</div>
</div>
<div className="container">
<Paper zDepth={2} className="navbar-fixed">
<BottomNavigation selectedIndex={this.state.selectedIndex}>
<BottomNavigationItem
label="ABC News"
icon={popularIcon}
onTouchTap={() => this.selectCategory(0)}
/>
<BottomNavigationItem
label="Al-Jazeera"
icon={latestIcon}
onTouchTap={() => this.selectCategory(1)}
/>
<BottomNavigationItem
label="Bloomberg"
icon={topIcon}
onTouchTap={() => this.selectCategory(2)}
/>
</BottomNavigation>
</Paper>
</div>
</div>
)
}
}

export default Category
55 changes: 55 additions & 0 deletions pokemon-reactif/src/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react'
import {BrowserRouter as Router, Switch, Route} from 'react-router-dom'
import {Link} from 'react-router-dom'
import Beranda from './Beranda';
import Category from './Category';

const styles = {
navigation: {
backgroundColor: '#5b569e'
},
logo: {
paddingLeft: 50
},
navbarMenu: {
paddingRight: 10
}
}

class Header extends React.Component {
constructor (props) {
super(props)
this.state = {
value: ''
}
}

handleChange (event) {
console.log('ini event', event)
this.setState({
value: event.target.value
})
}

render () {
return (
<Router className="navbar-fixed">
<Switch>
<Route exact path="/Home" component={Beranda} />
<Route path="/Category" component={Category} />
</Switch>
<nav style={styles.navigation}>
<div className="nav-wrapper">
<a className="brand-logo left" style={styles.logo}><i className="large material-icons">chrome_reader_mode</i>TNWnews</a>
<ul id="nav-mobile" className="right hide-on-med-and-down" style={styles.navbarMenu}>
<li><Link to="/Home">Beranda</Link></li>
<li><Link to="/Category">Category</Link></li>
</ul>
</div>
</nav>
</Router>
)
}
}

export default Header;
5 changes: 5 additions & 0 deletions pokemon-reactif/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
13 changes: 13 additions & 0 deletions pokemon-reactif/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom';
import injectTapEventPlugin from 'react-tap-event-plugin';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import 'materialize-css/dist/css/materialize.min.css'
import 'materialize-css/dist/js/materialize.min.js'

injectTapEventPlugin();

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
Loading