Unable to set GridLayout height programatically - ios

I am trying to implement swipe actions on ListView for each element. Whole view is AbsoluteLayout, with two GridLayouts: one acting as "foreground"(list element) and other as "background" (swipe actions). I want them both to have equal height of "foreground" (which is dynamic and differs for every list element).
I succesfully implemented this on Android - I call a method on layoutChanged event
onLayoutChanged(args: EventData) {
const foregroundNotificationTemplate = (<AbsoluteLayout>(args.object)).getChildAt(1);
const backgroundButtons = (<AbsoluteLayout>args.object).getChildAt(0);
backgroundButtons.height = foregroundNotificationTemplate.getActualSize().height;
}
This unfortunatelly is not working on iOS. I tried to access Frame and UiView, but with no success - it has height of background content.
Demo presenting the problem on Nativescript Playground:
https://play.nativescript.org/?template=play-ng&id=4LRwDC

You don't necessarily have to use AbsoluteLayout as you are animating the position with translate which is possible with any layout. So using GridLayout instead of AbsoluteLayout should solve your problem on both platforms and you may also get rid layoutChanged event for measuring height.
Also note that your ListView item template can not be dynamic, you should not use ngIf or anything that would alter the structure of the list item, use multiple templates instead.

For anyone looking for working solution, thats what Manoj proposed: https://play.nativescript.org/?template=play-ng&id=yXggcv

Related

Get items visible in viewport of Grid in Vaadin 8 & 10

The Grid widget in Vaadin 8 & 10 offers a method to get a Set of the currently selected items: Grid::getSelectedItems.
In a similar vein, I would like to get a collection of the items that are currently visible to the user in the Grid. Say my Grid widget holds 10 items, but only 5 are viewable because the Grid widget is too short to display them all. I want to know which of the five can be seen by the user.
This is not trivial task, I have something similar, but not exactly this case before. First of all, I would I would create custom Layout component, e.g. by extending CssLayout in similar fashion as has been discussed here ( How to make UI receive scroll events ) in addition to reporting scroll events I would report the position of the layout on the viewport (see http://www.gwtproject.org/javadoc/latest/com/google/gwt/dom/client/Element.html ). Yes GWT and client side development is required.
I would use this layout as wrapper for the Grid, i.e. Grid would be in the layout. You could extend the Grid component as well. But I think doing the layout wrapper gives you nice tool that you can use with other components as well for which you need to determine, whether they are actually visible or not.
This way I can then calculate which portion of the layout is in the viewport. As you see, there are number of cases here, e.g. only bottom of the Grid or top of the Grid is visible. Then I need to know row-height, header height, etc. That enables me to calculate how many rows there are visible. I hope you get the idea. The outcome for the generic case will be rather lengthy piece of code when all possibilities are enumerated. This calculation you can do on server side.

Xamarin.Forms: iPhone X SafeArea with Forms ListView

How do you guys handle the safe area problem for ListViews with Xamarin.Forms? Just setting the safe area as margin on the whole ListView looks ugly AF. So I search for something like a custom renderer to make the ListView as equal als possible to the UITableView in the iPhone X. My current solution bringt the ViewCells in the correct position but the Seperator is going off screen and the ShortGroup index is behind the Notch in some rotations. Beside from that, my current solution is way to much work to implement it in every project (because I use a CustomViewCell class as Workaround).
So how to implement a custom renderer for this problem? All of my current implementations seems not to work properly. And I guess waiting for Xamarin to fix this is not an option (because MasterDetail pages still not work on iOS SplitView and this was reported back in 2015 and is just ignored by Xamarin...).
Edit: The problem with the ListView in Xamarin.Forms did only occur if the ListView control is not the root of the ContentPage. In my case it is inside a Grid because I want a SearchBar too on this side. In this case the content of the ListView (and the ShortGroup index) gets cut off by the iPhone X rounded corners and the notch. It looks really ugly and I guess it is a very common way to have a SearchBar and a ListView on one side. Here is a repository of a project which has a first workaround (the ShortGroup index still has the problem there and also the separator runs outside of the visible area while it normally would stop before that): https://github.com/Sebastian1989101/OpenGeoDB-App

Positioning dynamic controls dynamically in iOS ViewController

First of all, let me tell you that I am new in Xamarin.
I am facing a problem in rendering controls dynamically on UI.
Approach I am using is: Xamarin.iOS
I have list of Questions having different Question Types
I loop through all questions and render them according to the question type.
Client wants to have HTML in Question Title, so that he can add any type of html tags including images, links etc in HTML. (I cannot use ‘NSAttributedString’ because it doesn’t support all HTML tags)
I am not using AutoLayout
I think UIStackView is a new control which is not available for older versions
Problem is, when I render UIWebView for QuestionTitle, and other control (let us say UITextField) for simple input from user, I do not know about the exact content length of Title (which is HTML) and therefore, I set default height of UIWebView as ‘100’ and once WebView is loaded, I set the height of webview according to the content size height. While rendering control, I calculate the Y-axis for every control to be rendered. When WebView is loaded, its height gets shrunk or expanded according to the size of content and therefore, the preceding sibling’s y-axis remains there since we don’t know how much siblings are there whose y-axis should be adjusted. (Keep in mind we have multiple webviews, as we have more than 1 question).
Is there any way, we can position all controls automatically (Just like we have LinearLayout in Android)?
Is there any better approach I can follow in order to resolve this kind of blocker?
I will really appreciate your help in this problem.

Further customise a jQueryMobile custom select menu

Does anyone one know of a workaround/hack ;¬) to further customise jQuery custom select menu - i.e. when we've used
$(document).bind('mobileinit',function(){
$.mobile.selectmenu.prototype.options.nativeMenu = false;
});
to give us a nice list-item overlay in place of the standard listview page on selecting from a select menu.
The jQM docs here http://jquerymobile.com/demos/1.2.1/docs/forms/selects/custom.html - state:
When it has too many options to show on the device's screen, the
framework will automatically create a new "page" populated with a
standard listview for the options. This allows us to use the native
scrolling included on the device for moving through a long list.
I would like to prevent this and always show the custom overlay; obviously the problem is scrolling the options which are out of view. When my project is switched to landscape thus decreasing the screen height it swithces to the 'old school', clunky listview. I should imagine its down to 'absolute' screen metrics since i can see the custom menu overlay will (just about) fit without reverting to the standard view.
The custom view is a much nicer looking interface, and more intuitive from a UI/UX perspective also.
Anyone know of any tricks to keep this behavior??

How to scroll a tilelist using touch (Adobe Air for iOS)

I'm developing an iOS application using Adobe Flash.
It is working fine, except a tile list, that shows a scrollbar and it needs to be dragged to scroll the tile list and show all its content.
Is there a way to make it scroll by just touching and dragging it anywhere?
thanks.
If you are using Flex, this will work.
Don't set a height (or width, depending on your needs) and wrap it in a Scroller object. I'm not sure if a TileList is a valid ViewPort or not, so you may have to do one further level of abstraction and wrap the TileList in a generic Group object. This will provide a close-to-native scroll functionality to the object within the Scroller.
Example:
<s:Scroller width="100%" height="100%">
<s:TileList>
</s:TileList>
</s:Scroller>

Resources