Conversation
README.md
Outdated
| #### 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` |
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.
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.
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.
use Debug.WriteLine() from the System.Diagnostics namespace instead.
windows/RNViewShot/ViewShot.cs
Outdated
|
|
||
| private async Task<StorageFile> GetStorageFile() | ||
| { | ||
| StorageFolder storageFolder = ApplicationData.Current.LocalFolder; |
windows/RNViewShot/ViewShot.cs
Outdated
| using (InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream()) | ||
| { | ||
| await CaptureView(view, ras); | ||
| byte[] imageBytes = new byte[ras.Size]; |
windows/RNViewShot/ViewShot.cs
Outdated
| using (InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream()) | ||
| { | ||
| await CaptureView(view, ras); | ||
| byte[] imageBytes = new byte[ras.Size]; |
| } | ||
|
|
||
| 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.
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(); |
windows/RNViewShot/ViewShot.cs
Outdated
| } | ||
| else if ("data-uri" == result) | ||
| { | ||
| using (InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream()) |
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.
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