Skip to content

Commit 7fb011b

Browse files
committed
cleanup ui make it lazy
Signed-off-by: alperozturk <[email protected]>
1 parent 4c6c5c7 commit 7fb011b

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

app/src/main/java/com/nextcloud/ui/ClientIntegrationScreen.kt

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import androidx.compose.foundation.layout.Arrangement
1212
import androidx.compose.foundation.layout.Column
1313
import androidx.compose.foundation.layout.Row
1414
import androidx.compose.foundation.layout.fillMaxWidth
15+
import androidx.compose.foundation.lazy.LazyColumn
16+
import androidx.compose.foundation.lazy.LazyRow
17+
import androidx.compose.foundation.lazy.items
18+
import androidx.compose.material3.Button
1519
import androidx.compose.material3.TextButton
1620
import androidx.compose.runtime.Composable
1721
import androidx.compose.ui.Modifier
@@ -34,27 +38,28 @@ fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: S
3438

3539
Column {
3640
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
37-
TextButton({ close(activity) }) {
38-
androidx.compose.material3.Text("X")
41+
TextButton(onClick = { activity?.finish() }) {
42+
Text("X")
3943
}
4044
}
4145

42-
Row {
43-
if (clientIntegrationUI.root.orientation == Orientation.VERTICAL) {
44-
Column {
45-
clientIntegrationUI.root.rows.forEach { row ->
46-
Row {
47-
row.children.forEach { element ->
46+
when (clientIntegrationUI.root.orientation) {
47+
Orientation.VERTICAL -> {
48+
LazyColumn {
49+
items(clientIntegrationUI.root.rows) { row ->
50+
LazyRow {
51+
items(row.children) { element ->
4852
DisplayElement(element, baseUrl, activity)
4953
}
5054
}
5155
}
5256
}
53-
} else {
54-
Row {
55-
clientIntegrationUI.root.rows.forEach { row ->
56-
Column {
57-
row.children.forEach { element ->
57+
}
58+
else -> {
59+
LazyRow {
60+
items(clientIntegrationUI.root.rows) { row ->
61+
LazyColumn {
62+
items(row.children) { element ->
5863
DisplayElement(element, baseUrl, activity)
5964
}
6065
}
@@ -68,15 +73,15 @@ fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: S
6873
@Composable
6974
private fun DisplayElement(element: Element, baseUrl: String, activity: Activity?) {
7075
when (element) {
71-
is Button -> androidx.compose.material3.Button({ }) {
72-
androidx.compose.material3.Text(element.label)
76+
is Button -> Button(onClick = { }) {
77+
Text(element.label)
7378
}
7479

7580
is URL -> TextButton({
7681
openLink(activity, baseUrl, element.url)
77-
}) { androidx.compose.material3.Text(element.text) }
82+
}) { Text(element.text) }
7883

79-
is Text -> androidx.compose.material3.Text(element.text)
84+
is Text -> Text(element.text)
8085
}
8186
}
8287

@@ -86,10 +91,6 @@ private fun openLink(activity: Activity?, baseUrl: String, relativeUrl: String)
8691
}
8792
}
8893

89-
private fun close(activity: Activity?) {
90-
activity?.finish()
91-
}
92-
9394
@Composable
9495
@Preview
9596
private fun ClientIntegrationScreenPreviewVertical() {

0 commit comments

Comments
 (0)