Skip to content

Commit

Permalink
subindo aplicacao de lanterna desenvolvida em bootcamp DIO
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscofolli committed Jul 1, 2022
1 parent 59b09f1 commit 1ec94dd
Show file tree
Hide file tree
Showing 84 changed files with 11,423 additions and 0 deletions.
76 changes: 76 additions & 0 deletions App.js
@@ -0,0 +1,76 @@
import React, {useState, useEffect} from "react";
import { View, StyleSheet, Image, TouchableOpacity, Alert } from "react-native";
import dioLogoBranca from './assets/icons/logo-dio-white.png';
import dioLogoNormal from './assets/icons/logo-dio.png';
import Torch from "react-native-torch";
import RNShake from 'react-native-shake';

const App = () => {
const [toggle, settoggle] = useState(false);


const handleChangeToggle = () => {settoggle(((oldToggle) => !oldToggle))};


useEffect(() => {
Torch.switchState(toggle);
}, [toggle]);

useEffect(() => {

const subscription = RNShake.addListener(() => settoggle(((oldToggle) => !oldToggle)));


return () => subscription.remove();

}, [])
// modelando os dois jeitos de importar imagens
return <View style={toggle ? style.containerLight : style.container}>
<TouchableOpacity onPress={handleChangeToggle}>
<Image
style = {toggle ? style.litghtingOn : style.litghtingOff }
source= {toggle ? require('./assets/icons/eco-light.png') : require('./assets/icons/eco-light-off.png')}
/>
<Image
style = { style.dioLogo }
source= {toggle ? dioLogoNormal : dioLogoBranca}
/>
</TouchableOpacity>
</View>;
}

export default App;

const style = StyleSheet.create({
container: {
flex:1,
backgroundColor: 'black',
alignItems: 'center',
justifyContent: 'center',
},
containerLight: {
flex:1,
backgroundColor: 'white',
alignItems: 'center',
justifyContent: 'center',
},
lanternaAcesa: {
resizeMode: 'contain',
alignSelf: 'center',
width: 150,
height: 150
},
lanternaDesligada: {
resizeMode: 'contain',
alignSelf: 'center',
width: 150,
height: 150,
tintColor: 'white'
},
dioLogo: {
resizeMode: 'contain',
alignSelf: 'center',
width: 250,
height: 250,
}
});
6 changes: 6 additions & 0 deletions Gemfile
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '2.7.5'

gem 'cocoapods', '~> 1.11', '>= 1.11.2'
14 changes: 14 additions & 0 deletions __tests__/App-test.js
@@ -0,0 +1,14 @@
/**
* @format
*/

import 'react-native';
import React from 'react';
import App from '../App';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<App />);
});
55 changes: 55 additions & 0 deletions android/app/_BUCK
@@ -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.dioflashlight",
)

android_resource(
name = "res",
package = "com.dioflashlight",
res = "src/main/res",
)

android_binary(
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)

0 comments on commit 1ec94dd

Please sign in to comment.