1.0.1 • Published 10 months ago

rnn-copilot v1.0.1

Weekly downloads
102
License
-
Repository
-
Last release
10 months ago

rnn-copilot

An abstraction on top react-native-navigation with simplified, opinionated API

API

Components

App

A singleton that handles App actions

const app = new App()
  .withTopBar({noBorder: true, backButton: {icon: backIcon, color: 'black'}})
  .withLayout({componentBackgroundColor: 'grey'});

withStatusBar(statusBarOptions: OptionsStatusBar)

Set status bar options

withLayout(layoutOptions: OptionsLayout)

Set layout options

withTopBar(topBarOptions: OptionsTopBar)

Set top bar options

withBottomTabs(bottomTabsOptions: OptionsBottomTabs)

set bottom tabs options

withBottomTab(bottomTabOptions: OptionsBottomTab)

set bottom tab options

withOptions(options: Options)

Merge options with arbitrary set of options

clear()

Clear options

set()

Set options as default app style

Root

A singleton that handles Root actions

import {Root} from 'rnn-copilot';

Root.withBottomTab(...).withBottomTab(..).set();
// Or
Root.clear().withSingleStack('mainScreen').set();

withSingleStack(mainScreen: string | string[])

Set a single stack layout with a main screen or with a stack of screens

withBottomTab(bottomTab: BottomTab)

Add a single bottom tab to root layout

withProps(passProps?: object | object[])

Pass props to the main screen Pass an array of props in case you want to pass to a stack of screens

withOptions(options?: Options | Options[])

Pass options to the main screen Pass an array of options in case you want to pass to a stack of screens

clear()

Clear current layout settings in order to start a new one

set()

Set root with current layout configuration

changeTab(tabId: string)

Manually change selected tab

TopBar

import {TopBar} from 'rnn-copilot';

new TopBar().
  .withTitle('title', {color: 'red'})
  .withSubtitle(subtitle, {color: 'red'})
  .update();

update()

Executes RNN mergeOption API

withBackground(color?: string, options?: OptionsTopBar['background'])

Change top bar's background color. pass options for advanced configuration

withTitle(title: string, options)

Updates title text with support for passing customizable options

withSubtitle(subtitle: string, options)

Updates subtitle text with support for passing customizable options

withVisibility(visible: boolean)

Updates top bar visibility

withAnimation(animate: boolean)

Should next update be animated

withTransparency(transparent: boolean)

Toggle top bar transparency where content is drawn behind

withLeftButton(button: OptionsTopBarButton)

Add a single left button (pushes to existing buttons)

withLeftButtons(buttons: OptionsTopBarButton[])

Set multiple left buttons

withRightButton(button: OptionsTopBarButton)

Add a single right button (pushes to existing buttons)

withRightButtons(buttons: OptionsTopBarButton[])

Set multiple right buttons

setRightButton(buttonIndex: number, options: OptionsTopBarButton)

Update a specific right button

StatusBar

import {StatusBar} from 'rnn-copilot';

new StatusBar(componentId).withBackground('red')

withComponentId(componentId: string)

Set component id where the status should update

withVisibility(value: boolean)

Set status bar visibility

withTransparency(transparent: boolean)

Set status bar transparency

withBackgroundColor(color: string)

Set status bar background color

withDarkScheme(useDarkScheme: booolean)

Set status bar style with dark/light scheme

StaticOptions

import {StaticOptions} from 'rnn-copilot';

class MyScreen extends React.Component {
  static options() {
    return (
      new StaticOptions()
        .withTopBar(new TopBar().withTitle('My Screen'))
        .get()
    );
  }
}

withTopBar(topBar: TopBar)

Set a topBar using the TopBar class

withStatusBar(statusBar: StatusBar)

Set a statusBar using the StatusBar class

withOptions(options: Options)

Set custom set of StaticOptions options

get()

Returns the static options object

BottomTab

import {BottomTab} from 'rnn-copilot';

new BottomTab(tabId, screenId).withLabel(tabLabel)

withLabel(label: string)

Set tab label

get()

Retrieve (RNN) layout object

Events

import {Events} from 'rnn-copilot';

class MyScreen extends React.Component<ScreenProps> {
  events = new Events(this.props.componentId).withBindAllEvents(this);
  // Or
  events = new Events(this.props.componentId).withEvents({
    componentDidAppear: callback1,
    navigationButtonPressed: callback2,
  });
}

withBindAllEvents(component: Component, componentId?: string)

Bind all navigation events with the given component

withEvents(eventsListener: EventsListener)

Bind specific navigation events with the given events listener

Roadmap

  • Setup a build in CI
  • Create a StaticOptions component that combines all options
  • Support showing loader as right button (there's an issue)
  • Support easier ways to set app default styles for common behaviors

Know Issues

  • dismissing a pageSheet modal on iOS doesn't trigger didAppear event which breaks our push functionality.
  • After setting a custom right button (loader) - mergeOptions stops working completely
  • StatusBar update doesn't work on iOS
  • iOS - TopBar withBorder doesn't work when using update
1.0.1

10 months ago

0.0.84

1 year ago

0.0.85

12 months ago

0.0.81

1 year ago

0.0.82

1 year ago

0.0.83

1 year ago

0.0.80

1 year ago

0.0.79

1 year ago

0.0.78

2 years ago

0.0.75

2 years ago

0.0.76

2 years ago

0.0.77

2 years ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.39

2 years ago

0.0.73

2 years ago

0.0.74

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.70

2 years ago

0.0.71

2 years ago

0.0.72

2 years ago

0.0.26

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.62

2 years ago

0.0.63

2 years ago

0.0.64

2 years ago

0.0.65

2 years ago

0.0.66

2 years ago

0.0.67

2 years ago

0.0.68

2 years ago

0.0.69

2 years ago

0.0.60

2 years ago

0.0.61

2 years ago

0.0.59

2 years ago

0.0.51

2 years ago

0.0.52

2 years ago

0.0.53

2 years ago

0.0.54

2 years ago

0.0.55

2 years ago

0.0.56

2 years ago

0.0.57

2 years ago

0.0.58

2 years ago

0.0.50

2 years ago

0.0.48

2 years ago

0.0.49

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.23

2 years ago

0.0.22

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago