### Run Example App Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/CONTRIBUTING.md Commands to navigate to the example directory, install its dependencies, and run the example app on iOS or Android. ```bash cd example pnpm install pnpm prebuild pnpm ios # or pnpm android ``` -------------------------------- ### Test Example App on iOS Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/CONTRIBUTING.md Navigate to the example directory and run this command to test the application on iOS. ```bash cd example pnpm ios ``` -------------------------------- ### Local iOS Development Loop Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Execute these commands from the `example/` directory to run the local iOS development loop: install dependencies, prebuild locally, build and run on iOS, and start Metro in local mode. ```bash pnpm i pnpm prebuild:local pnpm ios:local pnpm start:local ``` -------------------------------- ### Test Example App on Android Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/CONTRIBUTING.md Navigate to the example directory and run this command to test the application on Android. ```bash cd example pnpm android ``` -------------------------------- ### Run Android with Local Source Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/example/README.md Run the example on Android using the local package source. ```bash pnpm android:local ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/CONTRIBUTING.md Steps to clone the repository and install project dependencies using pnpm. ```bash git clone https://github.com/launchtodayhq/react-native-keyboard-composer.git cd react-native-keyboard-composer pnpm install ``` -------------------------------- ### Install Dependencies Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/example/README.md Install project dependencies using pnpm. ```bash pnpm install ``` -------------------------------- ### Run iOS with Local Source Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/example/README.md Run the example on iOS using the local package source. ```bash pnpm ios:local ``` -------------------------------- ### Run on Android Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/example/README.md Run the example application on an Android emulator or device. ```bash pnpm android ``` -------------------------------- ### Run on iOS Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/example/README.md Run the example application on an iOS simulator or device. ```bash pnpm ios ``` -------------------------------- ### Local Development: Use Local Version Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/CONTRIBUTING.md Commands to switch the example app to use the local version of the package for native development, including rebuilding. ```bash pnpm use:local pnpm prebuild:local pnpm android:local # or pnpm ios:local ``` -------------------------------- ### Local Development: Use Published Version Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/CONTRIBUTING.md Commands to switch the example app to use the published version of the package and then rebuild. ```bash pnpm use:published pnpm prebuild pnpm android # or pnpm ios ``` -------------------------------- ### Install Dependencies (npm/yarn) Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Run this command after updating your package.json to install all project dependencies, including the linked local package. ```bash npm install # or yarn install ``` -------------------------------- ### Install @launchhq/react-native-keyboard-composer Source: https://context7.com/launchtodayhq/react-native-keyboard-composer/llms.txt Use your preferred package manager to add the library to your project. For Expo managed workflow, run prebuild after installation. ```bash pnpm add @launchhq/react-native-keyboard-composer ``` ```bash npm install @launchhq/react-native-keyboard-composer ``` ```bash yarn add @launchhq/react-native-keyboard-composer ``` ```bash npx expo prebuild ``` -------------------------------- ### Install React Native Keyboard Composer Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Add the library to your project using npm, yarn, or pnpm. For Expo managed projects, run `npx expo prebuild` after installation. ```bash pnpm add @launchhq/react-native-keyboard-composer # or npm install @launchhq/react-native-keyboard-composer # or yarn add @launchhq/react-native-keyboard-composer ``` -------------------------------- ### Use Local Package Source Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/example/README.md Configure the example to use the local package source instead of the published npm package. ```bash pnpm use:local ``` -------------------------------- ### Local Development Setup for Keyboard Composer Source: https://context7.com/launchtodayhq/react-native-keyboard-composer/llms.txt Configure Metro bundler and `package.json` for local development when consuming the package from a clone. Rebuild native code after linking. ```js // metro.config.js (consuming app) const path = require("path"); const { getDefaultConfig } = require("expo/metro-config"); const config = getDefaultConfig(__dirname); const keyboardComposerPath = path.resolve( __dirname, "../react-native-keyboard-composer" // adjust to your clone location ); config.watchFolders = [keyboardComposerPath]; config.resolver.extraNodeModules = { "@launchhq/react-native-keyboard-composer": keyboardComposerPath, }; module.exports = config; ``` ```json { "dependencies": { "@launchhq/react-native-keyboard-composer": "file:../react-native-keyboard-composer" } } ``` ```bash npx expo prebuild --clean npx expo run:ios # or run:android ``` -------------------------------- ### iOS Native Logging Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/CONTRIBUTING.md Example of logging in iOS Swift code using emoji prefixes for categorization. ```swift print("🎯 [Component] message") ``` -------------------------------- ### Android Native Logging Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/CONTRIBUTING.md Example of logging in Android Kotlin code using a TAG for filtering. ```kotlin Log.d(TAG, "πŸ“ message") ``` -------------------------------- ### Basic Chat Screen Setup Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Integrate KeyboardComposer and KeyboardAwareWrapper into your chat screen. The wrapper manages content positioning relative to the keyboard, and KeyboardComposer handles input and height changes. ```tsx import { KeyboardComposer, KeyboardAwareWrapper, } from "@launchhq/react-native-keyboard-composer"; function ChatScreen() { const [composerHeight, setComposerHeight] = useState(48); return ( {/* Your chat messages */} handleSend(text)} onHeightChange={(height) => setComposerHeight(height)} onComposerFocus={() => console.log("Focused")} onComposerBlur={() => console.log("Blurred")} /> ); } ``` -------------------------------- ### ChatGPT-style Pin-to-Top Chat with Streaming Source: https://context7.com/launchtodayhq/react-native-keyboard-composer/llms.txt This example implements a ChatGPT-style chat interface with pin-to-top behavior and a streaming runway. It utilizes KeyboardAwareWrapper with `pinToTopEnabled` and `scrollToTopTrigger` props. The `handleSend` function arms the pin-to-top mechanism for subsequent message appends. ```tsx import React, { useState, useCallback } from "react"; import { View, ScrollView, Text, StyleSheet } from "react-native"; import { KeyboardAwareWrapper, KeyboardComposer, constants, } from "@launchhq/react-native-keyboard-composer"; // ─── Example 2: ChatGPT-style pin-to-top with streaming runway ────────────── function PinToTopChat() { const [composerHeight, setComposerHeight] = useState(constants.defaultMinHeight); const [scrollToTopTrigger, setScrollToTopTrigger] = useState(0); const handleSend = useCallback((text: string) => { // Arm pin-to-top so the next append snaps the message to the top setScrollToTopTrigger(Date.now()); console.log("Message sent:", text); }, []); return ( Messages appear here… ); } const styles = StyleSheet.create({ composerShell: { position: "absolute", left: 0, right: 0, bottom: 0, paddingHorizontal: 16, paddingBottom: 16, }, }); ``` -------------------------------- ### Standard Keyboard-Aware Chat Layout Source: https://context7.com/launchtodayhq/react-native-keyboard-composer/llms.txt Use this example for a standard chat interface where the keyboard pushes content up. It requires KeyboardAwareWrapper as the parent of ScrollView and KeyboardComposer. The onHeightChange prop of KeyboardComposer is used to manage the composer's height and the extraBottomInset of KeyboardAwareWrapper. ```tsx import React, { useState, useCallback } from "react"; import { View, ScrollView, Text, StyleSheet } from "react-native"; import { KeyboardAwareWrapper, KeyboardComposer, constants, } from "@launchhq/react-native-keyboard-composer"; // ─── Example 1: Standard keyboard-aware chat (no pin-to-top) ─────────────── function StandardChat() { const [composerHeight, setComposerHeight] = useState(constants.defaultMinHeight); return ( // pinToTopEnabled omitted β†’ standard push-up-on-keyboard-open behavior Message history… console.log("sent:", text)} onHeightChange={setComposerHeight} /> ); } ``` -------------------------------- ### Build and Publish Package Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Navigate to the package directory, build the project, and publish it to npm. Ensure you have the necessary permissions and have followed publishing best practices. ```bash cd react-native-keyboard-composer pnpm run build npm publish --access public ``` -------------------------------- ### Consumer Workflow: Add Package and Run Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/CONTRIBUTING.md How users typically add the package to their app and rebuild native code using Expo. ```bash pnpm add @launchhq/react-native-keyboard-composer npx expo prebuild --clean npx expo run:ios # or npx expo run:android ``` -------------------------------- ### Prebuild with Local Source Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/example/README.md Generate native projects using the local package source. ```bash pnpm prebuild:local ``` -------------------------------- ### Initialize Composer Height with Native Constants Source: https://context7.com/launchtodayhq/react-native-keyboard-composer/llms.txt Use native constants to initialize composer height state for consistent layout math. Ensure `extraBottomInset` is set to the composer's height. ```tsx import { constants } from "@launchhq/react-native-keyboard-composer"; // constants.defaultMinHeight β†’ 48 // constants.defaultMaxHeight β†’ 120 // constants.contentGap β†’ 32 function ChatScreen() { // Initialize composer height state from native constants const [composerHeight, setComposerHeight] = useState(constants.defaultMinHeight); return ( {/* Messages */} console.log(text)} /> ); } // Built-in spacing reference (handled natively β€” no manual CSS needed): // CONTENT_GAP 24pt/dp β€” gap between last message and composer // COMPOSER_KEYBOARD_GAP 8pt/dp β€” gap between composer bottom and keyboard top console.log(constants); // β†’ { defaultMinHeight: 48, defaultMaxHeight: 120, contentGap: 32 } ``` -------------------------------- ### Generate Native Projects Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/example/README.md Generate native projects for iOS and Android. ```bash pnpm prebuild ``` -------------------------------- ### Add Quick Toggle Scripts to package.json Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Include these scripts in your consuming app's package.json for easy switching between local development and the published version of the keyboard composer package. ```json { "scripts": { "use-local-keyboard": "pnpm pkg set dependencies.@launchhq/react-native-keyboard-composer=workspace:* && pnpm install", "use-published-keyboard": "pnpm pkg set dependencies.@launchhq/react-native-keyboard-composer=^0.1.0 && pnpm install" } } ``` -------------------------------- ### Accessing Default Constants Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Import and log default constants for minimum height, maximum height, and content gap from the library. ```tsx import { constants } from "@launchhq/react-native-keyboard-composer"; console.log(constants.defaultMinHeight); // 48 console.log(constants.defaultMaxHeight); // 120 console.log(constants.contentGap); // 32 ``` -------------------------------- ### Link Local Package with npm/yarn Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Configure your app's package.json to link to a local copy of the keyboard composer package. Adjust the file path to match your project structure. ```json { "dependencies": { "@launchhq/react-native-keyboard-composer": "file:../react-native-keyboard-composer" } } ``` -------------------------------- ### Add Package to pnpm Workspace Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Configure your pnpm-workspace.yaml to include the local keyboard composer package within your monorepo. Adjust the path as necessary. ```yaml packages: - apps/* - ../react-native-keyboard-composer # Adjust path as needed ``` -------------------------------- ### Use Workspace Protocol with pnpm Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Specify the keyboard composer package in your app's package.json using the workspace protocol for pnpm. This links directly to the package within your monorepo. ```json { "dependencies": { "@launchhq/react-native-keyboard-composer": "workspace:*" } } ``` -------------------------------- ### Rebuild Native Code Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md After linking a local native module, rebuild your app's native code to include the changes. This is essential for native modules to function correctly. ```bash npx expo prebuild --clean npx expo run:ios # or npx expo run:android ``` -------------------------------- ### Create Feature Branch Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/CONTRIBUTING.md Standard Git command to create a new branch for feature development. ```bash git checkout -b feature/your-feature-name ``` -------------------------------- ### Configure Metro for Local Package Source: https://github.com/launchtodayhq/react-native-keyboard-composer/blob/main/README.md Modify your metro.config.js to ensure Metro watches the external package directory and resolves the package correctly. Adjust the path as needed. ```javascript const path = require("path"); const { getDefaultConfig } = require("expo/metro-config"); const config = getDefaultConfig(__dirname); // Path to the local package const keyboardComposerPath = path.resolve( __dirname, "../react-native-keyboard-composer" // Adjust path as needed ); // Watch the external package folder for changes config.watchFolders = [keyboardComposerPath]; // Map the package name to the local path config.resolver.extraNodeModules = { "@launchhq/react-native-keyboard-composer": keyboardComposerPath, }; module.exports = config; ``` -------------------------------- ### Programmatically Dismiss Keyboard with blurTrigger Source: https://context7.com/launchtodayhq/react-native-keyboard-composer/llms.txt Use the `blurTrigger` prop to dismiss the keyboard programmatically. Update `blurTrigger` with any new value to trigger the dismissal. ```tsx import React, { useState, useCallback } from "react"; import { View, Button } from "react-native"; import { KeyboardComposer, KeyboardAwareWrapper, } from "@launchhq/react-native-keyboard-composer"; function DismissExample() { const [blurTrigger, setBlurTrigger] = useState(0); const dismissKeyboard = useCallback(() => { setBlurTrigger(Date.now()); // Any new value triggers blur }, []); const handleSend = useCallback((text: string) => { console.log("Message:", text); dismissKeyboard(); // Dismiss after sending }, [dismissKeyboard]); return (