1 00:00:01,180 --> 00:00:01,910 Welcome back. 2 00:00:01,930 --> 00:00:07,030 And this video, we are going to add some fake data, as you see here with a little bit of a user interface 3 00:00:07,030 --> 00:00:10,240 or just have to date and the images basically. 4 00:00:10,510 --> 00:00:14,500 So this is going to be the fake data where we have the image, the text and then the description, even 5 00:00:14,500 --> 00:00:16,780 though it's not perfect yet, we're going to take care of that. 6 00:00:16,990 --> 00:00:19,750 But for now, let's go ahead and build what we see here. 7 00:00:21,340 --> 00:00:23,860 Therefore, let's go ahead and create a model first. 8 00:00:23,890 --> 00:00:28,420 All right, so whenever we are working with data, it's always good to start with the model in mind. 9 00:00:28,720 --> 00:00:32,980 And therefore, I'm just going to put it directly into my main folder here. 10 00:00:33,910 --> 00:00:39,430 We could, of course, create a model folder for this, but that makes sense once we have multiple items. 11 00:00:39,730 --> 00:00:44,320 So I'm going to call this one and use data, which will be a class this time. 12 00:00:44,680 --> 00:00:51,910 But it will be a data class because, well, we want to store data and use this new data as the type 13 00:00:52,180 --> 00:00:53,350 for that data. 14 00:00:53,590 --> 00:00:56,080 So what kind of information do we want to store? 15 00:00:56,290 --> 00:01:01,780 Well, I would say every piece of news should get an idea that's always good practice with whatever 16 00:01:01,990 --> 00:01:03,160 model you're using. 17 00:01:03,460 --> 00:01:07,870 Then we should have something where we store the image. 18 00:01:08,480 --> 00:01:12,700 OK, then that image will by default, be breaking news. 19 00:01:12,790 --> 00:01:15,250 So we will need to add the resources to this. 20 00:01:15,610 --> 00:01:18,190 We would like to also know about the author. 21 00:01:18,250 --> 00:01:21,520 So who wrote this piece of news? 22 00:01:21,670 --> 00:01:23,980 Then what's the title of this news? 23 00:01:24,400 --> 00:01:26,410 Maybe a little bit of a description. 24 00:01:26,410 --> 00:01:29,150 So what are the details in those news? 25 00:01:29,170 --> 00:01:31,720 And then also, when was the news published? 26 00:01:32,230 --> 00:01:35,320 OK, so now we're going to require a bunch of troubles. 27 00:01:35,560 --> 00:01:39,100 Later on, we can draw them from the internet or get them from the internet. 28 00:01:39,100 --> 00:01:43,360 But for now, let's use a couple of dribbles that I have made ready. 29 00:01:44,940 --> 00:01:51,390 You can find them over here, so there's the Tiger King does Thomas, nanometre, lion and so forth. 30 00:01:51,570 --> 00:01:54,080 So let's go ahead and import the draw bowls. 31 00:01:54,090 --> 00:01:56,730 I'm going to get them directly from this folder here. 32 00:01:57,750 --> 00:02:05,790 So I'm going to mark all the images that I want to add and import them into my project. 33 00:02:06,510 --> 00:02:10,009 OK, now we have the breaking news as well for our new data. 34 00:02:10,259 --> 00:02:13,650 Now let's go ahead and set up a mock data object. 35 00:02:13,920 --> 00:02:18,570 Therefore, I'm just going to create a new covalent file class, which will just be an object. 36 00:02:18,570 --> 00:02:23,520 And I'm going to call this one mock data because we don't have a data source yet that is going to be 37 00:02:23,520 --> 00:02:26,790 from the internet, but we're going to set that up in the next chapter. 38 00:02:26,790 --> 00:02:28,910 So we have the mock data inside of it. 39 00:02:28,920 --> 00:02:35,520 We are going to require a top news list list of news data. 40 00:02:35,940 --> 00:02:40,800 So we just created this new class and now let's create a list of another list. 41 00:02:41,160 --> 00:02:42,900 So list of new data? 42 00:02:43,170 --> 00:02:49,170 And now let's put some data in here, and this is something I would recommend that you copy from our 43 00:02:49,170 --> 00:02:49,800 project. 44 00:02:50,100 --> 00:02:53,340 So just download the project and put the new data in here. 45 00:02:53,580 --> 00:03:01,980 It will just be a bunch of new data with an idea, an author and title description, as well as when 46 00:03:01,980 --> 00:03:02,820 it was published. 47 00:03:03,300 --> 00:03:06,840 OK, so yeah, I would recommend to really just download this. 48 00:03:06,840 --> 00:03:11,340 Otherwise, of course, you can also create your very own new data if you want to. 49 00:03:12,150 --> 00:03:18,390 OK, now let's go ahead and create a template of an individual news item. 50 00:03:18,750 --> 00:03:26,850 We will need to create a new item for individual news piece, and I'm going to put that into the top 51 00:03:26,850 --> 00:03:27,370 news. 52 00:03:27,390 --> 00:03:29,670 So here I'm going to create a new composable. 53 00:03:30,360 --> 00:03:34,520 So let me get rid of that at composable fun. 54 00:03:35,130 --> 00:03:37,530 Top news item. 55 00:03:37,800 --> 00:03:43,800 So inside of it, we will need to pass the news data because we need to know all about the news that 56 00:03:43,800 --> 00:03:44,880 we want to display. 57 00:03:45,360 --> 00:03:53,510 So I'm going to put everything into a box and the box will get some modifiers here, which will be modifier 58 00:03:53,520 --> 00:03:54,260 dot height. 59 00:03:55,350 --> 00:04:03,990 With 200 density pixels, so here for this to work, we need to, first of all, important box. 60 00:04:04,260 --> 00:04:12,270 Then let's import height, then it's important the 200 dpi and then I want to have a little bit of padding 61 00:04:12,270 --> 00:04:16,709 so that it's not going to be glued to the other items. 62 00:04:17,040 --> 00:04:20,100 OK, so this will be the default modifier. 63 00:04:20,100 --> 00:04:24,840 So the default UI settings for our box inside of it, I have an image first. 64 00:04:25,200 --> 00:04:27,600 So this image needs to be imported. 65 00:04:27,720 --> 00:04:32,790 So let's add image here import and the UI compose version. 66 00:04:33,600 --> 00:04:39,570 So then I can set the resource, which is a painter resource, as we've done multiple times before, 67 00:04:39,960 --> 00:04:43,110 which will be the image that we get from it and use data. 68 00:04:43,110 --> 00:04:44,090 So he had a new state. 69 00:04:44,200 --> 00:04:46,950 If you recall, it had an image which isn't adorable. 70 00:04:46,980 --> 00:04:51,660 By default, it's going to be the breaking news, but we're going to override it with the image that 71 00:04:51,660 --> 00:04:54,420 we have for the particular new data that we are looking at. 72 00:04:55,230 --> 00:04:58,560 Then, as always, with images, you need to have a content description. 73 00:04:58,560 --> 00:05:06,240 Otherwise your ID is going to be complaining, but I'm just going to for now, keep it empty and then 74 00:05:06,600 --> 00:05:12,630 we need to add the content scale or I'm going to scale this image. 75 00:05:12,870 --> 00:05:19,020 So there's this content scale property where you can use content scale and then fill bones, crop the 76 00:05:19,020 --> 00:05:21,220 image, fill the width of the image to hide. 77 00:05:21,240 --> 00:05:23,120 Make sure that it fits and so forth. 78 00:05:23,130 --> 00:05:28,050 I'm going to fill the bounce so you can try these different content, scales out with the image and 79 00:05:28,050 --> 00:05:32,790 see how they look and then decide what fits best to the images that you have. 80 00:05:33,570 --> 00:05:35,340 And then I want to have the column. 81 00:05:35,340 --> 00:05:41,280 So if we look at this, so we have the image right, and then we have a column where we set the texture 82 00:05:41,280 --> 00:05:46,230 at the top, then we have a big spacer and then underneath we have our description. 83 00:05:46,530 --> 00:05:50,460 OK, so this will all fit into our column here. 84 00:05:50,880 --> 00:05:56,190 So I'm going to create another modifier where I want to rep the content height. 85 00:05:56,280 --> 00:06:01,110 So I want to make sure that the content height is kept to the size that we have available for it. 86 00:06:01,410 --> 00:06:06,960 And then I'm going to add a little bit of padding towards the top of 16 dpi and towards the left of 87 00:06:08,130 --> 00:06:09,390 16 dpi as well. 88 00:06:10,920 --> 00:06:16,380 OK, and then as always, such a column needs to have contents. 89 00:06:16,680 --> 00:06:18,840 So let's go ahead and add some content. 90 00:06:19,590 --> 00:06:22,770 And by the way, let's add something else to this column. 91 00:06:23,040 --> 00:06:26,350 So we have to wrap content tied with the padding. 92 00:06:26,700 --> 00:06:30,750 And then we should take care of the arrangement inside of it. 93 00:06:30,840 --> 00:06:32,190 So how do we want to arrange it? 94 00:06:32,190 --> 00:06:37,950 And I'm going to say that it's going to be vertically arranged, that the arrangement will be space 95 00:06:38,250 --> 00:06:38,970 between. 96 00:06:39,000 --> 00:06:43,350 So I want to have some space between the items inside of this column. 97 00:06:44,010 --> 00:06:46,090 So what items do I want to have in the column? 98 00:06:46,110 --> 00:06:53,880 Well, first of all, a text which will display the new status published it so published at. 99 00:06:54,780 --> 00:06:56,940 Because if you look at it, you see in here at the top, I have one. 100 00:06:56,940 --> 00:07:00,900 It was published and you see also that the color was white. 101 00:07:01,080 --> 00:07:04,800 So I'm going to set the color to white like so. 102 00:07:05,790 --> 00:07:13,050 And the fund will be semi bolt, so font weight will be sensible, as we have used many times before. 103 00:07:13,500 --> 00:07:15,120 So this is going to be our first test. 104 00:07:15,420 --> 00:07:20,280 Then as I said, I want to have a spacer here, so a bunch of space in between. 105 00:07:20,790 --> 00:07:25,730 So we can use a spacer modifier with a modifier. 106 00:07:25,740 --> 00:07:27,840 So here, spacer, that's important. 107 00:07:28,740 --> 00:07:29,040 OK. 108 00:07:29,280 --> 00:07:37,350 And then here the modifier will be a height of, let's say, 80 than 50 pixels, something like that. 109 00:07:38,470 --> 00:07:45,640 And then finally, we have another text which will take the new state to that title. 110 00:07:46,600 --> 00:07:48,100 OK, so we get the title. 111 00:07:48,430 --> 00:07:51,820 The color, which will also be white, as we've seen before. 112 00:07:52,150 --> 00:07:56,410 At the same font weight that we had for our other text. 113 00:07:57,130 --> 00:08:00,460 OK, so let me put that into different lines as well. 114 00:08:00,460 --> 00:08:01,840 So it's going to be a little more readable. 115 00:08:02,110 --> 00:08:09,070 So we have the two texts with the spacer, and now we can go ahead and display this top news item inside 116 00:08:09,070 --> 00:08:10,210 of our preview here. 117 00:08:10,870 --> 00:08:17,680 So instead of displaying the top news, let's go ahead and display a top news item with some news data. 118 00:08:17,680 --> 00:08:20,980 And here I'm just going to use dummy data like so. 119 00:08:21,370 --> 00:08:25,030 So the new data will be a new state data object with some dummy data. 120 00:08:27,410 --> 00:08:31,460 OK, so this is just an object of foreign news data. 121 00:08:32,150 --> 00:08:32,840 The a class. 122 00:08:35,870 --> 00:08:41,090 OK, now let's display our top news items so we can run this, and we will not see it in our actual 123 00:08:41,090 --> 00:08:47,570 application because, well, we didn't set it up to display there, but let's see if we can get it into 124 00:08:47,570 --> 00:08:49,370 the preview because here we still have this button. 125 00:08:49,520 --> 00:08:54,860 Go to the details screen, but the design shows you this is the text. 126 00:08:54,860 --> 00:08:59,660 Then we have the image in the background and we have this other text, even though it doesn't look great. 127 00:08:59,660 --> 00:09:02,660 So maybe we want to give it a little bit of background and so forth. 128 00:09:03,020 --> 00:09:05,090 So that's something we can take care of later. 129 00:09:05,360 --> 00:09:08,750 But for now, let's make sure that we actually see this also in our application. 130 00:09:09,020 --> 00:09:13,430 So we need to display it instead of this go to detail screen. 131 00:09:13,940 --> 00:09:21,280 So instead of using this button, what we can use here is going to be, well, let's think about it. 132 00:09:21,290 --> 00:09:26,240 What would make sense if you look at the use application? 133 00:09:27,610 --> 00:09:31,840 It's similar to what we had here, so in this project, we had something where we could scroll, and 134 00:09:31,840 --> 00:09:34,150 this is always good to use a lazy column here. 135 00:09:34,570 --> 00:09:38,950 So let's use a lazy column which will only lazily load content. 136 00:09:39,730 --> 00:09:42,160 So I don't need to define the content in here. 137 00:09:42,640 --> 00:09:44,860 I'm going to define it via the items. 138 00:09:45,010 --> 00:09:51,340 So here the content will be items which will be pieces of mock data. 139 00:09:51,370 --> 00:09:54,190 So here I am saying what is the content of my lazy column? 140 00:09:54,760 --> 00:09:59,980 And it's going to be the mock data that top news list, which is a list, right? 141 00:09:59,980 --> 00:10:03,790 So you need to pass a list of items inside of this item's method. 142 00:10:04,510 --> 00:10:09,990 And then we can say what we want to do with every single piece of items. 143 00:10:10,000 --> 00:10:13,450 And here it needs to import something. 144 00:10:13,450 --> 00:10:16,300 Let me see that import the correct one. 145 00:10:17,510 --> 00:10:18,860 Call it lazy column. 146 00:10:21,170 --> 00:10:26,750 Because it should be happy with the mock data, the top news list, so it probably took the wrong items. 147 00:10:27,710 --> 00:10:30,050 So to me, who did it again? 148 00:10:32,370 --> 00:10:36,870 Everything that we're not using and all use items here. 149 00:10:40,460 --> 00:10:42,320 Well, I'm going to pass my mock data. 150 00:10:43,700 --> 00:10:44,090 Thought. 151 00:10:44,300 --> 00:10:45,250 Top news stories. 152 00:10:47,630 --> 00:10:48,770 Oh, still isn't happy. 153 00:10:55,970 --> 00:10:59,900 Well, let's make sure that we import it in case that's the problem. 154 00:11:00,200 --> 00:11:00,830 Import. 155 00:11:00,890 --> 00:11:02,900 OK, that seems to have been the problem. 156 00:11:03,260 --> 00:11:08,150 So we need to import our mock data over here, even though I had it imported earlier. 157 00:11:08,150 --> 00:11:09,410 But it's still the error appeared. 158 00:11:09,680 --> 00:11:12,100 So now we get the individual items. 159 00:11:12,110 --> 00:11:14,210 So here the lazy item scope. 160 00:11:16,720 --> 00:11:21,610 Which is going to be one by one to items that we have in here, so the first item, the second item, 161 00:11:21,610 --> 00:11:22,840 third item and so forth. 162 00:11:23,320 --> 00:11:31,090 OK, so now we can go back to our other file, which was, I think, top news and we can now design 163 00:11:31,090 --> 00:11:32,110 every single item. 164 00:11:32,470 --> 00:11:39,940 So here I'm going to say that I want to display for each item a top news item and which news item do 165 00:11:39,940 --> 00:11:40,810 I want to use? 166 00:11:41,440 --> 00:11:45,430 While the news data and what do I get this news data from? 167 00:11:46,060 --> 00:11:48,190 Well, that's this lazy item scope. 168 00:11:48,310 --> 00:11:57,700 OK, so I can just use it like this so I can say news data, which will be the use data items called 169 00:11:57,700 --> 00:11:59,120 this lazy item scope. 170 00:11:59,140 --> 00:12:04,900 So basically the individual item, as I said, so that's what this number gives us and then we can use 171 00:12:04,900 --> 00:12:06,400 this news data to display it. 172 00:12:06,700 --> 00:12:11,230 So at this point, we should be able to run the application and see the new state i our application. 173 00:12:12,890 --> 00:12:14,780 So there we are, we have the images. 174 00:12:15,050 --> 00:12:21,860 And it doesn't look perfect for each image, some just don't fit well and others look great. 175 00:12:22,370 --> 00:12:26,070 OK, so that's what we have set up now. 176 00:12:26,120 --> 00:12:29,510 We can play around, obviously with the details and make it look better. 177 00:12:29,510 --> 00:12:32,270 But for now, it's just important to display some dummy data. 178 00:12:32,510 --> 00:12:37,370 In the next, we were going to look at how to navigate with an argument because we can now navigate, 179 00:12:37,370 --> 00:12:39,860 as we saw earlier with the button to a different screen. 180 00:12:40,070 --> 00:12:45,440 But we need to pass to the details screen what article we want to have the details about. 181 00:12:45,530 --> 00:12:46,520 So do we want to have it? 182 00:12:46,520 --> 00:12:48,780 The bubbles breaking news about Tiger King. 183 00:12:49,100 --> 00:12:52,490 They want to have a over Cleo Smith news and so forth, right? 184 00:12:52,490 --> 00:12:57,230 So once we click on it, we want to go to the next screen to the detailed screen, which we will have 185 00:12:57,230 --> 00:12:58,340 to design as well. 186 00:12:58,730 --> 00:12:59,960 So that's it for this video. 187 00:13:00,050 --> 00:13:01,040 See you in the next one.