The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: update product sample
Hieu Vu89efd01aa8a7
diff --git a/examples/product-sample-supabase-kt/LICENSE b/examples/product-sample-supabase-kt/LICENSEnew file mode 100644index 00000000000..4651f913ec3--- /dev/null+++ b/examples/product-sample-supabase-kt/LICENSE@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2023 Hieu Vu++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/examples/product-sample-supabase-kt/README.md b/examples/product-sample-supabase-kt/README.mdnew file mode 100644index 00000000000..5e3d0c88cc5--- /dev/null+++ b/examples/product-sample-supabase-kt/README.md@@ -0,0 +1,20 @@+# product-sample-supabase-kt+Demonstration and best practices of how to use Supabase database for CRUD operation++[](https://github.com/hieuwu/product-sample-supabase-kt/actions/workflows/app-build.yml)++<!-- <img width="964" alt="Screen Shot 2023-06-02 at 21 33 16" src="https://github.com/hieuwu/product-sample-supabase-kt/assets/43868345/288eef97-d8fe-422f-8bb3-1c8424bab08e">++<img width="1092" alt="Screen Shot 2023-06-05 at 21 39 24" src="https://github.com/hieuwu/product-sample-supabase-kt/assets/43868345/3f154fda-aa9e-4baa-81f2-5b744c7ad2fe"> -->++++### Setup+Android Studio with SDK 30 or above+Open `local.properties` file, add these+```kotlin+API_KEY=YOUR_SUPABASE_API_KEY+SECRET=YOUR_SUPABASE_SECRET+SUPABASE_URL=YOUR_SUPABASE_URL++```diff --git a/examples/product-sample-supabase-kt/app/.gitignore b/examples/product-sample-supabase-kt/app/.gitignorenew file mode 100644index 00000000000..42afabfd2ab--- /dev/null+++ b/examples/product-sample-supabase-kt/app/.gitignore@@ -0,0 +1 @@+/build\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/build.gradle b/examples/product-sample-supabase-kt/app/build.gradlenew file mode 100644index 00000000000..1cdd75de001--- /dev/null+++ b/examples/product-sample-supabase-kt/app/build.gradle@@ -0,0 +1,98 @@+plugins {+ id 'com.android.application'+ id 'org.jetbrains.kotlin.android'+ id 'com.google.dagger.hilt.android'+ id 'kotlin-kapt'+ id 'dagger.hilt.android.plugin'+ id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.21'+}++android {+ namespace 'com.example.manageproducts'+ compileSdk 33++ defaultConfig {+ applicationId "com.example.manageproducts"+ minSdk 28+ targetSdk 33+ versionCode 1+ versionName "1.0"++ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"+ vectorDrawables {+ useSupportLibrary true+ }+ Properties properties = new Properties()+ properties.load(project.rootProject.file("local.properties").newDataInputStream())+ buildConfigField("String", "API_KEY", "\"${properties.getProperty("API_KEY")}\"")+ buildConfigField("String", "SECRET", "\"${properties.getProperty("SECRET")}\"")+ buildConfigField("String", "SUPABASE_URL", "\"${properties.getProperty("SUPABASE_URL")}\"")+ }++ buildTypes {+ release {+ minifyEnabled false+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'+ }+ }+ compileOptions {+ sourceCompatibility JavaVersion.VERSION_1_8+ targetCompatibility JavaVersion.VERSION_1_8+ }+ kotlinOptions {+ jvmTarget = '1.8'+ }+ buildFeatures {+ compose true+ }+ composeOptions {+ kotlinCompilerExtensionVersion '1.2.0'+ }+ packagingOptions {+ resources {+ excludes += '/META-INF/{AL2.0,LGPL2.1}'+ }+ }+}++dependencies {++ implementation 'androidx.core:core-ktx:1.7.0'+ implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'+ implementation 'androidx.activity:activity-compose:1.3.1'+ implementation "androidx.compose.ui:ui:$compose_version"+ implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"+ implementation 'androidx.compose.material3:material3:1.0.0-alpha11'+ testImplementation 'junit:junit:4.13.2'+ androidTestImplementation 'androidx.test.ext:junit:1.1.5'+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'+ androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"+ debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"+ debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"++ implementation 'androidx.compose.material3:material3:1.0.0-alpha02'+ implementation "androidx.compose.material:material:1.1.1"++ // Supabase setup+ implementation("io.ktor:ktor-client-cio:1.6.0")+ implementation("io.github.jan-tennert.supabase:postgrest-kt-android:1.0.0")+ implementation "io.ktor:ktor-client-android:2.2.1"+ implementation "io.ktor:ktor-utils-jvm:1.6.0"+ implementation "io.ktor:ktor-client-logging-jvm:1.6.0"+ implementation("io.ktor:ktor-client-core:2.2.4")+ implementation("io.github.jan-tennert.supabase:storage-kt:1.0.0")+ implementation "io.coil-kt:coil-compose:1.3.2"+++ implementation "com.google.dagger:hilt-android:$hilt_version"+ annotationProcessor "com.google.dagger:hilt-compiler:$hilt_version"+ implementation("androidx.hilt:hilt-navigation-compose:1.0.0")++ // For instrumentation tests+ androidTestImplementation "com.google.dagger:hilt-android-testing:$hilt_version"+ androidTestAnnotationProcessor "com.google.dagger:hilt-compiler:$hilt_version"+ kapt "com.google.dagger:hilt-android-compiler:$hilt_version"++ implementation 'androidx.navigation:navigation-compose:2.5.3'+ implementation 'com.google.accompanist:accompanist-swiperefresh:0.24.13-rc'+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/proguard-rules.pro b/examples/product-sample-supabase-kt/app/proguard-rules.pronew file mode 100644index 00000000000..481bb434814--- /dev/null+++ b/examples/product-sample-supabase-kt/app/proguard-rules.pro@@ -0,0 +1,21 @@+# Add project specific ProGuard rules here.+# You can control the set of applied configuration files using the+# proguardFiles setting in build.gradle.+#+# For more details, see+# http://developer.android.com/guide/developing/tools/proguard.html++# If your project uses WebView with JS, uncomment the following+# and specify the fully qualified class name to the JavaScript interface+# class:+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {+# public *;+#}++# Uncomment this to preserve the line number information for+# debugging stack traces.+#-keepattributes SourceFile,LineNumberTable++# If you keep the line number information, uncomment this to+# hide the original source file name.+#-renamesourcefileattribute SourceFile\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/androidTest/java/com/example/manageproducts/ExampleInstrumentedTest.kt b/examples/product-sample-supabase-kt/app/src/androidTest/java/com/example/manageproducts/ExampleInstrumentedTest.ktnew file mode 100644index 00000000000..8bafdae8a69--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/androidTest/java/com/example/manageproducts/ExampleInstrumentedTest.kt@@ -0,0 +1,24 @@+package com.example.manageproducts++import androidx.test.platform.app.InstrumentationRegistry+import androidx.test.ext.junit.runners.AndroidJUnit4++import org.junit.Test+import org.junit.runner.RunWith++import org.junit.Assert.*++/**+ * Instrumented test, which will execute on an Android device.+ *+ * See [testing documentation](http://d.android.com/tools/testing).+ */+@RunWith(AndroidJUnit4::class)+class ExampleInstrumentedTest {+ @Test+ fun useAppContext() {+ // Context of the app under test.+ val appContext = InstrumentationRegistry.getInstrumentation().targetContext+ assertEquals("com.example.manageproducts", appContext.packageName)+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/AndroidManifest.xml b/examples/product-sample-supabase-kt/app/src/main/AndroidManifest.xmlnew file mode 100644index 00000000000..3ce2a8a88c6--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/AndroidManifest.xml@@ -0,0 +1,28 @@+<?xml version="1.0" encoding="utf-8"?>+<manifest xmlns:android="http://schemas.android.com/apk/res/android"+ xmlns:tools="http://schemas.android.com/tools">+ <uses-permission android:name="android.permission.INTERNET"/>+ <application+ android:name=".ManageProductApplication"+ android:allowBackup="true"+ android:dataExtractionRules="@xml/data_extraction_rules"+ android:fullBackupContent="@xml/backup_rules"+ android:icon="@mipmap/ic_launcher"+ android:label="@string/app_name"+ android:supportsRtl="true"+ android:theme="@style/Theme.ManageProducts"+ tools:targetApi="31">+ <activity+ android:name=".MainActivity"+ android:exported="true"+ android:label="@string/app_name"+ android:theme="@style/Theme.ManageProducts">+ <intent-filter>+ <action android:name="android.intent.action.MAIN" />++ <category android:name="android.intent.category.LAUNCHER" />+ </intent-filter>+ </activity>+ </application>++</manifest>\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/MainActivity.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/MainActivity.ktnew file mode 100644index 00000000000..da28bf02ef9--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/MainActivity.kt@@ -0,0 +1,58 @@+package com.example.manageproducts++import android.os.Bundle+import androidx.activity.ComponentActivity+import androidx.activity.compose.setContent+import androidx.compose.foundation.layout.padding+import androidx.compose.material3.ExperimentalMaterial3Api+import androidx.compose.material3.Scaffold+import androidx.compose.material3.Text+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.tooling.preview.Preview+import androidx.navigation.compose.NavHost+import androidx.navigation.compose.currentBackStackEntryAsState+import androidx.navigation.compose.rememberNavController+import com.example.manageproducts.presentation.navigation.ProductListDestination+import com.example.manageproducts.presentation.navigation.navRegistration+import com.example.manageproducts.ui.theme.ManageProductsTheme+import dagger.hilt.android.AndroidEntryPoint++@AndroidEntryPoint+class MainActivity : ComponentActivity() {+ @OptIn(ExperimentalMaterial3Api::class)+ override fun onCreate(savedInstanceState: Bundle?) {+ super.onCreate(savedInstanceState)+ setContent {+ ManageProductsTheme {+ // A surface container using the 'background' color from the theme+ val navController = rememberNavController()+ val currentBackStack by navController.currentBackStackEntryAsState()+ val currentDestination = currentBackStack?.destination+ Scaffold { innerPadding ->+ NavHost(+ navController,+ startDestination = ProductListDestination.route,+ Modifier.padding(innerPadding)+ ) {+ navRegistration(navController)+ }+ }+ }+ }+ }+}++@Composable+fun Greeting(name: String) {+ Text(text = "Hello $name!")+}++@Preview(showBackground = true)+@Composable+fun DefaultPreview() {+ ManageProductsTheme {+ Greeting("Android")+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ManageProductApplication.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ManageProductApplication.ktnew file mode 100644index 00000000000..664636731eb--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ManageProductApplication.kt@@ -0,0 +1,7 @@+package com.example.manageproducts++import android.app.Application+import dagger.hilt.android.HiltAndroidApp++@HiltAndroidApp+class ManageProductApplication: Application()\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/network/dto/ProductDto.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/network/dto/ProductDto.ktnew file mode 100644index 00000000000..3fcf772d9b7--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/network/dto/ProductDto.kt@@ -0,0 +1,20 @@+package com.example.manageproducts.data.network.dto++import kotlinx.serialization.SerialName+import kotlinx.serialization.Serializable++@Serializable+data class ProductDto(++ @SerialName("name")+ val name: String,++ @SerialName("price")+ val price: Double,++ @SerialName("image")+ val image: String? = "",++ @SerialName("id")+ val id: String? = "",+)diff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/ImageRepository.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/ImageRepository.ktnew file mode 100644index 00000000000..4a84ebce96e--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/ImageRepository.kt@@ -0,0 +1,6 @@+package com.example.manageproducts.data.repository++interface ImageRepository {+ suspend fun uploadImage(fileName: String, image: ByteArray): String+ suspend fun getImage()+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/ProductRepository.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/ProductRepository.ktnew file mode 100644index 00000000000..9a431cbfcfd--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/ProductRepository.kt@@ -0,0 +1,14 @@+package com.example.manageproducts.data.repository++import com.example.manageproducts.data.network.dto.ProductDto+import com.example.manageproducts.domain.model.Product++interface ProductRepository {+ suspend fun createProduct(product: Product): Boolean+ suspend fun getProducts(): List<ProductDto>?+ suspend fun getProduct(id: String): ProductDto+ suspend fun deleteProduct(id: String)+ suspend fun updateProduct(+ id: String, name: String, price: Double, imageName: String, imageFile: ByteArray+ )+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/impl/ImageRepositoryImpl.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/impl/ImageRepositoryImpl.ktnew file mode 100644index 00000000000..348c40ec667--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/impl/ImageRepositoryImpl.kt@@ -0,0 +1,24 @@+package com.example.manageproducts.data.repository.impl++import com.example.manageproducts.BuildConfig+import com.example.manageproducts.data.repository.ImageRepository+import io.github.jan.supabase.storage.Storage+import javax.inject.Inject++class ImageRepositoryImpl @Inject constructor(+ private val storage: Storage+) : ImageRepository {+ override suspend fun uploadImage(fileName: String, image: ByteArray): String {+ val result =+ storage["Product%20Image"].upload(path = "$fileName.png", data = image, upsert = false)+ return result+ }++ override suspend fun getImage() {+ TODO("Not yet implemented")+ }++ private fun buildImageUrl(imageFileName: String) =+ "${BuildConfig.SUPABASE_URL}/storage/v1/object/public/"++}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/impl/ProductRepositoryImpl.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/impl/ProductRepositoryImpl.ktnew file mode 100644index 00000000000..058ea96d636--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/data/repository/impl/ProductRepositoryImpl.kt@@ -0,0 +1,94 @@+package com.example.manageproducts.data.repository.impl++import com.example.manageproducts.BuildConfig+import com.example.manageproducts.data.network.dto.ProductDto+import com.example.manageproducts.data.repository.ProductRepository+import com.example.manageproducts.domain.model.Product+import io.github.jan.supabase.postgrest.Postgrest+import io.github.jan.supabase.storage.Storage+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.withContext+import javax.inject.Inject++class ProductRepositoryImpl @Inject constructor(+ private val postgrest: Postgrest,+ private val storage: Storage,+) : ProductRepository {+ override suspend fun createProduct(product: Product): Boolean {+ return try {+ withContext(Dispatchers.IO) {+ val productDto = ProductDto(+ name = product.name,+ price = product.price,+ )+ postgrest["products"].insert(productDto)+ true+ }+ true+ } catch (e: java.lang.Exception) {+ throw e+ }+ }++ override suspend fun getProducts(): List<ProductDto>? {+ return withContext(Dispatchers.IO) {+ val result = postgrest["products"]+ .select().decodeList<ProductDto>()+ result+ }+ }+++ override suspend fun getProduct(id: String): ProductDto {+ return withContext(Dispatchers.IO) {+ postgrest["products"].select {+ eq("id", id)+ }.decodeSingle<ProductDto>()+ }+ }++ override suspend fun deleteProduct(id: String) {+ return withContext(Dispatchers.IO) {+ postgrest["products"].delete {+ eq("id", id)+ }+ }+ }++ override suspend fun updateProduct(+ id: String,+ name: String,+ price: Double,+ imageName: String,+ imageFile: ByteArray+ ) {+ withContext(Dispatchers.IO) {++ if (imageFile.isNotEmpty()) {+ val imageUrl =+ storage["Product%20Image"].upload(+ path = "$imageName.png",+ data = imageFile,+ upsert = true+ )+ postgrest["products"].update({+ set("name", name)+ set("price", price)+ set("image", buildImageUrl(imageFileName = imageUrl))+ }) {+ eq("id", id)+ }+ } else {+ postgrest["products"].update({+ set("name", name)+ set("price", price)+ }) {+ eq("id", id)+ }+ }+ }+ }++ private fun buildImageUrl(imageFileName: String) =+ "${BuildConfig.SUPABASE_URL}/storage/v1/object/public/${imageFileName}".replace(" ", "%20")+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/di/RepositoryModule.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/di/RepositoryModule.ktnew file mode 100644index 00000000000..25f416f383f--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/di/RepositoryModule.kt@@ -0,0 +1,22 @@+package com.example.manageproducts.di++import com.example.manageproducts.data.repository.ImageRepository+import com.example.manageproducts.data.repository.ProductRepository+import com.example.manageproducts.data.repository.impl.ImageRepositoryImpl+import com.example.manageproducts.data.repository.impl.ProductRepositoryImpl+import dagger.Binds+import dagger.Module+import dagger.hilt.InstallIn+import dagger.hilt.components.SingletonComponent++@InstallIn(SingletonComponent::class)+@Module+abstract class RepositoryModule {++ @Binds+ abstract fun bindProductRepository(impl: ProductRepositoryImpl): ProductRepository++ @Binds+ abstract fun bindImageRepository(impl: ImageRepositoryImpl): ImageRepository++}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/di/SupabaseModule.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/di/SupabaseModule.ktnew file mode 100644index 00000000000..a9a55683d05--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/di/SupabaseModule.kt@@ -0,0 +1,55 @@+package com.example.manageproducts.di++import com.example.manageproducts.BuildConfig+import dagger.Module+import dagger.Provides+import dagger.hilt.InstallIn+import dagger.hilt.components.SingletonComponent+import io.github.jan.supabase.SupabaseClient+import io.github.jan.supabase.createSupabaseClient+import io.github.jan.supabase.gotrue.GoTrue+import io.github.jan.supabase.gotrue.gotrue+import io.github.jan.supabase.postgrest.Postgrest+import io.github.jan.supabase.postgrest.postgrest+import io.github.jan.supabase.storage.Storage+import io.github.jan.supabase.storage.storage+import javax.inject.Singleton+++@InstallIn(SingletonComponent::class)+@Module+object SupabaseModule {++ @Provides+ @Singleton+ fun provideSupabaseClient(): SupabaseClient {+ return createSupabaseClient(+ supabaseUrl = BuildConfig.SUPABASE_URL,+ supabaseKey = BuildConfig.API_KEY+ ) {+ install(Postgrest)+ install(GoTrue)+ install(Storage)+ }+ }++ @Provides+ @Singleton+ fun provideSupabaseDatabase(client: SupabaseClient): Postgrest {+ return client.postgrest+ }++ @Provides+ @Singleton+ fun provideSupabaseGoTrue(client: SupabaseClient): GoTrue {+ return client.gotrue+ }+++ @Provides+ @Singleton+ fun provideSupabaseStorage(client: SupabaseClient): Storage {+ return client.storage+ }++}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/di/UseCaseModule.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/di/UseCaseModule.ktnew file mode 100644index 00000000000..fdc1af1de4d--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/di/UseCaseModule.kt@@ -0,0 +1,31 @@+package com.example.manageproducts.di++import com.example.manageproducts.domain.usecase.*+import com.example.manageproducts.domain.usecase.impl.*+import dagger.Binds+import dagger.Module+import dagger.hilt.InstallIn+import dagger.hilt.components.SingletonComponent++@InstallIn(SingletonComponent::class)+@Module+abstract class UseCaseModule {++ @Binds+ abstract fun bindGetProductsUseCase(impl: GetProductsUseCaseImpl): GetProductsUseCase++ @Binds+ abstract fun bindCreateProductUseCase(impl: CreateProductUseCaseImpl): CreateProductUseCase++ @Binds+ abstract fun bindGetProductDetailsUseCase(impl: GetProductDetailsUseCaseImpl): GetProductDetailsUseCase++ @Binds+ abstract fun bindDeleteProductUseCase(impl: DeleteProductUseCaseImpl): DeleteProductUseCase++ @Binds+ abstract fun bindUpdateProductUseCase(impl: UpdateProductUseCaseImpl): UpdateProductUseCase++ @Binds+ abstract fun bindUploadImageUseCaseImpl(impl: UploadImageUseCaseImpl): UploadImageUseCase+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/model/Product.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/model/Product.ktnew file mode 100644index 00000000000..2072b55b9a6--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/model/Product.kt@@ -0,0 +1,8 @@+package com.example.manageproducts.domain.model++data class Product(+ val id: String,+ val name: String,+ val price: Double,+ val image: String = ""+)diff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/CreateProductUseCase.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/CreateProductUseCase.ktnew file mode 100644index 00000000000..768ed01e195--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/CreateProductUseCase.kt@@ -0,0 +1,16 @@+package com.example.manageproducts.domain.usecase++import com.example.manageproducts.domain.model.Product++interface CreateProductUseCase : UseCase<CreateProductUseCase.Input, CreateProductUseCase.Output> {+ class Input(val product: Product)+ sealed class Output {+ class Success(val result: Boolean) : Output()+ open class Failure : Output() {+ object Conflict : Failure()+ object Unauthorized : Failure()+ object BadRequest : Failure()+ object InternalError : Failure()+ }+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/DeleteProductUseCase.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/DeleteProductUseCase.ktnew file mode 100644index 00000000000..b9fe9bf9535--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/DeleteProductUseCase.kt@@ -0,0 +1,9 @@+package com.example.manageproducts.domain.usecase++interface DeleteProductUseCase: UseCase<DeleteProductUseCase.Input, DeleteProductUseCase.Output> {+ class Input(val productId: String)++ sealed class Output {+ object Success: Output()+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/GetProductDetailsUseCase.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/GetProductDetailsUseCase.ktnew file mode 100644index 00000000000..f012e15e5f8--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/GetProductDetailsUseCase.kt@@ -0,0 +1,12 @@+package com.example.manageproducts.domain.usecase++import com.example.manageproducts.domain.model.Product++interface GetProductDetailsUseCase :+ UseCase<GetProductDetailsUseCase.Input, GetProductDetailsUseCase.Output> {+ class Input(val id: String)+ sealed class Output {+ class Success(val data: Product): Output()+ object Failure : Output()+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/GetProductsUseCase.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/GetProductsUseCase.ktnew file mode 100644index 00000000000..36fc89e1ed3--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/GetProductsUseCase.kt@@ -0,0 +1,11 @@+package com.example.manageproducts.domain.usecase++import com.example.manageproducts.domain.model.Product++interface GetProductsUseCase : UseCase<Unit, GetProductsUseCase.Output> {+ sealed class Output {+ class Success(val data: List<Product>): Output()+ object Failure : Output()+ }++}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/UpdateProductUseCase.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/UpdateProductUseCase.ktnew file mode 100644index 00000000000..e62781ac451--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/UpdateProductUseCase.kt@@ -0,0 +1,16 @@+package com.example.manageproducts.domain.usecase++interface UpdateProductUseCase : UseCase<UpdateProductUseCase.Input, UpdateProductUseCase.Output> {+ class Input(+ val id: String,+ val name: String,+ val price: Double,+ val imageName: String,+ val imageFile: ByteArray,+ )++ sealed class Output() {+ object Success : Output()+ object Failure : Output()+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/UploadImageUseCase.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/UploadImageUseCase.ktnew file mode 100644index 00000000000..83a7eb11e01--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/UploadImageUseCase.kt@@ -0,0 +1,8 @@+package com.example.manageproducts.domain.usecase++interface UploadImageUseCase : UseCase<UploadImageUseCase.Input, UploadImageUseCase.Output> {+ class Input(val fileName: String, val imageByteArray: ByteArray)+ sealed class Output {+ class Success(val image: String? = null) : Output()+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/UseCase.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/UseCase.ktnew file mode 100644index 00000000000..90c37002815--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/UseCase.kt@@ -0,0 +1,5 @@+package com.example.manageproducts.domain.usecase++interface UseCase<InputT, OutputT> {+ suspend fun execute(input: InputT): OutputT+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/CreateProductUseCaseImpl.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/CreateProductUseCaseImpl.ktnew file mode 100644index 00000000000..806a386b1db--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/CreateProductUseCaseImpl.kt@@ -0,0 +1,28 @@+package com.example.manageproducts.domain.usecase.impl++import com.example.manageproducts.data.repository.ProductRepository+import com.example.manageproducts.domain.usecase.CreateProductUseCase+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.withContext+import java.net.HttpURLConnection+import javax.inject.Inject++class CreateProductUseCaseImpl @Inject constructor(+ private val productRepository: ProductRepository,+) : CreateProductUseCase {+ override suspend fun execute(input: CreateProductUseCase.Input): CreateProductUseCase.Output {+ return try {+ withContext(Dispatchers.IO) {+ val result = productRepository.createProduct(product = input.product)+ if (result) {+ CreateProductUseCase.Output.Success(result = result)+ } else {+ CreateProductUseCase.Output.Failure()+ }+ }+ } catch (e: Exception) {+ return CreateProductUseCase.Output.Failure.Conflict++ }+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/DeleteProductUseCaseImpl.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/DeleteProductUseCaseImpl.ktnew file mode 100644index 00000000000..ce454c3d73a--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/DeleteProductUseCaseImpl.kt@@ -0,0 +1,14 @@+package com.example.manageproducts.domain.usecase.impl++import com.example.manageproducts.data.repository.ProductRepository+import com.example.manageproducts.domain.usecase.DeleteProductUseCase+import javax.inject.Inject++class DeleteProductUseCaseImpl @Inject constructor(+ private val productRepository: ProductRepository+) : DeleteProductUseCase {+ override suspend fun execute(input: DeleteProductUseCase.Input): DeleteProductUseCase.Output {+ productRepository.deleteProduct(input.productId)+ return DeleteProductUseCase.Output.Success+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/GetProductDetailsUseCaseImpl.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/GetProductDetailsUseCaseImpl.ktnew file mode 100644index 00000000000..2fa94333d9b--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/GetProductDetailsUseCaseImpl.kt@@ -0,0 +1,22 @@+package com.example.manageproducts.domain.usecase.impl++import com.example.manageproducts.data.repository.ProductRepository+import com.example.manageproducts.domain.model.Product+import com.example.manageproducts.domain.usecase.GetProductDetailsUseCase+import javax.inject.Inject++class GetProductDetailsUseCaseImpl @Inject constructor(+ private val productRepository: ProductRepository,+) : GetProductDetailsUseCase {+ override suspend fun execute(input: GetProductDetailsUseCase.Input): GetProductDetailsUseCase.Output {+ val result = productRepository.getProduct(input.id)+ return GetProductDetailsUseCase.Output.Success(+ data = Product(+ id = result.id ?: "",+ name = result.name,+ price = result.price,+ image = result.image ?: "",+ )+ )+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/GetProductsUseCaseImpl.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/GetProductsUseCaseImpl.ktnew file mode 100644index 00000000000..bf36d7bbb07--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/GetProductsUseCaseImpl.kt@@ -0,0 +1,29 @@+package com.example.manageproducts.domain.usecase.impl++import com.example.manageproducts.data.network.dto.ProductDto+import com.example.manageproducts.data.repository.ProductRepository+import com.example.manageproducts.domain.model.Product+import com.example.manageproducts.domain.usecase.GetProductsUseCase+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.withContext+import javax.inject.Inject++class GetProductsUseCaseImpl @Inject constructor(+ private val productRepository: ProductRepository,+) : GetProductsUseCase {+ override suspend fun execute(input: Unit): GetProductsUseCase.Output =+ withContext(Dispatchers.IO) {+ val result = productRepository.getProducts()+ return@withContext result?.let { it ->+ GetProductsUseCase.Output.Success(data = it.map {+ Product(+ id = it.id ?: "",+ name = it.name,+ price = it.price,+ image = it.image ?: ""+ )+ })+ } ?: GetProductsUseCase.Output.Failure+ }+}+diff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/UpdateProductUseCaseImpl.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/UpdateProductUseCaseImpl.ktnew file mode 100644index 00000000000..60fac7586f3--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/UpdateProductUseCaseImpl.kt@@ -0,0 +1,17 @@+package com.example.manageproducts.domain.usecase.impl++import com.example.manageproducts.data.repository.ProductRepository+import com.example.manageproducts.domain.usecase.UpdateProductUseCase+import javax.inject.Inject++class UpdateProductUseCaseImpl @Inject constructor(+ private val productRepository: ProductRepository+) : UpdateProductUseCase {+ override suspend fun execute(input: UpdateProductUseCase.Input): UpdateProductUseCase.Output {+ productRepository.updateProduct(+ id = input.id, name = input.name, price = input.price,+ imageName = input.imageName, imageFile = input.imageFile+ )+ return UpdateProductUseCase.Output.Success+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/UploadImageUseCaseImpl.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/UploadImageUseCaseImpl.ktnew file mode 100644index 00000000000..b12eb7af3c4--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/domain/usecase/impl/UploadImageUseCaseImpl.kt@@ -0,0 +1,20 @@+package com.example.manageproducts.domain.usecase.impl++import android.util.Log+import com.example.manageproducts.data.repository.ImageRepository+import com.example.manageproducts.domain.usecase.UploadImageUseCase+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.withContext+import javax.inject.Inject++class UploadImageUseCaseImpl @Inject constructor(+ private val imageRepository: ImageRepository+) : UploadImageUseCase {+ override suspend fun execute(input: UploadImageUseCase.Input): UploadImageUseCase.Output {+ return withContext(Dispatchers.IO) {+ val url = imageRepository.uploadImage(input.fileName, input.imageByteArray)+ Log.d("UploadImageUseCase", url)+ UploadImageUseCase.Output.Success()+ }+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/AddProductContract.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/AddProductContract.ktnew file mode 100644index 00000000000..d34d0d0acfc--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/AddProductContract.kt@@ -0,0 +1,14 @@+package com.example.manageproducts.presentation.feature.addproduct++import com.example.manageproducts.domain.usecase.CreateProductUseCase+import kotlinx.coroutines.flow.Flow++interface AddProductContract {++ val navigateAddProductSuccess: Flow<CreateProductUseCase.Output?>+ val isLoading: Flow<Boolean>+ val showSuccessMessage: Flow<Boolean>+ fun onCreateProduct(name: String, price: Double)+ fun onAddMoreProductSelected()+ fun onRetrySelected()+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/AddProductScreen.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/AddProductScreen.ktnew file mode 100644index 00000000000..7e4584956fa--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/AddProductScreen.kt@@ -0,0 +1,129 @@+package com.example.manageproducts.presentation.feature.addproduct++import android.annotation.SuppressLint+import androidx.compose.foundation.layout.*+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.foundation.text.KeyboardOptions+import androidx.compose.material.TopAppBar+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.filled.ArrowBack+import androidx.compose.material3.*+import androidx.compose.material3.Button+import androidx.compose.material3.Icon+import androidx.compose.material3.IconButton+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.OutlinedButton+import androidx.compose.material3.Text+import androidx.compose.runtime.*+import androidx.compose.runtime.saveable.rememberSaveable+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.input.KeyboardType+import androidx.compose.ui.unit.dp+import androidx.hilt.navigation.compose.hiltViewModel+import androidx.navigation.NavController+import com.example.manageproducts.R+import com.example.manageproducts.domain.usecase.CreateProductUseCase+import com.example.manageproducts.presentation.feature.addproduct.composables.FailScreen+import com.example.manageproducts.presentation.feature.addproduct.composables.LoadingScreen+import com.example.manageproducts.presentation.feature.addproduct.composables.SuccessScreen++@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")+@OptIn(ExperimentalMaterial3Api::class)+@Composable+fun AddProductScreen(+ modifier: Modifier = Modifier,+ navController: NavController,+ viewModel: AddProductViewModel = hiltViewModel(),+) {+ Scaffold(+ topBar = {+ TopAppBar(+ navigationIcon = {+ IconButton(onClick = {+ navController.navigateUp()+ }) {+ Icon(+ imageVector = Icons.Filled.ArrowBack,+ contentDescription = null,+ tint = MaterialTheme.colorScheme.onPrimary+ )+ }+ },+ backgroundColor = MaterialTheme.colorScheme.primary,+ title = {+ Text(+ text = stringResource(R.string.add_product_text_screen_title),+ color = MaterialTheme.colorScheme.onPrimary,+ )+ },+ )+ }+ ) { padding ->+ Column(+ modifier = modifier+ .padding(padding)+ .padding(16.dp)+ .fillMaxSize()+ ) {+ val name = rememberSaveable { mutableStateOf("") }+ val price = rememberSaveable { mutableStateOf("") }+ OutlinedTextField(+ label = {+ Text(+ text = "Product name",+ color = MaterialTheme.colorScheme.primary,+ style = MaterialTheme.typography.titleMedium+ )+ },+ maxLines = 2,+ shape = RoundedCornerShape(32),+ modifier = modifier.fillMaxWidth(),+ value = name.value,+ onValueChange = {+ name.value = it+ },+ )+ Spacer(modifier = modifier.height(12.dp))+ OutlinedTextField(+ label = {+ Text(+ text = "Product price",+ color = MaterialTheme.colorScheme.primary,+ style = MaterialTheme.typography.titleMedium+ )+ },+ maxLines = 2,+ shape = RoundedCornerShape(32),+ modifier = modifier.fillMaxWidth(),+ value = price.value,+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),+ onValueChange = {+ price.value = it+ },+ )+ Spacer(modifier = modifier.height(12.dp))+ Spacer(modifier = modifier.weight(1f))+ OutlinedButton(+ modifier = modifier+ .fillMaxWidth(),+ onClick = {+ navController.navigateUp()+ }) {+ Text(text = "Cancel")+ }+ Spacer(modifier = modifier.height(12.dp))+ Button(+ modifier = modifier.fillMaxWidth(),+ onClick = {+ viewModel.onCreateProduct(+ name = name.value,+ price = if (price.value.isEmpty()) 0.0 else price.value.trim()+ .toDouble(),+ )+ }) {+ Text(text = "Add Product")+ }+ }+ }+}diff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/AddProductViewModel.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/AddProductViewModel.ktnew file mode 100644index 00000000000..aa0ff925d8b--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/AddProductViewModel.kt@@ -0,0 +1,36 @@+package com.example.manageproducts.presentation.feature.addproduct++import androidx.lifecycle.ViewModel+import androidx.lifecycle.viewModelScope+import com.example.manageproducts.data.repository.ProductRepository+import com.example.manageproducts.domain.model.Product+import com.example.manageproducts.domain.usecase.CreateProductUseCase+import dagger.hilt.android.lifecycle.HiltViewModel+import kotlinx.coroutines.flow.Flow+import kotlinx.coroutines.flow.MutableStateFlow+import kotlinx.coroutines.launch+import java.util.UUID+import javax.inject.Inject++@HiltViewModel+class AddProductViewModel @Inject constructor(+ private val productRepository: ProductRepository,+) : ViewModel() {++ private val _isLoading = MutableStateFlow(false)+ val isLoading: Flow<Boolean> = _isLoading++ fun onCreateProduct(name: String, price: Double) {+ if (name.isEmpty() || price <= 0) return+ viewModelScope.launch {+ _isLoading.value = true+ val product = Product(+ id = UUID.randomUUID().toString(),+ name = name,+ price = price,+ )+ productRepository.createProduct(product = product)+ _isLoading.value = false+ }+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/composables/FailScreen.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/composables/FailScreen.ktnew file mode 100644index 00000000000..a5e40791880--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/composables/FailScreen.kt@@ -0,0 +1,51 @@+package com.example.manageproducts.presentation.feature.addproduct.composables++import androidx.compose.foundation.layout.*+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.filled.Close+import androidx.compose.material3.Icon+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.OutlinedButton+import androidx.compose.material3.Text+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.unit.dp++@Composable+fun FailScreen(+ modifier: Modifier = Modifier,+ message: String,+ reason: String,+ onRetrySelected: () -> Unit,+ onNavigateBack: () -> Unit,+) {++ Column(+ modifier = modifier+ .padding(16.dp),+ horizontalAlignment = Alignment.CenterHorizontally) {+ Icon(imageVector = Icons.Filled.Close, contentDescription = null,+ modifier = modifier.size(128.dp),+ tint = Color.Red)+ Text(text = message,+ style = MaterialTheme.typography.titleLarge)+ Spacer(modifier = modifier.height(24.dp))+ Text(text = reason)+ Spacer(modifier = modifier.height(24.dp))+ OutlinedButton(+ modifier = modifier+ .fillMaxWidth(),+ onClick = onRetrySelected) {+ Text(text = "Retry")+ }+ Spacer(modifier = modifier.height(12.dp))+ OutlinedButton(+ modifier = modifier+ .fillMaxWidth(),+ onClick = onNavigateBack) {+ Text(text = "Cancel")+ }+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/composables/LoadingScreen.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/composables/LoadingScreen.ktnew file mode 100644index 00000000000..7a861d55494--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/composables/LoadingScreen.kt@@ -0,0 +1,36 @@+package com.example.manageproducts.presentation.feature.addproduct.composables++import androidx.compose.foundation.layout.*+import androidx.compose.material.CircularProgressIndicator+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.OutlinedButton+import androidx.compose.material3.Text+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.unit.dp++@Composable+fun LoadingScreen(+ modifier: Modifier = Modifier,+ message: String,+ onCancelSelected: () -> Unit,+) {+ Column(+ modifier = modifier+ .padding(16.dp),+ horizontalAlignment = Alignment.CenterHorizontally) {+ CircularProgressIndicator(modifier = modifier.size(64.dp))+ Text(text = message,+ style = MaterialTheme.typography.titleLarge)+ Spacer(modifier = modifier.weight(1f))+ OutlinedButton(+ modifier = modifier+ .fillMaxWidth(),+ onClick = onCancelSelected+ ) {+ Text(text = "Cancel")+ }+ }++}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/composables/SuccessScreen.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/composables/SuccessScreen.ktnew file mode 100644index 00000000000..780ac68a50c--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/addproduct/composables/SuccessScreen.kt@@ -0,0 +1,53 @@+package com.example.manageproducts.presentation.feature.addproduct.composables++import androidx.compose.foundation.layout.*+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.filled.CheckCircle+import androidx.compose.material3.*+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.unit.dp++@Composable+fun SuccessScreen(+ modifier: Modifier = Modifier,+ message: String,+ onMoreAction: () -> Unit,+ onNavigateBack: () -> Unit,+) {+ Column(+ modifier = modifier+ .padding(24.dp)+ .fillMaxHeight(),+ horizontalAlignment = Alignment.CenterHorizontally+ ) {+ Icon(+ imageVector = Icons.Filled.CheckCircle, contentDescription = null,+ modifier = modifier.size(128.dp),+ tint = Color.Green+ )+ Text(+ text = message,+ style = MaterialTheme.typography.titleLarge+ )+ Spacer(modifier = modifier.weight(1.0f))+ OutlinedButton(+ modifier = modifier+ .fillMaxWidth(),+ onClick = onMoreAction+ ) {+ Text(text = "Add More Product")+ }+ Spacer(modifier = modifier.height(12.dp))+ Spacer(modifier = modifier.height(12.dp))+ Button(+ modifier = modifier+ .fillMaxWidth(),+ onClick = onNavigateBack+ ) {+ Text(text = "Done")+ }+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productdetails/ProductDetailsContract.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productdetails/ProductDetailsContract.ktnew file mode 100644index 00000000000..94c66684571--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productdetails/ProductDetailsContract.kt@@ -0,0 +1,14 @@+package com.example.manageproducts.presentation.feature.productdetails++import com.example.manageproducts.domain.model.Product+import kotlinx.coroutines.flow.Flow++interface ProductDetailsContract {+ val product: Flow<Product?>+ val name: Flow<String>+ val price: Flow<Double>+ val imageUrl: Flow<String>++ fun onSaveProduct(image: ByteArray)+ fun onImageChange(url: String)+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productdetails/ProductDetailsScreen.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productdetails/ProductDetailsScreen.ktnew file mode 100644index 00000000000..578d93865ed--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productdetails/ProductDetailsScreen.kt@@ -0,0 +1,205 @@+package com.example.manageproducts.presentation.feature.productdetails++import android.annotation.SuppressLint+import android.content.ContentResolver+import android.net.Uri+import androidx.activity.compose.rememberLauncherForActivityResult+import androidx.activity.result.contract.ActivityResultContracts+import androidx.compose.foundation.Image+import androidx.compose.foundation.layout.*+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.foundation.text.KeyboardOptions+import androidx.compose.material.*+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.filled.ArrowBack+import androidx.compose.material.icons.filled.Edit+import androidx.compose.material3.Button+import androidx.compose.material3.Icon+import androidx.compose.material3.IconButton+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.OutlinedButton+import androidx.compose.material3.Text+import androidx.compose.runtime.*+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.text.input.KeyboardType+import androidx.compose.ui.unit.dp+import androidx.hilt.navigation.compose.hiltViewModel+import androidx.navigation.NavController+import coil.annotation.ExperimentalCoilApi+import coil.compose.rememberImagePainter+import com.example.manageproducts.R+import kotlinx.coroutines.launch+import java.io.ByteArrayOutputStream+import java.io.InputStream++@OptIn(ExperimentalCoilApi::class)+@SuppressLint("UnusedMaterialScaffoldPaddingParameter")+@Composable+fun ProductDetailsScreen(+ modifier: Modifier = Modifier,+ viewModel: ProductDetailsViewModel = hiltViewModel(),+ navController: NavController,+ productId: String?,+) {+ val snackBarHostState = remember { SnackbarHostState() }+ val coroutineScope = rememberCoroutineScope()++ Scaffold(+ snackbarHost = { SnackbarHost(snackBarHostState) },+ topBar = {+ TopAppBar(+ navigationIcon = {+ IconButton(onClick = {+ navController.navigateUp()+ }) {+ Icon(+ imageVector = Icons.Filled.ArrowBack,+ contentDescription = null,+ tint = MaterialTheme.colorScheme.onPrimary+ )+ }+ },+ backgroundColor = MaterialTheme.colorScheme.primary,+ title = {+ Text(+ text = stringResource(R.string.product_details_text_screen_title),+ color = MaterialTheme.colorScheme.onPrimary,+ )+ },+ )+ }+ ) {+ val name = viewModel.name.collectAsState(initial = "")+ val price = viewModel.price.collectAsState(initial = 0.0)+ var imageUrl = Uri.parse(viewModel.imageUrl.collectAsState(initial = "").value)+ val contentResolver = LocalContext.current.contentResolver++ Column(+ modifier = modifier+ .padding(16.dp)+ .fillMaxSize()+ ) {+ val galleryLauncher =+ rememberLauncherForActivityResult(ActivityResultContracts.GetContent())+ { uri ->+ uri?.let {+ if (it.toString() != imageUrl.toString()) {+ viewModel.onImageChange(it.toString())+ }+ }+ }++ Image(+ painter = rememberImagePainter(imageUrl),+ contentScale = ContentScale.Fit,+ contentDescription = null,+ modifier = Modifier+ .padding(16.dp, 8.dp)+ .size(100.dp)+ .align(Alignment.CenterHorizontally)+ )+ IconButton(modifier = modifier.align(alignment = Alignment.CenterHorizontally),+ onClick = {+ galleryLauncher.launch("image/*")+ }) {+ Icon(+ imageVector = Icons.Filled.Edit,+ contentDescription = null,+ tint = MaterialTheme.colorScheme.primary+ )+ }+ OutlinedTextField(+ label = {+ Text(+ text = "Product name",+ color = MaterialTheme.colorScheme.primary,+ style = MaterialTheme.typography.titleMedium+ )+ },+ maxLines = 2,+ shape = RoundedCornerShape(32),+ modifier = modifier.fillMaxWidth(),+ value = name.value,+ onValueChange = {+ viewModel.onNameChange(it)+ },+ )+ Spacer(modifier = modifier.height(12.dp))+ OutlinedTextField(+ label = {+ Text(+ text = "Product price",+ color = MaterialTheme.colorScheme.primary,+ style = MaterialTheme.typography.titleMedium+ )+ },+ maxLines = 2,+ shape = RoundedCornerShape(32),+ modifier = modifier.fillMaxWidth(),+ value = price.value.toString(),+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),+ onValueChange = {+ viewModel.onPriceChange(it.toDouble())+ },+ )+ Spacer(modifier = modifier.weight(1f))+ Button(+ modifier = modifier.fillMaxWidth(),+ onClick = {+ if (imageUrl.host?.contains("supabase") == true) {+ viewModel.onSaveProduct(image = byteArrayOf())+ } else {+ val image = uriToByteArray(contentResolver, imageUrl)+ viewModel.onSaveProduct(image = image)+ }+ coroutineScope.launch {+ snackBarHostState.showSnackbar(+ message = "Product updated successfully !",+ duration = SnackbarDuration.Short+ )+ }+ }) {+ Text(text = "Save changes")+ }+ Spacer(modifier = modifier.height(12.dp))+ OutlinedButton(+ modifier = modifier+ .fillMaxWidth(),+ onClick = {+ navController.navigateUp()+ }) {+ Text(text = "Cancel")+ }++ }++ }+}+++private fun getBytes(inputStream: InputStream): ByteArray {+ val byteBuffer = ByteArrayOutputStream()+ val bufferSize = 1024+ val buffer = ByteArray(bufferSize)+ var len = 0+ while (inputStream.read(buffer).also { len = it } != -1) {+ byteBuffer.write(buffer, 0, len)+ }+ return byteBuffer.toByteArray()+}+++private fun uriToByteArray(contentResolver: ContentResolver, uri: Uri): ByteArray {+ if (uri == Uri.EMPTY) {+ return byteArrayOf()+ }+ val inputStream = contentResolver.openInputStream(uri)+ if (inputStream != null) {+ return getBytes(inputStream)+ }+ return byteArrayOf()+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productdetails/ProductDetailsViewModel.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productdetails/ProductDetailsViewModel.ktnew file mode 100644index 00000000000..bafa82a7cb8--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productdetails/ProductDetailsViewModel.kt@@ -0,0 +1,85 @@+package com.example.manageproducts.presentation.feature.productdetails++import androidx.lifecycle.SavedStateHandle+import androidx.lifecycle.ViewModel+import androidx.lifecycle.viewModelScope+import com.example.manageproducts.data.network.dto.ProductDto+import com.example.manageproducts.data.repository.ProductRepository+import com.example.manageproducts.domain.model.Product+import com.example.manageproducts.domain.usecase.GetProductDetailsUseCase+import com.example.manageproducts.domain.usecase.UpdateProductUseCase+import com.example.manageproducts.domain.usecase.UploadImageUseCase+import com.example.manageproducts.presentation.navigation.ProductDetailsDestination+import dagger.hilt.android.lifecycle.HiltViewModel+import kotlinx.coroutines.flow.Flow+import kotlinx.coroutines.flow.MutableStateFlow+import kotlinx.coroutines.launch+import javax.inject.Inject++@HiltViewModel+class ProductDetailsViewModel @Inject constructor(+ private val productRepository: ProductRepository,+ savedStateHandle: SavedStateHandle,++ ) : ViewModel(), ProductDetailsContract {+ private val _product = MutableStateFlow<Product?>(null)+ override val product: Flow<Product?> = _product++ private val _name = MutableStateFlow("")+ override val name: Flow<String> = _name++ private val _price = MutableStateFlow(0.0)+ override val price: Flow<Double> = _price++ private val _imageUrl = MutableStateFlow("")+ override val imageUrl: Flow<String> = _imageUrl++ init {+ val productId = savedStateHandle.get<String>(ProductDetailsDestination.productId)+ productId?.let {+ getProduct(productId = it)+ }+ }++ private fun getProduct(productId: String) {+ viewModelScope.launch {+ val result = productRepository.getProduct(productId).asDomainModel()+ _product.emit(result)+ _name.emit(result.name)+ _price.emit(result.price)+ }+ }++ fun onNameChange(name: String) {+ _name.value = name+ }++ fun onPriceChange(price: Double) {+ _price.value = price+ }++ override fun onSaveProduct(image: ByteArray) {+ viewModelScope.launch {+ productRepository.updateProduct(+ id = _product.value?.id ?: "",+ price = _price.value,+ name = _name.value,+ imageFile = image,+ imageName = "image_${_product.value?.id}",+ )+ }+ }++ override fun onImageChange(url: String) {+ _imageUrl.value = url+ }++ private fun ProductDto.asDomainModel(): Product {+ return Product(+ id = this.id ?: "",+ name = this.name,+ price = this.price,+ image = this.image ?: ""+ )+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListContract.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListContract.ktnew file mode 100644index 00000000000..881c345babf--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListContract.kt@@ -0,0 +1,10 @@+package com.example.manageproducts.presentation.feature.productlist++import com.example.manageproducts.domain.model.Product+import kotlinx.coroutines.flow.Flow++interface ProductListContract {+ val productList: Flow<List<Product>?>+ fun removeItem(product: Product)+ fun getProducts()+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListItem.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListItem.ktnew file mode 100644index 00000000000..39e9c9632d5--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListItem.kt@@ -0,0 +1,56 @@+package com.example.manageproducts.presentation.feature.productlist++import androidx.compose.foundation.Image+import androidx.compose.foundation.layout.*+import androidx.compose.foundation.shape.RoundedCornerShape+import androidx.compose.material.Card+import androidx.compose.material.ExperimentalMaterialApi+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.Text+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.unit.dp+import coil.annotation.ExperimentalCoilApi+import coil.compose.rememberImagePainter+import com.example.manageproducts.domain.model.Product++@OptIn(ExperimentalMaterialApi::class, ExperimentalCoilApi::class)+@Composable+fun ProductListItem(+ modifier: Modifier = Modifier,+ product: Product,+ onClick: () -> Unit+) {+ Card(+ modifier = modifier+ .padding(4.dp)+ .fillMaxWidth(),+ elevation = 8.dp,+ shape = RoundedCornerShape(12.dp),+ onClick = onClick+ ) {+ Row(+ modifier = modifier.padding(10.dp),+ horizontalArrangement = Arrangement.SpaceBetween+ ) {+ Image(+ contentDescription = null,+ painter = rememberImagePainter(product.image),+ contentScale = ContentScale.Fit,+ modifier = Modifier+ .padding(16.dp, 8.dp)+ .size(64.dp)+ )+ Text(+ text = product.name,+ modifier = modifier.weight(1.0f)+ )+ Text(+ text = "$${product.price}",+ style = MaterialTheme.typography.titleMedium,+ color = MaterialTheme.colorScheme.primary+ )+ }+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListScreen.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListScreen.ktnew file mode 100644index 00000000000..c09813df30d--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListScreen.kt@@ -0,0 +1,152 @@+package com.example.manageproducts.presentation.feature.productlist++import android.annotation.SuppressLint+import androidx.compose.animation.animateColorAsState+import androidx.compose.foundation.background+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.foundation.lazy.itemsIndexed+import androidx.compose.material.*+import androidx.compose.material.icons.Icons+import androidx.compose.material.icons.filled.Add+import androidx.compose.material.icons.filled.Delete+import androidx.compose.material3.ExperimentalMaterial3Api+import androidx.compose.material3.FloatingActionButton+import androidx.compose.material3.Icon+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.Scaffold+import com.example.manageproducts.R+import androidx.compose.material3.Text+import androidx.compose.runtime.*+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.platform.LocalLifecycleOwner+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import androidx.hilt.navigation.compose.hiltViewModel+import androidx.lifecycle.Lifecycle+import androidx.lifecycle.LifecycleEventObserver+import androidx.lifecycle.LifecycleOwner+import androidx.navigation.NavController+import com.google.accompanist.swiperefresh.SwipeRefresh+import com.google.accompanist.swiperefresh.rememberSwipeRefreshState+import com.example.manageproducts.presentation.navigation.AddProductDestination+import com.example.manageproducts.presentation.navigation.ProductDetailsDestination++@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterialApi::class)+@Composable+fun ProductListScreen(+ modifier: Modifier = Modifier,+ navController: NavController,+ viewModel: ProductListViewModel = hiltViewModel(),+) {+ val isLoading by viewModel.isLoading.collectAsState(initial = false)+ val swipeRefreshState = rememberSwipeRefreshState(isRefreshing = isLoading)+ SwipeRefresh(state = swipeRefreshState, onRefresh = { viewModel.getProducts() }) {+ Scaffold(+ topBar = {+ TopAppBar(+ backgroundColor = MaterialTheme.colorScheme.primary,+ title = {+ Text(+ text = stringResource(R.string.product_list_text_screen_title),+ color = MaterialTheme.colorScheme.onPrimary,+ )+ },+ )+ },+ floatingActionButton = {+ AddProductButton(onClick = { navController.navigate(AddProductDestination.route) })+ }+ ) { padding ->+ val productList = viewModel.productList.collectAsState(initial = listOf()).value+ if (!productList.isNullOrEmpty()) {+ LazyColumn(+ modifier = modifier.padding(padding),+ contentPadding = PaddingValues(5.dp)+ ) {+ itemsIndexed(+ items = productList,+ key = { _, product -> product.name }) { _, item ->+ val state = rememberDismissState(+ confirmStateChange = {+ if (it == DismissValue.DismissedToStart) {+ // Handle item removed+ viewModel.removeItem(item)+ }+ true+ }+ )+ SwipeToDismiss(+ state = state,+ background = {+ val color by animateColorAsState(+ targetValue = when (state.dismissDirection) {+ DismissDirection.StartToEnd -> MaterialTheme.colorScheme.primary+ DismissDirection.EndToStart -> MaterialTheme.colorScheme.primary.copy(+ alpha = 0.2f+ )+ null -> Color.Transparent+ }+ )+ Box(+ modifier = modifier+ .fillMaxSize()+ .background(color = color)+ .padding(16.dp),+ ) {+ Icon(+ imageVector = Icons.Filled.Delete,+ contentDescription = null,+ tint = MaterialTheme.colorScheme.primary,+ modifier = modifier.align(Alignment.CenterEnd)+ )+ }++ },+ dismissContent = {+ ProductListItem(+ product = item,+ modifier = modifier,+ onClick = {+ navController.navigate(+ ProductDetailsDestination.createRouteWithParam(+ item.id+ )+ )+ },+ )+ },+ directions = setOf(DismissDirection.EndToStart),+ )+ }+ }+ } else {+ Text("Product list is empty!")+ }++ }+ }+}++@Composable+private fun AddProductButton(+ modifier: Modifier = Modifier,+ onClick: () -> Unit,+) {+ FloatingActionButton(+ modifier = modifier,+ onClick = onClick,+ containerColor = MaterialTheme.colorScheme.primary,+ contentColor = MaterialTheme.colorScheme.onPrimary+ ) {+ Icon(+ imageVector = Icons.Filled.Add,+ contentDescription = null,+ )+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListViewModel.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListViewModel.ktnew file mode 100644index 00000000000..bcb9d4f1b4c--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/feature/productlist/ProductListViewModel.kt@@ -0,0 +1,57 @@+package com.example.manageproducts.presentation.feature.productlist++import androidx.lifecycle.ViewModel+import androidx.lifecycle.viewModelScope+import com.example.manageproducts.data.network.dto.ProductDto+import com.example.manageproducts.data.repository.ProductRepository+import com.example.manageproducts.domain.model.Product+import dagger.hilt.android.lifecycle.HiltViewModel+import kotlinx.coroutines.flow.Flow+import kotlinx.coroutines.flow.MutableStateFlow+import kotlinx.coroutines.launch+import javax.inject.Inject++@HiltViewModel+class ProductListViewModel @Inject constructor(+ private val productRepository: ProductRepository,+) : ViewModel(), ProductListContract {++ private val _productList = MutableStateFlow<List<Product>?>(listOf())+ override val productList: Flow<List<Product>?> = _productList+++ private val _isLoading = MutableStateFlow(false)+ val isLoading: Flow<Boolean> = _isLoading++ init {+ getProducts()+ }++ override fun getProducts() {+ viewModelScope.launch {+ val products = productRepository.getProducts()+ _productList.emit(products?.map { it -> it.asDomainModel() })+ }+ }++ override fun removeItem(product: Product) {+ viewModelScope.launch {+ val newList = mutableListOf<Product>().apply { _productList.value?.let { addAll(it) } }+ newList.remove(product)+ _productList.emit(newList.toList())+ // Call api to remove+ productRepository.deleteProduct(id = product.id)+ // Then fetch again+ getProducts()+ }+ }++ private fun ProductDto.asDomainModel(): Product {+ return Product(+ id = this.id ?: "",+ name = this.name,+ price = this.price,+ image = this.image ?: ""+ )+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/navigation/Destination.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/navigation/Destination.ktnew file mode 100644index 00000000000..e65c32e75d4--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/navigation/Destination.kt@@ -0,0 +1,31 @@+package com.example.manageproducts.presentation.navigation++import androidx.navigation.NavType+import androidx.navigation.navArgument+++interface Destination {+ val route: String+ val title: String+}+++object ProductListDestination : Destination {+ override val route = "product_list"+ override val title = "Product List"+}++object ProductDetailsDestination : Destination {+ override val route = "product_details"+ override val title = "Product Details"+ const val productId = "product_id"+ val arguments = listOf(navArgument(name = productId) {+ type = NavType.StringType+ })+ fun createRouteWithParam(productId: String) = "$route/${productId}"+}++object AddProductDestination : Destination {+ override val route = "add_product"+ override val title = "Add Product"+}diff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/navigation/NavRegister.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/navigation/NavRegister.ktnew file mode 100644index 00000000000..a4518dc8df8--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/presentation/navigation/NavRegister.kt@@ -0,0 +1,32 @@+package com.example.manageproducts.presentation.navigation++import androidx.navigation.NavController+import androidx.navigation.NavGraphBuilder+import androidx.navigation.compose.composable+import com.example.manageproducts.presentation.feature.addproduct.AddProductScreen+import com.example.manageproducts.presentation.feature.productdetails.ProductDetailsScreen+import com.example.manageproducts.presentation.feature.productlist.ProductListScreen++fun NavGraphBuilder.navRegistration(navController: NavController) {+ composable(ProductListDestination.route) {+ ProductListScreen(+ navController = navController+ )+ }++ composable(AddProductDestination.route) {+ AddProductScreen(+ navController = navController+ )+ }+ composable(route = "${ProductDetailsDestination.route}/{${ProductDetailsDestination.productId}}",+ arguments = ProductDetailsDestination.arguments) { navBackStackEntry ->+ val productName =+ navBackStackEntry.arguments?.getString(ProductDetailsDestination.productId)+ ProductDetailsScreen(+ productId = productName,+ navController = navController,+ )+ }++}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ui/theme/Color.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ui/theme/Color.ktnew file mode 100644index 00000000000..ee8610408d3--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ui/theme/Color.kt@@ -0,0 +1,11 @@+package com.example.manageproducts.ui.theme++import androidx.compose.ui.graphics.Color++val Purple80 = Color(0xFFD0BCFF)+val PurpleGrey80 = Color(0xFFCCC2DC)+val Pink80 = Color(0xFFEFB8C8)++val Purple40 = Color(0xFF6650a4)+val PurpleGrey40 = Color(0xFF625b71)+val Pink40 = Color(0xFF7D5260)\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ui/theme/Theme.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ui/theme/Theme.ktnew file mode 100644index 00000000000..7f6befdc86e--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ui/theme/Theme.kt@@ -0,0 +1,68 @@+package com.example.manageproducts.ui.theme++import android.app.Activity+import android.os.Build+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.material3.MaterialTheme+import androidx.compose.material3.darkColorScheme+import androidx.compose.material3.dynamicDarkColorScheme+import androidx.compose.material3.dynamicLightColorScheme+import androidx.compose.material3.lightColorScheme+import androidx.compose.runtime.Composable+import androidx.compose.runtime.SideEffect+import androidx.compose.ui.graphics.toArgb+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.platform.LocalView+import androidx.core.view.ViewCompat++private val DarkColorScheme = darkColorScheme(+ primary = Purple80,+ secondary = PurpleGrey80,+ tertiary = Pink80+)++private val LightColorScheme = lightColorScheme(+ primary = Purple40,+ secondary = PurpleGrey40,+ tertiary = Pink40++ /* Other default colors to override+ background = Color(0xFFFFFBFE),+ surface = Color(0xFFFFFBFE),+ onPrimary = Color.White,+ onSecondary = Color.White,+ onTertiary = Color.White,+ onBackground = Color(0xFF1C1B1F),+ onSurface = Color(0xFF1C1B1F),+ */+)++@Composable+fun ManageProductsTheme(+ darkTheme: Boolean = isSystemInDarkTheme(),+ // Dynamic color is available on Android 12++ dynamicColor: Boolean = true,+ content: @Composable () -> Unit+) {+ val colorScheme = when {+ dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {+ val context = LocalContext.current+ if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)+ }+ darkTheme -> DarkColorScheme+ else -> LightColorScheme+ }+ val view = LocalView.current+ if (!view.isInEditMode) {+ SideEffect {+ (view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()+ ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = darkTheme+ }+ }++ MaterialTheme(+ colorScheme = colorScheme,+ typography = Typography,+ content = content+ )+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ui/theme/Type.kt b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ui/theme/Type.ktnew file mode 100644index 00000000000..a121b1a25e1--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/java/com/example/manageproducts/ui/theme/Type.kt@@ -0,0 +1,34 @@+package com.example.manageproducts.ui.theme++import androidx.compose.material3.Typography+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.text.font.FontFamily+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.sp++// Set of Material typography styles to start with+val Typography = Typography(+ bodyLarge = TextStyle(+ fontFamily = FontFamily.Default,+ fontWeight = FontWeight.Normal,+ fontSize = 16.sp,+ lineHeight = 24.sp,+ letterSpacing = 0.5.sp+ )+ /* Other default text styles to override+ titleLarge = TextStyle(+ fontFamily = FontFamily.Default,+ fontWeight = FontWeight.Normal,+ fontSize = 22.sp,+ lineHeight = 28.sp,+ letterSpacing = 0.sp+ ),+ labelSmall = TextStyle(+ fontFamily = FontFamily.Default,+ fontWeight = FontWeight.Medium,+ fontSize = 11.sp,+ lineHeight = 16.sp,+ letterSpacing = 0.5.sp+ )+ */+)\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/examples/product-sample-supabase-kt/app/src/main/res/drawable-v24/ic_launcher_foreground.xmlnew file mode 100644index 00000000000..2b068d11462--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/res/drawable-v24/ic_launcher_foreground.xml@@ -0,0 +1,30 @@+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ xmlns:aapt="http://schemas.android.com/aapt"+ android:width="108dp"+ android:height="108dp"+ android:viewportWidth="108"+ android:viewportHeight="108">+ <path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">+ <aapt:attr name="android:fillColor">+ <gradient+ android:endX="85.84757"+ android:endY="92.4963"+ android:startX="42.9492"+ android:startY="49.59793"+ android:type="linear">+ <item+ android:color="#44000000"+ android:offset="0.0" />+ <item+ android:color="#00000000"+ android:offset="1.0" />+ </gradient>+ </aapt:attr>+ </path>+ <path+ android:fillColor="#FFFFFF"+ android:fillType="nonZero"+ android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"+ android:strokeWidth="1"+ android:strokeColor="#00000000" />+</vector>\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/res/drawable/ic_launcher_background.xml b/examples/product-sample-supabase-kt/app/src/main/res/drawable/ic_launcher_background.xmlnew file mode 100644index 00000000000..07d5da9cbf1--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/res/drawable/ic_launcher_background.xml@@ -0,0 +1,170 @@+<?xml version="1.0" encoding="utf-8"?>+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="108dp"+ android:height="108dp"+ android:viewportWidth="108"+ android:viewportHeight="108">+ <path+ android:fillColor="#3DDC84"+ android:pathData="M0,0h108v108h-108z" />+ <path+ android:fillColor="#00000000"+ android:pathData="M9,0L9,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,0L19,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M29,0L29,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M39,0L39,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M49,0L49,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M59,0L59,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M69,0L69,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M79,0L79,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M89,0L89,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M99,0L99,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,9L108,9"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,19L108,19"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,29L108,29"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,39L108,39"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,49L108,49"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,59L108,59"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,69L108,69"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,79L108,79"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,89L108,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,99L108,99"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,29L89,29"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,39L89,39"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,49L89,49"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,59L89,59"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,69L89,69"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,79L89,79"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M29,19L29,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M39,19L39,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M49,19L49,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M59,19L59,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M69,19L69,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M79,19L79,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+</vector>diff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xmlnew file mode 100644index 00000000000..eca70cfe52e--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml@@ -0,0 +1,5 @@+<?xml version="1.0" encoding="utf-8"?>+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">+ <background android:drawable="@drawable/ic_launcher_background" />+ <foreground android:drawable="@drawable/ic_launcher_foreground" />+</adaptive-icon>\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xmlnew file mode 100644index 00000000000..eca70cfe52e--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml@@ -0,0 +1,5 @@+<?xml version="1.0" encoding="utf-8"?>+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">+ <background android:drawable="@drawable/ic_launcher_background" />+ <foreground android:drawable="@drawable/ic_launcher_foreground" />+</adaptive-icon>\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xmlnew file mode 100644index 00000000000..6f3b755bf50--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml@@ -0,0 +1,6 @@+<?xml version="1.0" encoding="utf-8"?>+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">+ <background android:drawable="@drawable/ic_launcher_background" />+ <foreground android:drawable="@drawable/ic_launcher_foreground" />+ <monochrome android:drawable="@drawable/ic_launcher_foreground" />+</adaptive-icon>\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-hdpi/ic_launcher.webpnew file mode 100644index 00000000000..c209e78ecd3Binary files /dev/null and b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-hdpi/ic_launcher.webp differdiff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-hdpi/ic_launcher_round.webpnew file mode 100644index 00000000000..b2dfe3d1ba5Binary files /dev/null and b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differdiff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-mdpi/ic_launcher.webpnew file mode 100644index 00000000000..4f0f1d64e58Binary files /dev/null and b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-mdpi/ic_launcher.webp differdiff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-mdpi/ic_launcher_round.webpnew file mode 100644index 00000000000..62b611da081Binary files /dev/null and b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differdiff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xhdpi/ic_launcher.webpnew file mode 100644index 00000000000..948a3070fe3Binary files /dev/null and b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differdiff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webpnew file mode 100644index 00000000000..1b9a6956b3aBinary files /dev/null and b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differdiff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxhdpi/ic_launcher.webpnew file mode 100644index 00000000000..28d4b77f9f0Binary files /dev/null and b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differdiff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webpnew file mode 100644index 00000000000..9287f508362Binary files /dev/null and b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differdiff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webpnew file mode 100644index 00000000000..aa7d6427e6fBinary files /dev/null and b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differdiff --git a/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webpnew file mode 100644index 00000000000..9126ae37cbcBinary files /dev/null and b/examples/product-sample-supabase-kt/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differdiff --git a/examples/product-sample-supabase-kt/app/src/main/res/values/colors.xml b/examples/product-sample-supabase-kt/app/src/main/res/values/colors.xmlnew file mode 100644index 00000000000..f8c6127d327--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/res/values/colors.xml@@ -0,0 +1,10 @@+<?xml version="1.0" encoding="utf-8"?>+<resources>+ <color name="purple_200">#FFBB86FC</color>+ <color name="purple_500">#FF6200EE</color>+ <color name="purple_700">#FF3700B3</color>+ <color name="teal_200">#FF03DAC5</color>+ <color name="teal_700">#FF018786</color>+ <color name="black">#FF000000</color>+ <color name="white">#FFFFFFFF</color>+</resources>\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/res/values/strings.xml b/examples/product-sample-supabase-kt/app/src/main/res/values/strings.xmlnew file mode 100644index 00000000000..bf4e9fe7d7b--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/res/values/strings.xml@@ -0,0 +1,6 @@+<resources>+ <string name="app_name">ManageProducts</string>+ <string name="product_list_text_screen_title">Product List</string>+ <string name="product_details_text_screen_title">Product Details</string>+ <string name="add_product_text_screen_title">Add Product</string>+</resources>\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/res/values/themes.xml b/examples/product-sample-supabase-kt/app/src/main/res/values/themes.xmlnew file mode 100644index 00000000000..2c9a78d5a47--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/res/values/themes.xml@@ -0,0 +1,5 @@+<?xml version="1.0" encoding="utf-8"?>+<resources>++ <style name="Theme.ManageProducts" parent="android:Theme.Material.Light.NoActionBar" />+</resources>\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/res/xml/backup_rules.xml b/examples/product-sample-supabase-kt/app/src/main/res/xml/backup_rules.xmlnew file mode 100644index 00000000000..fa0f996d2c2--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/res/xml/backup_rules.xml@@ -0,0 +1,13 @@+<?xml version="1.0" encoding="utf-8"?><!--+ Sample backup rules file; uncomment and customize as necessary.+ See https://developer.android.com/guide/topics/data/autobackup+ for details.+ Note: This file is ignored for devices older that API 31+ See https://developer.android.com/about/versions/12/backup-restore+-->+<full-backup-content>+ <!--+ <include domain="sharedpref" path="."/>+ <exclude domain="sharedpref" path="device.xml"/>+-->+</full-backup-content>\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/main/res/xml/data_extraction_rules.xml b/examples/product-sample-supabase-kt/app/src/main/res/xml/data_extraction_rules.xmlnew file mode 100644index 00000000000..9ee9997b0b4--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/main/res/xml/data_extraction_rules.xml@@ -0,0 +1,19 @@+<?xml version="1.0" encoding="utf-8"?><!--+ Sample data extraction rules file; uncomment and customize as necessary.+ See https://developer.android.com/about/versions/12/backup-restore#xml-changes+ for details.+-->+<data-extraction-rules>+ <cloud-backup>+ <!-- TODO: Use <include> and <exclude> to control what is backed up.+ <include .../>+ <exclude .../>+ -->+ </cloud-backup>+ <!--+ <device-transfer>+ <include .../>+ <exclude .../>+ </device-transfer>+ -->+</data-extraction-rules>\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/app/src/test/java/com/example/manageproducts/ExampleUnitTest.kt b/examples/product-sample-supabase-kt/app/src/test/java/com/example/manageproducts/ExampleUnitTest.ktnew file mode 100644index 00000000000..d10e3727921--- /dev/null+++ b/examples/product-sample-supabase-kt/app/src/test/java/com/example/manageproducts/ExampleUnitTest.kt@@ -0,0 +1,17 @@+package com.example.manageproducts++import org.junit.Test++import org.junit.Assert.*++/**+ * Example local unit test, which will execute on the development machine (host).+ *+ * See [testing documentation](http://d.android.com/tools/testing).+ */+class ExampleUnitTest {+ @Test+ fun addition_isCorrect() {+ assertEquals(4, 2 + 2)+ }+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/build.gradle b/examples/product-sample-supabase-kt/build.gradlenew file mode 100644index 00000000000..323f0e263c1--- /dev/null+++ b/examples/product-sample-supabase-kt/build.gradle@@ -0,0 +1,13 @@+buildscript {+ ext {+ compose_version = '1.2.0'+ hilt_version = '2.44.2'+ }+}// Top-level build file where you can add configuration options common to all sub-projects/modules.+plugins {+ id 'com.android.application' version '7.4.2' apply false+ id 'com.android.library' version '7.4.2' apply false+ id 'org.jetbrains.kotlin.android' version '1.7.0' apply false+ id("com.google.dagger.hilt.android") version "2.44" apply false+ id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.21'+}\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/gradle.properties b/examples/product-sample-supabase-kt/gradle.propertiesnew file mode 100644index 00000000000..3c5031eb7d6--- /dev/null+++ b/examples/product-sample-supabase-kt/gradle.properties@@ -0,0 +1,23 @@+# Project-wide Gradle settings.+# IDE (e.g. Android Studio) users:+# Gradle settings configured through the IDE *will override*+# any settings specified in this file.+# For more details on how to configure your build environment visit+# http://www.gradle.org/docs/current/userguide/build_environment.html+# Specifies the JVM arguments used for the daemon process.+# The setting is particularly useful for tweaking memory settings.+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8+# When configured, Gradle will run in incubating parallel mode.+# This option should only be used with decoupled projects. More details, visit+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects+# org.gradle.parallel=true+# AndroidX package structure to make it clearer which packages are bundled with the+# Android operating system, and which are packaged with your app's APK+# https://developer.android.com/topic/libraries/support-library/androidx-rn+android.useAndroidX=true+# Kotlin code style for this project: "official" or "obsolete":+kotlin.code.style=official+# Enables namespacing of each library's R class so that its R class includes only the+# resources declared in the library itself and none from the library's dependencies,+# thereby reducing the size of the R class for that library+android.nonTransitiveRClass=true\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/gradle/wrapper/gradle-wrapper.jar b/examples/product-sample-supabase-kt/gradle/wrapper/gradle-wrapper.jarnew file mode 100644index 00000000000..e708b1c023eBinary files /dev/null and b/examples/product-sample-supabase-kt/gradle/wrapper/gradle-wrapper.jar differdiff --git a/examples/product-sample-supabase-kt/gradle/wrapper/gradle-wrapper.properties b/examples/product-sample-supabase-kt/gradle/wrapper/gradle-wrapper.propertiesnew file mode 100644index 00000000000..521e373506b--- /dev/null+++ b/examples/product-sample-supabase-kt/gradle/wrapper/gradle-wrapper.properties@@ -0,0 +1,6 @@+#Wed May 31 23:01:48 ICT 2023+distributionBase=GRADLE_USER_HOME+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip+distributionPath=wrapper/dists+zipStorePath=wrapper/dists+zipStoreBase=GRADLE_USER_HOMEdiff --git a/examples/product-sample-supabase-kt/gradlew b/examples/product-sample-supabase-kt/gradlewnew file mode 100755index 00000000000..4f906e0c811--- /dev/null+++ b/examples/product-sample-supabase-kt/gradlew@@ -0,0 +1,185 @@+#!/usr/bin/env sh++#+# Copyright 2015 the original author or authors.+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# https://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+#++##############################################################################+##+## Gradle start up script for UN*X+##+##############################################################################++# Attempt to set APP_HOME+# Resolve links: $0 may be a link+PRG="$0"+# Need this for relative symlinks.+while [ -h "$PRG" ] ; do+ ls=`ls -ld "$PRG"`+ link=`expr "$ls" : '.*-> \(.*\)$'`+ if expr "$link" : '/.*' > /dev/null; then+ PRG="$link"+ else+ PRG=`dirname "$PRG"`"/$link"+ fi+done+SAVED="`pwd`"+cd "`dirname \"$PRG\"`/" >/dev/null+APP_HOME="`pwd -P`"+cd "$SAVED" >/dev/null++APP_NAME="Gradle"+APP_BASE_NAME=`basename "$0"`++# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'++# Use the maximum available, or set MAX_FD != -1 to use that value.+MAX_FD="maximum"++warn () {+ echo "$*"+}++die () {+ echo+ echo "$*"+ echo+ exit 1+}++# OS specific support (must be 'true' or 'false').+cygwin=false+msys=false+darwin=false+nonstop=false+case "`uname`" in+ CYGWIN* )+ cygwin=true+ ;;+ Darwin* )+ darwin=true+ ;;+ MINGW* )+ msys=true+ ;;+ NONSTOP* )+ nonstop=true+ ;;+esac++CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar+++# Determine the Java command to use to start the JVM.+if [ -n "$JAVA_HOME" ] ; then+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then+ # IBM's JDK on AIX uses strange locations for the executables+ JAVACMD="$JAVA_HOME/jre/sh/java"+ else+ JAVACMD="$JAVA_HOME/bin/java"+ fi+ if [ ! -x "$JAVACMD" ] ; then+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME++Please set the JAVA_HOME variable in your environment to match the+location of your Java installation."+ fi+else+ JAVACMD="java"+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.++Please set the JAVA_HOME variable in your environment to match the+location of your Java installation."+fi++# Increase the maximum file descriptors if we can.+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then+ MAX_FD_LIMIT=`ulimit -H -n`+ if [ $? -eq 0 ] ; then+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then+ MAX_FD="$MAX_FD_LIMIT"+ fi+ ulimit -n $MAX_FD+ if [ $? -ne 0 ] ; then+ warn "Could not set maximum file descriptor limit: $MAX_FD"+ fi+ else+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"+ fi+fi++# For Darwin, add options to specify how the application appears in the dock+if $darwin; then+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""+fi++# For Cygwin or MSYS, switch paths to Windows format before running java+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`++ JAVACMD=`cygpath --unix "$JAVACMD"`++ # We build the pattern for arguments to be converted via cygpath+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`+ SEP=""+ for dir in $ROOTDIRSRAW ; do+ ROOTDIRS="$ROOTDIRS$SEP$dir"+ SEP="|"+ done+ OURCYGPATTERN="(^($ROOTDIRS))"+ # Add a user-defined pattern to the cygpath arguments+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"+ fi+ # Now convert the arguments - kludge to limit ourselves to /bin/sh+ i=0+ for arg in "$@" ; do+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option++ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`+ else+ eval `echo args$i`="\"$arg\""+ fi+ i=`expr $i + 1`+ done+ case $i in+ 0) set -- ;;+ 1) set -- "$args0" ;;+ 2) set -- "$args0" "$args1" ;;+ 3) set -- "$args0" "$args1" "$args2" ;;+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;+ esac+fi++# Escape application args+save () {+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done+ echo " "+}+APP_ARGS=`save "$@"`++# Collect all arguments for the java command, following the shell quoting and substitution rules+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"++exec "$JAVACMD" "$@"diff --git a/examples/product-sample-supabase-kt/gradlew.bat b/examples/product-sample-supabase-kt/gradlew.batnew file mode 100644index 00000000000..107acd32c4e--- /dev/null+++ b/examples/product-sample-supabase-kt/gradlew.bat@@ -0,0 +1,89 @@+@rem+@rem Copyright 2015 the original author or authors.+@rem+@rem Licensed under the Apache License, Version 2.0 (the "License");+@rem you may not use this file except in compliance with the License.+@rem You may obtain a copy of the License at+@rem+@rem https://www.apache.org/licenses/LICENSE-2.0+@rem+@rem Unless required by applicable law or agreed to in writing, software+@rem distributed under the License is distributed on an "AS IS" BASIS,+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+@rem See the License for the specific language governing permissions and+@rem limitations under the License.+@rem++@if "%DEBUG%" == "" @echo off+@rem ##########################################################################+@rem+@rem Gradle startup script for Windows+@rem+@rem ##########################################################################++@rem Set local scope for the variables with windows NT shell+if "%OS%"=="Windows_NT" setlocal++set DIRNAME=%~dp0+if "%DIRNAME%" == "" set DIRNAME=.+set APP_BASE_NAME=%~n0+set APP_HOME=%DIRNAME%++@rem Resolve any "." and ".." in APP_HOME to make it shorter.+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi++@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"++@rem Find java.exe+if defined JAVA_HOME goto findJavaFromJavaHome++set JAVA_EXE=java.exe+%JAVA_EXE% -version >NUL 2>&1+if "%ERRORLEVEL%" == "0" goto execute++echo.+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.+echo.+echo Please set the JAVA_HOME variable in your environment to match the+echo location of your Java installation.++goto fail++:findJavaFromJavaHome+set JAVA_HOME=%JAVA_HOME:"=%+set JAVA_EXE=%JAVA_HOME%/bin/java.exe++if exist "%JAVA_EXE%" goto execute++echo.+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%+echo.+echo Please set the JAVA_HOME variable in your environment to match the+echo location of your Java installation.++goto fail++:execute+@rem Setup the command line++set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar+++@rem Execute Gradle+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*++:end+@rem End local scope for the variables with windows NT shell+if "%ERRORLEVEL%"=="0" goto mainEnd++:fail+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of+rem the _cmd.exe /c_ return code!+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1+exit /b 1++:mainEnd+if "%OS%"=="Windows_NT" endlocal++:omegadiff --git a/examples/product-sample-supabase-kt/local.properties b/examples/product-sample-supabase-kt/local.propertiesnew file mode 100644index 00000000000..e735b7260b8--- /dev/null+++ b/examples/product-sample-supabase-kt/local.properties@@ -0,0 +1,13 @@+## This file is automatically generated by Android Studio.+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!+#+# This file should *NOT* be checked into Version Control Systems,+# as it contains information specific to your local configuration.+#+# Location of the SDK. This is only used by Gradle.+# For customization when using a Version Control System, please read the+# header note.+sdk.dir=/Users/hieuvu/Library/Android/sdk+API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InR5anh6b2RmcmFoaWJka2hncXV5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODUxMTM2MDcsImV4cCI6MjAwMDY4OTYwN30.rXN-_rGEHKjOlo75xoDYOPkshrno9rK7h1H-CXFb2_g+SECRET=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InR5anh6b2RmcmFoaWJka2hncXV5Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTY4NTExMzYwNywiZXhwIjoyMDAwNjg5NjA3fQ.lWsaScQutgWFsikOFvs17jHdZEe95HYOVjwE8Dm_n1U+SUPABASE_URL=https://tyjxzodfrahibdkhgquy.supabase.co\ No newline at end of filediff --git a/examples/product-sample-supabase-kt/settings.gradle b/examples/product-sample-supabase-kt/settings.gradlenew file mode 100644index 00000000000..a361de9a218--- /dev/null+++ b/examples/product-sample-supabase-kt/settings.gradle@@ -0,0 +1,16 @@+pluginManagement {+ repositories {+ google()+ mavenCentral()+ gradlePluginPortal()+ }+}+dependencyResolutionManagement {+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)+ repositories {+ google()+ mavenCentral()+ }+}+rootProject.name = "ManageProducts"+include ':app'