Skip to content

Instantly share code, notes, and snippets.

@ChronSyn
ChronSyn / babel.config.js
Last active June 12, 2025 12:52
Expo - Alias path example
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
["@babel/plugin-transform-flow-strip-types"],
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
["module-resolver", {
"alias": {
@ChronSyn
ChronSyn / useTheme.ts
Last active February 15, 2021 01:41
React Native - useTheme hook
import { ITheme } from "@Themes/interfaces";
import { DarkTheme } from "@Themes/theme.dark";
import { LightTheme } from "@Themes/theme.light";
import React from "react";
import { useColorScheme } from "react-native-appearance";
export const useTheme = (): [ITheme] => {
const scheme = useColorScheme();
const [currentTheme, setCurrentTheme] = React.useState<ITheme>(DarkTheme);
@ChronSyn
ChronSyn / App.tsx
Last active December 29, 2020 00:38
React Navigation 5 - Multiple Navigator Handling
/*
IMPORTANT NOTE
The below is just an example showing how the root component of your project should be structured to support this multiple-navigator setup
You should adapt your app around it
*/
import React from "react";
@ChronSyn
ChronSyn / CustomText.tsx
Last active May 8, 2020 00:16
CustomText componnent for Expo - loads any google font
import * as React from "react";
import RN, { Text, TextProps } from "react-native";
import { Asset } from 'expo-asset';
import { useFonts } from '@use-expo/font';
import * as fonts from "@expo-google-fonts/dev";
enum FontDisplay {
AUTO = "auto",
SWAP = "swap",
@ChronSyn
ChronSyn / CustomText.tsx
Created May 7, 2020 15:43
CustomText component which can display expo google fonts. Direct replacement for Text from react-native
import * as React from "react";
import { Text, TextProps } from "react-native";
import { useFonts } from '@use-expo/font';
import {
Nunito_Regular400,
Nunito_SemiBold600_Italic,
} from '@expo-google-fonts/nunito';
const CustomText: React.FC<TextProps> = (props) => {
const [fontsLoaded] = useFonts({
@ChronSyn
ChronSyn / useKeyboard.tsx
Created April 19, 2020 14:46
React + React Native useKeyboard hook
import { useEffect, useState } from "react";
import { Keyboard, KeyboardEvent } from "react-native";
export const useKeyboard = (): [number, boolean] => {
const [keyboardHeight, setKeyboardHeight] = useState(0);
const [keyboardVisible, setKeyboardVisible] = useState(false);
function onKeyboardDidShow(e: KeyboardEvent): void {
setKeyboardHeight(e.endCoordinates.height);
setKeyboardVisible(true);
@ChronSyn
ChronSyn / adaptTimeForToday.ts
Created April 18, 2020 02:30
Allows you to take a time from an existing Date object (or date-format string) and set todays' Date object to that time
const adaptTimeForToday = (time: Date | string): Date => {
const existingFormattedDate: Date = new Date(time);
const [hours, minutes, seconds]: number[] = existingFormattedDate.toLocaleTimeString().split(":").map((segment) => Number(segment));
const output: Date = new Date();
output.setHours(hours);
output.setMinutes(minutes);
output.setSeconds(seconds);
return output;
}
@ChronSyn
ChronSyn / demo.tsx
Created April 17, 2020 19:52
expo useNotification
import * as React from "react";
import { TouchableOpacity, Text } from "react-native";
import { Notifications } from "expo"
import { useNotification } from "./useNotification";
const sendNotification = async () => await Notifications.presentLocalNotificationAsync(
{
title: "Notified!",
body: "Hello, World!",
data: {}
@ChronSyn
ChronSyn / uk_train_classes.json
Last active February 9, 2020 17:45
UK Train Classes
{
"140": {
"Manufacturer": "",
"Date Built": 1980,
"Number Built": "1 × 2-car set",
"Withdrawn": 1981,
"Scrapped": ""
},
"141": {
"Type": "Pacer",
@ChronSyn
ChronSyn / README.md
Created January 30, 2020 10:36 — forked from nikcub/README.md
Facebook PHP Source Code from August 2007