A simple copy of the Reddit app using it's API in React Native

Overview

REDDITECH DOCUMENTATION


BACK :

API :

API call method :

import { authorize } from 'react-native-app-auth'

const config = {
    redirectUrl: 'com.redditech://oauth2redirect/reddit',
    clientId: 'fcafYt6_OhrlQEN6NTTyUQ',
    clientSecret: '',
    scopes: ['identity', 'edit', 'subscribe', 'save', 'submit', 'read', 'modconfig', 'account', 'vote', 'flair', 'mysubreddits'],
    serviceConfiguration: {
        authorizationEndpoint: 'https://www.reddit.com/api/v1/authorize.compact',
        tokenEndpoint: 'https://www.reddit.com/api/v1/access_token',
    },
    customHeaders: {
        token: {
            Authorization: 'Basic ZmNhZll0Nl9PaHJsUUVONk5UVHlVUQ==',
        },
    },
};

const Auth = useCallback(
    async call => {
        try {
            const authState = await authorize(config);
                console.log(authState.accessToken)
        } catch(e) {
            console.log(e)
        }
    }
)

This returns the user token which we needs to get the user's information, subscribed subreddits, settings...

Knowing the token we can now use reddit's api to call the user information for exemple

const options = {
    method: 'GET',
    url: 'https://oauth.reddit.com/api/v1/me',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        Authorization: "Bearer " + global.Token,
    },
};

We can also use the API without needing the the token, we can for exemple get the top post on reddit like this

const options = {
        method: 'GET',
        url: 'https://www.reddit.com/r/' + 'top' + '.json',
    };

Now to get the output we need in json, after adding options we are going to do an axios call

axios.request(options).then(function (res) {
    console.log(res.data)
}).catch(function (error) {
    console.error(error);
});

We are now outputing in the console the content from our GET call from the API

Having this we can use a UseState to keep it and call it later

const [User, setUser] = useState(
    { all: null }
)

For the rest of the application we just use the different api call listed in the reddit documentation listed here : https://www.reddit.com/dev/api/

NAVIGATION :

In our application we only have a topbar with a Home, Profile & Search button. The rest of the navigation is used in the content of the application like if you click on the subreddit name on post you will be redirected to the subreddit.

We are using stacks for naigation from react-navigation

">
<Stack.Screen name="Search" component={Search} />
<Stack.Screen name="Settings" component={Settings} />
<Stack.Screen name="Connection" component={Connection} />
<Stack.Screen name="Subreddit" component={Subreddit} options={{
  headerTintColor: '#fff',
  headerTitleStyle: {
    fontWeight: 'bold',
  }, headerStyle: { backgroundColor: '#ffa31a' }
}} />

Here we have multiple Stacks (each representing one file), we can also see that some stacks have specific values added to them for the Front

To call those different Stacks in app we mostly use onPress like this

onPress={() => navigation.navigate('Search')}

A diagram to show how the stacks works

menu

TECHNOLOGIES

We used different libraries :

  • axios
    • Call API
  • react-native-app-auth
    • Connection to Reddit
  • react-navigation
    • Create Stack Navigator

FRONT

Regarding the Front of our application we first got inspired by PornHub Colors and Logo. We decided to use their orange, our 3 colors are

Orange: #ffa31a Black: #000000 White: #ffffff

and our logo:

menu

For the UI we have as I said a TopBar with 3 buttons, on the Home page where we have the feed on the bottom left we have a button to choose how we want to filter our feed.

menu

Our UX is straight forward and simple to understand and use :

  • Only 4 Button on the home page
    • Filters
    • Home
    • Search
    • Profile
  • Only one fuctionnality per page

TECHNOLOGIES

We used different libraries :

  • react-native-elements
    • Buttons / Icons / FAB / Card
  • react-native-paper
    • Searchbar
You might also like...

This project is used to extract media from various posting platfroms like Twitter, Reddit, Pixiv, Youtube and many other

Social-Picker-API This project is used to extract media from various posting platfroms like Twitter, Reddit, Pixiv, Youtube and many others. It's writ

Nov 29, 2022

A recreation of a startpage posted on Reddit without the source, so I rewrote it in Next.js + Tailwind for the open source community.

Startpage "Figma Balls" Rewrite Why Did I Make This I saw a startpage posted on the subreddit r/startpages that I thought looked nice, but when I look

Mar 29, 2022

Tool to automate making Reddit accounts, written in Node.

redgen Tool to automate making Reddit accounts, written in Node. installation & configuration NOTE: This program requires that you have a 2Captcha acc

Sep 1, 2022

The /r/place Atlas is a project aiming to catalog all the artworks created during Reddit's 2022 /r/place event.

The 2022 Place Atlas The /r/place Atlas is a project aiming to catalog all the artworks created during Reddit's 2022 /r/place event. This project was

Dec 28, 2022

Reddit Clone in TypeScript

Reddit Clone in TypeScript Kind of out of inspiration for hobby projects, so instead... I will dig into reddit and create a clone with its core functi

Jul 21, 2022

3D Infinite Art Gallery! This pulls from Reddit's r/Art and creates a procedural infinite art gallery from random (sfw-only) posts.

3D Infinite Art Gallery! This pulls from Reddit's r/Art and creates a procedural infinite art gallery from random (sfw-only) posts.

Infinite-Art-Gallery Click for Demo! 3D Infinite Procedurally-Generated Art Gallery! This pulls from Reddit's r/Art and creates a procedural infinite

Dec 15, 2022

📕 The minimal and reddit like forum

📕 The minimal and reddit like forum

jeddit 📕 The minimal and reddit like forum Install git clone https://github.com/kyro95/jeddit.git cd reddit npm install npx prisma db push Setup Crea

Sep 1, 2022

Extension forcing Reddit videos to be played by the fallback player.

⚡ FRP: The "Fuck Reddit Player" extension Simple extension to force Reddit videos to be played by the fallback player. Installation: 🦊 addons.mozilla

Oct 21, 2022

Extension forcing Reddit videos to be played by the fallback player.

⚡ FRP: The "Fuck Reddit Player" extension Simple extension to force Reddit videos to be played by the fallback player. Installation: 🦊 addons.mozilla

Oct 21, 2022
Owner
Arthur
Developer in the making
Arthur
Reddit Place Tracer is a browser based userscript for the 2022 Reddit /r/Place project

Reddit Place Tracer is a browser based userscript for the 2022 Reddit /r/Place project which adds a transparent image on top of the canvas to aid communities with drawing the same image. It shows how the canvas should look, where each pixel goes, and what color. The user must manually click on these spots. It is not an automated bot and does not break any rules.

null 3 Apr 3, 2022
It's a repository to studies. Its idea is to learn about Nx and its plugins.

StudyingNx This project was generated using Nx. ?? Smart, Fast and Extensible Build System Adding capabilities to your workspace Nx supports many plug

Open-ish 4 May 13, 2022
Can see everything, beware of its omniscience, kneel before its greatness.

Can see everything, beware of its omniscience, kneel before its greatness. Summary Presentation Installation Removing Credits Presentation Main goal T

Duc Justin 3 Sep 30, 2022
"Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations and read random math-related quotes. Its built using react

Math Magician "Math magicians" is a website for all fans of mathematics. It is a Single Page App (SPA) that allows users to make simple calculations a

Charles Gobina 5 Feb 23, 2022
Reddit Page CLONE using Angular! A repository to contribute at hacktoberfest 2022. Make sure to share love by giving it a star.🌟 Have a great day!

Reddit_tool Reddit Site CLONE using Angular, Springboot and Swagger OpenAI ! Introduction This project was developed with the following technologies:

Momo-Solaris8 4 Oct 20, 2022
Its an app that uses a weather API with access to over 200,000 cities current weather conditons.

Weather App Its an app that uses a weather API with access to over 200,000 cities current weather conditons. Screenshots Links Live Site URL: live sit

Yusuf Lawal 5 Aug 17, 2022
Reddit Wherever Chrome Extension

Reddit Wherever Reddit Wherever adds Reddit comments to Youtube Videos and also allows you to view Reddit comments of any webpage. By default YouTube

null 1 Jan 3, 2022