Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cactuslab/native-navigation

Package Overview
Dependencies
Maintainers
3
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cactuslab/native-navigation

Native navigation for Capacitor apps

  • 0.7.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
3
Weekly downloads
 
Created
Source

Capacitor Native Navigation Plugin

Native navigation for Capacitor apps.

This package provides a Capacitor plugin for controlling native navigation UI from a React DOM app.

Please see the root of this repository for a discussion of how to use this plugin.

Install

npm install @cactuslab/native-navigation
npx cap sync

API

present(...)

present(options: PresentOptions) => Promise<PresentResult>

Present a new native UI.

See dismiss for removing the presentation

ParamType
optionsPresentOptions

Returns: Promise<PresentResult>


dismiss(...)

dismiss(options?: DismissOptions | undefined) => Promise<DismissResult>

Dismiss a native UI. The component id may be a component that was previously presented or a component within a previously presented component.

See present for presenting native UI.

ParamType
optionsDismissOptions

Returns: Promise<DismissResult>


push(...)

push(options: PushOptions) => Promise<PushResult>

Push a new component onto a stack, or replace an existing component.

See pop for removing a component from the stack.

ParamType
optionsPushOptions

Returns: Promise<PushResult>


pop(...)

pop(options: PopOptions) => Promise<PopResult>

Pop the top component off a stack.

See push for adding a component to the stack.

ParamType
optionsPopOptions

Returns: Promise<PopResult>


update(...)

update(options: UpdateOptions) => Promise<void>

Set the options for an existing component

ParamType
optionsUpdateOptions

reset(...)

reset(options?: ResetOptions | undefined) => Promise<void>

Remove all of the native UI and reset back to the root Capacitor webview.

ParamType
optionsResetOptions

get(...)

get(options?: GetOptions | undefined) => Promise<GetResult>

Get the spec and context of a component

ParamType
optionsGetOptions

Returns: Promise<GetResult>


message(...)

message<D>(options: MessageOptions<D>) => Promise<void>

Send a message to a component.

ParamType
optionsMessageOptions<D>

Interfaces

PresentResult
PropType
idComponentId
PresentOptions
PropTypeDescription
componentAnyComponentSpecThe component to present.
stylePresentationStyleThe presentation style. Defaults to 'fullScreen'
cancellablebooleanWhether to allow the user to use system gestures or the back button to unwind the presentation. Useful to prevent the accidental dismissal of a form. Defaults to true
animatedbooleanWhether to animate the presenting. Defaults to true
StackSpec
PropTypeDescription
type'stack'
componentsViewSpec[]
barBarSpec
titlestring
stateStateObjectState that will be mixed into the state of each of the contained components
ViewSpec
PropTypeDescription
type'view'
pathstringThe path representing the view.
stateStateObject
titlestringThe title is shown in the title bar when the view is shown in a stack. Titles may also be used in other ways by the native environment and are a good idea.
stackItemStackItemSpecOptions for when the component is used in a stack
android{ backButtonId?: string; }Options for Android specific features
StackItemSpec
PropTypeDescription
backItemStackBarButtonItemThe back item used when this stack item is on the back stack. This is only currently used by iOS as Android will show an arrow with no title if back is enabled
leftItemsStackBarButtonItem[]Setting any value to leftItems will disable the navigation back buttons on both iOS and Android. (Android hardware back button is not affected). iOS: items will show on the left side of the navigation bar replacing the back button. The swipe back gesture will be disabled. Android: Toolbars have support for only a single image-button on the left. If the first item has an image then the toolbar will insert this item left of the title replacing the default back button if there would have been one. The remaining left items will appear on the right of the toolbar ahead of any right items.
rightItemsStackBarButtonItem[]Right items will show on the rightmost edge of the navigation bar.
barBarSpecCustomise the bar on top of the default options provided by the stack
StackBarButtonItem
PropTypeDescription
idButtonId
titlestringA title for the button or context for a screen reader if the button has an icon
imageImageSpecIf image is present then the title will be replaced by the image
android{ image?: ImageSpec; }Custom options for Android specific behaviours
ImageObject
PropTypeDescription
uristringThe uri for the image.
scalenumberThe scale to use for the image, e.g. 2 for a 2x scale image. If not provided the scale will be determined automatically from the filename, or it will default to 1.
disableTintbooleanBy default if this image is used in a button it will get tinted the color of the button. If your image needs to keep its original colors set disableTint: true to prevent the tinting.
BarSpec
PropType
backgroundFillSpec
titleLabelSpec
buttonsLabelSpec
visibleboolean
iOSBarSpecIOS
FillSpec
PropType
colorstring
LabelSpec
PropType
colorstring
fontFontSpec
FontSpec
PropType
namestring
sizenumber
BarSpecIOS
PropTypeDescription
hideShadowboolean | nullDefault behaviour is to show the shadow
TabsSpec
PropTypeDescription
type'tabs'
tabsTabSpec[]
titlestring
stateStateObjectState that will be mixed into the state of each of the contained components
TabSpec
PropTypeDescription
aliasComponentAlias
titlestring
imageImageSpec
badgeValuestring
componentViewSpec | StackSpec
stateStateObjectState that will be mixed into the state of each of the contained components
DismissResult
PropType
idComponentId
DismissOptions
PropType
idstring | ComponentId
animatedboolean
PushResult
PropTypeDescription
idComponentIdThe id of the component that was pushed.
stackComponentIdThe stack that was pushed to, if it was pushed to a stack.
PushOptions
PropTypeDescription
componentViewSpecThe options for the view to push onto the stack.
targetstring | ComponentIdThe target component to push to, usually a stack, or undefined to push to the current stack or component.
animatedbooleanWhether to animate the push. Defaults to true
modePushModeThe mode to use for the push. Defaults to 'push'. push: Push the component onto the stack. replace: Replace the current top-most component in the stack. root: Reset the stack back to just the new component.
popCountnumberHow many items to pop first
PopResult
PropTypeDescription
stackComponentId
countnumberThe number of components that were popped
idComponentIdThe id of the component that was popped, if any. If multiple components are popped, the id will be of the last component popped.
PopOptions
PropTypeDescription
stackstring | ComponentIdThe stack to pop from, or undefined to pop from the current stack.
countnumberHow many items to pop
animatedbooleanWhether to animate the pop. Defaults to true
UpdateOptions
PropTypeDescription
idstring | ComponentId
animatedbooleanWhether to animate the changes. Defaults to false
updateStackUpdate | TabsUpdate | TabUpdate | ViewUpdate
StackUpdate

Options for stack components

PropType
componentsViewSpec[]
barBarUpdate
BarUpdate
PropType
backgroundFillUpdate | null
titleLabelUpdate | null
buttonsLabelUpdate | null
visibleboolean | null
iOSBarSpecIOS
FillUpdate
PropType
colorstring | null
LabelUpdate
PropType
colorstring | null
fontFontUpdate | null
FontUpdate
PropType
namestring | null
sizenumber | null
TabsUpdate

Options for tabs components

PropType
tabsTabSpec[]
TabUpdate
PropType
titlestring | null
imageImageSpec | null
badgeValuestring | null
componentViewSpec | StackSpec
ViewUpdate

Options for view components

PropTypeDescription
stackItemStackItemUpdateOptions for when the component is used in a stack
android{ backButtonId?: string | null; }Options for Android specific features
StackItemUpdate
PropTypeDescription
backItemStackBarButtonItem | nullThe back item used when this stack item is on the back stack. This is only currently used by iOS as Android will show an arrow with no title if back is enabled
leftItemsStackBarButtonItem[] | nullSetting any value to leftItems will disable the navigation back buttons on both iOS and Android. (Android hardware back button is not affected). iOS: items will show on the left side of the navigation bar replacing the back button. The swipe back gesture will be disabled. Android: Toolbars have support for only a single image-button on the left. If the first item has an image then the toolbar will insert this item left of the title replacing the default back button if there would have been one. The remaining left items will appear on the right of the toolbar ahead of any right items.
rightItemsStackBarButtonItem[] | nullRight items will show on the rightmost edge of the navigation bar.
barBarUpdate | nullCustomise the bar on top of the default options provided by the stack
ResetOptions
PropTypeDescription
animatedbooleanWhether to animate resetting the navigation back to Capacitor Defaults to false
GetResult
PropTypeDescription
componentAnyComponentModelThe component, if any.
stackStackModelThe stack containing the component, if any.
tabsTabsModelThe tabs containing the component, if any.
StackModel
PropType
idComponentId
TabsModel
PropType
idComponentId
ViewModel
PropType
idComponentId
GetOptions
PropTypeDescription
idstring | ComponentIdThe component id to get, or undefined to get the top-most component.
MessageOptions
PropTypeDescription
targetComponentIdThe target component of the message, or undefined to send to the top-most component.
typestringThe message type.
valueDA message value. Must be JSON stringifiable.

Type Aliases

ComponentId

Opaque<'ComponentId', string>

Opaque

T & { TYPE: K }

AnyComponentSpec

StackSpec | TabsSpec | ViewSpec

StateObject

Record<string, string | number | boolean | null>

Record

Construct a type with a set of properties K of type T

{ [P in K]: T; }

ButtonId

string

ImageSpec

ImageObject | string

ComponentAlias

string

PresentationStyle

'fullScreen' | 'pageSheet' | 'formSheet' | 'dialog'

PushMode

push: Push the component onto the stack. replace: Replace the current top-most component in the stack. root: Reset the stack back to just the new component.

'push' | 'replace' | 'root'

AnyComponentModel

StackModel | TabsModel | ViewModel

Keywords

FAQs

Package last updated on 28 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc