-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React Native Windows Support #45
Conversation
README.md
Outdated
@@ -95,7 +95,10 @@ react-native link react-native-view-shot | |||
|
|||
#### Windows | |||
|
|||
No support yet. Feel free to PR. | |||
1. In Visual Studio, in the solution explorer, right click on your project solution then select `Add` ➜ `ExisitingProject` |
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.
s/project solution/solution
README.md
Outdated
No support yet. Feel free to PR. | ||
1. In Visual Studio, in the solution explorer, right click on your project solution then select `Add` ➜ `ExisitingProject` | ||
2. Go to `node_modules` ➜ `react-native-view-shot` and add `RNViewShot.csproj` (UWP) or optionally `RNViewShot.Net46.csproj` (WPF) | ||
3. In Visual Studio, in the solution explorer, right click on your project then select `Add` ➜ `Reference` |
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.
might want to say "Application project" here to be clear
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
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.
need to get rid of the dreaded AnyCPU. x86, x64, and ARM only for RNW.
windows/RNViewShot/ViewShot.cs
Outdated
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.ToString()); |
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.
use Debug.WriteLine() from the System.Diagnostics namespace instead.
windows/RNViewShot/ViewShot.cs
Outdated
|
||
private async Task<StorageFile> GetStorageFile() | ||
{ | ||
StorageFolder storageFolder = ApplicationData.Current.LocalFolder; |
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.
var
windows/RNViewShot/ViewShot.cs
Outdated
using (InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream()) | ||
{ | ||
await CaptureView(view, ras); | ||
byte[] imageBytes = new byte[ras.Size]; |
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.
var
windows/RNViewShot/ViewShot.cs
Outdated
using (InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream()) | ||
{ | ||
await CaptureView(view, ras); | ||
byte[] imageBytes = new byte[ras.Size]; |
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.
var
} | ||
|
||
UIManagerModule uiManager = this._reactContext.GetNativeModule<UIManagerModule>(); | ||
uiManager.AddUIBlock(new ViewShot(tag, format, quality, width, height, path, result, promise)); |
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.
extract new ViewShot to a variable for easier debugger inspection
windows/RNViewShot/ViewShot.cs
Outdated
using (InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream()) | ||
{ | ||
await CaptureView(view, ras); | ||
StorageFile file = await GetStorageFile(); |
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.
var
windows/RNViewShot/ViewShot.cs
Outdated
} | ||
else if ("data-uri" == result) | ||
{ | ||
using (InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream()) |
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.
var
windows/RNViewShot/ViewShot.cs
Outdated
{ | ||
string fileName = Guid.NewGuid().ToString(); | ||
fileName = Path.ChangeExtension(fileName, extension); | ||
return await storageFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting); |
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.
why not assign path here and then ditch the else{} wrapper on the next line?
incredible PR. How awesome is that! |
@ryanlntn is the PR ready to be merged now? :) |
@gre Yes but you might want to hold off until microsoft/react-native-windows#1050 is merged since it won't work without that. |
@ryanlntn ok nice! BTW if you want to have more testing, maybe it would be great to make that https://github.com/gre/react-native-view-shot-example a windows app too. it's basically an app I use to test the library and it should cover all different options / different kind of views. |
@gre Planning on it! 😄 I'm also working on integrating it into https://github.com/Galooshi/happo |
It's funny you had to PR in RN the same third party UIBlock feature for the same limitation hehe. |
@gre Yeah a blatant copy actually. 😛 |
* This will allow gre/react-native-view-shot#45 (and in turn, Galooshi/happo ) to allow us to do screenshot-based tests in the CI
@gre microsoft/react-native-windows#1050 has landed in RNW master. |
so cool! I'll probably get this merged anyway :) thanks again! |
Adds support for react-native-windows UWP and WPF.
Depends on upstream PR to RNW: microsoft/react-native-windows#1050