Flutter: Responsive Web - Multiple Listviews in a Column - flutter

I am working on a flutter web application and need to place multiple list views in a column.
I am trying to use responsive-framework. But it doesn't seem to work with my project. I tried Wrap widget. I doesn't work either.
What I want to do is moving around the list views based on the screen size.
Just one Column two Columns for wider screen
| 1 | | 1 | | 5 |
| 2 | | 2 | | 6 |
| 3 | => | 3 |
| 4 | | 4 |
| 5 |
| 6 |
This order of the list views should be exactly what I illustrated above.
Below is not what I need.
| 1 | | 2 |
| 3 | | 4 |
| 5 | | 6 |
| 7 |
Any tips??

Try GridView. There's a lot to it depending on your requirements for the Container Size. But GridView.builder with SliverGridDelegateWithMaxCrossAxisExtent (there are other variants).
You'll need to change the axis direction to horizontal in your case.

Related

Dynamically grow user selection when they have selected "all"

I have users with multiple email preferences and I want to grow their preference selection when new preference options are added if they have selected 'all' as their preference.
I can do this through triggers for each of the preference options table. On INSERT I can also UPDATE the user preference array and append the new options. I am worried about performance when the user list begins to grow since each preference option may be updated and each user can have multiple preferences.
USER_1
PREFERENCE_1
OPTION_1 -> ALL
OPTION_2 -> [1, 2, 3]
OPTION_3 -> [1, 2]
PREFERENCE_2
OPTION_1 -> ALL
OPTION_2 -> ALL
OPTION_3 -> ALL
How should I design the schema to accommodate dynamic column arrays? Or perhaps I shouldn't be using arrays at all?
Additional question:
Is it possible to achieve the All but x selection? A user may want all of the options but not some of the options. The selection should still grow dynamically.
It looks like your question isn't getting much love around here.
You have a couple of options. The best option is to build out the relational tables to store this, but you will need to use a trigger or another indicator column to denote that a user is up for every option.
A second option that I have used a number of times is a bitstring. This is essentially a bitmask. The only regret I have about using this is having to explain how it works to developers fresh out of some shake-and-bake correspondence course who fancy themselves "full-stack."
create table preference (
bitmask bit(30) not null primary key, -- Adjust size to some overkill number
pref_name text
);
insert into preference
select ((2^n)::bigint)::bit(30) as bitmask,
'Option '||(n+1)::text as pref_name
from generate_series(0, 10, 1) as gs(n);
create table prefs_user (
id int primary key,
user_name text,
user_prefs bit(30)
);
insert into prefs_user values
(1, 'me', ~(0::bit(30))),
(2, 'you', 22::bit(30)),
(3, 'him', ~(8::bit(30))); -- all except Option 4
To join to see which options are enabled for a prefs_user:
select *
from prefs_user u
join preference p
on (u.user_prefs & p.bitmask)::bigint > 0
order by u.id, p.bitmask;
id | user_name | user_prefs | bitmask | pref_name
----+-----------+--------------------------------+--------------------------------+-----------
1 | me | 111111111111111111111111111111 | 000000000000000000000000000001 | Option 1
1 | me | 111111111111111111111111111111 | 000000000000000000000000000010 | Option 2
1 | me | 111111111111111111111111111111 | 000000000000000000000000000100 | Option 3
1 | me | 111111111111111111111111111111 | 000000000000000000000000001000 | Option 4
1 | me | 111111111111111111111111111111 | 000000000000000000000000010000 | Option 5
1 | me | 111111111111111111111111111111 | 000000000000000000000000100000 | Option 6
1 | me | 111111111111111111111111111111 | 000000000000000000000001000000 | Option 7
1 | me | 111111111111111111111111111111 | 000000000000000000000010000000 | Option 8
1 | me | 111111111111111111111111111111 | 000000000000000000000100000000 | Option 9
1 | me | 111111111111111111111111111111 | 000000000000000000001000000000 | Option 10
1 | me | 111111111111111111111111111111 | 000000000000000000010000000000 | Option 11
2 | you | 000000000000000000000000010110 | 000000000000000000000000000010 | Option 2
2 | you | 000000000000000000000000010110 | 000000000000000000000000000100 | Option 3
2 | you | 000000000000000000000000010110 | 000000000000000000000000010000 | Option 5
3 | him | 111111111111111111111111110111 | 000000000000000000000000000001 | Option 1
3 | him | 111111111111111111111111110111 | 000000000000000000000000000010 | Option 2
3 | him | 111111111111111111111111110111 | 000000000000000000000000000100 | Option 3
3 | him | 111111111111111111111111110111 | 000000000000000000000000010000 | Option 5
3 | him | 111111111111111111111111110111 | 000000000000000000000000100000 | Option 6
3 | him | 111111111111111111111111110111 | 000000000000000000000001000000 | Option 7
3 | him | 111111111111111111111111110111 | 000000000000000000000010000000 | Option 8
3 | him | 111111111111111111111111110111 | 000000000000000000000100000000 | Option 9
3 | him | 111111111111111111111111110111 | 000000000000000000001000000000 | Option 10
3 | him | 111111111111111111111111110111 | 000000000000000000010000000000 | Option 11
User me selected all options, so any options you add up to a count of 30 will always be selected.
User you selected only three options. Adding options will not affect the user's selection.
User him selected every option except option 4. New options will be selected for this user.
The bit string maps easily to an array from a checkbox group with name properties set to log-base-2 of the bitmask:
select log(2, bitmask::bigint)::int, pref_name from preference;
log | pref_name
-----+-----------
0 | Option 1
1 | Option 2
2 | Option 3
3 | Option 4
4 | Option 5
5 | Option 6
6 | Option 7
7 | Option 8
8 | Option 9
9 | Option 10
10 | Option 11
(11 rows)
When the post comes in, you can create the bitmap value through a simple loop or list comprehension on the host language side.

In emacs org mode, is there a formula I can use to count the number of cells?

I'm new to emacs (spacemacs, actually) and org-mode. I'd like to have a final line in my table that shows how many rows there are in the table. Is there a formula function for that?
This formula should work: vlen(#I..#II).
Example:
| Title |
|-------|
| one |
| two |
| three |
| four |
|-------|
| 4 |
#+Tblfm: #6$1=vlen(#I..#II)
the example above is specified as "#6" which requires you to know hte sum in advance. The following seems to work:
| Title |
|-------|
| one |
| two |
| three |
| four |
|-------|
| 4 |
#+Tblfm: #II$1=vlen(#I..#II)

How to compute the dot product of two column (think full column as a vector)?

gave this table:
| a | b | c |
|---+---+----+
| 3 | 4 | |
| 1 | 2 | |
| 1 | 3 | |
| 2 | 2 | |
I want to get the dot product of two column a and b ,the result should be equel to (3*4)+(1*2)+(1*3)+(2*2) which is 21.
I don't want use the clumsy formula (B1*B2+C1*C2+D1*D2+E1*E2) because actually I have a large table waiting to calculate.
I know emacs's Calc tool has a "vprod" function which can do those sort of things ,but I dont' know how to turn the full column to a vector.
Can anybody tell me how to achieve this task,appreciate it!
In emacs-calc, the simple product of 2 vectors calculates the dot product.
This works (I put the result in #6$3; also the parenthesis can be omitted):
| a | b | c |
|---+---+----|
| 3 | 4 | |
| 1 | 2 | |
| 1 | 3 | |
| 2 | 2 | |
|---+---+----|
| | | 21 |
#+TBLFM: #6$3=(#I$1..#II$1)*(#I$2..#II$2)
#I and #II span from the 1st hline to the second.
This can be solved using babel and R in org-mode:
#+name: mytable
| a | b | c |
|---+---+----+
| 3 | 4 | |
| 1 | 2 | |
| 1 | 3 | |
| 3 | 2 | |
#+begin_src R :var mytable=mytable
sum(mytable$a * mytable$b)
#+end_src
#+RESULTS:
: 23

Numbering the rows in reverse order in an Emacs Org Mode table

I'd like to do something like this:
How to achieve a row index column in Emacs Org Mode using a Calc column rule
but I'd like the rows to be numbered in reverse order. I suspect this should be very easy, and should have something to do with #>, but e.g. $1=#>-## doesn't work.
You can try this example
| row | data |
|-----+------|
| 8 | |
| 7 | |
|-----+------|
| 6 | |
| 5 | |
| 4 | |
| 3 | 5123 |
| 2 | |
| 1 | 4234 |
#+TBLFM: $1='(- (length org-table-dlines) ##)

What is the best way to "paginate" a loooong SVG file on iOS?

I am facing an interesting problem with SVG and iOS.
I need to render very long SVG files (up to about 5mb large), which hasn't been a problem using UIWebView. I also haven't had a problem scrolling them smoothly with JS, but since I'm waiting on my developer program application to be approved I haven't tested the performance on an actual device.
I'm now trying to achieve a page-turning effect like how the iBooks app flips pages. It doesn't have to be as elaborate and intricate, the gist of the idea is that the next section of the svg will "wipe over" the last.
Reason being, I need both "pages" of content to remain static to ease the reading of the content during the "flipping" process. Scrolling very quickly makes the contents of the SVG difficult to read.
Here is a graphic representation of what I would like to achieve:
---------------------------
| |
| |
| |
| 1 |
| |
| |
| |
| |
---------------------------
---------------------------
| | |
| | |
| | |
| 2 | 1 |
| |-> |
| | |
| / |
| / |
---------------------------
---------------------------
| | |
| | |
| | |
| 2 | 1 |
| |-> |
| | |
| / |
| / |
---------------------------
---------------------------
| |
| |
| |
| 2 |
| |
| |
| |
| |
---------------------------
Looking forward to some interesting ideas from you veterans!
I haven't rut to such needs, but from what I know, it could be made by two UIViews (or any of their subclasses). All you have to do is a custom animation on flip(a simple one if you interested in flip only, a harder one if you need the animation actually to go one with the finger). And of course you'll need to put corresponding part of your file to those views. Actually I would suggest using 3 views, so you'll be able to put content of the next "page" while it still offscreen. That will make your animation smoother.