Skip to content

Instantly share code, notes, and snippets.

import React, {Component} from "react";
import {Animated, Dimensions, Platform, Text, View} from 'react-native';
import {Body, Header, List, ListItem as Item, ScrollableTab, Tab, Tabs, Title} from "native-base";
const NAVBAR_HEIGHT = 56;
const {width: SCREEN_WIDTH} = Dimensions.get("window");
const COLOR = "rgb(45,181,102)";
const TAB_PROPS = {
tabStyle: {width: SCREEN_WIDTH / 2, backgroundColor: COLOR},
activeTabStyle: {width: SCREEN_WIDTH / 2, backgroundColor: COLOR},
@andigu
andigu / TabParallax.js
Last active October 23, 2023 07:34
A react native component featuring parallax scrolling with tabs
import React, {Component} from "react";
import {Animated, Dimensions, Platform, Text, TouchableOpacity, View} from "react-native";
import {Body, Header, List, ListItem as Item, ScrollableTab, Tab, TabHeading, Tabs, Title} from "native-base";
import LinearGradient from "react-native-linear-gradient";
const {width: SCREEN_WIDTH} = Dimensions.get("window");
const IMAGE_HEIGHT = 250;
const HEADER_HEIGHT = Platform.OS === "ios" ? 64 : 50;
const SCROLL_HEIGHT = IMAGE_HEIGHT - HEADER_HEIGHT;
const THEME_COLOR = "rgba(85,186,255, 1)";
export const diffClamp = function(
a: Animated.Value<number>,
min: number,
max: number,
): AnimatedDiffClamp {
return new AnimatedDiffClamp(a, min, max);
};
class AnimatedDiffClamp {
constructor(a: Animated.Value<number>, min: number, max: number) {
@andigu
andigu / navigator.js
Last active February 26, 2023 18:02
import React, { Component } from 'react'
import { Animated, Easing, StyleSheet, View, Dimensions } from 'react-native'
import { Transitioner } from 'react-navigation'
const {height: screenHeight} = Dimensions.get('window');
export default class BubbleTransition extends Component {
renderScene = ({position}, {index, key, route}) => {
const Screen = this.props.router.getComponentForRouteName(route.routeName)
return <View style={StyleSheet.absoluteFill} key={key}>
public class GeoLocationModule extends ReactContextBaseJavaModule {
public GeoLocationModule(ReactApplicationContext reactContext) {
super(reactContext);
BroadcastReceiver geoLocationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Location message = intent.getParcelableExtra("message");
GeoLocationModule.this.sendEvent(message);
}
};
public class AlarmService extends HeadlessJsTaskService {
static long lastActive = 0;
@Override
protected @Nullable
HeadlessJsTaskConfig getTaskConfig(Intent intent) {
long current = System.currentTimeMillis();
if ((current - lastActive) >= 30 * 1000) {
lastActive = current;
return new HeadlessJsTaskConfig(
@andigu
andigu / Alarm.java
Last active February 26, 2023 18:01
public class Alarm extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
final Intent service = new Intent(context, AlarmService.class);
HeadlessJsTaskService.acquireWakeLockNow(context);
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
context.startService(service);
import React, { Component } from 'react'
import { Animated, Dimensions, Image, StyleSheet, View } from 'react-native'
import MapView from 'react-native-maps'
import LinearGradient from 'react-native-linear-gradient'
import { Body, Card, CardItem, Header, Left, Text, Thumbnail, Title } from 'native-base'
import ContentComponent from './ContentComponent'
const {height: screenHeight, width: screenWidth} = Dimensions.get('window')
export default class MyApp extends Component {
@andigu
andigu / 3DAnimation.js
Last active February 26, 2023 17:59
Advanced demo for panresponder
import React, {Component} from "react";
import {Animated, Dimensions, Easing, PanResponder, StyleSheet, View} from "react-native";
import {Card} from "./Card";
const {width: screenWidth, height: screenHeight} = Dimensions.get("window");
export class Sliding extends Component {
bottomPadding = 10;
data = new Array(20).fill({
name: "John Smith",
public class GeoLocationService extends Service {
public static final String FOREGROUND = "com.app_name.location.FOREGROUND";
private static int GEOLOCATION_NOTIFICATION_ID = 12345689;
LocationManager locationManager = null;
LocationListener locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
GeoLocationService.this.sendMessage(location);
}