webapp/gemini.md

34 lines
2.1 KiB
Markdown
Raw Normal View History

# Gemini Project: MyReactNativeApp
This is a React Native application built with TypeScript.
## General Instructions
- Always use Chinese to answer.
- Check for potential errors in the user's prompt and try to fix them.
- If the proposed changes are significant or alter the core logic, ask the user for confirmation before proceeding. Otherwise, you can make the changes directly.
## AI-Assisted Development Guidelines
### 1. Code Style & Conventions
- **Adherence:** Strictly follow the existing code style, formatting (Prettier), and linting rules (ESLint) of the project.
- **Consistency:** When adding new features, first analyze the surrounding code to ensure new code matches the existing patterns in terms of naming, structure, and architecture.
### 2. Component-Based Architecture
- **Modularity:** Prioritize creating modular, reusable, and single-purpose components. Place all reusable components in the `src/components/` directory.
- **Props:** Define explicit TypeScript interfaces for all component props in the `src/types/` directory or co-located with the component file.
### 3. State Management
- **React Context:** For global or shared state, utilize the existing React Context API structure located in `src/context/`.
- **Local State:** For component-specific state that doesn't need to be shared, use the `useState` and `useReducer` hooks.
### 4. API & Data Fetching
- **Service Layer:** All interactions with external APIs must be encapsulated within the service layer (`src/services/`). Do not make direct API calls (e.g., using `fetch` or `axios`) from within UI components.
- **Type Safety:** Define clear TypeScript types for all API request payloads and responses in the `src/types/` directory.
### 5. Navigation
- **Centralized Logic:** All screen navigation logic should be managed within the `src/navigation/` directory, using the established React Navigation setup.
### 6. Testing
- **Unit Tests:** When creating new components or services, please also create corresponding unit tests in the `__tests__` directory.
- **Existing Tests:** When modifying existing code, ensure all related tests are updated and continue to pass.