Skip to content

Instantly share code, notes, and snippets.

View khwilo's full-sized avatar
🔍
I'm open to back-end developer roles!

Khwilo Kabaka khwilo

🔍
I'm open to back-end developer roles!
View GitHub Profile
@khwilo
khwilo / Home-v6.js
Created September 19, 2020 08:19
Tip Calculator App Home component with TouchableWithoutFeedback
// ...
import { Keyboard,TouchableWithoutFeedback, /* ... other component imports */} from 'react-native';
// ...
const Home = () => {
// ...
return (
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
@khwilo
khwilo / index.js
Created September 18, 2020 09:46
Tip Calculator App index.js
import { registerRootComponent } from 'expo';
import App from './src/App';
registerRootComponent(App);
@khwilo
khwilo / Home-v5.js
Last active September 18, 2020 13:56
Tip Calculator App with split total calculation logic
import React, { useEffect, useState } from 'react';
// ...
const Home = () => {
const defaultValue = 0;
// ...
useEffect(() => {
const total = parseFloat(bill) || defaultValue;
@khwilo
khwilo / Home-v4.js
Last active September 18, 2020 13:29
Tip Calculator App component tip count handler functions
// ...
const Home = () => {
// ...
const handleSplitAdd = () => {
setSplit((split) => {
const total = parseInt(split) + 1;
return total.toString();
});
@khwilo
khwilo / Home-v3.js
Last active September 18, 2020 13:28
Tip Calculator App bill and tip input handler functions
// ...
const Home = () => {
// ...
const handleBillChange = (value) => {
setBill(value);
};
const handleTipChange = (value) => {
@khwilo
khwilo / Home-v2.js
Last active September 18, 2020 13:13
Tip Calculator App Home component with state
import React, { useState } from 'react';
// ....
const Home = () => {
const [bill, setBill] = useState('0.00');
const [tip, setTip] = useState('10');
const [split, setSplit] = useState('2');
const [splitTotal, setSplitTotal] = useState('0.00');
@khwilo
khwilo / App.js
Last active September 18, 2020 12:54
Tip Calculator App root component file
import React from 'react';
import Home from './screens/Home';
const App = () => {
return <Home />;
};
export default App;
@khwilo
khwilo / Home-v1.js
Last active September 18, 2020 12:53
Tip Calculator Home Screen without state
import React from 'react';
import { StyleSheet, View } from 'react-native';
import Input from '../components/Input';
import SplitOutput from '../containers/SplitOutput';
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 40,
@khwilo
khwilo / SplitTotal.js
Last active September 19, 2020 09:00
Tip Calculator App Split Total component file
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
const styles = StyleSheet.create({
textHeader: {
fontSize: 18,
color: '#ffffff',
fontWeight: '700',
letterSpacing: 1.5,
},
@khwilo
khwilo / SplitCount.js
Last active September 19, 2020 08:59
Tip Calculator SplitCount component file
import React from 'react';
import { MaterialIcons } from '@expo/vector-icons';
import { StyleSheet, Text, View } from 'react-native';
const styles = StyleSheet.create({
textHeader: {
fontSize: 18,
color: '#ffffff',
fontWeight: '700',