Import ReactNative libraries into a NativeScript application - nativescript

I have some Android development experience along with React.js. I'm working on a new mobile project and I haven't been sold entirely on either framework yet.
I'm thinking about using the NativeScript framework for its maturity and because it has more libraries with the functionality that I need but I'd like to design my views in a manner similar to ReactJS. I know I could write my own modules for ReactNative but that would require then I'd have to write modules for both Android and iOS. I'd like to avoid that if I could.
I was thinking about importing the necessary ReactNative libraries into a NativeScript project and then being able to write views in a way similar to ReactNative but still using NativeScript.
Is this doable?

Not sure about your exact question. I did just see an integration between Preact and NativeScript you may be interested in. Take a look here: https://github.com/staydecent/nativescript-preact
I believe that repo is in the early stages, but if enough people want something similar, it'll get worked on faster.

Using React Native in NativeScript is not the right approach, either of it are not built to work together and wouldn't work due to architectural reasons. Here is an NativeScript official comparison of these two.
Both are built for solving same problem (building native apps using JS, without webview hybrid app approach) by trans-compiling XML based view layer(which both these framework has its own syntax and so cant be shared) to build Native UI.
Said that view layer has its own syntax for both and cant be shared, model and controller layer cant be shared as well, due to the fact that NativeScript has few things packed as part of the application package, like JavaScript runtime, c++ and Java API layer which helps in exposing all the Native API without the need for any explicit native API wrapper we have in ReactNative.
React Native have platform specific UI components as well as hardware capabilities, which is not the case with NativeScript. Offcouse, that comes with the cost of a fatter app package size(50+MB) compared to <10MB for ReactNative. More on ReactNative vs NativeScript comparison here.

Related

Is ReactiveUI.Blazor ready for use ? .. Are there any examples?

.. I'm new to ReactiveUI ..
trying to use ReactiveUI.Blazor .. in Blazor Server Side
.. it has been released but I can't see any examples in the solution
https://github.com/reactiveui/ReactiveUI/tree/master/src/ReactiveUI.Blazor
The only example I can find of Blazor with ReactiveUI
is https://github.com/Nethereum/NethereumBlazor and it's just using ReactiveUI .. not ReactiveUI.Blazor
Any one using ReactiveUI.Blazor ?
cheers in advance
Stu
ReactiveUI is never finished, but there are working samples for Blazor Server-Side (which is now released as of AspNetCore 3.1) and also working samples for Blazor Hosted and Blazor Client models in the ReactiveUI.Samples repository.
You can find the direct link here
TLDR: I had an amazing experience working with Reactive.Blazor in a WASM Blazor application and can absolutely recommend using it.
I used ReactiveUI.Blazor together with Blazorise in platform for managing offers in a more structured way to perform estimates based on the structured (meta)data of the offers.
I used the WASM version of Blazor and my experience was very good. Reactive functional programming (FRP) works well in React and Angular so it seemed like a good fit for Blazor as well.
My review:
The setup was pretty easy. I took a few notes from this arcticle and the code behind it.
I used DynamicData as well, which for me is somehow already part of the whole ReactiveUI stack. It fit very well into the whole application layout, although most of the components in Blazorise do not support the appropriate listeners for collection changes - there you need to support a bit with your code. I absolutely recommend using DynamicData as proxy/cache for your APIs though - state management has never been easier.
The easy form validation, which was a near natural fit for the Blazorise components was for me one of the major selling points - because I rely heavily on dynamic forms.
I am not too happy with the routing and IoC approaches yet. I am used to Autofac for most of my development, which I could easily use my services although for my views and viewmodels I had to rely on a service locator pattern (with Splat backed by Autofac).

Cannot add Judopay to Xamarin forms project

I am trying to include Judopay in my project, and I was able to add it to Android and iOS, but not to the Xamarin forms project. There is no NuGet to be included and I can't seem to add the component reference. Any idea on how can I add it? I cannot use any of these:
using JudoDotNetXamarin;
using JudoPayDotNet.Enums;
using JudoPayDotNet.Models;
Again, they only work on iOS or Android, but not Xam forms.
That is because they only provide platform implementations. You will need to tell your Forms app which implementation to use at what time.
The correct way to go about this is with some form of IoC, using dependency injection or service location. Luckily Xamarin Forms has this integrated:
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/dependency-service/introduction/
Using the references from the Android or iOS projects in your shared code will likely not work completely or break things. Maybe not immediately but surely later on. (Except when there really is no platform-specific functionality, then you might get away with this.)

How to create complex UI component (ex- seatmap) using NativeScript

I am working with Nativescript and while it's great to create interfaces with the provided UI components, I haven't found a way to implement custom components that can be used across platforms.
What is the proper way of implementing a complex UI element(directive?) in NativeScript? I am trying to implement a seat map for Android and iOS.
Should the native ui components created and wrapped for NativeScript, or is it possible to create the directive using the web technologies(HTML/CSS/JS)?
You can create custom components that can be reused in your application. Nice how-to blog on that matter can be found here.
The articles above are describing the mechanism to reuse a portion of your UI and creating a separation to ease the developing process.
However, if that is not what you ar looking for you can create your own custom UI element using the native one. TO do that you will need to do marshalling. For example take a look at this documentation section (for Android) and this section (for iOS)
With data conversion you can either use native components directly inside your nativeScript app or you can even extend further and create your own UI plugin.

Is it possible to perform Sqlite sync via Azure Mobile Services completely within Xamarin Forms iOS PCL project

After spending two straight days chasing the answer, I have to fall back and just ask:
Is it possible to perform Sqlite sync via Azure Mobile Services completely within Xamarin Forms iOS PCL project?
Any examples I have looked at (including those that claim that their emphasis is on PCL) all end up instantiating the MobileServicesClient within the Native iOS part of the solution, as well as performing the Sqlite sync via Azure Mobile Services within the native project as well.
My goal is to have a Xamarin.Forms solution, which relies on a Sqlite / Azure Mobile Services sync for all of its data and its offline needs. Such solution would not have to have any additional platform specific code, beside what is generated by the project template.
Furthermore, I intent on using Syncfusion Xamarin charts library, which only works within Xamarin.Forms project. The idea is to have Syncfusion chart source its data from the local Sqlite db, which, in turn, is periodically auto-refreshed using Azure Mobile Services Sqlite sync.
I think, that if I had to do all if the data sync business within my platform specific project, then I may not be able to use this Syncfusion Forms-only library.
Is it actually possible to do the Sqlite / Azure sync completely within the bounds of the PCL?
-Eugene
Yes, you can do so. Check out the book - http://aka.ms/zumobook - particularly Chapter 3. In addition, check out the underlying repo (link in the book) - there are several example setups of Xamarin Forms with Offline Sync in SQLite in there. The Chapter3 sample is a good place to start.
I'm able to use them with my project with removing Silverlight optins from my PCL project because of some System.Web methods are not available with it.
On PCL:
Microsoft.IdentityModel.Clients.ActiveDirectory
Newtonsoft.Json
SQLite.Net
SQLite.Net.Async
On iOS Project:
Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.1.0.0
Microsoft.IdentityModel.Clients.ActiveDirectory.Platform
Newtonsoft.Json
SQLite.Net
SQLite.Net.Platform.XamarinIOS.Unified

Using HttpClient in a Xamarin core project

I am doing a project for multiple platforms where I have followed best practices and created a core project to contain all the code that is the same on all platforms.
To do the network communication I would like to use HttpClient which seems to be the recommended approach for communicating with web services going forward.
I am NOT doing a PCL but just a standard C# library to contain the core project. However it seems that there is no common implementation of HttpClient but only platform specific ones. I cannot reference and use it in my core but only in my Android and iOS projects.
I would very much prefer to have all networking code in my core project and as I see it there are two options - neither of which I like.
Make a common interface that I can use in the core project that is implemented as a wrapper on both Android and iOS.
Use another technology that is supported in the core project - I am thinking webclient or the like.
What is the recommended approach and why hasn't Xamarin made HttpClient available as a common library?
Hope someone can help,
Thanks
I recommend checking out ModernHttpClient https://github.com/paulcbetts/modernhttpclient
It is a cross-platform networking library for iOS and Android. From the project:
This library brings the latest platform-specific networking libraries
to Xamarin applications via a custom HttpClient handler. Write your
app using System.Net.Http, but drop this library in and it will go
drastically faster.
You should be able to use System.Net.Http in your core library just fine, I've done it recently.
Make sure your core library is a .Net 4.5 project. There is a setting in project options for selecting the .Net version. After checking this, all you should have to do is reference System.Net.Http.dll.
If that doesn't solve your issue, are you on Windows or Mac(Xamarin Studio)?
I'm afraid you can't use HttpClient on Mono at the moment due to licensing restrictions. There is a UserVoice suggestion that you can vote on if you like.

Resources