import { PropsWithChildren, useLayoutEffect } from 'react'
import { Button, StyleSheet, Text, View } from 'react-native'
import { Box, Row, Text as BacaText } from '@/design-system'
import { useScreenOptions, useState } from '@/hooks'
const COUNT = 1000
const NativeViews = () => {
return (
{new Array(COUNT).fill(0).map((_, i) => (
))}
)
}
const NativeTexts = () => {
return (
{new Array(COUNT).fill(0).map((_, i) => (
{i}
))}
)
}
const BacaViews = () => {
return (
{new Array(COUNT).fill(0).map((_, i) => (
))}
)
}
const BacaTexts = () => {
return (
{new Array(COUNT).fill(0).map((_, i) => (
{i}
))}
)
}
const TimedRender = (props: PropsWithChildren) => {
const [start] = useState(Date.now())
const [end, setEnd] = useState(0)
useLayoutEffect(() => {
setEnd(Date.now())
}, [])
return (
<>
{!!end && Took {end - start}ms}
{props.children}
>
)
}
type StyleType = 'React Native' | 'React Native Text' | 'Baca' | 'Baca Text' | undefined
export const StyleBenchmarkScreen = (): JSX.Element => {
// Setting screen title
useScreenOptions({
title: 'Style Benchmark',
})
const [styleType, setStyleType] = useState(undefined)
const onStyleTypePress = (curry: StyleType) => () => {
setStyleType(curry)
}
const renderStyleLibrary = () => {
switch (styleType) {
case 'React Native':
return
case 'React Native Text':
return
case 'Baca':
return
case 'Baca Text':
return
default:
return null
}
}
// Render
return (
{styleType ? (
Rendering with {styleType}
) : null}
{renderStyleLibrary()}
)
}
const styles = StyleSheet.create({
bold: {
fontSize: 16,
fontWeight: 'bold',
},
// eslint-disable-next-line react-native/no-color-literals
styledText: {
borderColor: 'red',
borderWidth: 2,
color: 'green',
padding: 8,
},
// eslint-disable-next-line react-native/no-color-literals
styledView: {
borderColor: 'red',
borderWidth: 2,
padding: 8,
},
// eslint-disable-next-line react-native/no-color-literals
text: {
color: 'blue',
marginVertical: 12,
},
// eslint-disable-next-line react-native/no-color-literals
timeText: {
color: 'green',
fontSize: 18,
marginTop: 12,
},
viewsContainer: {
display: 'flex',
flexDirection: 'row',
},
})