Auto-resizing images to fit page and creating new pages - flutter

I have a list of 12 images that I would like to display on the screen, however I would like to cap the number of images that can fit onto the screen at 9, with the user having to swipe left to see the remaining 3 images.
I have currently hardcoded it, but I would like to know if there is a way to write it such that a maximum of 9 images will automatically resize themselves to fit onto the page, with future images being shown on the next screen, which the user can swipe to.
e.g. In the future if I have 25 images, first 9 will fit themselves onto the first screen, user can swipe to the second screen to see the next 9 and user can swipe again to see the last 7 - without hardcoding 9, 9, 7 per screen respectively.

You can define a screen that takes the list of images to be shown and the starting number in that list.
Images can be shown with a GridView Widget.
So for your example of 25 images:
ShowImagesScreen([image1, image2 ... image25], 0) will show the screen with the first 9 images, the 0 indicates that the screens starts with the first image (index 0 in the list). Swiping on that page will result in going to the next screen. Which is the same screen widget:
ShowImagesScreen([image1, image2 ... image25], 9) this time showing image 9 till 18. Swiping on this screen can go to previous page or to the next:
ShowImagesScreen([image1, image2 ... image25], 18)
On the screen you make logic to disable swiping back or forward when it is the first or last page respectively. You also need to check the length of the list on each page and check whether you are at the end.

Related

How can I maintain a users position in a listview when images dynamically load above the current position?

I have a feed type app with multiple news items,
News items are ordered with the oldest item on top and newest item at the bottom (the reverse of what you would see with twitter for example)
News items are arranged in a Listview.builder
Each news item has a variable number of images associated with them
Each image is of variable height
Old news item(s)
Image 1
Image 2
image 3
Image 4
Image 5
Unread news item
New news item(s)
Image 1
Image 2
image 3
When the feed first opens, the app automatically scrolls to the first unread news item using a scrollable-ensurevisible
scrollController.position.ensureVisible(
unreadnewsitemKey.currentContext!.findRenderObject()!,
alignment: 1,
duration: Duration(milliseconds: 500),
curve: Curves.linear
);
The problem:
The automatic scroll works flawlessly, however because of slow network connections/cellular connections, the images part of the Old news item(s) may load after the automatic scroll finishes.
When this happens, a content shift occurs, pushing the currently viewed Unread news item downwards, and the user loses their reading position.
The question:
Is there anyways to maintain the users current position in the listview no matter what images are loaded above the current position? I am willing to change anything and everything about my app's structure except 1 thing. Using a fixed size image height is not an option. Image heights must remain variable to their true original dimensions
Are you getting image width and height when you load the news to list? If yes, you can find the ratio of width/height and based on that you can calculate the position.

Show as much elements as it can render without overflow

I have a long list of tags, let say 20 tags, I want to show as many tags(widgets) in a row as a device can render with its screen width. Let say that the device renders 3 tags in the row without overflowing, but the forth is just half rendered, so I want to hide all overflowing tags from 4 to 20 and show three dots, so something like text ellipsis but with widgets. And I need to know how many elements are overflowing (the three dots are opening a menu which shows all the other tags). The tags have different width based on the text which is inside them.
Use Wrap that will do your work

ie8 bookmark # click moves page

I have a few basic controls that are anchors with no urls, such as
<a id="UP" href="#">UP</a>
there's jQuery stuff attaching it to the click event (it's a jcarousel control with overflow hidden)
I understand that onclick needs a return false on it to stop scrolling to "#" on the page to that anchor. The issue is that on fresh load, no scrolling and the UP click all in view, the page still moves. Worse, it appears # has 3 or 4 different places! As I click UP repeatedly, the page moves up and down a few pixels as i click and click. This is always different than the absolute top where the page originally rendered.
Is it the overflow of the list that is no longer visibile due to the clipping causing this? Would adjusting heights of the elements so that the list items clip out evenly provide a stop to this? or is there some other ie8 flaw i'm not aware of?
Thanks!
After a bit of trail and error, I figured out that I needed to 'return false' the click handler so that it stopped the chain of events from continuing (ie, following the hash).
Further, I adjusted heights on the wrappers and clippers so that they were even, as that was the kicker on the 3 or 4 differnt height moves

UITextField position is different on iPhone 5 versus older iPhone (3GS/4/4S)

I have a UITextbox on the bottom of my screen (which is the table you see in the graphic below).
On the iPhone 3GS/4/4S it shows up correctly on the bottom. However, on my iphone 5, it is on the same screen where it would normally be on a regular iphone, screenshot below:
Is there a way to resolve this through IB or must it be done with code?
You can see a bit of blank white space at the bottom where the last tab is cut off, it looks like its still reserving room for the input box.
In interface builder (where you're using strings & struts and NOT auto layout), you can change what you're looking at by selecting the view controller you want to work with and then, in the Attributes Inspector for the view controller, touch this pop-up menu:
iPhone 5 screen size:
iPhone 4 & earlier screen size:
You can then see the difference between the two iPhone screen sizes.
Now, to get the text field to hug (or stay aligned at the bottom), click the bottom strut for the text field. It should look something like this:

jQuery Mobile/ jqTouch Image width

I want to have a static footer image with 5 buttons for navigation in my mobile phone website. The image is here http://www.pintum.com.au/jm/footer3a.jpg. The blue icons should be the default, the yellow icon should only be visible for the hover or active state.
I want to know how can I make this image scale to the correct width on all mobile devices (landscape and portrait) and have links to other pages and make the current/active pages icon the yellow color?
What I have tried so far
I first tried to make a CSS Sprite but that go ugly (complex) quickly. Painful working with widths everywhere so the image scales correctly as I had no way of knowing the height in pixels since the width is dynamic. I could use JS to find the width and calculate height on the fly. But this sounds like overkill.
Next I tried to have a single image with a width of 100% then place div overlays on top of the image. But with this solution I could not figure out how to navigate pages using JavaScript click event, or figure out how I would be able to change the image icon on the selected page http://jsbin.com/uraya5/3/ . And detrmining the correct height for the div
Last I tried to make each button a seperate image. These seems like the easist soultion. But jQuery Mobile adds a bunch of extra styles to the button I do not know how to remove. See http://jsbin.com/uraya5/4
So whats the best/easiest way to do this?
How can I remove the style around
links?
Or can I use a single image CSS sliding door method? To reduce HTTP request.
Ok I figured it out
See soultion here http://jsbin.com/uraya5/10/
I had to:
Set width to 19% of each button for
some reason there is spacing between
each button so 20% does not work.
Set ui-bar-a background to black so
it hides the spaces between my
images
Use this JS code to navigate pages $.mobile.changePage($("#about"),
"flip", true, true);
I would still like to use a single image instead of having 5 different images to reduce http calls. So if anyone finds a eligant soultion for this please let me know.