-
Notifications
You must be signed in to change notification settings - Fork 16
WIP: React Native Windows Support #193
base: master
Are you sure you want to change the base?
Changes from 5 commits
9b9ef08
7fb6130
3331cf1
475ed43
e8b87b2
e2cf7d1
7ed71dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,4 @@ StoryManager.make('some red example', () => ( | |
<Text>Hello World!</Text> | ||
</View> | ||
)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,16 @@ | |
"scripts": { | ||
"build:runner:ios": "./scripts/build-runner-ios.sh", | ||
"build:runner:android": "./scripts/build-runner-android.sh", | ||
"build:runner:windows": "./scripts/build-runner-windows.sh", | ||
"build:server": "../../node_modules/.bin/babel src -d lib --ignore __tests__", | ||
"build": "npm run build:runner:ios && npm run build:runner:android && npm run build:server", | ||
"watch": "npm run build:server -- --watch" | ||
}, | ||
"devDependencies": { | ||
"react-native": "^0.40.0", | ||
"react-native-view-shot": "^1.5.1" | ||
"react-native-view-shot": "^1.5.1", | ||
"react-native-windows": "^0.43.0-rc.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just curious, but does having react-native and react-native-windows both in our dev deps preclude us from doing non react-native-windows development? I'm somewhat ignorant of how this works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lelandrichardson It doesn't preclude non react-native-windows development but it is a fairly large dependency to include if you're not working on windows. I was thinking of including as an optional dependency but I wasn't sure if that was the right approach either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. I'm tempted to agree this should be an optionalDependency. We could even create There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"rnpm-plugin-windows": "^0.2.4" | ||
}, | ||
"peerDependencies": { | ||
"react-native": "*", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
*AppPackages* | ||
*BundleArtifacts* | ||
*ReactAssets* | ||
|
||
#OS junk files | ||
[Tt]humbs.db | ||
*.DS_Store | ||
|
||
#Visual Studio files | ||
*.[Oo]bj | ||
*.user | ||
*.aps | ||
*.pch | ||
*.vspscc | ||
*.vssscc | ||
*_i.c | ||
*_p.c | ||
*.ncb | ||
*.suo | ||
*.tlb | ||
*.tlh | ||
*.bak | ||
*.[Cc]ache | ||
*.ilk | ||
*.log | ||
*.lib | ||
*.sbr | ||
*.sdf | ||
*.opensdf | ||
*.opendb | ||
*.unsuccessfulbuild | ||
ipch/ | ||
[Oo]bj/ | ||
[Bb]in | ||
[Dd]ebug*/ | ||
[Rr]elease*/ | ||
Ankh.NoLoad | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opendb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
*.VC.db | ||
*.VC.VC.opendb | ||
|
||
#MonoDevelop | ||
*.pidb | ||
*.userprefs | ||
|
||
#Tooling | ||
_ReSharper*/ | ||
*.resharper | ||
[Tt]est[Rr]esult* | ||
*.sass-cache | ||
|
||
#Project files | ||
[Bb]uild/ | ||
|
||
#Subversion files | ||
.svn | ||
|
||
# Office Temp Files | ||
~$* | ||
|
||
# vim Temp Files | ||
*~ | ||
|
||
#NuGet | ||
packages/ | ||
*.nupkg | ||
|
||
#ncrunch | ||
*ncrunch* | ||
*crunch*.local.xml | ||
|
||
# visual studio database projects | ||
*.dbmdl | ||
|
||
#Test files | ||
*.testsettings | ||
|
||
#Other files | ||
*.DotSettings | ||
.vs/ | ||
*project.lock.json |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Application | ||
x:Class="HappoRunner.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:HappoRunner" | ||
RequestedTheme="Light"> | ||
|
||
</Application> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
using ReactNative; | ||
using ReactNative.Modules.Launch; | ||
using System; | ||
using Windows.ApplicationModel; | ||
using Windows.ApplicationModel.Activation; | ||
using Windows.UI.Core; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
namespace HappoRunner | ||
{ | ||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
sealed partial class App : Application | ||
{ | ||
private readonly ReactPage _reactPage; | ||
|
||
/// <summary> | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
public App() | ||
{ | ||
this.InitializeComponent(); | ||
this.Suspending += OnSuspending; | ||
this.Resuming += OnResuming; | ||
|
||
_reactPage = new MainPage(); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when the application is launched normally by the end user. Other entry points | ||
/// will be used such as when the application is launched to open a specific file. | ||
/// </summary> | ||
/// <param name="e">Details about the launch request and process.</param> | ||
protected override void OnLaunched(LaunchActivatedEventArgs e) | ||
{ | ||
base.OnLaunched(e); | ||
OnCreate(e.Arguments); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when the application is activated. | ||
/// </summary> | ||
/// <param name="args">The activated event arguments.</param> | ||
protected override void OnActivated(IActivatedEventArgs args) | ||
{ | ||
base.OnActivated(args); | ||
|
||
switch (args.Kind) | ||
{ | ||
case ActivationKind.Protocol: | ||
case ActivationKind.ProtocolForResults: | ||
var protocolArgs = (IProtocolActivatedEventArgs)args; | ||
LauncherModule.SetActivatedUrl(protocolArgs.Uri.AbsoluteUri); | ||
break; | ||
} | ||
|
||
if (args.PreviousExecutionState != ApplicationExecutionState.Running && | ||
args.PreviousExecutionState != ApplicationExecutionState.Suspended) | ||
{ | ||
OnCreate(null); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Called whenever the app is opened to initia | ||
/// </summary> | ||
/// <param name="arguments"></param> | ||
private void OnCreate(string arguments) | ||
{ | ||
_reactPage.OnResume(Exit); | ||
|
||
#if DEBUG | ||
if (System.Diagnostics.Debugger.IsAttached) | ||
{ | ||
this.DebugSettings.EnableFrameRateCounter = true; | ||
} | ||
|
||
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = | ||
AppViewBackButtonVisibility.Visible; | ||
#endif | ||
|
||
Frame rootFrame = Window.Current.Content as Frame; | ||
|
||
// Do not repeat app initialization when the Window already has content, | ||
// just ensure that the window is active | ||
if (rootFrame == null) | ||
{ | ||
_reactPage.OnCreate(arguments); | ||
|
||
// Create a Frame to act as the navigation context and navigate to the first page | ||
rootFrame = new Frame(); | ||
|
||
rootFrame.NavigationFailed += OnNavigationFailed; | ||
|
||
// Place the frame in the current Window | ||
Window.Current.Content = rootFrame; | ||
} | ||
|
||
if (rootFrame.Content == null) | ||
{ | ||
// When the navigation stack isn't restored navigate to the first page, | ||
// configuring the new page by passing required information as a navigation | ||
// parameter | ||
rootFrame.Content = _reactPage; | ||
} | ||
|
||
// Ensure the current window is active | ||
Window.Current.Activate(); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when Navigation to a certain page fails | ||
/// </summary> | ||
/// <param name="sender">The Frame which failed navigation</param> | ||
/// <param name="e">Details about the navigation failure</param> | ||
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e) | ||
{ | ||
throw new Exception("Failed to load Page " + e.SourcePageType.FullName); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when application execution is being suspended. Application state is saved | ||
/// without knowing whether the application will be terminated or resumed with the contents | ||
/// of memory still intact. | ||
/// </summary> | ||
/// <param name="sender">The source of the suspend request.</param> | ||
/// <param name="e">Details about the suspend request.</param> | ||
private void OnSuspending(object sender, SuspendingEventArgs e) | ||
{ | ||
_reactPage.OnSuspend(); | ||
} | ||
|
||
/// <summary> | ||
/// Invoked when application execution is being resumed. | ||
/// </summary> | ||
/// <param name="sender">The source of the resume request.</param> | ||
/// <param name="e">Details about the resume request.</param> | ||
private void OnResuming(object sender, object e) | ||
{ | ||
_reactPage.OnResume(Exit); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!