Skip to content

Instantly share code, notes, and snippets.

View OkancanCosar's full-sized avatar
😎
Focusing To React-Native

OkancanCosar

😎
Focusing To React-Native
View GitHub Profile
@OkancanCosar
OkancanCosar / info.txt
Created December 28, 2018 13:32
all android screen dimensions...
res/values/dimens.xml(default)
res/values-ldpi/dimens.xml (240x320 and nearer resolution)
res/values-mdpi/dimens.xml (320x480 and nearer resolution)
res/values-hdpi/dimens.xml (480x800, 540x960 and nearer resolution)
res/values-xhdpi/dimens.xml (720x1280 - Samsung S3, Micromax Canvas HD, etc)
res/values-xxhdpi/dimens.xml (1080x1920 - Samsung S4, HTC one, etc)
res/values-large/dimens.xml (480x800)
res/values-large-mdpi/dimens.xml (600x1024)
res/values-sw600dp/dimens.xml (600x1024)
import { createContext, useContext, useState } from 'react'
interface IContextSession {
name: string
token: string
}
interface IContextProps {
session?: IContextSession
login: () => Promise<void>
logout: () => Promise<void>
@OkancanCosar
OkancanCosar / index.js
Last active January 25, 2024 08:00
InteractionManager.runAfterInteractions example
import React, { useState, useRef, useEffect } from 'react';
import {
Text,
InteractionManager,
} from 'react-native';
export default function App() {
const [screenLoading, setScreenLoading] = useState(true);
@OkancanCosar
OkancanCosar / App.tsx
Last active January 18, 2024 14:03
Download file button
import React, { useState } from 'react'
import { StyleSheet, TouchableOpacity, View, Text, Alert } from 'react-native'
import RNFS from 'react-native-fs'
const perc2color = (perc: number) => {
var r, g, b = 0
if (perc < 50) {
r = 255
g = Math.round(5.1 * perc)
}
@OkancanCosar
OkancanCosar / index.tsx
Created January 18, 2024 13:09
InAppReview
import InAppReview from 'react-native-in-app-review'
if (InAppReview.isAvailable()) {
InAppReview.RequestInAppReview()
}
@OkancanCosar
OkancanCosar / index.js
Created January 18, 2024 13:05
percentage to hex color
const perc2color = (perc: number) => {
var r, g, b = 0;
if (perc < 50) {
r = 255;
g = Math.round(5.1 * perc);
}
else {
g = 255;
r = Math.round(510 - 5.10 * perc);
}
@OkancanCosar
OkancanCosar / index.js
Last active September 24, 2023 15:28
RN Geolocation convert promise to async/await
import Geolocation from "react-native-geolocation-service";
const getCurrentLatLong = async () => {
const opt = {
// timeout:INFINITY,
// maximumAge:INFINITY,
// accuracy: { ios: "hundredMeters", android: "balanced" },
// enableHighAccuracy: false,
// distanceFilter:0,
showLocationDialog: true,
@OkancanCosar
OkancanCosar / links.txt
Created January 19, 2023 08:37
multi-app kiosk
@OkancanCosar
OkancanCosar / index.ts
Created September 8, 2022 06:39
excel time to moment
var excelDate = 44811;
var unixTimestamp = (excelDate - 25569) * 86400000 //as per the post above, convert Excel date to unix timestamp, assuming Mac/Windows Excel 2011 onwards
var date = moment(unixTimestamp); //Pass in unix timestamp instead of Excel date
var dateWithNewFormat = date.format('DD.MM.YYYY HH:mm');
console.log(dateWithNewFormat); //07-Eyl-2022
@OkancanCosar
OkancanCosar / app.tsx
Created August 26, 2022 05:48
expo record and play sound
import React, { useState } from "react";
import { View, Button } from "react-native";
import { Audio } from "expo-av";
const App = () => {
const [recording, setRecording] = useState<Audio.Recording>();
const startRecording = async () => {
try {
console.log("Requesting permissions..");