This repository has been archived by the owner on May 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement React Native example in code
- Loading branch information
1 parent
b2ab43b
commit 79dc44f
Showing
59 changed files
with
9,705 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
[android] | ||
target = Google Inc.:Google APIs:23 | ||
|
||
[maven_repositories] | ||
central = https://repo1.maven.org/maven2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
|
||
# Android/IntelliJ | ||
# | ||
build/ | ||
.idea | ||
.gradle | ||
local.properties | ||
*.iml | ||
*.hprof | ||
|
||
# node.js | ||
# | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
*.keystore | ||
!debug.keystore | ||
|
||
# Bundle artifacts | ||
*.jsbundle | ||
|
||
# CocoaPods | ||
/ios/Pods/ | ||
|
||
# Expo | ||
.expo/ | ||
web-build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* eslint-disable operator-linebreak */ | ||
import React, { useState, useEffect } from 'react'; | ||
import { StyleSheet, Text, View, TextInput, Button } from 'react-native'; | ||
import { useEasybase, EasybaseProvider } from 'easybase-react'; | ||
import ebconfig from './ebconfig'; | ||
|
||
function Account() { | ||
const [userVal, setUserVal] = useState(""); | ||
const [passVal, setPassVal] = useState(""); | ||
|
||
const { signIn, signUp } = useEasybase(); | ||
|
||
const clearInputs = () => { | ||
setUserVal(""); | ||
setPassVal(""); | ||
} | ||
|
||
const handleSignInPress = async () => { | ||
await signIn(userVal, passVal); | ||
clearInputs(); | ||
} | ||
|
||
const handleSignUpPress = async () => { | ||
const res = await signUp(userVal, passVal, { | ||
created_at: new Date().toString | ||
}); | ||
if (res.success) { | ||
await signIn(userVal, passVal); | ||
} | ||
clearInputs(); | ||
} | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Text style={styles.title}>Welcome to React-flix!</Text> | ||
<TextInput value={userVal} onChangeText={e => setUserVal(e)} style={styles.accountInput} placeholder="Username" /> | ||
<TextInput value={passVal} onChangeText={e => setPassVal(e)} style={styles.accountInput} placeholder="Password"/> | ||
<View style={{ display: "flex", flexDirection: "row", marginTop: 30 }}> | ||
<Button title="Sign In" onPress={handleSignInPress} /> | ||
<Button title="Sign Up" onPress={handleSignUpPress} /> | ||
</View> | ||
</View> | ||
) | ||
} | ||
|
||
function Router() { | ||
const { isUserSignedIn } = useEasybase(); | ||
|
||
return ( | ||
isUserSignedIn() ? | ||
<Text>Congrats! You're signed in.</Text> | ||
: | ||
<Account /> | ||
) | ||
} | ||
|
||
export default function App() { | ||
return ( | ||
<EasybaseProvider ebconfig={ebconfig}> | ||
<Router /> | ||
</EasybaseProvider> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
backgroundColor: '#fff', | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
}, | ||
accountInput: { | ||
height: 40, | ||
borderColor: 'gray', | ||
borderWidth: 1, | ||
width: "75%", | ||
margin: 10, | ||
fontSize: 22, | ||
textAlign: "center" | ||
}, | ||
title: { | ||
fontSize: 30, | ||
fontWeight: "500", | ||
fontStyle: "italic", | ||
marginBottom: 30 | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# To learn about Buck see [Docs](https://buckbuild.com/). | ||
# To run your application with Buck: | ||
# - install Buck | ||
# - `npm start` - to start the packager | ||
# - `cd android` | ||
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` | ||
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck | ||
# - `buck install -r android/app` - compile, install and run application | ||
# | ||
|
||
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") | ||
|
||
lib_deps = [] | ||
|
||
create_aar_targets(glob(["libs/*.aar"])) | ||
|
||
create_jar_targets(glob(["libs/*.jar"])) | ||
|
||
android_library( | ||
name = "all-libs", | ||
exported_deps = lib_deps, | ||
) | ||
|
||
android_library( | ||
name = "app-code", | ||
srcs = glob([ | ||
"src/main/java/**/*.java", | ||
]), | ||
deps = [ | ||
":all-libs", | ||
":build_config", | ||
":res", | ||
], | ||
) | ||
|
||
android_build_config( | ||
name = "build_config", | ||
package = "com.nativeexample", | ||
) | ||
|
||
android_resource( | ||
name = "res", | ||
package = "com.nativeexample", | ||
res = "src/main/res", | ||
) | ||
|
||
android_binary( | ||
name = "app", | ||
keystore = "//android/keystores:debug", | ||
manifest = "src/main/AndroidManifest.xml", | ||
package_type = "debug", | ||
deps = [ | ||
":app-code", | ||
], | ||
) |
Oops, something went wrong.