Use Common-UI Lib

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-03-04 13:26:32 +01:00 committed by Alper Öztürk
parent 96deb984e4
commit 6a8b50e116
3 changed files with 3 additions and 70 deletions

View file

@ -34,6 +34,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@ -46,7 +47,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.nextcloud.ui.composeActivity.ComposeActivity.Companion.colorScheme
import com.nextcloud.ui.composeComponents.bottomSheet.MoreActionsBottomSheet
import com.owncloud.android.R
import com.owncloud.android.lib.resources.assistant.model.Task
@ -65,7 +65,7 @@ fun TaskView(
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(16.dp))
.background(colorScheme.primary)
.background(MaterialTheme.colorScheme.primary)
.combinedClickable(onClick = {
expanded = !expanded
}, onLongClick = {

View file

@ -24,7 +24,6 @@ package com.nextcloud.ui.composeActivity
import android.content.Context
import android.os.Bundle
import android.view.MenuItem
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@ -37,7 +36,6 @@ import com.nextcloud.client.assistant.AssistantViewModel
import com.nextcloud.common.NextcloudClient
import com.nextcloud.common.User
import com.nextcloud.utils.extensions.getSerializableArgument
import com.nextcloud.utils.extensions.toColorScheme
import com.owncloud.android.R
import com.owncloud.android.databinding.ActivityComposeBinding
import com.owncloud.android.lib.common.OwnCloudClientFactory
@ -55,11 +53,8 @@ class ComposeActivity : DrawerActivity() {
const val DESTINATION = "DESTINATION"
const val TITLE = "TITLE"
const val MENU_ITEM = "MENU_ITEM"
lateinit var colorScheme: ColorScheme
}
@Suppress("DEPRECATION")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityComposeBinding.inflate(layoutInflater)
@ -73,11 +68,10 @@ class ComposeActivity : DrawerActivity() {
updateActionBarTitleAndHomeButtonByString(getString(titleId))
setupDrawer(menuItemId)
colorScheme = viewThemeUtils.getScheme(this).toColorScheme()
binding.composeView.setContent {
MaterialTheme(
colorScheme = colorScheme,
colorScheme = viewThemeUtils.getColorScheme(this),
content = {
Content(destination, storageManager.user, this)
}

View file

@ -1,61 +0,0 @@
/*
* Nextcloud Android client application
*
* @author Alper Ozturk
* Copyright (C) 2024 Alper Ozturk
* Copyright (C) 2024 Nextcloud GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.nextcloud.utils.extensions
import androidx.compose.material3.ColorScheme
import androidx.compose.ui.graphics.Color
import com.vanniktech.ui.color
import scheme.Scheme
fun Scheme.toColorScheme(): ColorScheme {
return ColorScheme(
primary = Color(primary.color.argb),
onPrimary = Color(onPrimary.color.argb),
primaryContainer = Color(primaryContainer.color.argb),
onPrimaryContainer = Color(onPrimaryContainer.color.argb),
inversePrimary = Color(inversePrimary.color.argb),
secondary = Color(secondary.color.argb),
onSecondary = Color(onSecondary.color.argb),
secondaryContainer = Color(secondaryContainer.color.argb),
onSecondaryContainer = Color(onSecondaryContainer.color.argb),
tertiary = Color(tertiary.color.argb),
onTertiary = Color(onTertiary.color.argb),
tertiaryContainer = Color(tertiaryContainer.color.argb),
onTertiaryContainer = Color(onTertiaryContainer.color.argb),
background = Color(background.color.argb),
onBackground = Color(onBackground.color.argb),
surface = Color(surface.color.argb),
onSurface = Color(onSurface.color.argb),
surfaceVariant = Color(surfaceVariant.color.argb),
onSurfaceVariant = Color(onSurfaceVariant.color.argb),
surfaceTint = Color(surfaceVariant.color.argb),
inverseSurface = Color(inverseSurface.color.argb),
inverseOnSurface = Color(inverseOnSurface.color.argb),
error = Color(error.color.argb),
onError = Color(onError.color.argb),
errorContainer = Color(errorContainer.color.argb),
onErrorContainer = Color(onErrorContainer.color.argb),
outline = Color(outline.color.argb),
outlineVariant = Color(outlineVariant.color.argb),
scrim = Color(scrim.color.argb)
)
}