Giter Club home page Giter Club logo

react-native-custom-window's Introduction

React Native Custom Window

version 0.22.7 License

preview thumbnail

This is a native module for React Native that provides access to certain window-related functionalities and file picking capabilities. The module is designed to work with both Android and iOS platforms.

Installation

To use this module in your React Native project, follow these steps:

  1. Install the npm package using the following command:
npm install react-native-custom-window --save
  1. Link the native module to your project:
react-native link react-native-custom-window

Usage

TitleBar Module

Import

import { FilePicker } from 'react-native-custom-window';

Methods

  interface TitleBarColorProps {
    backgroundColor: string;
    inactiveBackgroundColor?: string;
    buttonBackgroundColor?: string;
    buttonInactiveBackgroundColor?: string;
    buttonForegroundColor?: string;
    buttonHoverForegroundColor?: string;
    buttonPressedForegroundColor?: string;
    buttonInactiveForegroundColor?: string;
    foregroundColor?: string;
    inactiveForegroundColor?: string;
    buttonHoverBackgroundColor?: string;
    buttonPressedBackgroundColor?: string;
  }
  • enableExtend(): Promise Enables the extension of the window, allowing it to go titleBar.

  • TitlebarColor(props: TitleBarColorProps): Promise Sets the title bar color with the provided background and button background colors. The backgroundInactive and buttonBackgroundInactive are used when the window is inactive.

  • addBackButton(): Promise Adds a custom back button to the window.

  • removeBackButton(): Promise Removes the custom back button from the window.

  • disableBackButton(): Promise Disables the functionality of the default back button.

  • disableExtend(): Promise Disables the window extension, preventing it from going fullscreen.

FilePicker Module

Import

import { FilePicker } from 'react-native-window-file-picker-module';

Window Module

Import

import { titleBar } from 'react-native-custom-window';

Methods

  type ISetSize = {
    width: number;
    height: number;
  }
  • setSize(props: ISetSize): void Sets a custom size for the window.

  • isFullScreen(): Promise Checks if the window is in fullscreen mode.

  • enterFullscreen(): Promise Activates the fullscreen mode for the window.

  • leaveFullscreen(): Promise Deactivates the fullscreen mode for the window.

FilePicker Module

Import

import { FilePicker } from 'react-native-window-file-picker-module';

Method

  • pickFile(): Promise Opens a file picker dialog, allowing the user to select a file. Returns a promise that resolves to the selected file's path.

Example

import React from 'react';
import { View, Button } from 'react-native';
import { fullscreen, FilePicker } from 'react-native-window-file-picker-module';

const App = () => {
  const handlePickFile = async () => {
    try {
      const filePath = await FilePicker.pickFile();
      console.log('Selected file path:', filePath);
    } catch (error) {
      console.error('Error while picking a file:', error);
    }
  };

  return (
    <View>
      <Button title="Go Fullscreen" onPress={() => fullscreen.enableExtend()} />
      <Button
        title="Pick a File"
        onPress={handlePickFile}
      />
    </View>
  );
};

export default App;

Platform Support

  • Android
  • iOS
  • Windows

Note: Please ensure you have the necessary permissions and configurations for file picking functionality on both platforms.

Contribution

This module is open for contributions. Feel free to create issues, pull requests, or suggest improvements.

License

This project is licensed under the MIT License.

react-native-custom-window's People

Contributors

victor0814gui avatar austinhallock avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.