Skip to content

Instantly share code, notes, and snippets.

View youneshenniwrites's full-sized avatar
🎯
Focusing

Younes Henni youneshenniwrites

🎯
Focusing
View GitHub Profile
@youneshenniwrites
youneshenniwrites / App.js
Created December 11, 2018 14:05
Gist of first commit Zopher
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
</View>
);
@youneshenniwrites
youneshenniwrites / App.js
Last active December 12, 2018 15:59
Zopher second commit
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'
// Amplify auth imports and config
import Amplify from '@aws-amplify/core'
import { withAuthenticator } from 'aws-amplify-react-native'
import config from './aws-exports';
Amplify.configure(config)
@youneshenniwrites
youneshenniwrites / GraphQL.js
Created December 13, 2018 14:38
mutations and queries to perform CRUD operations to AWS DynamoDB
// Get all posts with all their likes
export const listPosts = `
query {
listPosts{
items {
id
postOwnerUsername
postContent
postOwnerId
likes {
@youneshenniwrites
youneshenniwrites / App.js
Created December 13, 2018 16:54
Post creation with AWS GraphQL
import React from 'react'
import {
StyleSheet,
View,
TextInput,
} from 'react-native'
// Amplify auth imports and config
import Amplify from '@aws-amplify/core'
import { withAuthenticator } from 'aws-amplify-react-native'
@youneshenniwrites
youneshenniwrites / Styles.js
Created December 14, 2018 18:19
Styling file for Zopher
import { StyleSheet, Dimensions } from 'react-native'
// Get the width of the device
let { width } = Dimensions.get('window')
const styles = StyleSheet.create({
container: {
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
@youneshenniwrites
youneshenniwrites / toggleLike.js
Created December 22, 2018 10:39
Functionality of the like button for the Zopher app
toggleLikePost = async (post) => {
const loggedInUser = await this.state.postOwnerId
// Get the like instance of the logged in user
const likeUserObject = await post.likes.items.filter(
obj => obj.likeOwnerId === loggedInUser
)
// If there is a like instance fire a delete action
if (likeUserObject.length !== 0) {
await this.deleteLike(likeUserObject)
return
@youneshenniwrites
youneshenniwrites / LikeButtonComponent.js
Last active December 22, 2018 12:33
Like button logic inside the render method of Zopher
<ScrollView contentContainerStyle={styles.container}>
<View style={{flex: 1, alignItems: 'center'}}>
{
this.state.posts.map((post, index) => (
<Card key={index} style={styles.cardStyle}>
{/* Post body */}
<Text style={styles.postBody}>
{post.postContent}
</Text>
<Text style={styles.postUsername}>
@youneshenniwrites
youneshenniwrites / PhoneInput.js
Last active January 4, 2019 12:32
Phone input basic level with keyboard avoiding view
import React from 'react'
import {
View,
StyleSheet,
SafeAreaView,
Keyboard,
KeyboardAvoidingView,
TouchableWithoutFeedback
} from 'react-native'
// native base imports
@youneshenniwrites
youneshenniwrites / PhoneInputStyle.js
Created January 4, 2019 12:36
Final styling of the phone input app
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#aa73b7',
justifyContent: 'center',
flexDirection: 'column'
},
infoContainer: {
position: 'absolute',
left: 0,
@youneshenniwrites
youneshenniwrites / WelcomeScreen.js
Created January 8, 2019 12:44
First design for the welcome screen of the RNAuthAWS
import React from 'react'
import {
StyleSheet,
View,
Text,
TouchableOpacity,
} from 'react-native'
export default class WelcomeScreen extends React.Component {
handleRoute = async (destination) => {