Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ dependencies {
debugImplementation(libs.androidx.ui.test.manifest)

// Compose dependencies
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0-beta01")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7")
implementation("androidx.navigation:navigation-compose:2.8.3")
implementation("androidx.compose.material:material-icons-extended:1.7.5")
implementation("androidx.hilt:hilt-navigation-compose:1.0.0-alpha03")
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")

// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0")

//Dagger - Hilt
implementation("com.google.dagger:hilt-android:2.49")
Expand All @@ -77,9 +77,11 @@ dependencies {
// Room
implementation("androidx.room:room-runtime:2.6.1")
kapt("androidx.room:room-compiler:2.6.1")

// Kotlin Extensions and Coroutines support for Room
implementation("androidx.room:room-ktx:2.6.1")

// Splash Screen
implementation("androidx.core:core-splashscreen:1.0.0")

}

kapt {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<application
android:name=".NoteApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/icon_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/icon_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CleanArchitectureNoteApp">
<activity
android:name=".feature_note.presentation.MainActivity"
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.CleanArchitectureNoteApp">
Expand Down
Binary file added app/src/main/icon_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.plcoding.cleanarchitecturenoteapp

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.ui.Modifier
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.plcoding.cleanarchitecturenoteapp.ui.navigation.NoteNavigation
import com.plcoding.cleanarchitecturenoteapp.ui.theme.CleanArchitectureNoteAppTheme
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
@ExperimentalAnimationApi
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)
setContent {
CleanArchitectureNoteAppTheme {
Scaffold (
modifier = Modifier.fillMaxSize()
) { paddingValues ->
NoteNavigation(
modifier = Modifier.fillMaxSize().padding(paddingValues)
)
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.plcoding.cleanarchitecturenoteapp.data.database

import androidx.room.*
import com.plcoding.cleanarchitecturenoteapp.data.model.Note
import kotlinx.coroutines.flow.Flow

@Dao
interface NoteDao {

@Query("SELECT * FROM note")
fun getAllNoteDatabase(): Flow<List<Note>>

@Query("SELECT * FROM note WHERE id = :id")
suspend fun getSingleNoteDatabase(id: Int): Note?

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertNoteDatabase(note: Note)

@Delete
suspend fun deleteNoteDatabase(note: Note)
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.plcoding.cleanarchitecturenoteapp.feature_note.data.data_source
package com.plcoding.cleanarchitecturenoteapp.data.database

import androidx.room.Database
import androidx.room.RoomDatabase
import com.plcoding.cleanarchitecturenoteapp.feature_note.domain.model.Note
import com.plcoding.cleanarchitecturenoteapp.data.model.Note

@Database(
entities = [Note::class],
version = 1
version = 1,
exportSchema = false
)
abstract class NoteDatabase: RoomDatabase() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.plcoding.cleanarchitecturenoteapp.feature_note.domain.model
package com.plcoding.cleanarchitecturenoteapp.data.model

import androidx.room.Entity
import androidx.room.PrimaryKey
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.plcoding.cleanarchitecturenoteapp.data.repository

import com.plcoding.cleanarchitecturenoteapp.data.database.NoteDao
import com.plcoding.cleanarchitecturenoteapp.data.model.Note
import com.plcoding.cleanarchitecturenoteapp.domain.repository.NoteRepository
import kotlinx.coroutines.flow.Flow

class NoteRepositoryImpl(
private val noteDao: NoteDao
) : NoteRepository {

override fun getAllNoteRepository(): Flow<List<Note>> {
return noteDao.getAllNoteDatabase()
}

override suspend fun getSingleNoteRepository(id: Int): Note? {
return noteDao.getSingleNoteDatabase(id)
}

override suspend fun insertNoteRepository(note: Note) {
noteDao.insertNoteDatabase(note)
}

override suspend fun deleteNoteRepository(note: Note) {
noteDao.deleteNoteDatabase(note)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.plcoding.cleanarchitecturenoteapp.di

import android.app.Application
import android.content.Context
import androidx.room.Room
import com.plcoding.cleanarchitecturenoteapp.data.database.NoteDatabase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {

@Provides
@Singleton
fun provideNoteDatabase(@ApplicationContext context: Context): NoteDatabase {
return Room.databaseBuilder(
context,
NoteDatabase::class.java,
NoteDatabase.DATABASE_NAME
).build()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.plcoding.cleanarchitecturenoteapp.di

import com.plcoding.cleanarchitecturenoteapp.data.database.NoteDatabase
import com.plcoding.cleanarchitecturenoteapp.data.repository.NoteRepositoryImpl
import com.plcoding.cleanarchitecturenoteapp.domain.repository.NoteRepository
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object RepositoryModule {

@Provides
@Singleton
fun provideNoteRepository(noteDatabase: NoteDatabase): NoteRepository {
return NoteRepositoryImpl(noteDatabase.noteDao)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.plcoding.cleanarchitecturenoteapp.di

import com.plcoding.cleanarchitecturenoteapp.domain.repository.NoteRepository
import com.plcoding.cleanarchitecturenoteapp.domain.usecase.AddNote
import com.plcoding.cleanarchitecturenoteapp.domain.usecase.DeleteNote
import com.plcoding.cleanarchitecturenoteapp.domain.usecase.GetNote
import com.plcoding.cleanarchitecturenoteapp.domain.usecase.GetNotes
import com.plcoding.cleanarchitecturenoteapp.domain.usecase.NoteUseCase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object UseCaseModule {

@Provides
@Singleton
fun provideNoteUseCases(repository: NoteRepository): NoteUseCase {
return NoteUseCase(
getNotes = GetNotes(repository),
deleteNote = DeleteNote(repository),
addNote = AddNote(repository),
getNote = GetNote(repository)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.plcoding.cleanarchitecturenoteapp.domain.repository

import com.plcoding.cleanarchitecturenoteapp.data.model.Note
import kotlinx.coroutines.flow.Flow

interface NoteRepository {

fun getAllNoteRepository(): Flow<List<Note>>

suspend fun getSingleNoteRepository(id: Int): Note?

suspend fun insertNoteRepository(note: Note)

suspend fun deleteNoteRepository(note: Note)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.plcoding.cleanarchitecturenoteapp.feature_note.domain.use_case
package com.plcoding.cleanarchitecturenoteapp.domain.usecase

import com.plcoding.cleanarchitecturenoteapp.feature_note.domain.model.InvalidNoteException
import com.plcoding.cleanarchitecturenoteapp.feature_note.domain.model.Note
import com.plcoding.cleanarchitecturenoteapp.feature_note.domain.repository.NoteRepository
import com.plcoding.cleanarchitecturenoteapp.data.model.InvalidNoteException
import com.plcoding.cleanarchitecturenoteapp.data.model.Note
import com.plcoding.cleanarchitecturenoteapp.domain.repository.NoteRepository
import javax.inject.Inject

class AddNote(
class AddNote @Inject constructor(
private val repository: NoteRepository
) {

Expand All @@ -16,6 +17,6 @@ class AddNote(
if(note.content.isBlank()) {
throw InvalidNoteException("The content of the note can't be empty.")
}
repository.insertNote(note)
repository.insertNoteRepository(note)
}
}
Loading