1
+ package dev.jvmname.acquisitive.ui.screen
2
+
3
+ import androidx.compose.foundation.layout.Arrangement
4
+ import androidx.compose.foundation.layout.Column
5
+ import androidx.compose.foundation.layout.Row
6
+ import androidx.compose.foundation.layout.heightIn
7
+ import androidx.compose.foundation.layout.size
8
+ import androidx.compose.foundation.layout.wrapContentWidth
9
+ import androidx.compose.material.TextButton
10
+ import androidx.compose.material3.OutlinedCard
11
+ import androidx.compose.material3.Text
12
+ import androidx.compose.runtime.Composable
13
+ import androidx.compose.ui.Modifier
14
+ import androidx.compose.ui.graphics.vector.ImageVector
15
+ import androidx.compose.ui.tooling.preview.Preview
16
+ import androidx.compose.ui.unit.dp
17
+
18
+ private val MIN_ITEM_HEIGHT = 200 .dp
19
+
20
+
21
+ @Composable
22
+ fun MainListItem (
23
+ modifier : Modifier = Modifier ,
24
+ title : String ,
25
+ isHot : Boolean ,
26
+ rank : Int ,
27
+ score : Int ,
28
+ urlHost : String ,
29
+ numChildren : Int ,
30
+ time : String ,
31
+ author : String ,
32
+ icon : ImageVector ? ,
33
+ onItemClick : ()
34
+ ) {
35
+ // TODO size, color, etc.
36
+ OutlinedCard (modifier = modifier) {
37
+ Row (horizontalArrangement = Arrangement .Start ) {
38
+
39
+ // ranking
40
+ Column (
41
+ modifier.size(width = 150 .dp, height = MIN_ITEM_HEIGHT ),
42
+ verticalArrangement = Arrangement .Center
43
+ ) {
44
+ Text (rank.toString())
45
+ Text (score.toString())
46
+ }
47
+
48
+ // main "content" -- TODO this should prob be a constraintlayout
49
+ Column (
50
+ modifier
51
+ .heightIn(min = MIN_ITEM_HEIGHT )
52
+ .wrapContentWidth()
53
+ ) {
54
+ Text (title)
55
+ Text (urlHost)
56
+
57
+ Row {
58
+ Text (
59
+ " $time - $author " , // would probably want this sent by VM
60
+ modifier.weight(1f )
61
+ )
62
+
63
+ TextButton (modifier = modifier.weight(1f ),
64
+ onClick = {},
65
+ content = { })
66
+ }
67
+
68
+
69
+ }
70
+ }
71
+
72
+ }
73
+ }
74
+
75
+
76
+ @[Preview Composable ]
77
+ fun PreviewMainListItem () {
78
+ MainListItem (
79
+ title = " Archimedes, Vitruvius, and Leonardo: The Odometer Connection (2020)" ,
80
+ isHot = false ,
81
+ rank = 2 ,
82
+ score = 950 ,
83
+ numChildren = 100 ,
84
+ time = " 19h" ,
85
+ author = " JvmName" ,
86
+ icon = null
87
+ )
88
+ }
0 commit comments