Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,410 --> 00:00:08,650
With that list of transactions available, let's output these transactions and for that here, instead of that
2
00:00:08,650 --> 00:00:12,440
second card, which is a placeholder for that list of transactions,
3
00:00:12,490 --> 00:00:15,170
I want to have the actual list of transactions.
4
00:00:15,310 --> 00:00:21,280
So since we have more than one transaction, we need a widget that can hold more than one widget because
5
00:00:21,310 --> 00:00:22,600
each transaction
6
00:00:22,600 --> 00:00:29,050
here in our list of transactions should be mapped into a widget that outputs the data of that transaction.
7
00:00:29,060 --> 00:00:34,440
No one which widget can we use if we have more than one widget column?
8
00:00:34,480 --> 00:00:41,920
So here in the column, we add the children key and again now we can output our different transactions.
9
00:00:41,920 --> 00:00:46,290
Now each transaction might now be a card,
10
00:00:46,450 --> 00:00:52,300
so therefore we could add a card here and now populate it with data for the first transaction and then
11
00:00:52,300 --> 00:00:56,590
add a second card and populate that with the data of the second transaction
12
00:00:56,590 --> 00:00:58,990
but this approach would have a flaw.
13
00:00:59,080 --> 00:01:01,070
Do you know which?
14
00:01:01,330 --> 00:01:07,250
Well we as a developer would have to hardcode as many cards as we have transactions
15
00:01:07,410 --> 00:01:12,810
and whilst we know how many transactions we have at the moment because the transactions are hardcoded
16
00:01:12,840 --> 00:01:18,300
too, later the transactions will be dynamic because the users of our application will add them,
17
00:01:18,660 --> 00:01:21,840
so we don't know in advance how many cards we need
18
00:01:21,840 --> 00:01:29,940
So in the end, our goal should be to take our transactions list and map that into a list of widgets and
19
00:01:30,060 --> 00:01:31,770
we did this earlier
20
00:01:31,770 --> 00:01:32,600
So here,
21
00:01:32,760 --> 00:01:38,880
children will now not be an array like this but instead here I'll point at transactions which is my list
22
00:01:38,880 --> 00:01:45,720
of transaction objects and there, we can use the map method to transform this list of objects into a
23
00:01:45,720 --> 00:01:50,910
list of widgets, widgets technically also are objects but you get my point.
24
00:01:50,970 --> 00:01:55,820
Keep in mind you need to call to list here at the end because map will always give you an iterable
25
00:01:55,820 --> 00:01:58,800
which you need to transform to a list
26
00:01:58,800 --> 00:02:05,330
but right now there is nothing to transform, map doesn't do anything. You might remember that map takes
27
00:02:05,360 --> 00:02:11,030
a function, a function which automatically gets executed on every element in that list,
28
00:02:11,060 --> 00:02:13,470
so in this case on every transaction.
29
00:02:13,520 --> 00:02:20,620
So what we get here is a single transaction and I'll name it tx here just as an abbreviation.
30
00:02:20,810 --> 00:02:26,990
So we get a transaction here as an input to this function we pass to map and this function again executes
31
00:02:26,990 --> 00:02:32,180
on every transaction in here and we need to return a new element here and that new element of course should
32
00:02:32,180 --> 00:02:38,210
be a widget that represents our transaction and there, we could use a card with a child
33
00:02:38,210 --> 00:02:43,360
and for now, let's simply output the title of the transaction and we'll output the rest later.
34
00:02:43,370 --> 00:02:49,400
So here we get our card with our text in there and the text of course should be drawn from the transaction
35
00:02:49,400 --> 00:02:50,890
we have and in there,
36
00:02:50,900 --> 00:02:56,570
I want to access the title. That's by the way the convenient thing of using a custom class and object
37
00:02:56,600 --> 00:02:59,180
instead of a map for our transactions,
38
00:02:59,180 --> 00:03:00,890
here I get nice auto completion
39
00:03:00,890 --> 00:03:06,980
as soon as I type a dot to access the different properties of this object, I don't have to use title
40
00:03:07,010 --> 00:03:09,590
as we did it for a map.
41
00:03:09,590 --> 00:03:11,890
So here I output my title
42
00:03:12,100 --> 00:03:18,220
and with that, we actually already transform our list of transactions to a list of cards where each card
43
00:03:18,280 --> 00:03:24,670
outputs the title of the transaction. If we save that, our application is taking shape and we see the
44
00:03:24,670 --> 00:03:26,330
two titles here.
45
00:03:26,410 --> 00:03:31,970
Now of course, a transaction should be more than a tiny card with no spacing at all inside of it
46
00:03:32,020 --> 00:03:33,040
and then the title,
47
00:03:33,040 --> 00:03:37,510
so let's work on how we output a single transaction in the next lecture.
5151
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.