1
00:00:01,300 --> 00:00:10,000
Hi, welcome back in this video, we will make our app more advanced by adding to drop zone lists here

2
00:00:10,000 --> 00:00:13,690
on top of these other widgets somewhere in here.

3
00:00:14,740 --> 00:00:22,630
The first dropdown list will contain the inputs currency and the second from the list will contain the

4
00:00:22,630 --> 00:00:31,390
target's currency, so the user can choose between currencies to convert the value that the user enters

5
00:00:31,390 --> 00:00:32,800
in this text box here.

6
00:00:33,490 --> 00:00:39,850
So let's do this for dropdown lists, you need to use a so-called combo box.

7
00:00:40,870 --> 00:00:43,930
So in one of these lines, go ahead and.

8
00:00:45,920 --> 00:00:48,830
Import cute combo books.

9
00:00:50,910 --> 00:00:54,090
And then let's go down here.

10
00:00:55,600 --> 00:01:01,990
So we said that we want to add the first combo box on top of the other widgets, and currently the first

11
00:01:01,990 --> 00:01:07,810
widget is a queue line, edit widgets, so the input text books.

12
00:01:08,320 --> 00:01:11,550
Therefore, I'm going to have some space here and add.

13
00:01:12,220 --> 00:01:16,900
You can see in combo for the input currency.

14
00:01:18,420 --> 00:01:20,700
And then we're going to have targets, Campbell.

15
00:01:21,330 --> 00:01:28,800
So that is equal to cucumber books, which doesn't get any arguments, but then.

16
00:01:30,570 --> 00:01:38,940
You shouldn't mention in Cornwall and then add items to that drop don't list, because currently it's

17
00:01:38,940 --> 00:01:41,070
no items if you just leave it like that.

18
00:01:41,370 --> 00:01:48,060
So using the ads items methods, you can provide a list of strings.

19
00:01:49,500 --> 00:01:52,860
Or you could write the list beforehand.

20
00:01:53,280 --> 00:01:56,490
So, right, it's in between here, let's say, currencies.

21
00:01:58,170 --> 00:02:03,150
You have a list of, let's say you as the and so euro all.

22
00:02:03,720 --> 00:02:09,270
And I and or for Indian rupees.

23
00:02:10,199 --> 00:02:17,790
And you can add some more currency codes to your as many as you want or to be more accurate as many

24
00:02:17,790 --> 00:02:19,530
as this exit rates.

25
00:02:20,190 --> 00:02:22,170
That's common website supports.

26
00:02:22,350 --> 00:02:29,250
So you can go there to the websites and see how many currencies it supports, and then you can add them

27
00:02:29,250 --> 00:02:30,630
in your list in here.

28
00:02:31,110 --> 00:02:36,750
So then once you define your list, you say in combo at items and then you mentioned the list here,

29
00:02:36,760 --> 00:02:37,950
currencies, that one.

30
00:02:38,670 --> 00:02:47,010
So we have created our combo box, but we want to add it now to the layout by mentioning the layout

31
00:02:47,010 --> 00:02:48,680
and then add to widgets.

32
00:02:49,170 --> 00:02:56,460
And than you say in combo, we can do the same by duplicating these lines down here.

33
00:02:58,050 --> 00:03:06,900
So we have the same here now, but I want to change that to targets combo and the list stays the same.

34
00:03:07,950 --> 00:03:11,320
Actually, I'm going to delete this cut out.

35
00:03:11,750 --> 00:03:15,330
That's Lisa's declaration, because we have it in here already.

36
00:03:15,600 --> 00:03:20,670
So in Target's combo, we add that list again.

37
00:03:20,910 --> 00:03:26,910
We're going to have the same currencies, both in the input combo and in the target's combo.

38
00:03:27,420 --> 00:03:31,860
And finally, we need to add that target's combo to the layout.

39
00:03:33,090 --> 00:03:40,980
Now I'm going to run this code and hopefully we see the two dropdown lists in here.

40
00:03:42,810 --> 00:03:47,220
The both of them have the same items.

41
00:03:48,780 --> 00:03:55,950
However, now the next step is to see how we can get to the current selection.

42
00:03:56,130 --> 00:04:02,940
The current user selection in each of the Droukdel is so that we can get that string, for example,

43
00:04:03,210 --> 00:04:13,740
and and you euro for this other one, and then we can send those two strings to this function here.

44
00:04:13,750 --> 00:04:20,070
So that's the first string goes in this place here and the next string goes in here.

45
00:04:20,250 --> 00:04:21,779
So let's see how we can do that.

46
00:04:22,890 --> 00:04:32,400
Currently, our function is a bit rigid in the sense that it's using these static strings as default

47
00:04:32,400 --> 00:04:32,790
values.

48
00:04:32,790 --> 00:04:39,330
So we want to delete those default values for the arguments of the gets currency function.

49
00:04:39,720 --> 00:04:44,670
And then we go here in the show currency function definition.

50
00:04:45,000 --> 00:04:49,020
Here is where we call that function that gets currency function.

51
00:04:49,200 --> 00:04:57,630
So we get the reads the gets currency function is responsible to scrape the current rate between those

52
00:04:57,630 --> 00:04:59,100
two given currencies.

53
00:04:59,670 --> 00:05:02,030
And then we get the rates in here.

54
00:05:02,040 --> 00:05:05,250
We save it in this variable by calling that function.

55
00:05:06,090 --> 00:05:14,340
But now that we removed the default values from these arguments, we need to provide those values in

56
00:05:14,340 --> 00:05:14,790
here.

57
00:05:15,390 --> 00:05:22,770
So that means that we need to get access to the selections, to the drop zone list selections from the

58
00:05:22,770 --> 00:05:24,180
show currency function.

59
00:05:24,570 --> 00:05:37,080
To do that, we can write a variable such as in for input currency is equal to in Combo Dot current

60
00:05:37,470 --> 00:05:38,060
text.

61
00:05:38,460 --> 00:05:47,910
So this is a method that returns the current selection of the dropdown lists so that current selection

62
00:05:47,910 --> 00:05:49,770
is going to be stored in this variable.

63
00:05:49,920 --> 00:05:57,810
And we do the same for target currency UM, which is equal to target convert the current text.

64
00:05:58,650 --> 00:06:05,880
So before we do anything further, let's check if we got those two values correctly incur and targets

65
00:06:06,690 --> 00:06:07,330
cur.

66
00:06:08,030 --> 00:06:16,530
And so we expect to see a print in the terminal when the button is pressed.

67
00:06:16,530 --> 00:06:22,260
So show currency is called to when the button is clicked.

68
00:06:22,770 --> 00:06:26,010
So let's run the codes.

69
00:06:27,320 --> 00:06:32,660
And change to the second selection to Euro, right, a number here.

70
00:06:33,230 --> 00:06:34,400
Press convert.

71
00:06:36,170 --> 00:06:37,730
And let's see the terminal.

72
00:06:40,020 --> 00:06:48,090
So we have an error in line 22, which is in here, so it gets currency.

73
00:06:48,360 --> 00:06:54,330
We have an error, but the print function is before that error, so let's see where the print function

74
00:06:54,750 --> 00:06:55,290
returns.

75
00:06:55,290 --> 00:06:59,010
So you as the euro, that means it's working.

76
00:06:59,010 --> 00:07:02,490
We have access to these two values.

77
00:07:02,910 --> 00:07:06,720
So USD and euros the selection in the dropdown list.

78
00:07:07,200 --> 00:07:11,820
Now we can provide, incur and targets Kerr.

79
00:07:13,580 --> 00:07:22,010
As inputs to this function, to the gets currency function, so those two values, USD and Euro will

80
00:07:22,010 --> 00:07:29,300
go in here and then from here in currency, we'll go to this took us from the URL and all its currency

81
00:07:29,300 --> 00:07:30,800
will go to its own place.

82
00:07:31,130 --> 00:07:39,920
And then the function lists crave the current rate and it will return needs and this rate will be equal

83
00:07:39,920 --> 00:07:40,740
to the current rate.

84
00:07:40,990 --> 00:07:49,280
And then we calculate the ultimate single to round input tax, which is the number how many currency

85
00:07:49,280 --> 00:07:51,260
units the user wants to convert.

86
00:07:51,710 --> 00:07:58,370
And we multiply that by the rates we rounded by two so that we don't have many numbers often of a decimal

87
00:07:58,370 --> 00:07:58,820
points.

88
00:07:58,820 --> 00:08:04,490
And then we write off the outputs in the label and let's run this.

89
00:08:05,930 --> 00:08:10,060
USD two euros 10 convert.

90
00:08:10,940 --> 00:08:21,860
And that's the output if you want to make this output more user friendly, you can go here to altitudes

91
00:08:22,460 --> 00:08:29,000
and create another variable, such as message is equal to a string.

92
00:08:29,300 --> 00:08:35,720
And you can see inputs text, which is the input value of the user.

93
00:08:36,950 --> 00:08:38,870
And then you say incur.

94
00:08:39,110 --> 00:08:48,890
So let's say the user enters 10 and we say 10 USD is how many in euros?

95
00:08:48,890 --> 00:08:50,120
Well, outputs.

96
00:08:52,970 --> 00:08:55,320
And targets Kerr.

97
00:08:56,240 --> 00:08:58,100
So 10.

98
00:08:59,220 --> 00:09:03,810
USD is eight point eight euro.

99
00:09:04,950 --> 00:09:09,370
Let's see if this works, oh, first, we need to provide a message in here.

100
00:09:09,720 --> 00:09:16,710
So instead of writing the altitudes, we write the entire message now that we construct it in here and

101
00:09:16,800 --> 00:09:18,120
now we're ready to run this.

102
00:09:20,340 --> 00:09:30,810
Go to INR and three and convert and three USD is that much and are so rupees.

103
00:09:33,840 --> 00:09:36,930
And that's a final coats, so thanks a lot for falling.

104
00:09:36,960 --> 00:09:38,520
And I'll talk to you later.

105
00:09:38,690 --> 00:09:38,830
You.

