You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I started using RootLayout and it feels quite interesting but I think it needs few improvements in terms of usage.
I'll use vanilla NativeScript as an example of how RootLayout is currently usable.
The first step is to create a view programmatically.
Then, call RootLayout' s open method. It's first argument is the view we created earlier which will be used as a popup.
To close popup, we need to call close method and give the same view again as first argument.
// Usage example
var view = new StackLayout();
getRootLayout().open(view, {...}).then(...);
getRootLayout().close(view, {...}).then(...);
That flow does its work as it should but there is a feeling of inconvenience in terms of view design and styling.
As a developer, one would like to compose a view using markup, which would be an XML file in our case.
In that part, RootLayout has its limitations.
The only way to possibly load view from XML right now is this:
// Usage example
var view = Builder.createViewFromEntry({moduleName: '/views/bottom-sheet/bottom-sheet'});
getRootLayout().open(view, {...}).then(...);
getRootLayout().close(view, {...}).then(...);
After thinking about it for a while, I came up with the concept of an existing behaviour.
Class Frame has a navigate method that accepts a view or a module path and navigates to that view (usually page).
This method will call Builder' s method createViewFromEntry that instantiates the view.
If we apply the same concept to RootLayout, things might be more interesting.
How would this affect existing API?
// A way to load view from XML and create an instance
var view = await getRootLayout().open({moduleName: '/views/bottom-sheet/bottom-sheet', ...});
getRootLayout().close(view, {...}).then(...);
// A way to use a view instance
var view = await getRootLayout().open({create: () => new StackLayout(), ...});
getRootLayout().close(view, {...}).then(...);
// OR
var view = new StackLayout();
getRootLayout().open({create: () => view, ...}).then(...);
getRootLayout().close(view, {...}).then(...);
To keep a reference of view instance, I thought of returning it in promise of method open.
I have been thinking of this concept as an enhancement for all flavors of NS but that is my own opinion.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
So, I started using
RootLayout
and it feels quite interesting but I think it needs few improvements in terms of usage.I'll use vanilla NativeScript as an example of how RootLayout is currently usable.
The first step is to create a view programmatically.
Then, call RootLayout' s
open
method. It's first argument is the view we created earlier which will be used as a popup.To close popup, we need to call
close
method and give the same view again as first argument.That flow does its work as it should but there is a feeling of inconvenience in terms of view design and styling.
As a developer, one would like to compose a view using markup, which would be an XML file in our case.
In that part, RootLayout has its limitations.
The only way to possibly load view from XML right now is this:
After thinking about it for a while, I came up with the concept of an existing behaviour.
Class
Frame
has anavigate
method that accepts a view or a module path and navigates to that view (usually page).This method will call
Builder
' s methodcreateViewFromEntry
that instantiates the view.If we apply the same concept to RootLayout, things might be more interesting.
How would this affect existing API?
To keep a reference of view instance, I thought of returning it in promise of method
open
.I have been thinking of this concept as an enhancement for all flavors of NS but that is my own opinion.
Beta Was this translation helpful? Give feedback.
All reactions