@@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.Arrangement
1212import androidx.compose.foundation.layout.Row
1313import androidx.compose.foundation.layout.fillMaxSize
1414import androidx.compose.foundation.layout.fillMaxWidth
15+ import androidx.compose.foundation.layout.padding
1516import androidx.compose.foundation.lazy.LazyColumn
1617import androidx.compose.foundation.lazy.LazyRow
1718import androidx.compose.foundation.lazy.items
@@ -20,17 +21,19 @@ import androidx.compose.material.icons.filled.Close
2021import androidx.compose.material3.Icon
2122import androidx.compose.material3.IconButton
2223import androidx.compose.material3.Scaffold
24+ import androidx.compose.material3.Text
2325import androidx.compose.material3.TextButton
2426import androidx.compose.runtime.Composable
2527import androidx.compose.ui.Modifier
2628import androidx.compose.ui.platform.LocalContext
2729import androidx.compose.ui.tooling.preview.Preview
28- import com.nextcloud.android.lib.resources.clientintegration.Button
2930import com.nextcloud.android.lib.resources.clientintegration.ClientIntegrationUI
3031import com.nextcloud.android.lib.resources.clientintegration.Element
3132import com.nextcloud.android.lib.resources.clientintegration.Layout
32- import com.nextcloud.android.lib.resources.clientintegration.Orientation
33- import com.nextcloud.android.lib.resources.clientintegration.Text
33+ import com.nextcloud.android.lib.resources.clientintegration.LayoutButton
34+ import com.nextcloud.android.lib.resources.clientintegration.LayoutOrientation
35+ import com.nextcloud.android.lib.resources.clientintegration.LayoutRow
36+ import com.nextcloud.android.lib.resources.clientintegration.LayoutText
3437import com.nextcloud.android.lib.resources.clientintegration.URL
3538import com.nextcloud.utils.extensions.getActivity
3639import com.owncloud.android.lib.resources.status.OCCapability
@@ -39,6 +42,7 @@ import com.owncloud.android.utils.DisplayUtils
3942@Composable
4043fun ClientIntegrationScreen (clientIntegrationUI : ClientIntegrationUI , baseUrl : String ) {
4144 val activity = LocalContext .current.getActivity()
45+ val layoutRows = clientIntegrationUI.root?.layoutRows ? : listOf ()
4246
4347 Scaffold (topBar = {
4448 Row (Modifier .fillMaxWidth(), horizontalArrangement = Arrangement .End ) {
@@ -50,10 +54,10 @@ fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: S
5054 }
5155 }
5256 }, modifier = Modifier .fillMaxSize()) {
53- when (clientIntegrationUI.root.orientation) {
54- Orientation .VERTICAL -> {
55- LazyColumn {
56- items(clientIntegrationUI.root.rows ) { row ->
57+ when (clientIntegrationUI.root? .orientation) {
58+ LayoutOrientation .VERTICAL -> {
59+ LazyColumn (modifier = Modifier .padding(it)) {
60+ items(layoutRows ) { row ->
5761 LazyRow {
5862 items(row.children) { element ->
5963 DisplayElement (element, baseUrl, activity)
@@ -63,8 +67,8 @@ fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: S
6367 }
6468 }
6569 else -> {
66- LazyRow {
67- items(clientIntegrationUI.root.rows ) { row ->
70+ LazyRow (modifier = Modifier .padding(it)) {
71+ items(layoutRows ) { row ->
6872 LazyColumn {
6973 items(row.children) { element ->
7074 DisplayElement (element, baseUrl, activity)
@@ -80,15 +84,15 @@ fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: S
8084@Composable
8185private fun DisplayElement (element : Element , baseUrl : String , activity : Activity ? ) {
8286 when (element) {
83- is Button -> androidx.compose.material3.Button (onClick = { }) {
84- androidx.compose.material3. Text (element.label)
87+ is LayoutButton -> androidx.compose.material3.Button (onClick = { }) {
88+ Text (element.label)
8589 }
8690
8791 is URL -> TextButton ({
8892 openLink(activity, baseUrl, element.url)
89- }) { androidx.compose.material3. Text (element.text) }
93+ }) { Text (element.text) }
9094
91- is Text -> androidx.compose.material3. Text (element.text)
95+ is LayoutText -> Text (element.text)
9296 }
9397}
9498
@@ -104,15 +108,15 @@ private fun ClientIntegrationScreenPreviewVertical() {
104108 val clientIntegrationUI = ClientIntegrationUI (
105109 OCCapability .CLIENT_INTEGRATION_VERSION ,
106110 Layout (
107- Orientation .VERTICAL ,
111+ LayoutOrientation .VERTICAL ,
108112 mutableListOf (
109- com.nextcloud.android.lib.resources.clientintegration. Row (
110- listOf (Button (" Click" , " Primary" ), Text (" 123" ))
113+ LayoutRow (
114+ listOf (LayoutButton (" Click" , " Primary" ), LayoutText (" 123" ))
111115 ),
112- com.nextcloud.android.lib.resources.clientintegration. Row (
113- listOf (Button (" Click2" , " Primary" ))
116+ LayoutRow (
117+ listOf (LayoutButton (" Click2" , " Primary" ))
114118 ),
115- com.nextcloud.android.lib.resources.clientintegration. Row (
119+ LayoutRow (
116120 listOf (URL (" Analytics report created" , " https://nextcloud.com" ))
117121 )
118122 )
@@ -131,15 +135,15 @@ private fun ClientIntegrationScreenPreviewHorizontal() {
131135 val clientIntegrationUI = ClientIntegrationUI (
132136 OCCapability .CLIENT_INTEGRATION_VERSION ,
133137 Layout (
134- Orientation .HORIZONTAL ,
138+ LayoutOrientation .HORIZONTAL ,
135139 mutableListOf (
136- com.nextcloud.android.lib.resources.clientintegration. Row (
137- listOf (Button (" Click" , " Primary" ), Text (" 123" ))
140+ LayoutRow (
141+ listOf (LayoutButton (" Click" , " Primary" ), LayoutText (" 123" ))
138142 ),
139- com.nextcloud.android.lib.resources.clientintegration. Row (
140- listOf (Button (" Click2" , " Primary" ))
143+ LayoutRow (
144+ listOf (LayoutButton (" Click2" , " Primary" ))
141145 ),
142- com.nextcloud.android.lib.resources.clientintegration. Row (
146+ LayoutRow (
143147 listOf (URL (" Analytics report created" , " https://nextcloud.com" ))
144148 )
145149 )
@@ -155,7 +159,7 @@ private fun ClientIntegrationScreenPreviewEmpty() {
155159 val clientIntegrationUI = ClientIntegrationUI (
156160 OCCapability .CLIENT_INTEGRATION_VERSION ,
157161 Layout (
158- Orientation .HORIZONTAL ,
162+ LayoutOrientation .HORIZONTAL ,
159163 emptyList()
160164 )
161165 )
0 commit comments