-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Declarative UI #16111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tobiasKaminsky
wants to merge
13
commits into
master
Choose a base branch
from
declarative-ui
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,855
−32
Open
Declarative UI #16111
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
073194f
wip
tobiasKaminsky ff42bde
wip
tobiasKaminsky 6a41db3
wip
tobiasKaminsky 721381f
fix git conflict
alperozturk96 107e2ab
code cleanup
alperozturk96 978ae1a
cleanup ui make it lazy
alperozturk96 b8ae14f
fix crash
alperozturk96 d632c9b
fix crash
alperozturk96 ac1bb85
new lib
tobiasKaminsky 11116dc
fix empty screen
alperozturk96 7ed9478
handle lib
alperozturk96 0a07d6c
handle lib
alperozturk96 999c848
handle lib
alperozturk96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1,298 changes: 1,298 additions & 0 deletions
1,298
app/schemas/com.nextcloud.client.database.NextcloudDatabase/97.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
app/src/main/java/com/nextcloud/ui/ClientIntegrationScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| /* | ||
| * Nextcloud - Android Client | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Alper Ozturk <alper.ozturk@nextcloud.com> | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <tobias.kaminsky@nextcloud.com> | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| package com.nextcloud.ui | ||
|
|
||
| import android.app.Activity | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.foundation.lazy.LazyRow | ||
| import androidx.compose.foundation.lazy.items | ||
| import androidx.compose.material.icons.Icons | ||
| import androidx.compose.material.icons.filled.Close | ||
| import androidx.compose.material3.Button | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.IconButton | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.material3.TextButton | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import com.nextcloud.android.lib.resources.clientintegration.ClientIntegrationUI | ||
| import com.nextcloud.android.lib.resources.clientintegration.Element | ||
| import com.nextcloud.android.lib.resources.clientintegration.Layout | ||
| import com.nextcloud.android.lib.resources.clientintegration.LayoutButton | ||
| import com.nextcloud.android.lib.resources.clientintegration.LayoutOrientation | ||
| import com.nextcloud.android.lib.resources.clientintegration.LayoutRow | ||
| import com.nextcloud.android.lib.resources.clientintegration.LayoutText | ||
| import com.nextcloud.android.lib.resources.clientintegration.LayoutURL | ||
| import com.nextcloud.utils.extensions.getActivity | ||
| import com.owncloud.android.lib.resources.status.OCCapability | ||
| import com.owncloud.android.utils.DisplayUtils | ||
|
|
||
| @Composable | ||
| fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: String) { | ||
| val activity = LocalContext.current.getActivity() | ||
| val layoutRows = clientIntegrationUI.root?.rows ?: listOf() | ||
|
|
||
| Scaffold(topBar = { | ||
| Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { | ||
| IconButton(onClick = { activity?.finish() }) { | ||
| Icon( | ||
| imageVector = Icons.Filled.Close, | ||
| contentDescription = "Close" | ||
| ) | ||
| } | ||
| } | ||
| }, modifier = Modifier.fillMaxSize()) { | ||
| when (clientIntegrationUI.root?.orientation) { | ||
| LayoutOrientation.VERTICAL -> { | ||
| LazyColumn(modifier = Modifier.padding(it)) { | ||
| items(layoutRows) { row -> | ||
| LazyRow { | ||
| items(row.children) { element -> | ||
| DisplayElement(element, baseUrl, activity) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| else -> { | ||
| LazyRow(modifier = Modifier.padding(it)) { | ||
| items(layoutRows) { row -> | ||
| LazyColumn { | ||
| items(row.children) { element -> | ||
| DisplayElement(element, baseUrl, activity) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun DisplayElement(element: Element, baseUrl: String, activity: Activity?) { | ||
| when (element) { | ||
| is LayoutButton -> Button(onClick = { }) { | ||
| Text(element.label) | ||
| } | ||
|
|
||
| is LayoutURL -> TextButton({ | ||
| openLink(activity, baseUrl, element.url) | ||
| }) { Text(element.text) } | ||
|
|
||
| is LayoutText -> Text(element.text) | ||
| } | ||
| } | ||
|
|
||
| private fun openLink(activity: Activity?, baseUrl: String, relativeUrl: String) { | ||
| activity?.let { | ||
| DisplayUtils.startLinkIntent(activity, baseUrl + relativeUrl) | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| @Preview | ||
| private fun ClientIntegrationScreenPreviewVertical() { | ||
| val clientIntegrationUI = ClientIntegrationUI( | ||
| OCCapability.CLIENT_INTEGRATION_VERSION, | ||
| Layout( | ||
| LayoutOrientation.VERTICAL, | ||
| mutableListOf( | ||
| LayoutRow( | ||
| listOf(LayoutButton("Click", "Primary"), LayoutText("123")) | ||
| ), | ||
| LayoutRow( | ||
| listOf(LayoutButton("Click2", "Primary")) | ||
| ), | ||
| LayoutRow( | ||
| listOf(LayoutURL("Analytics report created", "https://nextcloud.com")) | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| ClientIntegrationScreen( | ||
| clientIntegrationUI, | ||
| "http://nextcloud.local" | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| @Preview | ||
| private fun ClientIntegrationScreenPreviewHorizontal() { | ||
| val clientIntegrationUI = ClientIntegrationUI( | ||
| OCCapability.CLIENT_INTEGRATION_VERSION, | ||
| Layout( | ||
| LayoutOrientation.HORIZONTAL, | ||
| mutableListOf( | ||
| LayoutRow( | ||
| listOf(LayoutButton("Click", "Primary"), LayoutText("123")) | ||
| ), | ||
| LayoutRow( | ||
| listOf(LayoutButton("Click2", "Primary")) | ||
| ), | ||
| LayoutRow( | ||
| listOf(LayoutURL("Analytics report created", "https://nextcloud.com")) | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| ClientIntegrationScreen(clientIntegrationUI, "http://nextcloud.local") | ||
| } | ||
|
|
||
| @Composable | ||
| @Preview | ||
| private fun ClientIntegrationScreenPreviewEmpty() { | ||
| val clientIntegrationUI = ClientIntegrationUI( | ||
| OCCapability.CLIENT_INTEGRATION_VERSION, | ||
| Layout( | ||
| LayoutOrientation.HORIZONTAL, | ||
| emptyList() | ||
| ) | ||
| ) | ||
|
|
||
| ClientIntegrationScreen(clientIntegrationUI, "http://nextcloud.local") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.