1.2.9 • Published 4 months ago

mayo-settings v1.2.9

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

A generic user settings modal for React Native

Easily integrate a user preference modal in your React Native applications with MayoSettingsModal, now supporting multiple independent modal instances.

🚀 Installation

npm install mayo-settings
# OR
yarn add mayo-settings

📖 Usage

Wrapping your app with MayoSettingsProvider

First, wrap your application with MayoSettingsProvider. This provides the necessary context for managing multiple MayoSettingsModal instances.

import { MayoSettingsProvider } from 'mayo-settings';

function App() {
  return (
    <MayoSettingsProvider>
      {/* Rest of your app components */}
    </MayoSettingsProvider>
  );
}

Using MayoSettingsModal in your component

Here's how you can use the MayoSettingsModal in your component:

import { MayoSettingsModal, useMayoSettings } from 'mayo-settings';

function SettingsComponent() {
  const { openModal, closeModal } = useMayoSettings();

  return (
    <>
      <Button onPress={() => openModal("settingsModalId")} title="Open Settings" />

      <MayoSettingsModal
        id="settingsModalId"
        onClose={() => closeModal("settingsModalId")}
        onLogout={handleLogout}
        config={{
          headerTitle: 'Custom Settings',
          logoutButtonText: 'Custom Logout',
        }}
      >
        {/* Your custom settings go here */}
      </MayoSettingsModal>
    </>
  );
}

🛠️ Props and Configuration

Here are some of the available props and configuration options you can pass to MayoSettingsModal:

Prop NameTypeDescription
idbooleanA unique identifier for the modal instance.
onClosefunctionCallback function when closing the modal.
onLogoutfunctionCallback function when the logout action is triggered.
configobjectConfiguration object for additional modal settings.

For the config object:

Property NameTypeDescription
headerTitlestringTitle text for the modal header.
logoutButtonTextstringText for the logout action button.
showFooterbooleanShows of not the footer with the logout button

 🔍 API

MayoSettingsModal

PropTypeDescription
onLogoutfunctionCallback to handle logout logic.
childrenReactNodeChildren components for your settings.
configobject (optional)Configuration for the modal.

useMayoSettings

Hook to manage user preferences.

  • openModal(id: string): Opens a modal by its unique ID.
  • closeModal(id: string): Closes a modal by its unique ID.

📚 License

This project is licensed under the MIT License.

1.2.9

4 months ago

1.2.8

4 months ago

1.2.7

5 months ago

1.2.6

6 months ago

1.2.5

6 months ago

1.2.4

6 months ago

1.2.3

6 months ago

1.2.2

7 months ago

1.2.1

7 months ago

1.2.0

7 months ago

1.1.10

7 months ago

1.1.9

7 months ago

1.1.8

7 months ago

1.1.7

7 months ago

1.1.6

7 months ago

1.1.4

7 months ago