├── admin ├── src │ ├── components │ │ ├── Admin.js │ │ ├── login.js │ │ ├── Users.js │ │ ├── Ride.js │ │ ├── Post.js │ │ ├── User.js │ │ └── Home.js │ ├── setupTests.js │ ├── config │ │ └── config.js │ ├── App.test.js │ ├── reportWebVitals.js │ ├── App.css │ ├── index.js │ ├── App.js │ ├── index.css │ └── logo.svg ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── index.html ├── .gitignore ├── package.json └── README.md ├── .vscode └── settings.json ├── images ├── mockup.png └── simcoder.png ├── frontend ├── assets │ ├── icon.png │ ├── logo.png │ ├── splash.png │ ├── favicon.png │ ├── account.svg │ └── confirm.svg ├── babel.config.js ├── redux │ ├── reducers │ │ ├── index.js │ │ ├── user.js │ │ └── users.js │ ├── constants │ │ └── index.js │ └── actions │ │ └── index.js ├── components │ ├── main │ │ ├── random │ │ │ ├── Blocked.js │ │ │ └── CachedImage.js │ │ ├── profile │ │ │ ├── Search.js │ │ │ ├── Edit.js │ │ │ └── Profile.js │ │ ├── post │ │ │ ├── Feed.js │ │ │ ├── Comment.js │ │ │ └── Post.js │ │ ├── chat │ │ │ ├── List.js │ │ │ └── Chat.js │ │ └── add │ │ │ ├── Save.js │ │ │ └── Camera.js │ ├── utils.js │ ├── auth │ │ ├── Login.js │ │ └── Register.js │ ├── styles.js │ └── Main.js ├── app.json ├── package.json └── App.js ├── .gitignore ├── storage_rules.txt ├── firestore_rules.txt ├── backend └── functions │ └── index.js ├── README.md └── LICENSE /admin/src/components/Admin.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "git.ignoreLimitWarning": true 3 | } -------------------------------------------------------------------------------- /admin/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /images/mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimCoderYoutube/InstagramClone/HEAD/images/mockup.png -------------------------------------------------------------------------------- /images/simcoder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimCoderYoutube/InstagramClone/HEAD/images/simcoder.png -------------------------------------------------------------------------------- /admin/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimCoderYoutube/InstagramClone/HEAD/admin/public/favicon.ico -------------------------------------------------------------------------------- /admin/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimCoderYoutube/InstagramClone/HEAD/admin/public/logo192.png -------------------------------------------------------------------------------- /admin/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimCoderYoutube/InstagramClone/HEAD/admin/public/logo512.png -------------------------------------------------------------------------------- /frontend/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimCoderYoutube/InstagramClone/HEAD/frontend/assets/icon.png -------------------------------------------------------------------------------- /frontend/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimCoderYoutube/InstagramClone/HEAD/frontend/assets/logo.png -------------------------------------------------------------------------------- /frontend/assets/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimCoderYoutube/InstagramClone/HEAD/frontend/assets/splash.png -------------------------------------------------------------------------------- /frontend/assets/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimCoderYoutube/InstagramClone/HEAD/frontend/assets/favicon.png -------------------------------------------------------------------------------- /frontend/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function(api) { 2 | api.cache(true); 3 | return { 4 | presets: ['babel-preset-expo'], 5 | }; 6 | }; 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/**/* 2 | .expo/* 3 | npm-debug.* 4 | *.jks 5 | *.p8 6 | *.p12 7 | *.key 8 | *.mobileprovision 9 | *.orig.* 10 | web-build/ 11 | 12 | # macOS 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /admin/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /frontend/redux/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from 'redux' 2 | import { user } from './user' 3 | import { users } from './users' 4 | 5 | const Reducers = combineReducers({ 6 | userState: user, 7 | usersState: users 8 | }) 9 | 10 | export default Reducers -------------------------------------------------------------------------------- /admin/src/config/config.js: -------------------------------------------------------------------------------- 1 | export var firebaseConfig = { 2 | apiKey: "****", 3 | authDomain: "****", 4 | databaseURL: "****", 5 | projectId: "****", 6 | storageBucket: "****", 7 | messagingSenderId: "****", 8 | appId: "****", 9 | measurementId: "****" 10 | 11 | }; 12 | -------------------------------------------------------------------------------- /admin/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /storage_rules.txt: -------------------------------------------------------------------------------- 1 | rules_version = '2'; 2 | service firebase.storage { 3 | match /b/{bucket}/o { 4 | match /profile/{uid} { 5 | allow read: if true; 6 | allow write: if request.auth.uid == uid; 7 | } 8 | match /post/{uid}/{post=**} { 9 | allow read: if true; 10 | allow write: if request.auth.uid == uid; 11 | } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /admin/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /admin/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /admin/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /admin/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /admin/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | import firebase from 'firebase'; 8 | 9 | const firebaseConfig = require('./config/config').firebaseConfig; 10 | firebase.initializeApp(firebaseConfig) 11 | 12 | 13 | ReactDOM.render( 14 | 15 | 16 | , 17 | document.getElementById('root') 18 | ); 19 | 20 | // If you want to start measuring performance in your app, pass a function 21 | // to log results (for example: reportWebVitals(console.log)) 22 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 23 | reportWebVitals(); 24 | 25 | 26 | -------------------------------------------------------------------------------- /admin/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component, useState, useEffect } from 'react' 2 | import { BrowserRouter as Router, Route } from 'react-router-dom' 3 | import firebase from 'firebase' 4 | import login from './components/login' 5 | import 'bootstrap/dist/css/bootstrap.css'; 6 | import Home from './components/Home'; 7 | 8 | 9 | 10 | function App() { 11 | const [loggedIn, setLoggedIn] = useState(false) 12 | useEffect(() => { 13 | firebase.auth().onAuthStateChanged(user => { 14 | if (!user) { 15 | setLoggedIn(false); 16 | } 17 | else { 18 | setLoggedIn(true); 19 | } 20 | }) 21 | }, []) 22 | 23 | if (loggedIn) { 24 | return ( 25 | 26 | ) 27 | } 28 | return ( 29 | 30 | 31 | 32 | ) 33 | } 34 | 35 | export default App 36 | -------------------------------------------------------------------------------- /frontend/redux/constants/index.js: -------------------------------------------------------------------------------- 1 | export const USER_STATE_CHANGE = 'USER_STATE_CHANGE' 2 | export const USER_POSTS_STATE_CHANGE = 'USER_POSTS_STATE_CHANGE' 3 | export const USER_FOLLOWING_STATE_CHANGE = 'USER_FOLLOWING_STATE_CHANGE' 4 | export const USER_CHATS_STATE_CHANGE = 'USER_CHATS_STATE_CHANGE' 5 | 6 | export const USERS_POSTS_STATE_CHANGE = 'USERS_POSTS_STATE_CHANGE' 7 | export const USERS_LIKES_STATE_CHANGE = 'USERS_LIKES_STATE_CHANGE' 8 | export const USERS_DATA_STATE_CHANGE = 'USERS_DATA_STATE_CHANGE' 9 | 10 | export const USER_FRIENDS_REQUESTS_SENT_STATE_CHANGE = 'USER_FRIDENDS_REQUESTS_SENT_STATE_CHANGE' 11 | export const USER_FRIENDS_REQUESTS_RECEIVED_STATE_CHANGE = 'USER_FRIDENDS_REQUESTS_RECEIVED_STATE_CHANGE' 12 | export const USER_FRIENDS_STATE_CHANGE = 'USER_FRIDENDS_STATE_CHANGE' 13 | 14 | export const USER_CLEAR_FRIENDS = 'USER_CLEAR_FRIENDS' 15 | 16 | 17 | export const CLEAR_DATA = 'CLEAR_DATA' 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /frontend/components/main/random/Blocked.js: -------------------------------------------------------------------------------- 1 | import { Feather } from '@expo/vector-icons'; 2 | import React, { useEffect } from 'react'; 3 | import { BackHandler, Text, View } from 'react-native'; 4 | export default function Blocked() { 5 | useEffect(() => { 6 | BackHandler.addEventListener('hardwareBackPress', () => true) 7 | return () => 8 | BackHandler.removeEventListener('hardwareBackPress', () => true) 9 | }, []) 10 | 11 | return ( 12 | 13 | 14 | 15 | 16 | 17 | Your account has been blocked 18 | 19 | 20 | 21 | ) 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /frontend/components/utils.js: -------------------------------------------------------------------------------- 1 | function timeDifference(current, previous) { 2 | 3 | var msPerMinute = 60 * 1000; 4 | var msPerHour = msPerMinute * 60; 5 | var msPerDay = msPerHour * 24; 6 | var msPerMonth = msPerDay * 30; 7 | var msPerYear = msPerDay * 365; 8 | 9 | var elapsed = current - previous; 10 | 11 | if (elapsed < msPerMinute) { 12 | return 'Now'; 13 | } 14 | 15 | else if (elapsed < msPerHour) { 16 | return Math.round(elapsed / msPerMinute) + ' minutes ago'; 17 | } 18 | 19 | else if (elapsed < msPerDay) { 20 | return Math.round(elapsed / msPerHour) + ' hours ago'; 21 | } 22 | 23 | else if (elapsed < msPerMonth) { 24 | return Math.round(elapsed / msPerDay) + ' days ago'; 25 | } 26 | 27 | else if (elapsed < msPerYear) { 28 | return Math.round(elapsed / msPerMonth) + ' months ago'; 29 | } 30 | 31 | else { 32 | return Math.round(elapsed / msPerYear) + ' years ago'; 33 | } 34 | } 35 | 36 | export { timeDifference }; 37 | -------------------------------------------------------------------------------- /frontend/assets/account.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/redux/reducers/user.js: -------------------------------------------------------------------------------- 1 | import { CLEAR_DATA, USER_CHATS_STATE_CHANGE, USER_FOLLOWING_STATE_CHANGE, USER_POSTS_STATE_CHANGE, USER_STATE_CHANGE } from "../constants" 2 | 3 | const initialState = { 4 | currentUser: null, 5 | posts: [], 6 | chats: [], 7 | following: [], 8 | } 9 | 10 | export const user = (state = initialState, action) => { 11 | switch (action.type) { 12 | case USER_STATE_CHANGE: 13 | return { 14 | ...state, 15 | currentUser: action.currentUser 16 | } 17 | case USER_POSTS_STATE_CHANGE: 18 | return { 19 | ...state, 20 | posts: action.posts 21 | } 22 | 23 | case USER_FOLLOWING_STATE_CHANGE: 24 | return { 25 | ...state, 26 | following: action.following 27 | } 28 | case USER_CHATS_STATE_CHANGE: { 29 | return { 30 | ...state, 31 | chats: action.chats 32 | } 33 | } 34 | case CLEAR_DATA: 35 | return initialState 36 | default: 37 | return state; 38 | } 39 | } -------------------------------------------------------------------------------- /frontend/redux/reducers/users.js: -------------------------------------------------------------------------------- 1 | import { CLEAR_DATA, USERS_DATA_STATE_CHANGE, USERS_LIKES_STATE_CHANGE, USERS_POSTS_STATE_CHANGE } from "../constants" 2 | 3 | const initialState = { 4 | users: [], 5 | feed: [], 6 | usersFollowingLoaded: 0, 7 | } 8 | 9 | export const users = (state = initialState, action) => { 10 | switch (action.type) { 11 | case USERS_DATA_STATE_CHANGE: 12 | return { 13 | ...state, 14 | users: [...state.users, action.user] 15 | } 16 | case USERS_POSTS_STATE_CHANGE: 17 | return { 18 | ...state, 19 | usersFollowingLoaded: state.usersFollowingLoaded + 1, 20 | feed: [...state.feed, ...action.posts] 21 | } 22 | case USERS_LIKES_STATE_CHANGE: 23 | return { 24 | ...state, 25 | feed: state.feed.map(post => post.id == action.postId ? 26 | { ...post, currentUserLike: action.currentUserLike } : 27 | post) 28 | } 29 | case CLEAR_DATA: 30 | return initialState 31 | default: 32 | return state; 33 | } 34 | } -------------------------------------------------------------------------------- /frontend/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo": { 3 | "name": "instagram", 4 | "slug": "instagram", 5 | "version": "1.0.0", 6 | "orientation": "portrait", 7 | "icon": "./assets/logo.png", 8 | "splash": { 9 | "image": "./assets/logo.png", 10 | "resizeMode": "contain", 11 | "backgroundColor": "#ffffff" 12 | }, 13 | "updates": { 14 | "fallbackToCacheTimeout": 0 15 | }, 16 | "assetBundlePatterns": [ 17 | "**/*" 18 | ], 19 | "android": { 20 | "useNextNotificationsApi": true, 21 | "package": "com.instagram.simcoder", 22 | "googleServicesFile": "./google-services.json", 23 | "config": { 24 | "googleSignIn": { 25 | "apiKey": "****" 26 | } 27 | } 28 | }, 29 | "ios": { 30 | "buildNumber": "1.0.0", 31 | "supportsTablet": true, 32 | "bundleIdentifier": "com.instagram.simcoder", 33 | "config": { 34 | "googleSignIn": { 35 | "reservedClientId": "****" 36 | }, 37 | "googleMapsApiKey": "****" 38 | }, 39 | "googleServicesFile": "./GoogleService-Info.plist" 40 | }, 41 | "web": { 42 | "favicon": "./assets/logo.png" 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /frontend/assets/confirm.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /admin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "admin", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@material-ui/core": "^4.11.3", 7 | "@material-ui/data-grid": "^4.0.0-alpha.18", 8 | "@material-ui/icons": "^4.11.2", 9 | "@material-ui/x-grid": "^4.0.0-alpha.18", 10 | "@testing-library/jest-dom": "^5.11.9", 11 | "@testing-library/react": "^11.2.5", 12 | "@testing-library/user-event": "^12.6.3", 13 | "bootstrap": "^4.6.0", 14 | "expo-device": "^3.1.1", 15 | "firebase": "^8.2.5", 16 | "firebase-admin": "^9.4.2", 17 | "react": "^17.0.1", 18 | "react-dom": "^17.0.1", 19 | "react-icons": "^4.1.0", 20 | "react-router-dom": "^5.2.0", 21 | "react-scripts": "4.0.2", 22 | "web-vitals": "^1.1.0" 23 | }, 24 | "scripts": { 25 | "start": "react-scripts start", 26 | "build": "react-scripts build", 27 | "test": "react-scripts test", 28 | "eject": "react-scripts eject" 29 | }, 30 | "eslintConfig": { 31 | "extends": [ 32 | "react-app", 33 | "react-app/jest" 34 | ] 35 | }, 36 | "browserslist": { 37 | "production": [ 38 | ">0.2%", 39 | "not dead", 40 | "not op_mini all" 41 | ], 42 | "development": [ 43 | "last 1 chrome version", 44 | "last 1 firefox version", 45 | "last 1 safari version" 46 | ] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /frontend/components/auth/Login.js: -------------------------------------------------------------------------------- 1 | import firebase from 'firebase'; 2 | import React, { useState } from 'react'; 3 | import { Button, Text, TextInput, View } from 'react-native'; 4 | import { container, form } from '../styles'; 5 | 6 | export default function Login(props) { 7 | const [email, setEmail] = useState(''); 8 | const [password, setPassword] = useState(''); 9 | 10 | const onSignUp = () => { 11 | firebase.auth().signInWithEmailAndPassword(email, password) 12 | } 13 | 14 | return ( 15 | 16 | 17 | setEmail(email)} 21 | /> 22 | setPassword(password)} 27 | /> 28 | 29 | 40 | 41 | 42 | 43 | 44 | ) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /firestore_rules.txt: -------------------------------------------------------------------------------- 1 | service cloud.firestore { 2 | match /databases/{database}/documents { 3 | function isAdmin() { 4 | return exists(/databases/$(database)/documents/admin/$(request.auth.uid)) 5 | } 6 | match /users/{user} { 7 | allow read: if true; 8 | allow write, update: if request.auth.uid == user; 9 | allow write, update: if isAdmin(); 10 | } 11 | match /posts/{user}/userPosts { 12 | allow read: if true; 13 | allow write: if request.auth.uid == user; 14 | allow write, update: if isAdmin(); 15 | 16 | } 17 | match /posts/{user}/userPosts/{postId} { 18 | allow read: if true; 19 | allow write: if request.auth.uid == user; 20 | allow write, update: if isAdmin(); 21 | 22 | } 23 | match /posts/{user}/userPosts/{postId}/likes/{likeId} { 24 | allow read: if true; 25 | allow write: if request.auth.uid == likeId; 26 | allow write, update: if isAdmin(); 27 | } 28 | match /posts/{user}/userPosts/{postId}/comments/{commentId} { 29 | allow read: if true; 30 | allow write: if request.auth.uid != null; 31 | allow write, update: if isAdmin(); 32 | } 33 | 34 | match /feed/{documents=**}{ 35 | allow read, write: if request.auth.uid != null; 36 | } 37 | match /following/{user}/userFollowing/{following} { 38 | allow read: if true; 39 | allow write: if user == request.auth.uid; 40 | 41 | } 42 | match /admin/{documents=**}{ 43 | allow write, update, read: if false; 44 | } 45 | match /chats/{chatId}{ 46 | allow read, update: if request.auth.uid in resource.data.users; 47 | allow write: if request.auth.uid != null; 48 | } 49 | match /chats/{chatId}/messages/{documents=**}{ 50 | allow read, write: if true; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /admin/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /admin/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | 15 | @import url('https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600,700,800'); 16 | 17 | * { 18 | box-sizing: border-box; 19 | } 20 | body { 21 | min-height: 100vh; 22 | display: flex; 23 | font-weight: 400; 24 | font-family: 'Fira Sans', sans-serif; 25 | } 26 | 27 | h1,h2,h3,h4,h5,h6,label,span { 28 | font-weight: 500; 29 | font-family: 'Fira Sans', sans-serif; 30 | } 31 | 32 | body, html, .App, #root, .auth-wrapper { 33 | width: 100%; 34 | height: 100%; 35 | } 36 | 37 | .navbar-light { 38 | background-color: #ffffff; 39 | box-shadow: 0px 14px 80px rgba(34, 35, 58, 0.2); 40 | } 41 | 42 | .auth-wrapper { 43 | display: flex; 44 | justify-content: center; 45 | flex-direction: column; 46 | text-align: left; 47 | } 48 | 49 | .auth-inner { 50 | width: 450px; 51 | margin: auto; 52 | background: #ffffff; 53 | box-shadow: 0px 14px 80px rgba(34, 35, 58, 0.2); 54 | padding: 40px 55px 45px 55px; 55 | border-radius: 15px; 56 | transition: all .3s; 57 | } 58 | 59 | .auth-wrapper .form-control:focus { 60 | border-color: #167bff; 61 | box-shadow: none; 62 | } 63 | 64 | .auth-wrapper h3 { 65 | text-align: center; 66 | margin: 0; 67 | line-height: 1; 68 | padding-bottom: 20px; 69 | } 70 | 71 | .custom-control-label { 72 | font-weight: 400; 73 | } 74 | 75 | .forgot-password, 76 | .forgot-password a { 77 | text-align: right; 78 | font-size: 13px; 79 | padding-top: 10px; 80 | color: #7f7d7d; 81 | margin: 0; 82 | } 83 | 84 | .forgot-password a { 85 | color: #167bff; 86 | } 87 | 88 | .vertical-center { 89 | min-height: 100%; /* Fallback for browsers do NOT support vh unit */ 90 | min-height: 100vh; /* These two lines are counted as one :-) */ 91 | 92 | display: flex; 93 | align-items: center; 94 | } 95 | -------------------------------------------------------------------------------- /admin/src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/components/main/profile/Search.js: -------------------------------------------------------------------------------- 1 | import { FontAwesome5 } from '@expo/vector-icons'; 2 | import React, { useState } from 'react'; 3 | import { FlatList, Image, Text, TextInput, TouchableOpacity, View } from 'react-native'; 4 | import { connect } from 'react-redux'; 5 | import { bindActionCreators } from 'redux'; 6 | import { queryUsersByUsername } from '../../../redux/actions/index'; 7 | import { container, text, utils } from '../../styles'; 8 | 9 | require('firebase/firestore'); 10 | 11 | 12 | function Search(props) { 13 | const [users, setUsers] = useState([]) 14 | return ( 15 | 16 | 17 | props.queryUsersByUsername(search).then(setUsers)} /> 21 | 22 | 23 | 24 | ( 29 | props.navigation.navigate("Profile", { uid: item.id, username: undefined })}> 32 | 33 | {item.image == 'default' ? 34 | ( 35 | 38 | 39 | ) 40 | : 41 | ( 42 | 48 | ) 49 | } 50 | 51 | {item.username} 52 | {item.name} 53 | 54 | 55 | 56 | )} 57 | /> 58 | 59 | ) 60 | } 61 | 62 | const mapDispatchProps = (dispatch) => bindActionCreators({ queryUsersByUsername }, dispatch); 63 | 64 | export default connect(null, mapDispatchProps)(Search); -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "node_modules/expo/AppEntry.js", 3 | "scripts": { 4 | "start": "expo start", 5 | "android": "expo start --android", 6 | "ios": "expo start --ios", 7 | "web": "expo start --web", 8 | "eject": "expo eject" 9 | }, 10 | "dependencies": { 11 | "@ffprobe-installer/ffprobe": "^1.1.0", 12 | "@react-native-community/cameraroll": "^4.0.1", 13 | "@react-native-community/masked-view": "0.1.10", 14 | "@react-native-community/netinfo": "6.0.0", 15 | "@react-native-community/slider": "3.0.3", 16 | "@react-navigation/bottom-tabs": "^5.8.0", 17 | "@react-navigation/material-bottom-tabs": "^5.2.16", 18 | "@react-navigation/material-top-tabs": "^5.3.13", 19 | "@react-navigation/native": "^5.7.3", 20 | "@react-navigation/stack": "^5.9.0", 21 | "@skele/components": "^1.0.0-alpha.40", 22 | "babel-preset-expo": "^8.3.0", 23 | "expo": "~42.0.3", 24 | "expo-av": "~9.2.3", 25 | "expo-camera": "~11.2.2", 26 | "expo-cameraroll": "^1.1.0", 27 | "expo-checkbox": "^1.0.3", 28 | "expo-device": "~3.3.0", 29 | "expo-image-picker": "~10.2.2", 30 | "expo-linear-gradient": "~9.2.0", 31 | "expo-media-library": "~12.1.2", 32 | "expo-notifications": "~0.12.3", 33 | "expo-status-bar": "~1.0.4", 34 | "expo-updates": "~0.8.3", 35 | "expo-video-player": "^2.0.1", 36 | "expo-video-thumbnails": "~5.2.1", 37 | "firebase": "8.2.3", 38 | "get-video-duration": "^3.1.0", 39 | "queue": "^6.0.2", 40 | "react": "16.13.1", 41 | "react-dom": "16.13.1", 42 | "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz", 43 | "react-native-bottomsheet-reanimated": "0.0.22", 44 | "react-native-elements": "^3.0.0-alpha.1", 45 | "react-native-expo-cached-image": "^1.3.1", 46 | "react-native-fast-image": "^8.3.4", 47 | "react-native-gesture-handler": "~1.10.2", 48 | "react-native-interactable-reanimated": "0.0.8", 49 | "react-native-mentions": "^1.1.4", 50 | "react-native-optimized-flatlist": "^1.0.4", 51 | "react-native-paper": "^4.7.1", 52 | "react-native-parsed-text": "0.0.22", 53 | "react-native-reanimated": "~2.2.0", 54 | "react-native-restart": "0.0.20", 55 | "react-native-screens": "~3.4.0", 56 | "react-native-tab-view": "^2.15.2", 57 | "react-native-unimodules": " ~0.14.6", 58 | "react-native-vector-icons": "^7.1.0", 59 | "react-native-web": "~0.13.12", 60 | "react-redux": "^7.2.1", 61 | "react-uuid": "^1.0.2", 62 | "react-visibility-sensor": "^5.1.1", 63 | "reanimated-bottom-sheet": "^1.0.0-alpha.22", 64 | "redux": "^4.0.5", 65 | "redux-thunk": "^2.3.0", 66 | "sentry-expo": "^4.0.0" 67 | }, 68 | "devDependencies": { 69 | "@babel/core": "~7.13.0", 70 | "babel-plugin-module-resolver": "^4.1.0" 71 | }, 72 | "private": true 73 | } -------------------------------------------------------------------------------- /admin/src/components/Users.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react' 2 | 3 | import firebase from 'firebase/app'; 4 | import 'firebase/firestore'; 5 | 6 | import { DataGrid } from '@material-ui/data-grid'; 7 | import Chip from '@material-ui/core/Chip'; 8 | import { Clear, Check } from '@material-ui/icons'; 9 | import DoneIcon from '@material-ui/icons/Done'; 10 | import Button from '@material-ui/core/Button'; 11 | import { useHistory } from "react-router-dom"; 12 | 13 | export default function Users() { 14 | const [users, setUsers] = useState([]) 15 | useEffect(() => { 16 | firebase.firestore() 17 | .collection("users") 18 | 19 | .onSnapshot((snapshot) => { 20 | let result = snapshot.docs.map(doc => { 21 | const data = doc.data(); 22 | const id = doc.id; 23 | return { id, ...data } 24 | }) 25 | setUsers(result) 26 | }) 27 | }, []) 28 | const history = useHistory(); 29 | 30 | const columns = [ 31 | { field: 'id', headerName: 'ID', width: 280 }, 32 | { field: 'name', headerName: 'Name', width: 130 }, 33 | { field: 'username', headerName: 'Username', width: 130 }, 34 | { 35 | field: 'banned', headerName: 'banned', width: 150, 36 | renderCell: (params) => ( 37 |
38 | {params.value ? 39 | } 41 | label="True" 42 | color="primary" 43 | variant="outlined" 44 | /> 45 | : 46 | } 48 | label="False" 49 | color="secondary" 50 | variant="outlined" 51 | /> 52 | 53 | 54 | } 55 |
56 | 57 | ), 58 | 59 | }, 60 | { 61 | field: 'link', headerName: 'Detail', width: 150, 62 | renderCell: (params) => ( 63 | 64 |
65 | 68 |
69 | 70 | ), 71 | 72 | }, 73 | ]; 74 | 75 | 76 | 77 | return ( 78 |
79 | ({ 80 | ...column, 81 | disableClickEventBubbling: true, 82 | }))} /> 83 |
84 | ) 85 | } 86 | -------------------------------------------------------------------------------- /backend/functions/index.js: -------------------------------------------------------------------------------- 1 | const functions = require('firebase-functions'); 2 | 3 | const admin = require('firebase-admin'); 4 | admin.initializeApp(); 5 | 6 | const db = admin.firestore(); 7 | 8 | exports.addLike = functions.firestore.document('/posts/{creatorId}/userPosts/{postId}/likes/{userId}') 9 | .onCreate((snap, context) => { 10 | return db 11 | .collection("posts") 12 | .doc(context.params.creatorId) 13 | .collection("userPosts") 14 | .doc(context.params.postId) 15 | .update({ 16 | likesCount: admin.firestore.FieldValue.increment(1) 17 | }) 18 | }); 19 | exports.removeLike = functions.firestore.document('/posts/{creatorId}/userPosts/{postId}/likes/{userId}') 20 | .onDelete((snap, context) => { 21 | return db 22 | .collection('posts') 23 | .doc(context.params.creatorId) 24 | .collection('userPosts') 25 | .doc(context.params.postId) 26 | .update({ 27 | likesCount: admin.firestore.FieldValue.increment(-1) 28 | }) 29 | }) 30 | 31 | 32 | exports.addFollower = functions.firestore.document('/following/{userId}/userFollowing/{FollowingId}') 33 | .onCreate((snap, context) => { 34 | return db 35 | .collection('users') 36 | .doc(context.params.FollowingId) 37 | .update({ 38 | followersCount: admin.firestore.FieldValue.increment(1) 39 | }).then(() => { 40 | return db 41 | .collection('users') 42 | .doc(context.params.userId) 43 | .update({ 44 | followingCount: admin.firestore.FieldValue.increment(1) 45 | }) 46 | }) 47 | }) 48 | 49 | exports.removeFollower = functions.firestore.document('/following/{userId}/userFollowing/{FollowingId}') 50 | .onDelete((snap, context) => { 51 | return db 52 | .collection('users') 53 | .doc(context.params.FollowingId) 54 | .update({ 55 | followersCount: admin.firestore.FieldValue.increment(-1) 56 | }).then(() => { 57 | return db 58 | .collection('users') 59 | .doc(context.params.userId) 60 | .update({ 61 | followingCount: admin.firestore.FieldValue.increment(-1) 62 | }) 63 | }) 64 | }) 65 | 66 | exports.addComment = functions.firestore.document('/posts/{creatorId}/userPosts/{postId}/comments/{userId}') 67 | .onCreate((snap, context) => { 68 | return db 69 | .collection("posts") 70 | .doc(context.params.creatorId) 71 | .collection("userPosts") 72 | .doc(context.params.postId) 73 | .update({ 74 | commentsCount: admin.firestore.FieldValue.increment(1) 75 | }) 76 | }) 77 | -------------------------------------------------------------------------------- /admin/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /frontend/components/auth/Register.js: -------------------------------------------------------------------------------- 1 | import firebase from 'firebase'; 2 | import React, { useState } from 'react'; 3 | import { Button, Text, TextInput, View } from 'react-native'; 4 | import { Snackbar } from 'react-native-paper'; 5 | import { container, form } from '../styles'; 6 | 7 | require('firebase/firestore'); 8 | 9 | export default function Register(props) { 10 | const [email, setEmail] = useState(''); 11 | const [password, setPassword] = useState(''); 12 | const [name, setName] = useState(''); 13 | const [username, setUsername] = useState(''); 14 | const [isValid, setIsValid] = useState(true); 15 | 16 | const onRegister = () => { 17 | if (name.lenght == 0 || username.lenght == 0 || email.length == 0 || password.length == 0) { 18 | setIsValid({ bool: true, boolSnack: true, message: "Please fill out everything" }) 19 | return; 20 | } 21 | if (password.length < 6) { 22 | setIsValid({ bool: true, boolSnack: true, message: "passwords must be at least 6 characters" }) 23 | return; 24 | } 25 | if (password.length < 6) { 26 | setIsValid({ bool: true, boolSnack: true, message: "passwords must be at least 6 characters" }) 27 | return; 28 | } 29 | firebase.firestore() 30 | .collection('users') 31 | .where('username', '==', username) 32 | .get() 33 | .then((snapshot) => { 34 | 35 | if (!snapshot.exist) { 36 | firebase.auth().createUserWithEmailAndPassword(email, password) 37 | .then(() => { 38 | if (snapshot.exist) { 39 | return 40 | } 41 | firebase.firestore().collection("users") 42 | .doc(firebase.auth().currentUser.uid) 43 | .set({ 44 | name, 45 | email, 46 | username, 47 | image: 'default', 48 | followingCount: 0, 49 | followersCount: 0, 50 | 51 | }) 52 | }) 53 | .catch(() => { 54 | setIsValid({ bool: true, boolSnack: true, message: "Something went wrong" }) 55 | }) 56 | } 57 | }).catch(() => { 58 | setIsValid({ bool: true, boolSnack: true, message: "Something went wrong" }) 59 | }) 60 | 61 | } 62 | 63 | return ( 64 | 65 | 66 | setUsername(username.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, '').replace(/[^a-z0-9]/gi, ''))} 72 | /> 73 | setName(name)} 77 | /> 78 | setEmail(email)} 82 | /> 83 | setPassword(password)} 88 | /> 89 | 90 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 96 | 97 | 98 | 99 | 100 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | ) 117 | } 118 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Version](https://img.shields.io/badge/version-1.0-blue.svg?cacheSeconds=2592000) 2 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 3 | [![runs with expo](https://img.shields.io/badge/Runs%20with%20Expo-000.svg?style=flat-square&logo=EXPO&labelColor=f3f3f3&logoColor=000)](https://expo.io/) 4 | [![image](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://twitter.com/simcoder_here) 5 | [![image](https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white)](https://www.instagram.com/simcoder_here/) 6 | [![image](https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white)](https://www.youtube.com/channel/UCQ5xY26cw5Noh6poIE-VBog) 7 | [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/simcoder) 8 | 9 | 10 |
11 |

12 | 13 | Logo 14 | 15 | 16 |

Instagram Clone

17 | 18 |

19 | A Instagram clone app made with React Native and firebase 20 |
21 | Explore the docs » 22 |
23 |
24 | Report Bug 25 | · 26 | Request Feature 27 |

28 |

29 | 30 | 31 |
32 |

Table of Contents

33 |
    34 |
  1. 35 | About The Project 36 | 39 |
  2. 40 |
  3. 41 | Getting Started 42 | 46 |
  4. 47 |
  5. Roadmap
  6. 48 |
  7. Contributing
  8. 49 |
  9. Support
  10. 50 |
  11. License
  12. 51 |
  13. Contact
  14. 52 |
53 |
54 | 55 | 56 | 57 | ## ℹ️ About The Project 58 | 59 | ![alt text](images/mockup.png "Title") 60 | 61 | This repo contains the project made in my youtube chanel called simcoder. This project is a clone of the Instagram android app. 62 | 63 | It is made using React Native with Expo using firebase services (authentication, firestore and storage). 64 | The admin panel is made with ReactJS. 65 | The backend is all NodeJS 66 | 67 | In the [master](https://github.com/SimCoderYoutube/InstagramClone/tree/master) branch you have the redesign project which I was previously selling in my website, however you still have access to the youtube series repo in the [youtube_series](https://github.com/SimCoderYoutube/InstagramClone/tree/youtube_series) 68 | 69 | You can follow the youtube series in the following [link](https://www.youtube.com/watch?v=xE8UEX7vXVQ&list=PLxabZQCAe5fgatwOQny9wKJVs4YD6xkf1) 70 | 71 | ## 🆕 Getting Started 72 | 73 | - ### **Prerequisites** 74 | 75 | - [React Native](https://reactnative.dev/) 76 | - [Expo](https://expo.dev/) 77 | - [Firebase](https://firebase.google.com/) 78 | 79 | 80 | 81 | - ### **Installation** 82 | 83 | In order to deploy the project you'll need to follow the [wiki page](https://github.com/SimCoderYoutube/InstagramClone/wiki/Setup-your-project) dedicated to this effect. 84 | 85 | ## 🚧 Roadmap 86 | 87 | See the [open issues](https://github.com/SimCoderYoutube/InstagramClone/issues) for a list of proposed features (and known issues). 88 | 89 | 90 | 91 | ## ➕ Contributing 92 | 93 | Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**. Please check the [Wiki](https://github.com/SimCoderYoutube/InstagramClone/wiki/How-to-Contribute) 94 | 95 | ## 🌟 Show your support 96 | 97 | Give a ⭐️ if this project helped you! 98 | 99 | And don't forget to subscribe to the [youtube chanel](https://www.youtube.com/c/SimpleCoder?sub_confirmation=1) 100 | 101 | ## 📝 License 102 | 103 | Copyright © 2021 [SimCoder](https://github.com/simcoderYoutube). 104 | 105 | This project is [Apache License 2.0](https://github.com/SimCoderYoutube/InstagramClone/blob/master/LICENSE) licensed. Some of the dependencies are licensed differently. 106 | 107 | 108 | 109 | ## 👤 Contact 110 | 111 | **SimCoder** 112 | 113 | - Website: www.simcoder.com 114 | - Twitter: [@simcoder_here](https://twitter.com/simcoder_here) 115 | - Github: [@simcoderYoutube](https://github.com/simcoderYoutube) 116 | - Youtube: [SimCoder](https://www.youtube.com/channel/UCQ5xY26cw5Noh6poIE-VBog) 117 | -------------------------------------------------------------------------------- /admin/src/components/Post.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react' 2 | import { useLocation } from "react-router-dom"; 3 | import firebase from 'firebase/app'; 4 | import 'firebase/firestore'; 5 | import { Paper, Avatar, Divider, CircularProgress, Button, TextField } from '@material-ui/core'; 6 | import { DataGrid } from '@material-ui/data-grid'; 7 | 8 | import Chip from '@material-ui/core/Chip'; 9 | import { Clear, Check, PhotoSizeSelectLargeRounded, Markunread } from '@material-ui/icons'; 10 | import DoneIcon from '@material-ui/icons/Done'; 11 | import { useHistory } from "react-router-dom"; 12 | import { FaBeer } from 'react-icons/fa'; 13 | 14 | export default function Post(props) { 15 | const [post, setPost] = useState(null) 16 | const [comments, setComments] = useState([]) 17 | const [loaded, setLoaded] = useState(false) 18 | const location = useLocation(); 19 | const history = useHistory(); 20 | 21 | useEffect(() => { 22 | firebase.firestore() 23 | .collection("posts") 24 | .doc(props.match.params.uid) 25 | .collection('userPosts') 26 | .doc(props.match.params.id) 27 | .onSnapshot((snapshot) => { 28 | if (snapshot.exists) { 29 | let result = snapshot.data(); 30 | result.id = snapshot.id; 31 | setPost(result); 32 | } 33 | }) 34 | }, []) 35 | 36 | useEffect(() => { 37 | if (post == null) { 38 | return; 39 | } 40 | firebase.firestore() 41 | .collection("posts") 42 | .doc(props.match.params.uid) 43 | .collection("userPosts") 44 | .doc(props.match.params.id) 45 | .collection('comments') 46 | .onSnapshot((snapshot) => { 47 | let result = snapshot.docs.map(doc => { 48 | const data = doc.data(); 49 | const id = doc.id; 50 | return { id, ...data } 51 | }) 52 | setComments(result) 53 | setLoaded(true) 54 | }) 55 | }, [post]) 56 | 57 | const deleteComment = (id) => { 58 | firebase.firestore() 59 | .collection("posts") 60 | .doc(props.match.params.uid) 61 | .collection("userPosts") 62 | .doc(props.match.params.id) 63 | .collection('comments') 64 | .doc(id) 65 | .delete() 66 | } 67 | const deletePost = () => { 68 | firebase.firestore() 69 | .collection("posts") 70 | .doc(props.match.params.uid) 71 | .collection("userPosts") 72 | .doc(props.match.params.id) 73 | .delete() 74 | 75 | firebase.firestore() 76 | .collection("feed") 77 | .doc(post.id) 78 | .delete() 79 | } 80 | 81 | 82 | const columns = [ 83 | { field: 'id', headerName: 'ID', width: 280 }, 84 | { field: 'text', headerName: 'text', width: 400 }, 85 | { 86 | field: 'delete', headerName: 'delete', width: 150, 87 | renderCell: (params) => ( 88 | 89 |
90 | 93 |
94 | 95 | ), 96 | 97 | }, 98 | { 99 | field: 'user', headerName: 'user', width: 150, 100 | renderCell: (params) => ( 101 | 102 |
103 | 106 |
107 | 108 | ), 109 | 110 | }, 111 | ]; 112 | 113 | if (!loaded) { 114 | return ( 115 | 121 | ) 122 | } 123 | const date = new Date(post['creation'].seconds * 1000) 124 | return ( 125 |
126 | 127 |
128 | 129 |

Caption

130 |

{post.caption}

131 | 132 | 133 |

Date

134 |

{date.toString()}

135 |
136 | 137 | 138 | 141 |
142 | 143 | 144 | 145 | ({ 146 | ...column, 147 | disableClickEventBubbling: true, 148 | }))} /> 149 | 150 |
151 | ) 152 | } 153 | -------------------------------------------------------------------------------- /frontend/App.js: -------------------------------------------------------------------------------- 1 | import { getFocusedRouteNameFromRoute, NavigationContainer } from '@react-navigation/native'; 2 | import { createStackNavigator } from '@react-navigation/stack'; 3 | import 'expo-asset'; 4 | import * as firebase from 'firebase'; 5 | import _ from 'lodash'; 6 | import React, { Component } from 'react'; 7 | import { Image, LogBox } from 'react-native'; 8 | import { Provider } from 'react-redux'; 9 | import { applyMiddleware, createStore } from 'redux'; 10 | import thunk from 'redux-thunk'; 11 | import LoginScreen from './components/auth/Login'; 12 | import RegisterScreen from './components/auth/Register'; 13 | import MainScreen from './components/Main'; 14 | import SaveScreen from './components/main/add/Save'; 15 | import ChatScreen from './components/main/chat/Chat'; 16 | import ChatListScreen from './components/main/chat/List'; 17 | import CommentScreen from './components/main/post/Comment'; 18 | import PostScreen from './components/main/post/Post'; 19 | import EditScreen from './components/main/profile/Edit'; 20 | import ProfileScreen from './components/main/profile/Profile'; 21 | import BlockedScreen from './components/main/random/Blocked'; 22 | import { container } from './components/styles'; 23 | import rootReducer from './redux/reducers'; 24 | 25 | const store = createStore(rootReducer, applyMiddleware(thunk)) 26 | 27 | LogBox.ignoreLogs(['Setting a timer']); 28 | const _console = _.clone(console); 29 | console.warn = message => { 30 | if (message.indexOf('Setting a timer') <= -1) { 31 | _console.warn(message); 32 | } 33 | }; 34 | 35 | const firebaseConfig = { 36 | apiKey: "****", 37 | authDomain: "****", 38 | databaseURL: "****", 39 | projectId: "****", 40 | storageBucket: "****", 41 | messagingSenderId: "****", 42 | appId: "****", 43 | measurementId: "****" 44 | }; 45 | 46 | const logo = require('./assets/logo.png') 47 | 48 | if (firebase.apps.length === 0) { 49 | firebase.initializeApp(firebaseConfig) 50 | } 51 | 52 | const Stack = createStackNavigator(); 53 | 54 | export class App extends Component { 55 | constructor(props) { 56 | super() 57 | this.state = { 58 | loaded: false, 59 | } 60 | } 61 | 62 | componentDidMount() { 63 | firebase.auth().onAuthStateChanged((user) => { 64 | if (!user) { 65 | this.setState({ 66 | loggedIn: false, 67 | loaded: true, 68 | }) 69 | } else { 70 | this.setState({ 71 | loggedIn: true, 72 | loaded: true, 73 | }) 74 | } 75 | }) 76 | } 77 | render() { 78 | const { loggedIn, loaded } = this.state; 79 | if (!loaded) { 80 | return ( 81 | 82 | ) 83 | } 84 | 85 | if (!loggedIn) { 86 | return ( 87 | 88 | 89 | 90 | 91 | 92 | 93 | ); 94 | } 95 | 96 | return ( 97 | 98 | 99 | 100 | { 101 | const routeName = getFocusedRouteNameFromRoute(route) ?? 'Feed'; 102 | 103 | switch (routeName) { 104 | case 'Camera': { 105 | return { 106 | headerTitle: 'Camera', 107 | }; 108 | } 109 | case 'chat': { 110 | return { 111 | headerTitle: 'Chat', 112 | }; 113 | } 114 | case 'Profile': { 115 | return { 116 | headerTitle: 'Profile', 117 | }; 118 | } 119 | case 'Search': { 120 | return { 121 | headerTitle: 'Search', 122 | }; 123 | } 124 | case 'Feed': 125 | default: { 126 | return { 127 | headerTitle: 'Instagram', 128 | }; 129 | } 130 | } 131 | }} 132 | /> 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | ) 147 | } 148 | } 149 | 150 | export default App 151 | -------------------------------------------------------------------------------- /admin/src/components/User.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react' 2 | import { useHistory, useLocation } from "react-router-dom"; 3 | import firebase from 'firebase/app'; 4 | import 'firebase/firestore'; 5 | import { Paper, Avatar, Divider, CircularProgress, Button, TextField } from '@material-ui/core'; 6 | import { DataGrid } from '@material-ui/data-grid'; 7 | 8 | export default function User(props) { 9 | const [user, setUser] = useState([]) 10 | const [banReason, setBanReason] = useState('') 11 | const location = useLocation(); 12 | const [posts, setPosts] = useState([]) 13 | useEffect(() => { 14 | firebase.firestore() 15 | .collection("posts") 16 | .doc(props.match.params.id) 17 | .collection("userPosts") 18 | .onSnapshot((snapshot) => { 19 | let result = snapshot.docs.map(doc => { 20 | const data = doc.data(); 21 | const id = doc.id; 22 | return { id, ...data } 23 | }) 24 | setPosts(result) 25 | }) 26 | }, []) 27 | useEffect(() => { 28 | firebase.firestore() 29 | .collection("users") 30 | .doc(props.match.params.id) 31 | .onSnapshot((snapshot) => { 32 | if (snapshot.exists) { 33 | let user = snapshot.data(); 34 | user.uid = snapshot.id; 35 | 36 | setUser(user); 37 | } 38 | }) 39 | }, []) 40 | 41 | const banUser = () => { 42 | firebase.firestore() 43 | .collection("users") 44 | .doc(props.match.params.id) 45 | .update({ 46 | banned: true, 47 | banDetails: { 48 | banReason: banReason.target.value, 49 | date: firebase.firestore.FieldValue.serverTimestamp() 50 | } 51 | }) 52 | } 53 | const unbanUser = () => { 54 | firebase.firestore() 55 | .collection("users") 56 | .doc(props.match.params.id) 57 | .update({ 58 | banned: false, 59 | banDetails: {} 60 | }) 61 | } 62 | const history = useHistory(); 63 | const columns = [ 64 | { field: 'caption', headerName: 'caption', width: 400 }, 65 | 66 | { field: 'likesCount', headerName: 'likesCount', width: 130 }, 67 | { field: 'commentsCount', headerName: 'commentsCount', width: 130 }, 68 | { 69 | field: 'creation', headerName: 'creation', width: 200, 70 | valueGetter: (params) => 71 | `${new Date(params.value.seconds * 1000)}` 72 | }, 73 | { 74 | field: 'link', headerName: 'Detail', width: 150, 75 | renderCell: (params) => ( 76 |
77 | 80 |
81 | ), 82 | 83 | }, 84 | ]; 85 | 86 | if (user.length == 0) { 87 | return ( 88 | 94 | ) 95 | } 96 | return ( 97 |
98 | 99 | 100 |
101 | 102 |

{user.name}

103 |
{user.username}
104 |
105 |
106 | 107 | 108 | 109 |
110 | 111 |

email

112 |

{user.email}

113 | 114 | 115 | 116 |
117 |
118 | 119 | 120 | {!user.banned ? 121 |
122 | 132 | 133 | 134 | 135 |
136 | : 137 |
138 | 139 | 140 |
141 | } 142 |
143 | 144 | 145 | ({ 146 | ...column, 147 | disableClickEventBubbling: true, 148 | }))} /> 149 | 150 |
151 | ) 152 | } -------------------------------------------------------------------------------- /frontend/components/main/profile/Edit.js: -------------------------------------------------------------------------------- 1 | import { Feather, FontAwesome5 } from '@expo/vector-icons'; 2 | import * as ImagePicker from 'expo-image-picker'; 3 | import * as Updates from 'expo-updates'; 4 | import firebase from 'firebase'; 5 | import React, { useEffect, useLayoutEffect, useState } from 'react'; 6 | import { Button, Image, Text, TextInput, TouchableOpacity, View } from 'react-native'; 7 | import { connect } from 'react-redux'; 8 | import { bindActionCreators } from 'redux'; 9 | import { updateUserFeedPosts } from '../../../redux/actions/index'; 10 | import { container, form, navbar, text, utils } from '../../styles'; 11 | 12 | require('firebase/firestore') 13 | 14 | 15 | function Edit(props) { 16 | const [name, setName] = useState(props.currentUser.name); 17 | const [description, setDescription] = useState(""); 18 | const [image, setImage] = useState(props.currentUser.image); 19 | const [imageChanged, setImageChanged] = useState(false); 20 | const [hasGalleryPermission, setHasGalleryPermission] = useState(null); 21 | 22 | const onLogout = async () => { 23 | firebase.auth().signOut(); 24 | Updates.reloadAsync() 25 | } 26 | 27 | 28 | useEffect(() => { 29 | (async () => { 30 | if (props.currentUser.description !== undefined) { 31 | setDescription(props.currentUser.description) 32 | } 33 | 34 | })(); 35 | }, []); 36 | 37 | useLayoutEffect(() => { 38 | props.navigation.setOptions({ 39 | headerRight: () => ( 40 | 41 | { console.log({ name, description }); Save() }} /> 42 | ), 43 | }); 44 | }, [props.navigation, name, description, image, imageChanged]); 45 | 46 | 47 | const pickImage = async () => { 48 | if (true) { 49 | let result = await ImagePicker.launchImageLibraryAsync({ 50 | mediaTypes: ImagePicker.MediaTypeOptions.Images, 51 | allowsEditing: true, 52 | aspect: [1, 1], 53 | quality: 1, 54 | }); 55 | 56 | if (!result.cancelled) { 57 | setImage(result.uri); 58 | setImageChanged(true); 59 | } 60 | } 61 | }; 62 | 63 | 64 | const Save = async () => { 65 | if (imageChanged) { 66 | const uri = image; 67 | const childPath = `profile/${firebase.auth().currentUser.uid}`; 68 | 69 | const response = await fetch(uri); 70 | const blob = await response.blob(); 71 | 72 | const task = firebase 73 | .storage() 74 | .ref() 75 | .child(childPath) 76 | .put(blob); 77 | 78 | const taskProgress = snapshot => { 79 | console.log(`transferred: ${snapshot.bytesTransferred}`) 80 | } 81 | 82 | const taskCompleted = () => { 83 | task.snapshot.ref.getDownloadURL().then((snapshot) => { 84 | 85 | firebase.firestore().collection("users") 86 | .doc(firebase.auth().currentUser.uid) 87 | .update({ 88 | name, 89 | description, 90 | image: snapshot, 91 | }).then(() => { 92 | props.updateUserFeedPosts(); 93 | props.navigation.goBack() 94 | 95 | }) 96 | }) 97 | } 98 | 99 | const taskError = snapshot => { 100 | console.log(snapshot) 101 | } 102 | 103 | task.on("state_changed", taskProgress, taskError, taskCompleted); 104 | } else { 105 | saveData({ 106 | name, 107 | description, 108 | }) 109 | } 110 | } 111 | 112 | const saveData = (data) => { 113 | firebase.firestore().collection("users") 114 | .doc(firebase.auth().currentUser.uid) 115 | .update(data).then(() => { 116 | props.updateUserFeedPosts(); 117 | 118 | props.navigation.goBack() 119 | }) 120 | } 121 | 122 | return ( 123 | 124 | 125 | pickImage()} > 126 | {image == 'default' ? 127 | ( 128 | 131 | ) 132 | : 133 | ( 134 | 140 | ) 141 | } 142 | Change Profile Photo 143 | 144 | 145 | setName(name)} 150 | /> 151 | { setDescription(description); }} 157 | /> 158 |