Flutter: How to do responsiveness for "real" mobile/web applications? - flutter

I saw many articles and videos on how to do responsive design in flutter.
But they all have in common, that they show a standard web page with menu, pictures, text.
What I call "real" in the title, means a full interactive application, so with displaying tables of data, providing input fields and other input elements, showing charts, ... - so all the interaction of a "real" application, not just a web site.
Simple example: If I have a large data table on a desktop screen, it has to be different on a mobile screen to show data in a way, the user can read it and use it sensibly.
So, how do I make the app responsive for all screen sizes without having to implement something twice or have case distinctions all over the place?

Refractor codes into widgets. (very important to reduce boiler plates)
Create an idea on how the webpage will look like based on 12 grid system
In build method check for screen size and return layout based on the screen size.
Please note
The widgets should be responsive by itself based on the size available. For example a chart widget. It should build a chart within the space provided by its parent.
There may be instances where in desktop some elements are in a row and the same element will be in a column in mobile. So you can also write sections like banner section (define web and phone layout), about us section etc so its easier to manage
Use wrap widget to automatically bring widgets down based on screen size
Use BoxConstrains and max width to control a Containers max width
For tables you can use packages like responsive tables

Related

Binding to custom built control according to different data

Here's the issue, I build a special book reader/browser (For holy quran), my code behind loads the page and constructs how it should look. and then it should bind that look to a some kind of data-bindable custom control to view it properly. the problem is, the look differs from page to page, so I cannot bind to a certain control or wrap panel.
here's how it generally looks:
The decorative border top of the page is always there at any page, it indicates the part and chapter the viewer is in.
If you're starting a new chapter it have additional image under that decorative border or anywhere in the page (there can be multiple chapters in the same page) something like this
or this:
The normal text is not an issue, it's just a special font, however, I put each individual word in its own text block for reasons of user selection by word.
The issue here is, given the previous information, and knowing how random it is to place the decoration picture or the amount of words (text blocks) per page. how can I bind that to some kind of view to separate the view from the VM and Engine that builds the page.
my past solution was to actually build everything in the VM in a wrappanel built inside a scrollviewer having lots of textblocks and images according to the page. but that's naiive solution. I want to rebuild that in a more professional separated way. I also want to do this for Windows RT beside Windows phone so I need to reuse the code behind in a Portable class library.
I think all you need to do is slightly adjust your current design. So perhaps have a VM that represents the entire content, and that would have a Collection of say Pages or Sections. A second VM would represent the Page/Section, allowing you to create a property for the WrapPanel content (i.e. the words) and another property for the Header and or other things.
In the View you would have the scrollviewer and bind to the main VM collection. Then create another View or DataTemplate that represents the Page/Section.
You should be able to do this is a strict MVVM sense quite easily and it will be dynamic based on the content.
You could even cater for advanced scenarios where each section has a different template/view.

Android UI home screen design

I am up to create a section on my Android Home screen similar to this one,
but cannot really figuring out where to start. I mean is this a ListView I should go with? or are these simple images that are placed as different objects surrounded by straight lines? In either case, how to put these things together, is a question that I am wondering..
You can either use:
a GridLayout (for API < 14, there is a support library available somewhere on GitHub)
a vertical LinearLayout containing two horizontal LinearLayouts
a single RelativeLayout
For the buttons, use TextView or Button with a top drawable.
Please note that the dashboard pattern is now discouraged (link 1, link 2) (you should present useful information to the user on first screen such as there latest trips, friend's news, ...).
Instead of that, you could put your buttons in a sliding menu (jfeinstein has a nice implementation on github which can be integrated within an hour)

How to create a custom listview like iPhone in Android

I was designing a custom listview in Android following the online tutorial Android Series: Custom ListView items and adapters and I created a custom list view like this:
This is simple and fine. Now I was surfing the web and found this fantastic listview for iPhone:
How can I create something like this? How has he given a box like interface for each row separating them from background and each other?
You could try removing the list dividers (android:divider="#null" or android:dividerHeight="0px") and using a custom drawable as the background for each row (either a 9patch or ShapeDrawable, possibly arranged in a StateList so they can have pressed/selected states). Then just also put a margin on the row layout, and your spacing should be taken care of (alternatively, you could use a transparent image as the list's divider with an appropriate height). But be careful about simply aping an iOS style because it looks nice; think about the typical Android user and what they take as interface cues. If you made your Android list look exactly like that screenshot below, I think many Android users wouldn't even realize they could click on those rows, or that they're part of a scrollable list.
The listview and each item in the listview can have separate backgrounds. So all you need to do is make some PNG files that look like the background of the items and the list itself.
You can set the backgrounds in XML using the android:src.
Or at runtime using:
setImageDrawable(getResources().getDrawable(R.drawable."picture name"))

Length of text that can just fit into one screen without scrolling

I find some iphone book apps have such feature:
One screen one page of text without scrolling. The text can just fit into the whole screen with linebreaks and indentations.
I'm curious of how to implement this. How could I decide the length of text that just fit into the screen. And also, given the whole text, I can calculate out the number of pages.
If this is not possible to be done on iPhone(runtime?), then is it possible to process the text before storing it in app? I mean I calculate how many pages I need(how to split the raw text), probably how many lines per page.
I think this is what you are looking for
iPhone SDK: How do you measure the width and height of a string using Quartz?
The accepted answer gives methods you can call on NSString to calculate sizes
What I did for TouchTomes' books was have two iPhone apps. One was the reader that showed up on the App Store. The other was a renderer that calculated what could fit on each page, that only needed to be run in the simulator to create a book DB that the reader could use.
It would throw up a bunch of text, say 100 words, and see if that overflowed or underflowed. If it underflowed, more text was added (say 20 words) and it would binary search until it found exactly how much text would fit. Then it stored in a SQLite DB a row saying "page 12 shows words 100-228" for example. The app would go through this for each font. Another table held all the words in individual rows (!). An optimization step would chop that table down, combining words that always appeared on the same page no matter what font.
I used a Webkit display so the book could include HTML formatting. Now that really complicated the page breakup (e.g. had to keep italics going from page to page) but it let me include some fancier formatting in the text.
Then the reader app had very little to do to display pages; from the page id look up what range of words go on that page, then throw that text up into a webkit view. The user could jump between pages all over the book very quickly, all the hard CPU work had already been done by the rendering app.

GWT-Ext EditorGridPanel rendering problem

I am using GWT 1.6.4 and GWT-Ext 2.0.6. I am trying to use EditorGridPanel and facing rendering problems.
When the module loads I create a Panel (TopPanel) with BorderLayout and add that to the ViewPort. I then create another Panel (CenterPanel) and add EditorGridPanel, three buttons to the center of the BorderLayout Panel (TopPanel). I tried many layouts for CenterPanel but still not able to get what I want.
I want the table to showup with the required data and scrollbars. All the three buttons comes below the table. The data for the table come via Async call when the module loads, so when the screen is rendered to the user, the data is populated in the table. But looks like the table gets rendered with no data and when the async process finishes the table gets populated but don’t get resized to fit the screen so only show me one row.
The problem is with the Grid, I am not getting any scrollbars. Secondly I don’t want to define the height and width of the Grid. I want it to take as much as possible and show scrollbars, just like we do in html table by setting width and height as 100%.
Thanks
I have found the solution. I had to add the Grid on a panel. I had to set the layout of that panel to FitLayout(). Secondly had to call doLayout() on that panel after loading the Store with the data. I now get the scrollbars for the table as well as it fits the whole available space.