Skip to content

Instantly share code, notes, and snippets.

View jaunesarmiento's full-sized avatar

Jaune Carlo Sarmiento jaunesarmiento

View GitHub Profile
@jaunesarmiento
jaunesarmiento / MyComponent.js
Last active April 21, 2017 06:11
React Native Style Utils
'use strict'
import React, { Component } from 'react'
import {
Text,
View
} from 'react-native'
// Styles are separated from the component
// since components tend to have crazy number of lines
'use strict'
import React, { Component } from 'react'
import {
TouchableOpacity,
View,
} from 'react-native'
class ColorButton extends Component {
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@jaunesarmiento
jaunesarmiento / gist:fdb872f12f6521e1b088a84af69dd41a
Created November 19, 2017 09:14 — forked from xaphod/gist:7aab1302004f6e933593a11ad8f5a72d
Scroll keyboard up just enough to show control. Swift 3.
// note that currentFirstResponder is obtained by this:
//
// static var currentFirstResponder: UIResponder?
// func findFirstResponder(sender: Any) {
// currentFirstResponder = self
// }
//
// class func currentFirstResponder() -> UIResponder? {
// currentFirstResponder = nil
// UIApplication.shared.sendAction(#selector(findFirstResponder), to: nil, from: nil, for: nil)
// ... import statements here
function App() {
// Placeholder function for handling changes to our chat bar
const handleChange = () => {};
// Placeholder function for handling the form submission
const handleSubmit = () => {};
* {
box-sizing: border-box;
}
html, body {
height: 100%;
}
#root {
display: flex;
import React, { useEffect, useState } from 'react';
import API, { graphqlOperation } from '@aws-amplify/api';
import { listMessages } from './graphql/queries';
// ... rest of the code here
const [messages, setMessages] = useState([]);
useEffect(() => {
API
.graphql(graphqlOperation(listMessages))
.then((response) => {
const items = response.data?.listMessages?.items;
if (items) {
setMessages(items);
{messages.map((message) => (
<div
key={message.id}
className={message.author === 'Dave' ? 'message me' : 'message'}>{message.body}</div>
))}
.message {
align-self: flex-start;
...
}
.message.me {
align-self: flex-end;
...
}