|
@@ -1,21 +1,41 @@
|
|
package com.example.myapplication.view.theme.MainActivity.components
|
|
package com.example.myapplication.view.theme.MainActivity.components
|
|
|
|
|
|
import android.content.SharedPreferences.Editor
|
|
import android.content.SharedPreferences.Editor
|
|
|
|
+
|
|
import android.util.Log
|
|
import android.util.Log
|
|
|
|
+import androidx.compose.material3.Text
|
|
|
|
+import androidx.compose.foundation.Image
|
|
|
|
+import androidx.compose.foundation.layout.Box
|
|
|
|
+import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
+import androidx.compose.foundation.layout.height
|
|
|
|
+import androidx.compose.foundation.layout.padding
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
import androidx.compose.foundation.lazy.items
|
|
import androidx.compose.foundation.lazy.items
|
|
|
|
+import androidx.compose.material3.CircularProgressIndicator
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
import androidx.compose.runtime.LaunchedEffect
|
|
import androidx.compose.runtime.getValue
|
|
import androidx.compose.runtime.getValue
|
|
import androidx.compose.runtime.mutableStateOf
|
|
import androidx.compose.runtime.mutableStateOf
|
|
import androidx.compose.runtime.remember
|
|
import androidx.compose.runtime.remember
|
|
import androidx.compose.runtime.setValue
|
|
import androidx.compose.runtime.setValue
|
|
|
|
+import androidx.compose.ui.Alignment
|
|
|
|
+import androidx.compose.ui.Modifier
|
|
|
|
+import androidx.compose.ui.input.pointer.PointerIcon.Companion.Text
|
|
|
|
+import androidx.compose.ui.layout.ContentScale
|
|
|
|
+import androidx.compose.ui.platform.LocalContext
|
|
|
|
+import androidx.compose.ui.semantics.Role.Companion.Image
|
|
|
|
+import androidx.compose.ui.unit.dp
|
|
import com.example.myapplication.domain.utils.Constant
|
|
import com.example.myapplication.domain.utils.Constant
|
|
import com.example.myapplication.models.Editors
|
|
import com.example.myapplication.models.Editors
|
|
import io.github.jan.supabase.postgrest.from
|
|
import io.github.jan.supabase.postgrest.from
|
|
import io.github.jan.supabase.storage.BucketItem
|
|
import io.github.jan.supabase.storage.BucketItem
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.withContext
|
|
import kotlinx.coroutines.withContext
|
|
|
|
+import coil.compose.AsyncImagePainter
|
|
|
|
+import coil.compose.rememberAsyncImagePainter
|
|
|
|
+import coil.request.ImageRequest
|
|
|
|
+import coil.size.Size
|
|
|
|
+
|
|
|
|
|
|
@Composable
|
|
@Composable
|
|
fun EditorList(){
|
|
fun EditorList(){
|
|
@@ -35,6 +55,38 @@ fun EditorList(){
|
|
items(
|
|
items(
|
|
editors,
|
|
editors,
|
|
key = {editors -> editors.id},
|
|
key = {editors -> editors.id},
|
|
- ){}
|
|
|
|
|
|
+ ){
|
|
|
|
+ editors ->
|
|
|
|
+ val imageState = rememberAsyncImagePainter(
|
|
|
|
+ model = ImageRequest.Builder(LocalContext.current).data(editors.image).size(Size.ORIGINAL).build()).state
|
|
|
|
+ if(imageState is AsyncImagePainter.State.Error)
|
|
|
|
+ {
|
|
|
|
+ Box(
|
|
|
|
+ modifier = Modifier
|
|
|
|
+ .fillMaxWidth()
|
|
|
|
+ .height(200.dp),
|
|
|
|
+ contentAlignment = Alignment.Center
|
|
|
|
+ )
|
|
|
|
+ {
|
|
|
|
+ CircularProgressIndicator()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(imageState is AsyncImagePainter.State.Success)
|
|
|
|
+ {
|
|
|
|
+ Image(
|
|
|
|
+ modifier = Modifier
|
|
|
|
+ .fillMaxWidth()
|
|
|
|
+ .height(200.dp),
|
|
|
|
+ painter = imageState.painter,
|
|
|
|
+ contentDescription ="",
|
|
|
|
+ contentScale = ContentScale.Crop
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ Text(
|
|
|
|
+ editors.name,
|
|
|
|
+ modifier = Modifier.padding(8.dp)
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|