Skip to content

Instantly share code, notes, and snippets.

View bryanltobing's full-sized avatar
🏠
Working from home

Bryan Lumbantobing bryanltobing

🏠
Working from home
View GitHub Profile
@bryanltobing
bryanltobing / withMoEngagePlugin.js
Last active April 28, 2024 12:27
expo config plugin for react-native-moengage. tested in v8.5.3
const {
withAppDelegate,
withInfoPlist,
withEntitlementsPlist,
withAppBuildGradle,
withMainApplication,
withStringsXml,
AndroidConfig,
} = require('@expo/config-plugins');
const { mergeContents } = require('@expo/config-plugins/build/utils/generateCode');
@bryanltobing
bryanltobing / package.json
Created April 16, 2024 10:08
Changing Expo Router Entry Point
{
"main": "index.tsx",
}
@bryanltobing
bryanltobing / extend-tamagui-themes-with-color.tsx
Created April 10, 2024 14:58
add new color to tamagui themes, the first commit is the original, check revision for extended one
import {
blue,
blueDark,
gray,
grayDark,
green,
greenDark,
orange,
orangeDark,
pink,
@bryanltobing
bryanltobing / viewModelZustand.tsx
Last active April 22, 2024 12:57
ViewModelProvider with zustand and react context
import { createContext, useContext, useRef } from 'react'
import { Button, Text } from 'tamagui'
import { createStore, useStore, type StateCreator, type StoreApi } from 'zustand'
const ViewModelContext = createContext<StoreApi<any> | null>(null)
const ViewModelProvider = <T,>({
children,
initializer,
}: React.PropsWithChildren<{ initializer: StateCreator<T> }>) => {
@bryanltobing
bryanltobing / scrollview-non-fixed-header.tsx
Created April 5, 2024 15:32
Scrollview with non fixed header
import { useState } from 'react'
import Animated, {
Extrapolation,
interpolate,
useAnimatedScrollHandler,
useAnimatedStyle,
useSharedValue,
} from 'react-native-reanimated'
import { Card, Text, View } from 'tamagui'
import React from "react";
import { useForm, FormProvider } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
const baseRincianNilaiSchema = z
.object({
name: z.string(),
persenan: z.string(),
child: z.array(z.any()).optional(), // Fine-tune this as needed
@bryanltobing
bryanltobing / country-locale.ts
Last active February 7, 2024 09:25
Country name for libphonenumber-js
import { CountryCode } from 'libphonenumber-js';
import { AppLocale } from './i18n';
export const countriesWithLocale: Record<AppLocale, Record<CountryCode, string>> = {
en: {
AC: 'Ascension Island',
AD: 'Andorra',
AE: 'United Arab Emirates',
AF: 'Afghanistan',
@bryanltobing
bryanltobing / FormatCurrencyForTextInput.ts
Created February 4, 2024 07:19
Currency Formatter for TextInput
enum Currency {
IDR = "IDR",
USD = "USD",
}
const separator: Record<Currency, string> = {
IDR: ".",
USD: ",",
};
@bryanltobing
bryanltobing / Input.tsx
Created July 22, 2023 12:15
React native soft keyboard input repro view being scrolled when it is not needed on android
import { View, TextInput, Text } from 'react-native';
import { verticalScale, horizontalScale, moderateScale } from '@/utils/sizing';
export function Input(props: { placeholder: string; label: string; isNumPad?: boolean }) {
return (
<View
style={{
backgroundColor: '#F8FAFC',
paddingTop: verticalScale(8),
@bryanltobing
bryanltobing / Metrics.ts
Created June 19, 2023 07:18
Responsive unit size for react native using `Dimensions` Api
import { Dimensions } from 'react-native';
const { width, height } = Dimensions.get('window');
const guidelineBaseWidth = 360;
const guidelineBaseHeight = 724;
/**
*
* @param size number