瀏覽代碼

Update ui library, add jetpack compose preview capability

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 年之前
父節點
當前提交
cabde4e779

+ 3 - 0
app/build.gradle

@@ -265,6 +265,8 @@ dependencies {
     implementation("androidx.compose.ui:ui")
     implementation("androidx.compose.ui:ui-graphics")
     implementation("androidx.compose.material3:material3")
+    implementation("androidx.compose.ui:ui-tooling-preview:1.6.2")
+
 
     compileOnly 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
     // remove after entire switch to lib v2
@@ -304,6 +306,7 @@ dependencies {
 
     implementation "com.github.nextcloud-deps.hwsecurity:hwsecurity-fido:$fidoVersion"
     implementation "com.github.nextcloud-deps.hwsecurity:hwsecurity-fido2:$fidoVersion"
+    debugImplementation 'androidx.compose.ui:ui-tooling:1.6.2'
 
     // document scanner not available on FDroid (generic) due to OpenCV binaries
     gplayImplementation project(':appscan')

+ 39 - 6
app/src/main/java/com/nextcloud/client/assistant/component/TaskView.kt

@@ -46,6 +46,7 @@ import androidx.compose.ui.draw.clip
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.res.stringResource
 import androidx.compose.ui.text.style.TextAlign
+import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import com.nextcloud.ui.composeComponents.bottomSheet.MoreActionsBottomSheet
@@ -78,9 +79,9 @@ fun TaskView(
 
         task.input?.let {
             Text(
-                text = stringResource(id = R.string.assistant_screen_task_view_input, it),
+                text = it,
                 color = Color.White,
-                fontSize = 18.sp,
+                fontSize = 18.sp
             )
         }
 
@@ -90,10 +91,7 @@ fun TaskView(
             HorizontalDivider(modifier = Modifier.padding(horizontal = 4.dp, vertical = 8.dp))
 
             Text(
-                text = stringResource(
-                    id = R.string.assistant_screen_task_view_output,
-                    if (expanded) it else it.take(100) + "..."
-                ),
+                text = if (expanded) it else it.take(100) + "...",
                 fontSize = 12.sp,
                 color = Color.White,
                 modifier = Modifier
@@ -139,3 +137,38 @@ fun TaskView(
         }
     }
 }
+
+@Preview
+@Composable
+private fun TaskViewPreview() {
+    val output =
+        "Lorem Ipsum is simply dummy text of the printing and " +
+            "typesetting industry. Lorem Ipsum has been the " +
+            "industry's standard dummy text ever since the 1500s, " +
+            "when an unknown printer took a galley of type and " +
+            "scrambled it to make a type specimen book. " +
+            "It has survived not only five centuries, but also " +
+            "the leap into electronic typesetting, remaining" +
+            " essentially unchanged. It wLorem Ipsum is simply dummy" +
+            " text of the printing and typesetting industry. " +
+            "Lorem Ipsum has been the industry's standard dummy " +
+            "text ever since the 1500s, when an unknown printer took a" +
+            " galley of type and scrambled it to make a type specimen book. " +
+            "It has survived not only five centuries, but also the leap " +
+            "into electronic typesetting, remaining essentially unchanged."
+
+    TaskView(
+        task = Task(
+            1,
+            "Free Prompt",
+            0,
+            "1",
+            "1",
+            "Give me text",
+            output,
+            "",
+            ""
+        )
+    ) {
+    }
+}

+ 1 - 1
app/src/main/java/com/nextcloud/ui/composeActivity/ComposeActivity.kt

@@ -71,7 +71,7 @@ class ComposeActivity : DrawerActivity() {
 
         binding.composeView.setContent {
             MaterialTheme(
-                // colorScheme = viewThemeUtils.getColorScheme(this),
+                colorScheme = viewThemeUtils.getColorScheme(this),
                 content = {
                     Content(destination, storageManager.user, this)
                 }

+ 0 - 2
app/src/main/res/values/strings.xml

@@ -35,8 +35,6 @@
     <string name="assistant_screen_create_task_alert_dialog_input_field_placeholder">Type some text</string>
 
     <string name="assistant_screen_all_task_type">All</string>
-    <string name="assistant_screen_task_view_input">Input %s</string>
-    <string name="assistant_screen_task_view_output">Output\n%s</string>
     <string name="assistant_screen_task_view_show_more">Show more</string>
     <string name="assistant_screen_task_view_show_less">Show less</string>
 

+ 0 - 7
settings.gradle

@@ -14,10 +14,3 @@ include ':appscan'
 //        substitute module('com.github.nextcloud:android-library') using project(':library')
 //    }
 //}
-
-
-includeBuild('/Users/alperozturk/Desktop/nextcloud/nextcloud_android_common') {
-    dependencySubstitution {
-        substitute module('com.github.nextcloud.android-common:ui') using project(':ui')
-    }
-}