Skip to content

Commit d9d2eb1

Browse files
author
Section One
committed
Codi JC18 - Llistat d'elements amb classes en Jetpack Compose
1 parent 48dd272 commit d9d2eb1

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

app/src/main/java/es/cibernarium/jetpackcomposeapp/MainActivity.kt

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import androidx.compose.ui.unit.dp
3838
import androidx.compose.ui.unit.sp
3939
import es.cibernarium.jetpackcomposeapp.ui.theme.JetpackComposeAppTheme
4040

41+
4142
class MainActivity : ComponentActivity() {
4243
override fun onCreate(savedInstanceState: Bundle?) {
4344
super.onCreate(savedInstanceState)
@@ -51,40 +52,34 @@ class MainActivity : ComponentActivity() {
5152
//Tot el que posem aqui serà la part visible de la nostre Aplicació
5253
val scrollState = rememberScrollState()
5354
Column(
54-
modifier = Modifier.padding(15.dp).verticalScroll(scrollState)
55+
modifier = Modifier
56+
.padding(15.dp)
57+
.verticalScroll(scrollState)
5558
) {
56-
Element()
57-
Element()
58-
Element()
59-
Element()
60-
Element()
61-
Element()
62-
Element()
63-
Element()
64-
Element()
65-
Element()
66-
Element()
67-
Element()
59+
//Usuaris(perfils)
60+
Element(Perfil("Enric","Sòc un usuari molt actiu de la plataforma."))
6861
}
6962
}
7063
}
7164
}
7265
}
7366

67+
data class Perfil(val nom: String,val description: String)
68+
7469
@Composable
75-
private fun Element(){
70+
private fun Element(dades: Perfil){
7671
Row {
7772
Avatar()
7873
Column(
7974
modifier = Modifier.padding(15.dp)
8075
) {
81-
SalutacioPersonal(nom = "Francesc")
82-
Description()
76+
SalutacioPersonal(nom = dades.nom)
77+
Description(description = dades.description)
8378
}
8479
}
8580
}
8681
@Composable
87-
private fun SalutacioPersonal(nom: String){
82+
fun SalutacioPersonal(nom: String){
8883
Text(
8984
text = "Hola $nom!",
9085
color = Color.Red,
@@ -95,7 +90,7 @@ class MainActivity : ComponentActivity() {
9590
)
9691
}
9792
@Composable
98-
private fun Avatar(){
93+
fun Avatar(){
9994
Image(
10095
painter = painterResource(R.drawable.qx7jysym_400x400),
10196
contentDescription = "Logo Refus",
@@ -106,7 +101,7 @@ class MainActivity : ComponentActivity() {
106101
)
107102
}
108103
@Composable
109-
private fun Description(){
110-
Text(text = "Benvingut a la teva App de montanyisme i a on trobaràs tots els recursos a la teva disposició.")
104+
fun Description(description: String){
105+
Text(text = description)
111106
}
112107
}

0 commit comments

Comments
 (0)