Skip to content

Commit 7e9df35

Browse files
committed
refactor: update to use the new ui folder
1 parent 23edbc9 commit 7e9df35

12 files changed

+65
-65
lines changed

.vscode/project.code-snippets

+18-18
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@
44
"body": [
55
"<View className=\"flex-1 items-center justify-center\">",
66
" $1",
7-
"</View>"
7+
"</View>",
88
],
9-
"description": "A Simple View "
9+
"description": "A Simple View ",
1010
},
1111
"Text": {
1212
"prefix": "t",
1313
"body": [
1414
"<Text variant=\"body\" className=\"text-center\">",
1515
" $1",
16-
"</Text>"
16+
"</Text>",
1717
],
18-
"description": "A Simple Text"
18+
"description": "A Simple Text",
1919
},
2020
"export *": {
2121
"prefix": "ex *",
2222
"body": ["export * from '.$1';"],
23-
"description": "export *"
23+
"description": "export *",
2424
},
2525
"Component": {
2626
"prefix": "comp",
2727
"body": [
2828
"import * as React from 'react';",
2929
"",
30-
"import { Text, View } from '@/ui';",
30+
"import { Text, View } from '@/components/ui';",
3131
"",
3232
"type Props = {",
3333
" $2",
@@ -39,9 +39,9 @@
3939
" </View>",
4040
" );",
4141
"};",
42-
""
42+
"",
4343
],
44-
"description": "Component"
44+
"description": "Component",
4545
},
4646
// https://snippet-generator.app/?description=useQuery+with+variables&tabtrigger=useqv&snippet=import+type+%7B+AxiosError+%7D+from+%27axios%27%3B%0Aimport+%7B+createQuery+%7D+from+%27react-query-kit%27%3B%0A%0Aimport+%7B+client+%7D+from+%27..%2Fcommon%27%3B%0A%0Atype+Variables+%3D+%7B%243%7D%3B%0Atype+Response+%3D+%7B%244%7D%3B%0A%0Aexport+const+use%241+%3D+createQuery%3CResponse%2C+Variables%2C+AxiosError%3E%28%7B%0A++queryKey%3A+%5B%27%242%27%5D%2C+%0A++fetcher%3A+%28variables%29+%3D%3E+%7B%0A++++return+client%0A++++++.get%28%60%242%2F%5C%5C%24%7Bvariables.%24%7B5%7D%7D%60%29%22%2C%0A++++++.then%28%28response%29+%3D%3E+response.data%29%3B%0A++%7D%2C%0A%7D%29%3B%0A&mode=vscode
4747
"useQuery with variables": {
@@ -63,9 +63,9 @@
6363
" .then((response) => response.data);",
6464
" },",
6565
"});",
66-
""
66+
"",
6767
],
68-
"description": "useQuery with variables"
68+
"description": "useQuery with variables",
6969
},
7070
//https://snippet-generator.app/?description=useQuery&tabtrigger=useq&snippet=import+type+%7B+AxiosError+%7D+from+%27axios%27%3B%0Aimport+%7B+createQuery+%7D+from+%27react-query-kit%27%3B%0A%0Aimport+%7B+client+%7D+from+%27..%2Fcommon%27%3B%0A%0Atype+Response+%3D+%7B%243%7D%3B%0Atype+Variables+%3D+void%3B%0A%0Aexport+const+use%241+%3D+createQuery%3CResponse%2C+Variables%2C+AxiosError%3E%28%7B%0A++queryKey%3A+%5B%27%242%27%5D%2C%0A++fetcher%3A+%28%29+%3D%3E+%7B%0A++++return+client.get%28%60%242%60%29.then%28%28response%29+%3D%3E+response.data.posts%29%3B%0A++%7D%2C%0A%7D%29%3B%0A&mode=vscode
7171
"useQuery": {
@@ -85,9 +85,9 @@
8585
" return client.get(`$2`).then((response) => response.data.posts);",
8686
" },",
8787
"});",
88-
""
88+
"",
8989
],
90-
"description": "useQuery"
90+
"description": "useQuery",
9191
},
9292
//https://snippet-generator.app/?description=useInfiniteQuery&tabtrigger=useiq&snippet=import+type+%7B+AxiosError+%7D+from+%27axios%27%3B%0Aimport+%7B+createInfiniteQuery+%7D+from+%27react-query-kit%27%3B%0A%0Aimport+%7B+client+%7D+from+%27..%2Fcommon%2Fclient%27%3B%0Aimport+%7B+DEFAULT_LIMIT%2C+getNextPageParam+%7D+from+%27..%2Fcommon%2Futils%27%3B%0Aimport+type+%7B+PaginateQuery+%7D+from+%27..%2Ftypes%27%3B%0A%0Atype+Response+%3D+void%3B%0Atype+Variables+%3D+PaginateQuery%3C%243%3E%3B%0A%0Aexport+const+use%241+%3D+createInfiniteQuery%3CResponse%2C+Variables%2C+AxiosError%3E%28%7B%0A++queryKey%3A+%5B%27%242%27%5D%2C%0A++fetcher%3A+%28_variables%3A+any%2C+%7B+pageParam+%7D%29%3A+Promise%3CResponse%3E+%3D%3E+%7B%0A++++return+client%28%7B%0A++++++url%3A+%60%2F%242%2F%60%2C%0A++++++method%3A+%27GET%27%2C%0A++++++params%3A+%7B%0A++++++++limit%3A+DEFAULT_LIMIT%2C%0A++++++++offset%3A+pageParam%2C%0A++++++%7D%2C%0A++++%7D%29.then%28%28response%29+%3D%3E+response.data%29%3B%0A++%7D%2C%0A++getNextPageParam%2C%0A++initialPageParam%3A+0%2C%0A%7D%29%3B&mode=vscode
9393
"useInfiniteQuery": {
@@ -117,9 +117,9 @@
117117
" },",
118118
" getNextPageParam,",
119119
" initialPageParam: 0,",
120-
"});"
120+
"});",
121121
],
122-
"description": "useInfiniteQuery"
122+
"description": "useInfiniteQuery",
123123
},
124124

125125
//https://snippet-generator.app/?description=useMutation+&tabtrigger=usem&snippet=import+type+%7B+AxiosError+%7D+from+%27axios%27%3B%0Aimport+%7B+createMutation+%7D+from+%27react-query-kit%27%3B%0A%0Aimport+%7B+client+%7D+from+%27..%2Fcommon%27%3B%0A%0Atype+Variables+%3D+%7B%243%7D%3B%0Atype+Response+%3D+%7B%244%7D%3B%0A%0Aexport+const+use%241+%3D+createMutation%3CResponse%2C+Variables%2C+AxiosError%3E%28%0A++async+%28variables%29+%3D%3E%0A++++client%28%7B%0A++++++url%3A+%27%242%27%2C%0A++++++method%3A+%27POST%27%2C%0A++++++data%3A+variables%2C%0A++++%7D%29.then%28%28response%29+%3D%3E+response.data%29%0A%29%3B&mode=vscode
@@ -141,13 +141,13 @@
141141
" method: 'POST',",
142142
" data: variables,",
143143
" }).then((response) => response.data)",
144-
"});"
144+
"});",
145145
],
146-
"description": "useMutation "
146+
"description": "useMutation ",
147147
},
148148
"navigate": {
149149
"prefix": "navigate",
150150
"body": ["const { navigate } = useNavigation();", ""],
151-
"description": "navigate"
152-
}
151+
"description": "navigate",
152+
},
153153
}

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function (api) {
1212
root: ['./'],
1313
alias: {
1414
'@': './src',
15-
'@env': './src/core/env.js',
15+
'@env': './src/lib/env.js',
1616
},
1717
extensions: [
1818
'.ios.ts',

docs/src/content/docs/getting-started/environment-vars-config.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Code from '../../../components/code.astro';
1010

1111
Managing environment variables in your project is an essential task, but it can also be challenging. That's why we have included a complete setup for environment variables in this project. This setup comes with validation and type-checking using the `zod` library.
1212

13-
All the code related to environment variables is located in the `env.js` and `src/core/env.js` files. The `env.js` read the `APP_ENV` variable and loads the correct `.env` file, then defines the `zod` schema for the environment variables for client and build-time, parses the `_env` object, and returns the parsed object, or throws errors in case of invalid or missing variables.
13+
All the code related to environment variables is located in the `env.js` and `src/lib/env.js` files. The `env.js` read the `APP_ENV` variable and loads the correct `.env` file, then defines the `zod` schema for the environment variables for client and build-time, parses the `_env` object, and returns the parsed object, or throws errors in case of invalid or missing variables.
1414

1515
To increase security, we are splitting environment variables into two parts:
1616

@@ -90,7 +90,7 @@ export const client = axios.create({
9090
```
9191

9292
:::note[Important]
93-
Using `import { Env } from '@env';` will import the env from the `src/core/env.js` file, which export client only env vars.
93+
Using `import { Env } from '@env';` will import the env from the `src/lib/env.js` file, which export client only env vars.
9494
:::
9595

9696
6. Use `APP_ENV` to load the correct `.env` file :
@@ -147,7 +147,7 @@ Now it's as easy as importing `Env` , `ClientEnv` and `withEnvSuffix` from the `
147147
148148
Here, we added a separate file to export all variables that have already been passed in the `extra` property to the client side. We added a little bit of magic to make it type-safe and easy to use.
149149
150-
<Code file="src/core/env.js" />
150+
<Code file="src/lib/env.js" />
151151
152152
Now the environment variables are ready to use in your project. You can access them in your code by importing `Env` from `@env` and using it like this:
153153

docs/src/content/docs/getting-started/project-structure.mdx

+19-19
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ If you open the new project in VSCode you will see the following structure:
2525
- login.tsx
2626
- onboarding.tsx
2727
- components ## any reusable components
28+
- ui ## core ui and theme configuration
29+
- button.tsx
30+
- checkbox.tsx
31+
- colors.js
32+
- focus-aware-status-bar.tsx
33+
- icons
34+
- image.tsx
35+
- index.tsx
36+
- input.tsx
37+
- list.tsx
38+
- modal.tsx
39+
- progress-bar.tsx
40+
- select.tsx
41+
- text.tsx
42+
- utils.tsx
2843
- buttons.tsx
2944
- card.tsx
3045
- colors.tsx
@@ -35,7 +50,7 @@ If you open the new project in VSCode you will see the following structure:
3550
- settings/
3651
- title.tsx
3752
- typography.tsx
38-
- core ## core files such as auth, localization, storage and more
53+
- lib ## core files such as auth, localization, storage and more
3954
- auth
4055
- env.js
4156
- hooks
@@ -51,29 +66,14 @@ If you open the new project in VSCode you will see the following structure:
5166
- en.json
5267
- types ## global types
5368
- index.ts
54-
- ui ## core ui and theme configuration
55-
- button.tsx
56-
- checkbox.tsx
57-
- colors.js
58-
- focus-aware-status-bar.tsx
59-
- icons
60-
- image.tsx
61-
- index.tsx
62-
- input.tsx
63-
- list.tsx
64-
- modal.tsx
65-
- progress-bar.tsx
66-
- select.tsx
67-
- text.tsx
68-
- utils.tsx
6969

7070
</FileTree>
7171

72-
- `ui`: This folder contains all the UI components and the theme configuration. We provide minimal components with a basic `obytes` theme. You can add your own components and theme configuration here.
72+
- `components/ui`: This folder contains all the UI components and the theme configuration. We provide minimal components with a basic `obytes` theme. You can add your own components and theme configuration here.
7373

74-
- `components`: This folder contains the components of the app. mainly components used inside the app folder. The only difference between `ui` and `components` is that `ui` is more generic and can be used in any project, while `components` are more specific to the project.
74+
- `components`: This folder contains the components of the app. mainly components used inside the app folder.
7575

76-
- `core`: This folder contains the core files, such as authentication, localization, storage, and more. It can be shared with other projects. That's why we are only including modules that have nothing to do with project logic. This approach helps us share code between projects and also update the starter with new features.
76+
- `lib`: This folder contains the core files, such as authentication, localization, storage, and more. It can be shared with other projects. That's why we are only including modules that have nothing to do with project logic. This approach helps us share code between projects and also update the starter with new features.
7777

7878
- `app`: This folder contains the routes of the app, along with its layout routes such as stack and tab navigation structures. We provide a basic navigation structure for the demo app that you can modify to fit your needs.
7979

docs/src/content/docs/guides/authentication.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Zustand works very well with TypeScript and can be easily used outside the React
2020

2121
As mentioned earlier, we use Zustand to manage the authentication state of the application. The authentication store is located in `src/store/auth` and is utilized for managing the authentication state of the application.
2222

23-
<CodeBlock file="src/core/auth/index.tsx" />
23+
<CodeBlock file="src/lib/auth/index.tsx" />
2424

2525
The store is composed of 2 states and 3 actions:
2626

@@ -32,7 +32,7 @@ The store is composed of 2 states and 3 actions:
3232

3333
- `useToken`: The token of the user. It is used to authenticate the user to the API. It is stored in the storage of the device and we use it to hydrate the authentication status state when the application is started.
3434

35-
For the Demo app `useToken` is a simple object that contains the `accessToken` and the `refreshToken`. You can add more fields if you update the `TokenType` type in `src/core/auth/utils.ts`.
35+
For the Demo app `useToken` is a simple object that contains the `accessToken` and the `refreshToken`. You can add more fields if you update the `TokenType` type in `src/lib/auth/utils.ts`.
3636

3737
- `signIn`: TThe function performs user sign-in. It accepts a token as a parameter, sets the token state, stores it locally, and updates the status to `signIn`.
3838

docs/src/content/docs/guides/internationalization.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ The starter comes with a basic internationalization setup. It uses [expo-localiz
1212

1313
## Adding a new language
1414

15-
Mainly the demo app supports two languages: English and Arabic (RTL). You can add more languages by adding the translation files in the `src/translations` folder and adding the language code to the `src/core/i18n/resources.ts` file.
15+
Mainly the demo app supports two languages: English and Arabic (RTL). You can add more languages by adding the translation files in the `src/translations` folder and adding the language code to the `src/lib/i18n/resources.ts` file.
1616

17-
<CodeBlock file="src/core/i18n/resources.ts" />
17+
<CodeBlock file="src/lib/i18n/resources.ts" />
1818

1919
:::tip
20-
Anything related to internationalization should be found in the `src/core/i18n` folder.
20+
Anything related to internationalization should be found in the `src/lib/i18n` folder.
2121
:::
2222

2323
## Using translations in your app
@@ -30,7 +30,7 @@ The i18n core module provides a set of utility functions to help you use transla
3030
import React from 'react';
3131
import { useTranslation } from 'react-i18next';
3232

33-
import { Text } from '@/ui';
33+
import { Text } from '@/components/ui';
3434

3535
export const Foo = () => {
3636
const { t } = useTranslation();
@@ -47,7 +47,7 @@ or as `Text` component comes with translation support, you can easily use it as
4747
```tsx
4848
import React from 'react';
4949

50-
import { Text } from '@/ui';
50+
import { Text } from '@/components/ui';
5151

5252
export const Foo = () => {
5353
return <Text className="text-center" tx="settings.language" />;
@@ -58,7 +58,7 @@ export const Foo = () => {
5858

5959
Additionally, the `useSetLanguage` hook will save the selected language in device storage using `MMKV` and will be used as the default language when the app is opened again As well as adding some extra config for RTL languages while updating the selected language.
6060

61-
<CodeBlock file="src/core/i18n/utils.tsx" />
61+
<CodeBlock file="src/lib/i18n/utils.tsx" />
6262

6363
## Robust translation
6464

docs/src/content/docs/guides/storage.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ import CodeBlock from '../../../components/code.astro';
1212

1313
The starter comes with a simple storage module that uses [react-native-mmkv](https://github.com/mrousavy/react-native-mmkv) to store data in a key-value format. We also added a simple storage utility to assist you in using the storage module.
1414

15-
<CodeBlock file="src/core/storage.tsx" />
15+
<CodeBlock file="src/lib/storage.tsx" />
1616

1717
The `react-native-mmkv` library provides various features such as using hooks and adding encryption to stored data. Feel free to check the [official docs](https://github.com/mrousavy/react-native-mmkv) for more information.

docs/src/content/docs/recipes/sentry-setup.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ The starter kit did not come with Sentry pre-configured, but it's very easy to s
132132
```
133133

134134
8. Now you are ready to initialize Sentry in your app.
135-
Create a new file `src/core/sentry.ts` and add the following code:
135+
Create a new file `src/lib/sentry.ts` and add the following code:
136136

137-
```tsx title='src/core/sentry.ts'
137+
```tsx title='src/lib/sentry.ts'
138138
import { useNavigationContainerRef } from 'expo-router';
139139
import { useEffect } from 'react';
140140
import * as Sentry from '@sentry/react-native';

docs/src/content/docs/testing/unit-testing.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ As you may notice from the code, we are importing a bunch of things from the `@/
4646
:::tip
4747
You can update this file to add any other providers you need to wrap your components with as well as any other utility functions you need to use in your tests.
4848

49-
<CodeBlock file="src/core/test-utils.tsx" />
49+
<CodeBlock file="src/lib/test-utils.tsx" />
5050

5151
use `setup` function in case you need to test interactions with the component. It returns a user (userEvent) object that you can use to interact with the component.
5252
:::

docs/src/content/docs/ui-and-theme/Forms.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import { useForm } from 'react-hook-form';
5858
import * as z from 'zod';
5959

6060
import { useAuth } from '@/lib';
61-
import { Button, ControlledInput, View } from '@/ui';
61+
import { Button, ControlledInput, View } from '@/components/ui';
6262

6363
const schema = z.object({
6464
email: z.string().email(),

docs/src/content/docs/ui-and-theme/components.mdx

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import CodeBlock from '../../../components/code.astro';
1111

1212
The starter comes with a set of basic components and a simple design system based on Nativewind to help you get started and save you time.
1313

14-
All those components can be found in the `src/ui/core` folder. Our philosophy is to keep the components as simple as possible and to avoid adding too much logic to them. This way, they are easier to reuse and customize.
14+
All those components can be found in the `src/components/ui` folder. Our philosophy is to keep the components as simple as possible and to avoid adding too much logic to them. This way, they are easier to reuse and customize.
1515

1616
Based on your needs, you can either use them as they are or customize them to fit your needs. You can also create new ones based on the same approach.
1717

@@ -57,7 +57,7 @@ We also provide an `EmptyList` component that you can use to display a message w
5757

5858
```tsx
5959
import * as React from 'react';
60-
import { List, EmptyList, Text } from '@/ui';
60+
import { List, EmptyList, Text } from '@/components/ui';
6161

6262
const MyComponent = () => {
6363
return (
@@ -86,7 +86,7 @@ The `cssInterop` function from `nativewind` is used to apply styling and, in thi
8686

8787
```tsx
8888
import * as React from 'react';
89-
import { Image } from '@/ui';
89+
import { Image } from '@/components/ui';
9090

9191
const MyComponent = () => {
9292
return (
@@ -184,7 +184,7 @@ Read more about Handling Forms [here](../forms/).
184184

185185
```tsx
186186
import * as React from 'react';
187-
import { Input, View } from '@/ui';
187+
import { Input, View } from '@/components/ui';
188188

189189
const MyComponent = () => {
190190
return (
@@ -215,7 +215,7 @@ Based on your needs, you can use the `Modal` if you don't have a fixed height fo
215215

216216
```tsx
217217
import * as React from 'react';
218-
import { Modal, useModal, View, Button, Text } from '@/ui';
218+
import { Modal, useModal, View, Button, Text } from '@/components/ui';
219219

220220
const MyComponent = () => {
221221
const modal = useModal();
@@ -258,8 +258,8 @@ Feel free to update the component implementation to fit your need and as you kee
258258
```tsx
259259
import * as React from 'react';
260260

261-
import type { Option } from '@/ui';
262-
import { SelectInput, View } from '@/ui';
261+
import type { Option } from '@/components/ui';
262+
import { SelectInput, View } from '@/components/ui';
263263

264264
const options: Option[] = [
265265
{ value: 'chocolate', label: 'Chocolate' },
@@ -315,7 +315,7 @@ Animations are applied to the icons using the `MotiView` component from the `mot
315315
**Use Case**
316316

317317
```tsx
318-
import { Checkbox } from '@/ui';
318+
import { Checkbox } from '@/components/ui';
319319

320320
const App = () => {
321321
const [checked, setChecked] = useState(false);
@@ -336,7 +336,7 @@ By default the component will render a label with the text you passed as label p
336336
For rendering a custom Checkbox, you can use the `Checkbox.Root`, `Checkbox.Icon`, and `Checkbox.Label` components.
337337

338338
```tsx
339-
import { Checkbox } from '@/ui';
339+
import { Checkbox } from '@/components/ui';
340340

341341
const App = () => {
342342
const [checked, setChecked] = useState(false);

docs/src/content/docs/ui-and-theme/ui-theming.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ This template comes with dark mode support out of the box, and it's very easy to
7272
Since we're using [nativewind](https://www.nativewind.dev/) (which uses Tailwind CSS under the hood) and expo-router we let them handle the application of theme, and we just take care of the colors we want.
7373
We set the colors in `ui/theme/colors.js` and we use them in our hook `useThemeConfig.tsx` to get the theme object that we pass to ThemeProvider directly. For more information check out [expo-router](https://docs.expo.dev/router/appearance/)
7474

75-
<CodeBlock file="src/core/use-theme-config.tsx" />
75+
<CodeBlock file="src/lib/use-theme-config.tsx" />
7676

7777
<CodeBlock file="src/app/_layout.tsx" />
7878

@@ -81,7 +81,7 @@ We set the colors in `ui/theme/colors.js` and we use them in our hook `useThemeC
8181
We use the `loadSelectedTheme` function to load the theme from the storage if there's a theme saved in the storage, otherwise, we let nativwind use the default theme (system).
8282
To set the selected theme, we use the `useSelectedTheme` hook, which sets the theme in the storage and updates the color scheme of the app.
8383

84-
<CodeBlock file="src/core/hooks/use-selected-theme.tsx" />
84+
<CodeBlock file="src/lib/hooks/use-selected-theme.tsx" />
8585

8686
### Add dark mode for each component
8787

0 commit comments

Comments
 (0)