Skip to content

Instantly share code, notes, and snippets.

import { View, ScrollView, Text, Animated, PanResponder } from 'react-native';
class App extends Component {
constructor(props) {
super(props);
this.state = {
cards: [],
}
}
this.mainPanResponder = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onMoveShouldSetPanResponder: () => true,
onPanResponderMove: Animated.event([
null, { dx: this.mainPosition.x, dy: this.mainPosition.y }
]),
onPanResponderGrant: (event, gesture) => {
this.mainPosition.setOffset({
x: this.mainPosition.x._value,
y: this.mainPosition.y._value
addCard = (y) => {
const { cards } = this.state;
const newStack = [...cards];
const style = { ...styles.dropCard };
style.top = y;
const card = (
<view key="{y}" style="{style}">
<text>Sample</text>
</view>
import React, { Component } from 'react';
import { View, ScrollView, Text, Animated, PanResponder } from 'react-native';
class App extends Component {
constructor(props) {
super(props);
@iskenxan
iskenxan / addon.js
Created March 25, 2019 03:25
Gmail add-on basic setup
function buildAddOn(e) {
var accessToken = e.messageMetadata.accessToken;
GmailApp.setCurrentMessageAccessToken(accessToken);
var textWidget = CardService.newTextParagraph().setText('Hello World')
section.addWidget(textWidget);
var card = CardService.newCardBuilder()
.setHeader(CardService.newCardHeader()
@iskenxan
iskenxan / addon_auth.js
Created March 25, 2019 03:27
Gmail add-on authentication code
var scopes = [
'https://www.googleapis.com/auth/script.external_request',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/gmail.addons.execute',
'https://www.googleapis.com/auth/gmail.addons.current.message.readonly'
]
function getService() {
return OAuth2.createService('Demo Auth')
@iskenxan
iskenxan / addon_updated.js
Created March 25, 2019 03:29
Gmail add-on update buildAddon
function buildAddOn(e) {
var accessToken = e.messageMetadata.accessToken;
GmailApp.setCurrentMessageAccessToken(accessToken);
checkAuth()
var section = CardService.newCardSection()
var textWidget = CardService.newTextParagraph().setText('Hello World')
section.addWidget(textWidget);
@iskenxan
iskenxan / login.ejs
Created March 25, 2019 03:31
Gmail addon login page
<!DOCTYPE html>
<head>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="<%= clientId %>">
</head>
<body>
<div>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
@iskenxan
iskenxan / token_url.js
Created March 25, 2019 03:32
Gmail add-on. Token Url
app.post('/token', (req, res) => {
const { code } = req.body;
console.log(code);
const result = {};
if (!code || code.length <= 0) {
result.error = 'no valid code!'
} else {
result.expires_in = 2592000
}
@iskenxan
iskenxan / follow.js
Created April 7, 2019 19:11
GetStream follow user
const followUser = (username, following) => {
const timelineFeed = client.feed('timeline', username);
timelineFeed.follow('user', following);
};