Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AurangzaibRamzan committed Nov 27, 2019
0 parents commit e41fc45
Show file tree
Hide file tree
Showing 23 changed files with 6,770 additions and 0 deletions.
6 changes: 6 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import { createAppContainer } from 'react-navigation';

import SmartHome from './navigation/SmartHome';

export default createAppContainer(SmartHome);
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SmartHomeUI

## Install NodeModules
- `npm install`

## Starts the App server.
- `npm start`
30 changes: 30 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"expo": {
"name": "HomeUI",
"slug": "my-new-project",
"privacy": "public",
"sdkVersion": "35.0.0",
"platforms": [
"ios",
"android",
"web"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
}
}
}
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/smart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
47 changes: 47 additions & 0 deletions components/Block.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { Component } from 'react'
import { StyleSheet, View } from 'react-native'

export default class Block extends Component {
render() {
const { flex, row, column, center, middle, right, space, style, children, ...props } = this.props;
const blockStyles = [
styles.block,
flex && { flex },
flex === 'disabled' && { flex: 0 },
center && styles.center,
middle && styles.middle,
right && styles.right,
space && { justifyContent: `space-${space}` },
row && styles.row,
column && styles.column,
style,
];

return (
<View style={blockStyles} {...props}>
{children}
</View>
)
}
}

const styles = StyleSheet.create({
block: {
// flex: 1,
},
row: {
flexDirection: 'row'
},
column: {
flexDirection: 'column'
},
center: {
alignItems: 'center'
},
middle: {
justifyContent: 'center'
},
right: {
justifyContent: 'flex-end'
},
});
43 changes: 43 additions & 0 deletions components/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { Component } from 'react';
import {
TouchableNativeFeedback,
TouchableOpacity,
StyleSheet,
Platform,
View,
Text,
Dimensions
} from 'react-native';

const { width } = Dimensions.get('window')
const Button = ({
placeholder = "",
placeholderTextColor = 'white',
imgUrl,
onPress,
}) => {
const Touchable =
Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;
return (<Touchable onPress={onPress}>
<View style={styles.btnView}>
<Text style={{
color: 'white',
fontSize: 20,
}}>Login</Text>
</View>
</Touchable>)
}

export default Button

const styles = StyleSheet.create({
btnView: {
marginTop: 25,
height: 55,
width: 180,
alignItems: 'center',
borderRadius: 50,
justifyContent: 'center',
backgroundColor: 'grey',
}
});
Empty file added components/Buttons.js
Empty file.
42 changes: 42 additions & 0 deletions components/Input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { Component } from 'react';
import { TextInput, View, StyleSheet, Image } from 'react-native';

const Input = ({
placeholder = "",
placeholderTextColor = 'white',
imgUrl,
}) => <View style={styles.textInput}>
<TextInput
style={{
fontSize: 25,
height: 50,
flex: 1,
color: 'white'
}}
autoCorrect={false}
spellCheck={false}
underlineColorAndroid='transparent'
placeholder={placeholder}
placeholderTextColor='grey'
/>
</View>

export default Input

const styles = StyleSheet.create({
icon: {
width: 25,
height: 25,
marginRight: 15,
},
textInput: {
alignItems: 'center',
borderRadius: 10,
flexDirection: 'row',
borderWidth: 0.5,
paddingLeft: 15,
// paddingRigth: 15,
marginBottom: 10,
backgroundColor: 'white',
}
});
86 changes: 86 additions & 0 deletions components/PanSlider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import React, { Component } from 'react'
import { StyleSheet, PanResponder, Dimensions } from 'react-native'

import * as theme from '../theme';
import Block from './Block';
import Text from './Text';

const { height } = Dimensions.get('window');
const CONTROLLER_HEIGHT = height * 0.25;

class PanSlider extends Component {
state = {
panValue: 0,
rangeValue: 0,
percentage: 0,
}

handleMove = moveValue => {
const { panValue } = this.state;
const { minValue, maxValue } = this.props;
const max = maxValue > CONTROLLER_HEIGHT ? maxValue : CONTROLLER_HEIGHT;
const range = (maxValue || max) - minValue;

let value = panValue - (moveValue / range);
if (value > max) value = max;
if (value < minValue) value = minValue;

const percentage = (value / max) * 100;
const rangeValue = (range * percentage) / 100;

this.setState({ panValue: value, rangeValue, percentage });
}

panResponder = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onStartShouldSetPanResponderCapture: () => true,
onMoveShouldSetPanResponder: () => true,
onMoveShouldSetPanResponderCapture: () => true,
onPanResponderMove: (evt, { dy }) => this.handleMove(dy)
})

render() {
const { minValue } = this.props;
const { rangeValue, percentage } = this.state;

return (
<Block right {...this.panResponder.panHandlers} style={styles.controller}>
<Block center style={styles.controllerValue}>
<Text weight="600" color="black">
{rangeValue ? rangeValue.toFixed(0) : minValue}
</Text>
</Block>
<Block style={[styles.controllerOverlay, { height: `${percentage || minValue}%` }]} />
</Block>
)
}
}

PanSlider.defaultProps = {
minValue: 10,
maxValue: 45,
}

export default PanSlider;

const styles = StyleSheet.create({
controller: {
width: 85,
height: CONTROLLER_HEIGHT,
borderRadius: 10,
backgroundColor: theme.colors.gray2,
alignContent: 'center',
overflow: 'hidden'
},
controllerValue: {
position: 'absolute',
top: 24,
left: 0,
right: 0,
zIndex: 1,
},
controllerOverlay: {
width: 85,
backgroundColor: theme.colors.accent,
}
})
77 changes: 77 additions & 0 deletions components/Text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React, { Component } from 'react'
import { StyleSheet, Text } from 'react-native'
import * as theme from '../theme';

export default class Typography extends Component {
render() {
const {
center,
right,
color,
size,
height,
weight,
spacing,
h1,
welcome,
name,
caption,
medium,
bold,
light,
italic,
button,
style,
children,
...props
} = this.props;

const textStyles = [
styles.text,
h1 && styles.h1,
welcome && styles.welcome,
name && styles.name,
button && styles.button,
center && styles.center,
right && styles.right,
color && { color },
color && color === 'accent' && styles.accent,
color && color === 'black' && styles.black,
color && color === 'white' && styles.white,
color && color === 'gray' && styles.gray,
size && { fontSize: size },
bold && styles.bold,
light && styles.light,
caption && styles.caption,
height && { lineHeight: height },
weight && { fontWeight: weight },
spacing && { letterSpacing: spacing },
style
];

return (
<Text style={textStyles} {...props}>
{children}
</Text>
)
}
}

const styles = StyleSheet.create({
text: {
fontSize: theme.sizes.font,
color: theme.colors.black,
},
bold: { fontWeight: 'bold' },
light: { fontWeight: '200' },
center: { textAlign: 'center' },
right: { textAlign: 'right' },
black: { color: theme.colors.black, },
white: { color: theme.colors.white, },
gray: { color: theme.colors.gray, },
welcome: theme.fonts.welcome,
name: theme.fonts.name,
h1: theme.fonts.h1,
button: theme.fonts.button,
caption: theme.fonts.caption,
});
9 changes: 9 additions & 0 deletions components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Block from './Block';
import Text from './Text';
import PanSlider from './PanSlider';

export {
Block,
Text,
PanSlider,
}
15 changes: 15 additions & 0 deletions navigation/SmartHome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import React from 'react';
import { createStackNavigator } from 'react-navigation-stack';

import Dashboard from '../screens/Dashboard';
import Settings from '../screens/Settings';
import Login from '../screens/Login';

export default createStackNavigator({
Login,
Dashboard,
Settings,
}, {
initialRouteName: 'Login'
});
Loading

0 comments on commit e41fc45

Please sign in to comment.