Skip to content

Instantly share code, notes, and snippets.

View harrisrobin's full-sized avatar
🛳️
Shipping

harris.dev harrisrobin

🛳️
Shipping
View GitHub Profile
@harrisrobin
harrisrobin / button.dripsy.tsx
Last active February 6, 2024 08:03
Dripsy vs useColorToken
import React from "react"
import {
PressableStateCallbackType,
Pressable,
StyleProp,
ViewStyle,
} from "react-native"
import { ButtonProps, ButtonVariants } from "./button.props"
import { Text } from "../text"
import { useDripsyTheme, useSx } from "dripsy"
@harrisrobin
harrisrobin / Fastlane.rb
Created August 9, 2023 09:56
Fastlane CI/CD automation suite for React-Native. Supports multiple envs (staging app & prod app), slack notifications, Sentry sourcemaps & dsym uploading, codepush etc. Very extensive and handles all release/beta requirements.
require "json"
require "httparty"
require "sem_version"
require 'xcodeproj'
#
# CONSTS
#
FASTLANE_ENV_FILE = ".fastlane"
PROJECT = "REDACTED"
@harrisrobin
harrisrobin / analytics.ts
Last active August 9, 2023 10:00
Typed & re-useable analytics module to make it easy to add new analytics tools to the app without having to touch multiple files
import * as Analytics from "expo-firebase-analytics"
import { recordError } from "./exceptions"
export const setCurrentScreen = (screenName: string): void => {
void Analytics.logEvent("screen_view", { screen_name: screenName })
// track screens.
__DEV__ && console.tron.log(`currentScreen: ${screenName}`)
}
/**
@harrisrobin
harrisrobin / text.props.ts
Created August 9, 2023 09:31
Re-useable React-Native text component with proper theming, ability to pass "tx" for translations and theme-ui like styling prop (sx).
import { TextProps as TextProperties } from "react-native"
import type { SxProps } from "@bridge/ui/view"
import type { Nullable } from "@bridge/types"
import { TextVariants } from "../theme"
export interface TextProps extends TextProperties, SxProps {
/**
* Children components.
*/
children?: React.ReactNode
export const GENERATION_MODELS: Record<string, GenerationModel> = {
"6c2ccdf0300616cfca3ba78701b511def42447960b086bb47a487aed5a9a892d": {
name: "Realism",
path: "models/ckpt/aresmix.safetensors",
vae: "models/vae/vae-ft-mse-840000-ema-pruned.safetensors",
modelHash:
"6c2ccdf0300616cfca3ba78701b511def42447960b086bb47a487aed5a9a892d",
positivePromptStart: `${POSITIVE_PROMPT_START}, RAW photo, cinematic still, high quality, film grain, sharp focus, (high detailed skin:1.2), 8k uhd, dslr, award winning photograph,`,
},
c5b6055a843f079998738c7d115060a4e116f0eedd1a5cb10b2b52d6f5f0ff68: {
@harrisrobin
harrisrobin / screen-component.tsx
Last active August 9, 2023 14:19
React-Navigation screen cache component (wrap every screen with this to avoid re-creating new screens when react-navigation re-renders).
import React from "react"
import { SafeAreaProvider } from "react-native-safe-area-context"
// Cache the wrapper component to avoid creating a new one every time a screen
// is created.
const componentsCache = new WeakMap<
React.ComponentType<any>,
React.ComponentType<any>
>()
{
"common": {
"ok": "OK!",
"cancel": "Cancel",
"continue": "Continue",
"doThisLater": "Do This Later",
"percentageCompleted": "%{number}% Completed",
"needHelp": "Need help ?",
"done": "Done",
"next": "Next",
/* eslint-disable @typescript-eslint/no-explicit-any */
import React from "react"
import { SafeAreaProvider } from "react-native-safe-area-context"
// Cache the wrapper component to avoid creating a new one every time a screen
// is created.
const componentsCache = new WeakMap<
React.ComponentType<any>,
React.ComponentType<any>
>()
import React from "react"
import { KeyboardAvoidingView, Platform } from "react-native"
import { StatusBar } from "expo-status-bar"
import { ScreenProps } from "./screen.props"
import { isNonScrolling, offsets, variants } from "./screen.variants"
import { useAppColorScheme } from "@zaboca/ui/hooks/use-app-color-scheme"
import { useThemeColor } from "@zaboca/ui/hooks/use-theme-color"
import { View } from "@zaboca/ui/view"
import { useSafeAreaInsets } from "@zaboca/ui/dimensions"
import { ScrollView } from "@zaboca/ui/scroll-view"
import { useEffect, useRef } from "react"
import { noop } from "../../utils"
export function useInterval(
callback: () => void,
delay: number | null | false,
immediate?: boolean,
) {
const savedCallback = useRef(noop)