Snackbar-Plugin für React-Native.
$ npm install alopeyk-snackbar --save
Und dann:
$ react-native link alopeyk-snackbar
Da dieses Repo in Swift geschrieben ist, sollten Sie Test.swift
Schieben Sie von node_modulles/alopeyk-snackbar/ios
in das Xcode-Projekt Ihres [your project's name]
und dann auf copy items if needed
und dann auf die Eingabeaufforderung. Wählen Sie Brücke hinzufügen.
node_modules/alopeyk-snackbar/ios
Code mit Ihrem [your project's name]
zu Test.swift
Libraries
➜ Add Files to [your project's name]
node_modules
➜ alopeyk-snackbar
und fügen Sie RNSnackbar.xcodeproj
hinzulibRNSnackbar.a
in Build Phases
Ihres Projekts hinzu. ➜ Link Binary With Libraries
Cmd+R
) < android/app/src/main/java/[...]/MainApplication.java
import com.alopeyk.nativemodule.RNSnackbarPackage;
zu den Importen oben in der DateigetPackages()
-Methode zurückgegebenen Liste new RNSnackbarPackage()
hinzu.android/settings.gradle
an: include ':alopeyk-snackbar'
project(':alopeyk-snackbar').projectDir = new File(rootProject.projectDir, '../node_modules/alopeyk-snackbar/android')
android/app/build.gradle
: compile project(':alopeyk-snackbar')
import Snackbar from 'alopeyk-snackbar' ;
Snackbar . show ( {
title : 'Please agree to this.' ,
duration : Snackbar . LENGTH_INDEFINITE ,
backgroundColor : 'silver' ,
color : '#333' ,
maxLines : 3 , //Default: 2
barPosition : Snackbar . BAR_POSITION_TOP , //Default: Snackbar.BAR_POSITION_BOTTOM
direction : Snackbar . DIRECTION_RTL , //Default: Snackbar.DIRECTION_LTR
action : {
title : 'AGREE' ,
onPress : ( ) => Snackbar . show ( { title : 'Thank you!' } ) ,
color : '#992222' ,
} ,
} ) ;
// dismiss snackbar
Snackbar . dismiss ( ) ;