1.0.2 • Published 11 months ago

ovok-mobile-sdk v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

ovok-mobile-sdk

Ovok React Native SDK

Installation

npm install ovok-mobile-sdk
or
yarn add ovok-mobile-sdk

Init your instances

// First you need to init your axiosInstance and Theme object on your global component (app.js or index.js etc.)

initAxiosInstance(YOUR_AXIOS_INSTANCE);
initTheme(YOUR_THEME_OBJ);

Usage

// You can setup your screens with ovok mobile sdk
// Sample Login Screen

import React from 'react';
import {
  AuthHeader,
  Body,
  Button,
  Header,
  Screen,
  TextInput,
  auth,
} from 'ovok-mobile-sdk';

const LoginScreen = () => {
  const [email, setEmail] = React.useState('');
  const [password, setPassword] = React.useState('');

  const handleLogin = async () => {
    try {
      const result = await auth.login({
        email,
        password,
        clientId: Environment.CLIENT_ID,
      });

      if (result?.access_token) {
        // Success case
      } else {
        // Fail case
      }
    } catch (error) {
      // Handle error
    }
  };

  return (
    <Screen
      backgroundColor={palette.colors.background}
      preset="scroll"
      safeAreaEdges={['top', 'bottom']}
    >
      <Header title="Login" type={'singleCenter'} />
      <Body>
        <View style={styles.inputContainer}>
          <TextInput
            value={email}
            onChangeText={setEmail}
            placeholder="Email"
            keyboardType="email-address"
            autoCapitalize="none"
          />
          <TextInput
            value={password}
            onChangeText={setPassword}
            placeholder="Password"
            secureTextEntry
            autoCapitalize="none"
          />
        </View>
        <Button text="Login" onPress={handleLogin} />
      </Body>
    </Screen>
  );
};

export default LoginScreen;

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library