Skip to content

Commit

Permalink
Good enough working state
Browse files Browse the repository at this point in the history
  • Loading branch information
paramaggarwal committed Jul 21, 2016
1 parent d32627b commit 7f95ed5
Show file tree
Hide file tree
Showing 8 changed files with 78,608 additions and 64 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
"extends": "standard",
"installedESLint": true,
"plugins": [
"standard"
]
};
101 changes: 47 additions & 54 deletions index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,23 @@ let cardsMap = {
}
}

let darkRed = "#A91400";
let brightOrange = "#FF5505";
let panDiff = 240;

class Shroom extends Component {
constructor(props) {
super(props)

let pan = new Animated.ValueXY()
this.state = {
reactionCount: 5,
isDocked: true,
scroll: true,
pan: new Animated.ValueXY(),
pan: pan,
dockAnimation: pan.y.interpolate({
inputRange: [-panDiff, 0],
outputRange: [0, 1],
extrapolate: 'clamp'
})
}
}

Expand All @@ -63,18 +68,29 @@ class Shroom extends Component {
onPanResponderRelease: () => {
// this.setState({scroll: true})

if (this._pan.y < -100) {
if (Math.abs(this._pan.y) < panDiff / 3) {
// return
Animated.spring(this.state.pan.y, {
toValue: -400
toValue: this.state.isDocked ? 0 : 0
}).start();
} else {
Animated.spring(this.state.pan.y, {
toValue: 0
}).start(()=>{
toValue: this.state.isDocked ? (-panDiff) : panDiff
}).start(() => {

this.setState({
isDocked: false
})
});
isDocked: !this.state.isDocked,
dockAnimation: !this.state.isDocked ? this.state.pan.y.interpolate({
inputRange: [-panDiff, 0],
outputRange: [1, 0],
extrapolate: 'clamp'
}) : this.state.pan.y.interpolate({
inputRange: [0, panDiff],
outputRange: [0, 1],
extrapolate: 'clamp'
})
});
})
}
}
})
Expand Down Expand Up @@ -163,7 +179,9 @@ class Shroom extends Component {
👏
</Text>
</TouchableHighlight>
<Text style={styles.reactionCount}>
<Text style={[styles.reactionCount, {
color: cardsMap[type].colorDark
}]}>
{this.state.reactionCount}
</Text>
</View>
Expand All @@ -173,54 +191,43 @@ class Shroom extends Component {
}

render() {
let {
pan
} = this.state

return (
<View style={styles.box}>
<AnimatedScrollView
horizontal={true}
pagingEnabled={!this.state.isDocked}
scrollEnabled={this.state.scroll}
style={[styles.container,{
borderWidth: 1,
borderColor: 'red',
width: this.state.pan.y.interpolate({
inputRange: [-300, 0],
// borderWidth: 1,
// borderColor: 'red',
width: this.state.dockAnimation.interpolate({
inputRange: [0, 1],
outputRange: [Dimensions.get('window').width, Dimensions.get('window').width * 2],
extrapolate: 'clamp'
// extrapolate: 'clamp'
}),
}, {
transform: [{
scale: this.state.pan.y.interpolate({
inputRange: [-300, 0],
scale: this.state.dockAnimation.interpolate({
inputRange: [0, 1],
outputRange: [1, 0.5],
extrapolate: 'clamp'
// extrapolate: 'clamp'
}),
}, {
translateX: this.state.pan.y.interpolate({
inputRange: [-300, 0],
},
{
translateX: this.state.dockAnimation.interpolate({
inputRange: [0, 1],
outputRange: [0, -(Dimensions.get('window').width)],
extrapolate: 'clamp'
// extrapolate: 'clamp'
}),
}, {
translateY: this.state.pan.y.interpolate({
inputRange: [-300, 0],
},
{
translateY: this.state.dockAnimation.interpolate({
inputRange: [0, 1],
outputRange: [0, (Dimensions.get('window').height/2)],
extrapolate: 'clamp'
// extrapolate: 'clamp'
}),
}],
}]}
// style={[styles.container,{
// transform: [{
// scale: this.state.isDocked ? 0.5 : 1,
// }, {
// translateX: this.state.isDocked ? -150 : 0,
// }, {
// translateY: this.state.isDocked ? 260 : 0,
// }],
// }]}
{...this._panResponder.panHandlers}
>
{this.renderCard({
Expand Down Expand Up @@ -252,21 +259,13 @@ const styles = StyleSheet.create({
flex: 1,
backgroundColor: 'black',
},

container: {
flex: 1,
// overflow: 'visible',
// justifyContent: 'center',
// alignItems: 'center',

},
updateText: {
// fontFamily: 'Dosis',
fontSize: 32,
color: 'white',
backgroundColor: 'transparent',
// fontWeight: 300,
// textAlign: 'center',
margin: 20,
},
profilePicture: {
Expand All @@ -280,7 +279,6 @@ const styles = StyleSheet.create({
displayName: {
backgroundColor: 'transparent',
color: 'white',
// textAlign: 'center',
marginLeft: 0,
marginTop: 22,
fontSize: 20,
Expand All @@ -295,18 +293,15 @@ const styles = StyleSheet.create({
badgeSection: {
flex: 1,
alignItems: 'flex-end',
// marginTop: 20,
marginRight: 20,
justifyContent: 'center'
},
badgeSlug: {
backgroundColor: brightOrange,
borderRadius: 15,
paddingVertical: 5,
paddingHorizontal: 12,
},
badgeText: {
color: darkRed,
textAlign: 'center',
fontSize: 10,
fontWeight: 'bold'
Expand All @@ -321,7 +316,6 @@ const styles = StyleSheet.create({
backgroundColor: 'transparent',
fontSize: 50,
padding: 10,
textShadowColor: darkRed,
textShadowRadius: 10,
textShadowOffset: {
width: 5,
Expand All @@ -331,7 +325,6 @@ const styles = StyleSheet.create({
reactionCount: {
textAlign: 'center',
backgroundColor: 'transparent',
color: darkRed,
fontSize: 30,
padding: 0,
},
Expand Down
17 changes: 14 additions & 3 deletions ios/Shroom.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,17 @@
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 610;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
00E356ED1AD99517003FC87E = {
CreatedOnToolsVersion = 6.2;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = 8J6S3G3GZ8;
DevelopmentTeamName = "Param Aggarwal";
};
};
};
buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "Shroom" */;
Expand Down Expand Up @@ -618,6 +622,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Shroom.app/Shroom";
};
Expand All @@ -635,6 +640,7 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Shroom.app/Shroom";
};
Expand All @@ -658,6 +664,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = in.helpingo.Shroom;
PRODUCT_NAME = Shroom;
};
name = Debug;
Expand All @@ -679,6 +686,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = in.helpingo.Shroom;
PRODUCT_NAME = Shroom;
};
name = Release;
Expand All @@ -703,8 +711,10 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand All @@ -723,7 +733,7 @@
"$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
);
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -752,6 +762,7 @@
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -764,7 +775,7 @@
"$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-linear-gradient/BVLinearGradient",
);
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
13 changes: 8 additions & 5 deletions ios/Shroom.xcodeproj/xcshareddata/xcschemes/Shroom.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -37,10 +37,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -62,15 +62,18 @@
ReferencedContainer = "container:Shroom.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand All @@ -86,10 +89,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
2 changes: 1 addition & 1 deletion ios/Shroom/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/ShroomTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Loading

0 comments on commit 7f95ed5

Please sign in to comment.