Skip to content
Open
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
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.

13 changes: 12 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'androidx.navigation.safeargs'
}

android {
Expand Down Expand Up @@ -35,9 +36,19 @@ android {
viewBinding true
}
}

dependencies {
def lifecycle_version = "2.6.1"
def arch_version = "2.2.0"

// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
// reflection-free flavor
implementation 'com.github.kirich1409:viewbindingpropertydelegate-noreflection:1.5.8'
def nav_version = "2.5.3"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Three_lines"
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:name=".presentation.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
51 changes: 0 additions & 51 deletions app/src/main/java/com/example/three_lines/DataListAdapter.kt

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/java/com/example/three_lines/DataModel.kt

This file was deleted.

58 changes: 0 additions & 58 deletions app/src/main/java/com/example/three_lines/MainActivity.kt

This file was deleted.

54 changes: 0 additions & 54 deletions app/src/main/java/com/example/three_lines/ViewContact.kt

This file was deleted.

8 changes: 8 additions & 0 deletions app/src/main/java/com/example/three_lines/data/Note.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.example.three_lines.data

import java.util.*

data class Note(
val id : String = UUID.randomUUID().toString(),
val text : String,
)
11 changes: 11 additions & 0 deletions app/src/main/java/com/example/three_lines/data/NotesDataSource.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.three_lines.data

object NotesDataSource {
val notesList = mutableListOf<Note>()
fun addNote(text : String){
notesList.add(Note(text = text))
}
fun deleteNote(note: Note){
notesList.remove(note)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.three_lines.data.repository

import com.example.three_lines.data.Note
import com.example.three_lines.data.NotesDataSource

class NoteRepositoryImpl(
private val notesDataSource : NotesDataSource = NotesDataSource
) : NotesRepository {
override fun getNotes(): List<Note> {
return notesDataSource.notesList
}

override fun addNote(text: String) {
notesDataSource.addNote(text)
}

override fun deleteNote(note: Note) {
notesDataSource.deleteNote(note)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.three_lines.data.repository

import com.example.three_lines.data.Note

interface NotesRepository {
fun getNotes(): List<Note>
fun addNote(text: String)
fun deleteNote(note: Note)
}
11 changes: 11 additions & 0 deletions app/src/main/java/com/example/three_lines/domain/AddNoteUseCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example.three_lines.domain

import com.example.three_lines.data.repository.NoteRepositoryImpl
import com.example.three_lines.data.repository.NotesRepository

class AddNoteUseCase(private val notesRepository : NotesRepository = NoteRepositoryImpl()
) {
fun execute(text: String){
notesRepository.addNote(text)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.three_lines.domain

import com.example.three_lines.data.Note
import com.example.three_lines.data.repository.NoteRepositoryImpl
import com.example.three_lines.data.repository.NotesRepository
class DeleteNoteUseCase(
private val notesRepository: NotesRepository = NoteRepositoryImpl()
) {
fun execute(note: Note) {
notesRepository.deleteNote(note)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.three_lines.domain

import com.example.three_lines.data.Note
import com.example.three_lines.data.repository.NoteRepositoryImpl
import com.example.three_lines.data.repository.NotesRepository

class GetNotesUseCase(
private val notesRepository: NotesRepository = NoteRepositoryImpl()
) {
fun execute(): List<Note>{
return notesRepository.getNotes()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.three_lines.presentation

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import by.kirich1409.viewbindingdelegate.viewBinding
import com.example.three_lines.R
import com.example.three_lines.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity(R.layout.activity_main) {
private val binding by viewBinding(ActivityMainBinding::bind)


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.three_lines.presentation.fragment_add_note

import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import by.kirich1409.viewbindingdelegate.viewBinding
import com.example.three_lines.R
import com.example.three_lines.databinding.FragmentAddNoteBinding
import com.example.three_lines.presentation.list.NotesListViewModel

class AddNoteFragment : Fragment(R.layout.fragment_add_note) {
private val viewModel by viewModels<NotesListViewModel>()
private val binding by viewBinding(FragmentAddNoteBinding::bind)


override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
with(binding) {
toolbar.setNavigationOnClickListener {
findNavController().popBackStack()
}
floatingActionButton.setOnClickListener {
viewModel.onAddClicked(editTextNote.text.toString())
findNavController().popBackStack()
}
}
}
}
Loading