Permalink
Browse files

Add React Native High Score Screen

  • Loading branch information...
JoelMarcey committed May 24, 2016
1 parent c71dc79 commit 13272a31ee6dd46dc68b1dcf4eaf16c1a10f5229
View
@@ -20,4 +20,7 @@ DerivedData
*.xccheckout
#CocoaPods
Pods
Pods
#Node
node_modules/
View
@@ -0,0 +1,50 @@
'use strict';
import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
class RNHighScores extends React.Component {
render() {
console.log(this.props["scores"]);
var contents = this.props["scores"].map(
score => <Text key={score.name}>{score.name}:{score.value}{"\n"}</Text>
);
return (
<View style={styles.container}>
<Text style={styles.highScoresTitle}>
2048 High Scores!
</Text>
<Text style={styles.scores}>
{contents}
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#FFFFFF',
},
highScoresTitle: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
scores: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
// Module name
AppRegistry.registerComponent('RNHighScores', () => RNHighScores);
View
@@ -0,0 +1,19 @@
source 'https://github.com/CocoaPods/Specs.git'
# Required for Swift apps
platform :ios, '8.0'
use_frameworks!
# The target name is most likely the name of your project.
target 'swift-2048' do
# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'RCTText',
'RCTWebSocket', # needed for localhost testing of your app
# Add any other subspecs you want to use in your project
]
end
View
@@ -0,0 +1,22 @@
PODS:
- React/Core (0.26.1)
- React/RCTText (0.26.1):
- React/Core
- React/RCTWebSocket (0.26.1):
- React/Core
DEPENDENCIES:
- React/Core (from `../node_modules/react-native`)
- React/RCTText (from `../node_modules/react-native`)
- React/RCTWebSocket (from `../node_modules/react-native`)
EXTERNAL SOURCES:
React:
:path: ../node_modules/react-native
SPEC CHECKSUMS:
React: 9a7eb5f6e7146734fb50ab17f515087d302d5cca
PODFILE CHECKSUM: c3fc49e6aed4a94e4c2807aa6c681e13de6c13ab
COCOAPODS: 1.0.0
@@ -17,9 +17,10 @@
1AE8BEF2193EF1C7007592BA /* AppearanceProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AE8BEF1193EF1C7007592BA /* AppearanceProvider.swift */; };
1AE8BEF4193EF260007592BA /* NumberTileGame.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AE8BEF3193EF260007592BA /* NumberTileGame.swift */; };
1AE8BEF6193EF4B6007592BA /* TileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AE8BEF5193EF4B6007592BA /* TileView.swift */; };
1AEF46D01BAE736400119D81 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1AEF46CF1BAE736400119D81 /* Launch Screen.storyboard */; settings = {ASSET_TAGS = (); }; };
1AEF46D01BAE736400119D81 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1AEF46CF1BAE736400119D81 /* Launch Screen.storyboard */; };
1AF8F0B619403AA400A7049E /* AccessoryViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AF8F0B519403AA400A7049E /* AccessoryViews.swift */; };
1AF8F0B81941841000A7049E /* AuxiliaryModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AF8F0B71941841000A7049E /* AuxiliaryModels.swift */; };
AF6DF1BA6A4E4797AEFD0577 /* Pods_swift_2048.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 82A7C2F6B04B245291C71864 /* Pods_swift_2048.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -57,13 +58,17 @@
1AEF46CF1BAE736400119D81 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
1AF8F0B519403AA400A7049E /* AccessoryViews.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AccessoryViews.swift; path = Views/AccessoryViews.swift; sourceTree = "<group>"; };
1AF8F0B71941841000A7049E /* AuxiliaryModels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AuxiliaryModels.swift; path = Models/AuxiliaryModels.swift; sourceTree = "<group>"; };
6F766809529C75572C88B020 /* Pods-swift-2048.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-swift-2048.release.xcconfig"; path = "Pods/Target Support Files/Pods-swift-2048/Pods-swift-2048.release.xcconfig"; sourceTree = "<group>"; };
82A7C2F6B04B245291C71864 /* Pods_swift_2048.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_swift_2048.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9371645BE9BE5B53D065F5DA /* Pods-swift-2048.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-swift-2048.debug.xcconfig"; path = "Pods/Target Support Files/Pods-swift-2048/Pods-swift-2048.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
1AC563DA193DCE6000402286 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
AF6DF1BA6A4E4797AEFD0577 /* Pods_swift_2048.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -83,6 +88,8 @@
1AC563DF193DCE6000402286 /* swift-2048 */,
1AC563F2193DCE6000402286 /* swift-2048Tests */,
1AC563DE193DCE6000402286 /* Products */,
41F65F6D19A1853B09B99D76 /* Pods */,
D43546A0237900AA11D5D46A /* Frameworks */,
);
sourceTree = "<group>";
};
@@ -156,16 +163,36 @@
name = Views;
sourceTree = "<group>";
};
41F65F6D19A1853B09B99D76 /* Pods */ = {
isa = PBXGroup;
children = (
9371645BE9BE5B53D065F5DA /* Pods-swift-2048.debug.xcconfig */,
6F766809529C75572C88B020 /* Pods-swift-2048.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
D43546A0237900AA11D5D46A /* Frameworks */ = {
isa = PBXGroup;
children = (
82A7C2F6B04B245291C71864 /* Pods_swift_2048.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
1AC563DC193DCE6000402286 /* swift-2048 */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1AC563F9193DCE6000402286 /* Build configuration list for PBXNativeTarget "swift-2048" */;
buildPhases = (
CA4990FAFEAD4182640E3906 /* 📦 Check Pods Manifest.lock */,
1AC563D9193DCE6000402286 /* Sources */,
1AC563DA193DCE6000402286 /* Frameworks */,
1AC563DB193DCE6000402286 /* Resources */,
A721CE9FBD1BFB2F72F91507 /* 📦 Embed Pods Frameworks */,
90A41A8E993E47502AB6BD8E /* 📦 Copy Pods Resources */,
);
buildRules = (
);
@@ -253,6 +280,54 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
90A41A8E993E47502AB6BD8E /* 📦 Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-swift-2048/Pods-swift-2048-resources.sh\"\n";
showEnvVarsInLog = 0;
};
A721CE9FBD1BFB2F72F91507 /* 📦 Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-swift-2048/Pods-swift-2048-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
CA4990FAFEAD4182640E3906 /* 📦 Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
1AC563D9193DCE6000402286 /* Sources */ = {
isa = PBXSourcesBuildPhase;
@@ -387,8 +462,10 @@
};
1AC563FA193DCE6000402286 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9371645BE9BE5B53D065F5DA /* Pods-swift-2048.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "swift-2048/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -399,8 +476,10 @@
};
1AC563FB193DCE6000402286 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 6F766809529C75572C88B020 /* Pods-swift-2048.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "swift-2048/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
File renamed without changes.
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
@@ -26,11 +26,21 @@
<action selector="startGameButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Svv-I7-WP7"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ijf-df-t57">
<rect key="frame" x="258" y="362" width="84" height="30"/>
<state key="normal" title="High Scores">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="highScoreButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="6KD-wl-nK3"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Ng3-Kq-xkw" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="9LS-wc-aWw"/>
<constraint firstItem="Ng3-Kq-xkw" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="J3L-8R-oCZ"/>
<constraint firstItem="Ijf-df-t57" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="OIH-nJ-30A"/>
</constraints>
</view>
<simulatedOrientationMetrics key="simulatedOrientationMetrics"/>
@@ -30,5 +30,16 @@
<array>
<string>armv7</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
@@ -0,0 +1,44 @@
//
// ViewController.swift
// swift-2048
//
// Created by Austin Zheng on 6/3/14.
// Copyright (c) 2014 Austin Zheng. Released under the terms of the MIT license.
//
import UIKit
import React
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func startGameButtonTapped(sender : UIButton) {
let game = NumberTileGameViewController(dimension: 4, threshold: 2048)
self.presentViewController(game, animated: true, completion: nil)
}
@IBAction func highScoreButtonTapped(sender : UIButton) {
NSLog("Hello")
let jsCodeLocation = NSURL(string: "http://localhost:8081/index.ios.bundle?platform=ios")
let mockData:NSDictionary = ["scores":
[
["name":"Alex", "value":"42"],
["name":"Joel", "value":"10"]
]
]
let rootView = RCTRootView(
bundleURL: jsCodeLocation,
moduleName: "RNHighScores",
initialProperties: mockData as [NSObject : AnyObject],
launchOptions: nil
)
let vc = UIViewController()
vc.view = rootView
self.presentViewController(vc, animated: true, completion: nil)

This comment has been minimized.

Show comment
Hide comment
@manas-chaudhari

manas-chaudhari Jul 18, 2018

Can we have an example to show how to navigate back to home page?

@manas-chaudhari

manas-chaudhari Jul 18, 2018

Can we have an example to show how to navigate back to home page?

}
}
File renamed without changes.
View
@@ -0,0 +1,12 @@
{
"name": "NumberTileGame",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"react": "15.0.2",
"react-native": "0.26.1"
}
}
@@ -1,22 +0,0 @@
//
// ViewController.swift
// swift-2048
//
// Created by Austin Zheng on 6/3/14.
// Copyright (c) 2014 Austin Zheng. Released under the terms of the MIT license.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func startGameButtonTapped(sender : UIButton) {
let game = NumberTileGameViewController(dimension: 4, threshold: 2048)
self.presentViewController(game, animated: true, completion: nil)
}
}

0 comments on commit 13272a3

Please sign in to comment.