0.6.1 • Published 3 months ago

@classon/react-native v0.6.1

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

classon-react-native

classon react native sdk

Table of Contents

  1. Install
  2. Usage
  3. Components
  4. API
  5. Example

Install

  • classon react native is reuqired, install by running:
npm install @classon/react-native --save

or

yarn add @classon/react-native
  • For IOS install by running :
npx pod-install

Note that you need to save the key into file info.plist

NSURLIsExcludedFromBackupKey

(IOS only): The NSURLIsExcludedFromBackupKey property can be provided to set this attribute on iOS platforms. Apple will reject apps for storing offline cache data that does not have this attribute.

Note: The classon-react-native package uses several other library packages to build and support such as:

So during the integration and testing process, if any errors arise, please check if the above packages are installed in the project or not. If not, please install the required package and try again.

Usage

Basic

A simple usage:

import { ClassOn } from '@classon/react-native';

<ClassOn classId={classId} token={token} live={true} user={user} />;

Custom view

Customize the display view Example

import { ClassonPlayer, Connection } from '@classon/react-native';

// Some components are only visible in the teacher role:
import {
  ClassState,
  AgendaCurriculum,
  ScriptAction,
  ClassControl,
  ClassInfo,
} from '@classon/react-native';

<View style={styles.container}>
  {isTeacher && live && (
    <View style={styles.vControl}>
      <ClassState isTeacher={isTeacher} live={live} />
      <ClassControl />
      <ClassInfo />
    </View>
  )}

  <KeyboardAwareScrollView
    contentContainerStyle={{ width: '100%', height: '100%' }}
    scrollEnabled={false}
    nestedScrollEnabled
  >
    <View style={styles.vRow}>
      <View style={{ width: '100%', height: '100%' }}>
        <View style={styles.container}>
          {live ? (
            <Connection classId={classId} token={token} conferenceType={0}>
              <ClassonPlayer
                classId={classId}
                token={token}
                live={true}
                user={user}
              />
            </Connection>
          ) : (
            <ClassonPlayer classId={classId} token={token} user={user} />
          )}
        </View>

        {isTeacher && live && (
          <View>
            <AgendaCurriculum live={live} />
          </View>
        )}

        {isTeacher && live && <ScriptAction />}
      </View>
    </View>
  </KeyboardAwareScrollView>
</View>;

Components

- ClassOn

Default component of sdk. It contains full control buttons and status displays for learning and teaching.

NameDescriptionType
classId (required)ID of the lesson or classstring
token (required)Is the application token to connect to the socket serverstring
user (required)User informationObject ({id: number, role: string, fullname?:string})
live (required)Set class status online or offlineBoolean

- Connection

It is a necessary component to connect when studying online.

NameDescriptionType
classId (required)ID of the lesson or classstring
token (required)Is the application token to connect to the socket serverstring
conferenceType (required)Use the conference type for classesnumber (0: no conference, 1: bluesea conference )
children (required)Is a child component wrapped by Connection. It is ClassonPlayerJSX.Element

- ClassonPlayer

The component displays the status interface waiting for data processing and lesson display.

NameDescriptionType
classId (required)ID of the lesson or classstring
token (required)Is the application token to connect to the socket serverstring
user (required)User informationObject ({id: number, role: string, fullname?:string})
render (optional)Render progress component while waiting for the data to completedJSX.Element
live (optional)Set class status online or offlineBoolean

- BlueseaConference

The component displays a conference call between class members.

NameDescriptionType
horizontal (optional)List displays horizontally or verticallyBoolean
onlyAudio (optional)Allow only audio, no videoBoolean
containerStyles (optional)A style object that allow you to customize the BlueseaView container styleViewStyle
listContainerStyle (optional)A style object that allow you to customize list container styleViewStyle
itemStyles (optional)Customize view video itemBlueseaItemProps
renderBlueseaItem (optional)Customize view video item conferenceJSX.Element
renderBluseaView (optional)Customize video conference containerJSX.Element
- #BlueseaItemProps
NameDescriptionType
itemContainerStyle (optional)Style object to customize item containerViewStyle
videoStyle (optional)Style object to customize video item viewViewStyle

- ClassState

The component displays the status of the class.

NameDescriptionType
containerStylesStyle object to customize container viewViewStyle
buttonStylesStyle object to customize buttonViewStyle
logoStylesStyle object to customize logoBoolean
isTeacherSet teacher or studentBoolean
liveClass status online or offlineBoolean
logoCustomize logoImageRequireSource

- ClassControl

The component displays controls for the teacher in the classroom.

NameDescriptionType
containerStylesStyle object to customize container viewViewStyle
buttonStylesStyle object to customize buttonViewStyle
iconStylesStyle object to customize iconViewStyle
volumeStylesStyle object to customize volume viewVolumeProps)
- #VolumeProps
NameDescriptionType
viewContentStyle object to customize container viewViewStyle
volumeIconCustomize volume iconImageRequireSource
iconStylesStyle object to customize iconViewStyle
sliderStylesStyle object to customize volume viewMultiSliderProps

- ClassInfo

The component displays class information

NameDescriptionType
containerStylesStyle object to customize container viewViewStyle
placementWhere to position the tooltiptop, bottom, left, right, center
render (optional)Customize class info viewJSX.Element

- AgendaCurriculum

The component displays the classroom curriculum.

NameDescriptionType
containerStylesStyle object to customize container viewViewStyle
labelButtonStylesStyle object to customize button labelViewStyle
buttonStylesStyle object to customize buttonViewStyle
agendaItemStylesStyle object to customize item viewItemProps
liveClass status online or offlineBoolean
renderCustomize agenda/curriculum viewJSX.Element

API

Action type

NameDescription
LoadingProcessThe process of downloading lesson data
LoadingCompleteThe process of downloadig lesson data is completed
LoadingErrorError message while downloading lesson data
LoadingRetryReload lesson data failed
StartClassroomStart the lesson
FinishClassroomEnd of lesson

Methods

  • Call to reload file that failed during data download
pubsubClient.publish('control', { type: ActionClientType.LoadingRetry });
  • Call to start the lesson
pubsubClient.publish('control', { type: ActionClientType.StartClassroom }); // Offline

pubsub.publish('general', {
  type: ActionType.StartClass,
  payload: { action: 'request' },
}); // Online
  • Call when next/previous page the lesson
pubsub.publish('general', { type: 'next-page' }); // next page

pubsub.publish('general', { type: 'prev-page' }); // previous page

pubsub.publish('general', {
  type: 'jump-page',
  payload: { sectionId, pageId },
}); // jump page
  • Call to skip downloading file when trying to download the file many times and still has an error message
pubsubClient.publish('load-source', {
  type: ActionClientType.LoadingIgnore,
  payload: { url: string },
});

Events listen

  • Data download progress
useEffect(() => {
  const fnc = (a: ActionClient) => {
    switch(a.type){
      case ActionClientType.LoadingProcess
      //TODO Loading...
      // a.payload: {
      //   url: string;
      //   process: number;
      // }
      break;

      case ActionClientType.LoadingComplete:
      //TODO Complete
      // a.payload: {}
      break;

      case ActionClientType.LoadingError:
      //TODO Error: You can call the method LoadingRetry or LoadingIgnore
      // a.payload: {
      //   url: string;
      //   process: number;
      //   message?: string;
      // }
      break;
    }
  };

  const subscription = pubsubClient.subscribe('load-source', fnc);

  return subscription.unsubscribe;
}, []);
  • Listen at the end of the lesson
useEffect(() => {
  const fnc = (a: ActionClient) => {
    if (a.type === ActionClientType.FinishClassroom) {
      //TODO
    }
  };

  const subscriptionControl = pubsubClient.subscribe('control', fnc);

  return subscriptionControl.unsubscribe;
}, []);
  • Listen at the ready to start class
useEffect(() => {
  const fnc = (action: Action) => {
    if (action.type !== ActionType.ReadyToStart) {
      return;
    }
    if (action.payload.action === 'response') {
      // ready to start
    }

    if (action.payload.action === 'error') {
      Alert.alert('Error', action.payload.message);
      return;
    }
  };

  pubsub.subscribe('general', fnc);

  return () => {
    pubsub.unsubscribe('general', fnc);
  };
}, []);

Fix issues

Contributing

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

License

MIT


Commit Lint:

https://github.com/conventional-changelog/commitlint/#what-is-commitlint

0.5.10

3 months ago

0.5.11

3 months ago

0.5.12

3 months ago

0.5.4

3 months ago

0.5.3

3 months ago

0.5.6

3 months ago

0.5.5

3 months ago

0.5.2

3 months ago

0.5.1

3 months ago

0.5.8

3 months ago

0.5.7

3 months ago

0.5.9

3 months ago

0.6.1

3 months ago

0.6.0

3 months ago

0.5.0

4 months ago

0.4.0

7 months ago

0.3.9

9 months ago

0.3.8

9 months ago

0.3.7

9 months ago

0.3.6

11 months ago

0.3.5

11 months ago

0.3.4

12 months ago

0.3.3

12 months ago

0.3.2

1 year ago

0.3.0

1 year ago

0.3.1

1 year ago

0.2.15

1 year ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.12

1 year ago

0.2.11

1 year ago

0.2.10

1 year ago

0.2.9

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.8

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago