diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml new file mode 100644 index 0000000..4a53bee --- /dev/null +++ b/.idea/AndroidProjectSystem.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b86273d --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..b268ef3 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/deviceManager.xml b/.idea/deviceManager.xml new file mode 100644 index 0000000..91f9558 --- /dev/null +++ b/.idea/deviceManager.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..97f0a8e --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..cf247ce --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..74dd639 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..16660f1 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ReadMe.me b/ReadMe.me new file mode 100644 index 0000000..e69de29 diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..ac661b7 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,73 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.compose) + kotlin("kapt") +} + +val roomVersion = "2.8.4" + +android { + namespace = "com.dev.collectiondvd" + compileSdk { + version = release(36) + } + + defaultConfig { + applicationId = "com.dev.collectiondvd" + minSdk = 28 + targetSdk = 36 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } + buildFeatures { + compose = true + } +} + +dependencies { + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.ui.graphics) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(libs.androidx.compose.material3) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.compose.ui.test.junit4) + debugImplementation(libs.androidx.compose.ui.tooling) + debugImplementation(libs.androidx.compose.ui.test.manifest) + + //implementation pour RETROFIT (API) + implementation("com.squareup.retrofit2:retrofit:3.0.0") + implementation("com.squareup.retrofit2:converter-gson:3.0.0") + //pour Room + implementation("androidx.room:room-runtime:$roomVersion") + implementation("androidx.room:room-ktx:$roomVersion") + kapt("androidx.room:room-compiler:$roomVersion") + + +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/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 file diff --git a/app/src/androidTest/java/com/dev/collectiondvd/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/dev/collectiondvd/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..5ac0728 --- /dev/null +++ b/app/src/androidTest/java/com/dev/collectiondvd/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.dev.collectiondvd + +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.dev.collectiondvd", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..6fe2f96 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/dev/collectiondvd/MainActivity.kt b/app/src/main/java/com/dev/collectiondvd/MainActivity.kt new file mode 100644 index 0000000..73fde61 --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/MainActivity.kt @@ -0,0 +1,64 @@ +package com.dev.collectiondvd + +import android.content.Intent +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Button +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.dev.collectiondvd.ui.screen.AjoutDvdActivity +import com.dev.collectiondvd.ui.screen.ListDvdActivity +import com.dev.collectiondvd.ui.theme.CollectionDvdTheme +import com.dev.collectiondvd.ui.theme.MyButton +import kotlin.system.exitProcess + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { MenuScreen() } + } +} + +@Composable +fun MenuScreen() { + val context = LocalContext.current + + + Column( + modifier = Modifier + .fillMaxSize() + .padding(16.dp), + verticalArrangement = Arrangement.spacedBy(12.dp), + horizontalAlignment = Alignment.CenterHorizontally, + + + + ) { + Text("Gestion de clients", fontSize = 28.sp) + MyButton("Liste des clients") { context.startActivity(Intent(context, ListDvdActivity::class.java)) } + + MyButton("Ajouter un client") { context.startActivity(Intent(context, AjoutDvdActivity::class.java)) } + + } +} + +@Preview(showBackground = true) +@Composable +fun MenuScreenPreview() { + CollectionDvdTheme { + com.dev.collectiondvd.MenuScreen() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dev/collectiondvd/data/local/AppDatabase.kt b/app/src/main/java/com/dev/collectiondvd/data/local/AppDatabase.kt new file mode 100644 index 0000000..cff73ac --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/data/local/AppDatabase.kt @@ -0,0 +1,28 @@ +package com.dev.collectiondvd.data.local + +import android.content.Context +import androidx.room.Database +import androidx.room.Room +import androidx.room.RoomDatabase +import com.dev.collectiondvd.data.local.dao.DvdDao +import com.dev.collectiondvd.data.local.entities.Dvd + +@Database( entities = [Dvd::class], version = 1) +abstract class AppDatabase : RoomDatabase(){ + + abstract fun dvdDao(): DvdDao + + companion object{ + + @Volatile private var INSTANCE: AppDatabase? = null + fun getDatabase(context: Context): AppDatabase = + INSTANCE ?: synchronized(this){ + Room.databaseBuilder( + context.applicationContext, + AppDatabase::class.java, + "dvd_manager" + ).build().also { INSTANCE = it } + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/dev/collectiondvd/data/local/dao/DvdDao.kt b/app/src/main/java/com/dev/collectiondvd/data/local/dao/DvdDao.kt new file mode 100644 index 0000000..b4fd7e5 --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/data/local/dao/DvdDao.kt @@ -0,0 +1,19 @@ +package com.dev.collectiondvd.data.local.dao + +import androidx.room.Dao +import androidx.room.Delete +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import com.dev.collectiondvd.data.local.entities.Dvd +import kotlinx.coroutines.flow.Flow + +@Dao +interface DvdDao{ + @Insert(onConflict = OnConflictStrategy.REPLACE) + suspend fun insert(dvd : Dvd) + + @Query("SELECT * FROM dvds") + fun getAllDvdsFlow(): Flow> + +} \ No newline at end of file diff --git a/app/src/main/java/com/dev/collectiondvd/data/local/entities/Dvd.kt b/app/src/main/java/com/dev/collectiondvd/data/local/entities/Dvd.kt new file mode 100644 index 0000000..5c4f30a --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/data/local/entities/Dvd.kt @@ -0,0 +1,15 @@ +package com.dev.collectiondvd.data.local.entities + +import androidx.room.Entity +import androidx.room.PrimaryKey + + +@Entity(tableName = "dvds") +data class Dvd ( + @PrimaryKey(autoGenerate = true) val id: Long = 0, + val titre: String, + val annee: String, + val realisateur: String, + val genre: String, + val synced: Boolean = false +) \ No newline at end of file diff --git a/app/src/main/java/com/dev/collectiondvd/data/repository/LocalDvdRepository.kt b/app/src/main/java/com/dev/collectiondvd/data/repository/LocalDvdRepository.kt new file mode 100644 index 0000000..defa8c5 --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/data/repository/LocalDvdRepository.kt @@ -0,0 +1,13 @@ +package com.dev.collectiondvd.data.repository + +import com.dev.collectiondvd.data.local.dao.DvdDao +import com.dev.collectiondvd.data.local.entities.Dvd +import kotlinx.coroutines.flow.Flow + +private var all: List = TODO("initialize me") + +class LocalDvdRepository(private val dvdDao: DvdDao) { + fun getAllDvds(): Flow> = dvdDao.getAllDvdsFlow() + + suspend fun addDvd(dvd: Dvd) = dvdDao.insert(dvd) +} \ No newline at end of file diff --git a/app/src/main/java/com/dev/collectiondvd/ui/screen/AjoutDvdActivity.kt b/app/src/main/java/com/dev/collectiondvd/ui/screen/AjoutDvdActivity.kt new file mode 100644 index 0000000..1d29b77 --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/ui/screen/AjoutDvdActivity.kt @@ -0,0 +1,121 @@ +package com.dev.collectiondvd.ui.screen + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.viewModels +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.dev.collectiondvd.data.local.AppDatabase +import com.dev.collectiondvd.data.local.entities.Dvd +import com.dev.collectiondvd.data.repository.LocalDvdRepository +import com.dev.collectiondvd.ui.theme.MyButton +import com.dev.collectiondvd.viewmodel.LocalDvdViewModel +import com.dev.collectiondvd.viewmodel.factory.LocalDvdViewModelFactory + +class AjoutDvdActivity : ComponentActivity() { + + private val viewModel: LocalDvdViewModel by viewModels{ + LocalDvdViewModelFactory( + LocalDvdRepository( + AppDatabase.getDatabase(this).dvdDao() + ) + ) + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + AjoutDvdScreen(onQuit = { finish() }, onAdd = + { dvd -> + viewModel.addDvd(dvd) + finish() + } + ) + } + } + +} + +@Composable +fun AjoutDvdScreen(onQuit: () -> Unit, onAdd: (Dvd) -> Unit){ + //val context = LocalContext.current + var titre by remember() { mutableStateOf("") } + var annee by remember() { mutableStateOf("") } + var realisateur by remember() { mutableStateOf("") } + var genre by remember() { mutableStateOf("") } + Column( + modifier = Modifier + .fillMaxSize() + .padding(16.dp), + verticalArrangement = Arrangement.spacedBy(16.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text("Ajouter un dvd", + fontSize = 26.sp, + style = MaterialTheme.typography.titleLarge, + modifier = Modifier.padding(bottom = 20.dp) + ) + + OutlinedTextField( + value = titre, + onValueChange = { newValue -> titre = newValue }, + label = {Text("Titre")}, + modifier = Modifier.fillMaxWidth() + ) + OutlinedTextField( + value = realisateur, + onValueChange = { newValue -> realisateur = newValue }, + label = {Text("Réalisateur")}, + modifier = Modifier.fillMaxWidth() + ) + OutlinedTextField( + value = annee, + onValueChange = { newValue -> annee = newValue }, + label = {Text("Année")}, + modifier = Modifier.fillMaxWidth() + ) + OutlinedTextField( + value = genre, + onValueChange = { newValue -> genre = newValue }, + label = {Text("Genre")}, + modifier = Modifier.fillMaxWidth() + ) + + Spacer(modifier = Modifier.height(20.dp)) + + Column { + MyButton("Ajouter") { + if(titre.isNotBlank()){ + onAdd( + Dvd( + titre = titre, + annee = annee, + realisateur = realisateur, + genre = genre + ) + ) + } + } + } + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dev/collectiondvd/ui/screen/ListDvdActivity.kt b/app/src/main/java/com/dev/collectiondvd/ui/screen/ListDvdActivity.kt new file mode 100644 index 0000000..4f97478 --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/ui/screen/ListDvdActivity.kt @@ -0,0 +1,90 @@ +package com.dev.collectiondvd.ui.screen + +import android.graphics.ColorSpace +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.material3.Divider +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import com.dev.collectiondvd.data.local.AppDatabase +import com.dev.collectiondvd.data.repository.LocalDvdRepository +import com.dev.collectiondvd.ui.theme.MyButton +import com.dev.collectiondvd.viewmodel.LocalDvdViewModel +import com.dev.collectiondvd.viewmodel.factory.LocalDvdViewModelFactory + + +class ListDvdActivity : ComponentActivity() { + + private lateinit var viewModel: LocalDvdViewModel + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val database = AppDatabase.getDatabase(applicationContext) + val dvdDao = database.dvdDao() + val repository = LocalDvdRepository(dvdDao) + val factory = LocalDvdViewModelFactory(repository) + viewModel = ViewModelProvider(this, factory).get(LocalDvdViewModel::class.java) + setContent { ListDvdScreen(onQuit = { finish() }, viewModel = viewModel) } + } +} + +@Composable +fun ListDvdScreen( + viewModel: LocalDvdViewModel, + onQuit: ()-> Unit +){ + val dvds by viewModel.dvds.collectAsState(initial = emptyList()) + + Column( + modifier = Modifier + .fillMaxSize() + .padding(8.dp) + ) + { + + Text( + "Vos Dvds", + fontSize = 24.sp, + fontWeight = FontWeight.Bold, + modifier = Modifier.padding(bottom = 8.dp) + ) + + if(dvds.isEmpty()){ + Box( + modifier = Modifier.weight(1f), + contentAlignment = Alignment.Center + ){ + Text("Aucun Dvd dans votre collection") + } + } else { + LazyColumn(modifier = Modifier.weight(1f)) { + items ( dvds, key = { it.id}) { dvd -> + Column(modifier = Modifier.padding(8.dp)) { + Text(dvd.titre.orEmpty()) + Text(dvd.realisateur.orEmpty()) + Text(dvd.annee.orEmpty()) + Text(dvd.genre.orEmpty()) + Divider() + } + } + } + } + MyButton("Quitter") { onQuit() } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dev/collectiondvd/ui/theme/Color.kt b/app/src/main/java/com/dev/collectiondvd/ui/theme/Color.kt new file mode 100644 index 0000000..31a803b --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package com.dev.collectiondvd.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 file diff --git a/app/src/main/java/com/dev/collectiondvd/ui/theme/Theme.kt b/app/src/main/java/com/dev/collectiondvd/ui/theme/Theme.kt new file mode 100644 index 0000000..9dd8451 --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/ui/theme/Theme.kt @@ -0,0 +1,82 @@ +package com.dev.collectiondvd.ui.theme + +import android.app.Activity +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.layout.size +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +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.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.unit.dp + +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 CollectionDvdTheme( + 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 + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} + +@Composable +fun MyButton( + text: String, + onClick: () -> Unit +) { + Button( + onClick = onClick, + colors = ButtonDefaults.buttonColors( + containerColor = Color.Blue, // Couleur de fond + contentColor = Color.White // Couleur du texte + ), + modifier = Modifier.size(width = 200.dp, height = 50.dp) // Taille uniforme + ) { + Text(text) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dev/collectiondvd/ui/theme/Type.kt b/app/src/main/java/com/dev/collectiondvd/ui/theme/Type.kt new file mode 100644 index 0000000..823140c --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package com.dev.collectiondvd.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 file diff --git a/app/src/main/java/com/dev/collectiondvd/viewmodel/LocalDvdViewModel.kt b/app/src/main/java/com/dev/collectiondvd/viewmodel/LocalDvdViewModel.kt new file mode 100644 index 0000000..0ac85ee --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/viewmodel/LocalDvdViewModel.kt @@ -0,0 +1,19 @@ +package com.dev.collectiondvd.viewmodel + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.dev.collectiondvd.data.local.entities.Dvd +import com.dev.collectiondvd.data.repository.LocalDvdRepository +import kotlinx.coroutines.launch + +class LocalDvdViewModel ( + private val repository: LocalDvdRepository +) : ViewModel() { + val dvds = repository.getAllDvds() + + fun addDvd(dvd: Dvd){ + viewModelScope.launch{ + repository.addDvd(dvd) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/dev/collectiondvd/viewmodel/factory/LocalDvdViewModelFactory.kt b/app/src/main/java/com/dev/collectiondvd/viewmodel/factory/LocalDvdViewModelFactory.kt new file mode 100644 index 0000000..1ccf81c --- /dev/null +++ b/app/src/main/java/com/dev/collectiondvd/viewmodel/factory/LocalDvdViewModelFactory.kt @@ -0,0 +1,17 @@ +package com.dev.collectiondvd.viewmodel.factory + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import com.dev.collectiondvd.data.repository.LocalDvdRepository +import com.dev.collectiondvd.viewmodel.LocalDvdViewModel + +class LocalDvdViewModelFactory(private val repository: LocalDvdRepository): + ViewModelProvider.Factory { + override fun create(modelClass: Class): T { + if(modelClass.isAssignableFrom(LocalDvdViewModel::class.java)){ + @Suppress("UNCHECKED_CAST") + return LocalDvdViewModel(repository) as T + } + throw IllegalArgumentException("Unknown ViewModel class") + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/app/src/main/res/mipmap-anydpi/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..66f70dd --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + CollectionDvd + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..2e59b8d --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +