Skip to content

Instantly share code, notes, and snippets.

View tsapeta's full-sized avatar
🚴‍♂️
Cycling if not responding

Tomasz Sapeta tsapeta

🚴‍♂️
Cycling if not responding
View GitHub Profile
@tsapeta
tsapeta / VideoPlayer.ts
Last active April 28, 2024 20:51
useVideoPlayerVolume vs player.useVolume
// Returns a memoized player instance that updates when the source changes
function useVideoPlayer(source): VideoPlayer {
return useMemo(() => new VideoPlayer(source), [source]);
}
class VideoPlayer extends EventEmitter {
volume: number;
// Hook that updates when its `this` (the player) changes the volume
useVolume(): number {
@tsapeta
tsapeta / RSUIShadow.swift
Created January 8, 2021 11:19
Example of SwiftUI component for React Native
import SwiftUI
final class RSUIShadow: RSUIView {
func render(props: RSUIProps) -> some View {
let radius = props.cgFloat("radius", 0.0)
let offsetX = props.cgFloat("offsetX", 0.0)
let offsetY = props.cgFloat("offsetY", 0.0)
let color = props.color("color", Color.black)
let opacity = props.double("opacity", 0.33)
@tsapeta
tsapeta / MainApplication.java
Last active April 30, 2019 12:46
Configuring unimodules on Android
package com.myapp;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.myapp.generated.BasePackageList;
@tsapeta
tsapeta / withEventEmitter.js
Created December 31, 2018 11:52
Expo TaskManager example with EventEmitter
import React from 'react';
import { TaskManager } from 'expo';
import { EventEmitter } from 'fbemitter';
const taskName = 'task-name-of-your-choice';
const taskEventName = 'task-update';
const eventEmitter = new EventEmitter();
TaskManager.defineTask(taskName, ({ data, error }) => {
if (!error) {
@tsapeta
tsapeta / example.js
Last active December 31, 2018 11:51
Expo TaskManager example
import { TaskManager } from 'expo';
const taskName = 'task-name-of-your-choice';
TaskManager.defineTask(taskName, ({ data, error }) => {
// the contents of the `data` parameter depends on the task type
console.log(`Task ${taskName} has been called with params:`, data, error);
});
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'YOUR_PROJECT_NAME' do
pod 'ExpoKit',
:git => "http://github.com/expo/expo.git",
:tag => "ios/2.8.2",
:subspecs => [
"Core"
],