Lerka 1 месяц назад
Родитель
Сommit
1705867c99

+ 11 - 0
app/src/main/java/com/example/myapplication/models/Editors.kt

@@ -0,0 +1,11 @@
+package com.example.myapplication.models
+
+import kotlinx.serialization.Serializable
+
+@Serializable
+data class Editors(
+    val id: Int,
+    val name: String,
+    val description: String,
+    val image:String?
+)

+ 6 - 0
app/src/main/java/com/example/myapplication/view/theme/MainActivity/MainViewModel.kt

@@ -0,0 +1,6 @@
+package com.example.myapplication.view.theme.MainActivity
+
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import kotlinx.coroutines.launch
+

+ 40 - 0
app/src/main/java/com/example/myapplication/view/theme/MainActivity/components/EditorList.kt

@@ -0,0 +1,40 @@
+package com.example.myapplication.view.theme.MainActivity.components
+
+import android.content.SharedPreferences.Editor
+import android.util.Log
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import com.example.myapplication.domain.utils.Constant
+import com.example.myapplication.models.Editors
+import io.github.jan.supabase.postgrest.from
+import io.github.jan.supabase.storage.BucketItem
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
+
+@Composable
+fun EditorList(){
+    var editors by remember { mutableStateOf<List<Editors>>(listOf()) }
+    var bucket: ByteArray? = null
+    var bytes:ByteArray? = null
+    var files: List<BucketItem>? = null
+    LaunchedEffect(Unit) {
+        withContext(Dispatchers.IO){
+            editors = Constant.supabase.from("editors").select().decodeList<Editors>()
+            editors.forEach{it-> Log.d("C",it.name)}
+        }
+    }
+
+
+    LazyColumn {
+        items(
+            editors,
+            key = {editors -> editors.id},
+        ){}
+    }
+}

+ 4 - 0
app/src/main/java/com/example/myapplication/view/theme/MainActivity/components/ItemEditor.kt

@@ -0,0 +1,4 @@
+package com.example.myapplication.view.theme.MainActivity.components
+
+class ItemEditor {
+}

+ 2 - 0
app/src/main/java/com/example/myapplication/view/theme/MainActivity/components/auth.kt

@@ -0,0 +1,2 @@
+package com.example.myapplication.view.theme.MainActivity.components
+