├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── img.png
│ │ │ │ ├── logo.png
│ │ │ │ ├── github.png
│ │ │ │ ├── linkedin.png
│ │ │ │ ├── note_logo.png
│ │ │ │ ├── note_logo_1.png
│ │ │ │ ├── note_logo_2.png
│ │ │ │ ├── note_logo_3.png
│ │ │ │ ├── ic_baseline_check_24.xml
│ │ │ │ ├── ic_baseline_arrow_back_ios_24.xml
│ │ │ │ ├── ic_baseline_clear_24.xml
│ │ │ │ ├── about.xml
│ │ │ │ ├── ic_launcher_foreground.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── font
│ │ │ │ ├── hind_regular.ttf
│ │ │ │ ├── assistant_regular.ttf
│ │ │ │ ├── dancing_script_regular.ttf
│ │ │ │ ├── playfair_display_regular.ttf
│ │ │ │ └── plus_jakarta_sans_regular.ttf
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── values-night
│ │ │ │ └── colors.xml
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── values
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── themes.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── strings.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ └── xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ ├── ic_launcher-playstore.png
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── swancompany
│ │ │ │ └── journal
│ │ │ │ ├── data
│ │ │ │ ├── models
│ │ │ │ │ └── NoteModel.kt
│ │ │ │ ├── daos
│ │ │ │ │ └── NoteDao.kt
│ │ │ │ └── database
│ │ │ │ │ └── NoteDatabase.kt
│ │ │ │ ├── ui
│ │ │ │ ├── JournalAppScreens.kt
│ │ │ │ ├── presentation
│ │ │ │ │ ├── addNoteScreen
│ │ │ │ │ │ ├── AddNoteViewModel.kt
│ │ │ │ │ │ ├── AddNoteTopBar.kt
│ │ │ │ │ │ └── AddNoteScreen.kt
│ │ │ │ │ ├── homeScreen
│ │ │ │ │ │ ├── HomeViewModel.kt
│ │ │ │ │ │ ├── HomeTopBar.kt
│ │ │ │ │ │ └── HomeScreen.kt
│ │ │ │ │ ├── aboutScreen
│ │ │ │ │ │ ├── AboutTopBar.kt
│ │ │ │ │ │ └── AboutScreen.kt
│ │ │ │ │ └── updateNoteScreen
│ │ │ │ │ │ ├── UpdateNoteViewModel.kt
│ │ │ │ │ │ ├── UpdateNoteTopBar.kt
│ │ │ │ │ │ └── UpdateNoteScreen.kt
│ │ │ │ ├── theme
│ │ │ │ │ ├── Type.kt
│ │ │ │ │ ├── Color.kt
│ │ │ │ │ └── Theme.kt
│ │ │ │ └── JournalApp.kt
│ │ │ │ ├── domain
│ │ │ │ └── NoteRepository.kt
│ │ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── swancompany
│ │ │ └── journal
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── swancompany
│ │ └── journal
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── .idea
├── .gitignore
├── compiler.xml
├── misc.xml
├── gradle.xml
└── inspectionProfiles
│ └── Project_Default.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── settings.gradle
├── LICENSE
├── README.md
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/drawable/img.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/drawable/logo.png
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/drawable/github.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/linkedin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/drawable/linkedin.png
--------------------------------------------------------------------------------
/app/src/main/res/font/hind_regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/font/hind_regular.ttf
--------------------------------------------------------------------------------
/app/src/main/res/drawable/note_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/drawable/note_logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/note_logo_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/drawable/note_logo_1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/note_logo_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/drawable/note_logo_2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/note_logo_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/drawable/note_logo_3.png
--------------------------------------------------------------------------------
/app/src/main/res/font/assistant_regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/font/assistant_regular.ttf
--------------------------------------------------------------------------------
/app/src/main/res/font/dancing_script_regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/font/dancing_script_regular.ttf
--------------------------------------------------------------------------------
/app/src/main/res/font/playfair_display_regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/font/playfair_display_regular.ttf
--------------------------------------------------------------------------------
/app/src/main/res/font/plus_jakarta_sans_regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/font/plus_jakarta_sans_regular.ttf
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #1A160F
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kumarsushil10/journal-note/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #090909
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FBF7F2
4 | #1E92CA
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jan 01 16:58:41 IST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 | /.idea
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Journal
3 | Notes
4 | About
5 | Build this app as a learning project to understand Jetpack compose.Know more about me at ..
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/data/models/NoteModel.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.data.models
2 |
3 | import androidx.room.Entity
4 | import androidx.room.PrimaryKey
5 |
6 | @Entity(tableName = "noteModel")
7 | data class NoteModel (
8 | @PrimaryKey(autoGenerate = true)
9 | var id: Int,
10 | var title:String,
11 | var notes:String
12 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/JournalAppScreens.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui
2 |
3 | sealed class JournalAppScreens(val name : String){
4 | object Home : JournalAppScreens("home")
5 | object AddNotes : JournalAppScreens("add_note")
6 | object UpdateNotes : JournalAppScreens("update_note/{id}")
7 | object About:JournalAppScreens("about")
8 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_baseline_check_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 | rootProject.name = "Journal"
16 | include ':app'
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_baseline_arrow_back_ios_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_baseline_clear_24.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/test/java/com/swancompany/journal/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/addNoteScreen/AddNoteViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.addNoteScreen
2 |
3 | import android.app.Application
4 | import androidx.lifecycle.AndroidViewModel
5 | import androidx.lifecycle.viewModelScope
6 | import com.swancompany.journal.data.models.NoteModel
7 | import com.swancompany.journal.domain.NoteRepository
8 | import kotlinx.coroutines.launch
9 |
10 | class AddNoteViewModel(application: Application) : AndroidViewModel(application) {
11 | private val noteRepo = NoteRepository(application)
12 |
13 | fun insertNote(noteModel: NoteModel) {
14 | viewModelScope.launch {
15 | noteRepo.insertNoteToRoom(noteModel)
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/data/daos/NoteDao.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.data.daos
2 |
3 | import androidx.room.*
4 | import com.swancompany.journal.data.models.NoteModel
5 | import kotlinx.coroutines.flow.Flow
6 |
7 | @Dao
8 | interface NoteDao {
9 | @Query("SELECT * FROM noteModel ORDER BY id ASC")
10 | fun getAllNotes(): Flow>
11 |
12 | @Query("SELECT * FROM noteModel WHERE id = :noteId")
13 | fun getNoteById(noteId: Int): Flow
14 |
15 | @Insert(onConflict = OnConflictStrategy.REPLACE)
16 | suspend fun insertNote(noteModel: NoteModel)
17 |
18 | @Update
19 | suspend fun updateNote(noteModel: NoteModel)
20 |
21 | @Delete
22 | suspend fun deleteNote(noteModel: NoteModel)
23 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/about.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/swancompany/journal/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.swancompany.journal", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/domain/NoteRepository.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.domain
2 |
3 | import android.app.Application
4 | import com.swancompany.journal.data.daos.NoteDao
5 | import com.swancompany.journal.data.database.NoteDatabase
6 | import com.swancompany.journal.data.models.NoteModel
7 | import kotlinx.coroutines.flow.Flow
8 |
9 | class NoteRepository(application: Application) {
10 | private var noteDao: NoteDao
11 |
12 | init {
13 | val database = NoteDatabase.getInstance(application)
14 | noteDao = database.noteDao()
15 | }
16 |
17 | fun getAllNotesFromRoom(): Flow> = noteDao.getAllNotes()
18 | fun getNoteByIdFromRoom(noteId: Int):Flow = noteDao.getNoteById(noteId)
19 | suspend fun insertNoteToRoom(noteModel: NoteModel) = noteDao.insertNote(noteModel)
20 | suspend fun updateNoteInRoom(noteModel: NoteModel) = noteDao.updateNote(noteModel)
21 | suspend fun deleteNoteFromRoom(noteModel: NoteModel) = noteDao.deleteNote(noteModel)
22 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Sushil kumar
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/homeScreen/HomeViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.homeScreen
2 |
3 | import android.app.Application
4 | import androidx.compose.runtime.getValue
5 | import androidx.compose.runtime.mutableStateOf
6 | import androidx.compose.runtime.setValue
7 | import androidx.lifecycle.AndroidViewModel
8 | import androidx.lifecycle.viewModelScope
9 | import com.swancompany.journal.data.models.NoteModel
10 | import com.swancompany.journal.domain.NoteRepository
11 | import kotlinx.coroutines.launch
12 |
13 | class HomeViewModel(application: Application) : AndroidViewModel(application) {
14 | private val noteRepo = NoteRepository(application)
15 | var notesModel by mutableStateOf(emptyList())
16 |
17 | fun getAllNotes() {
18 | viewModelScope.launch {
19 | noteRepo.getAllNotesFromRoom().collect { response ->
20 | notesModel = response
21 | }
22 | }
23 | }
24 |
25 | fun deleteNote(noteModel: NoteModel) {
26 | viewModelScope.launch {
27 | noteRepo.deleteNoteFromRoom(noteModel)
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.theme
2 |
3 | import androidx.compose.material3.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | bodyLarge = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.material3.MaterialTheme
8 | import androidx.compose.material3.Surface
9 | import androidx.compose.ui.Modifier
10 | import androidx.lifecycle.ViewModelProvider
11 | import com.swancompany.journal.ui.JournalApp
12 | import com.swancompany.journal.ui.presentation.homeScreen.HomeViewModel
13 | import com.swancompany.journal.ui.theme.JournalTheme
14 |
15 | class MainActivity : ComponentActivity() {
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 | setContent {
19 | val viewModel = ViewModelProvider(this)[HomeViewModel::class.java]
20 | JournalTheme {
21 | // A surface container using the 'background' color from the theme
22 | Surface(modifier = Modifier.fillMaxSize(),
23 | color = MaterialTheme.colorScheme.background) {
24 | JournalApp()
25 | }
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/data/database/NoteDatabase.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.data.database
2 |
3 | import android.content.Context
4 | import androidx.room.Database
5 | import androidx.room.Room
6 | import androidx.room.RoomDatabase
7 | import com.swancompany.journal.data.daos.NoteDao
8 | import com.swancompany.journal.data.models.NoteModel
9 |
10 |
11 | @Database(entities = [NoteModel::class], version = 1)
12 | abstract class NoteDatabase :RoomDatabase(){
13 | abstract fun noteDao() : NoteDao
14 |
15 | companion object {
16 | private var INSTANCE: NoteDatabase? = null
17 | fun getInstance(context: Context ): NoteDatabase {
18 | synchronized(this) {
19 | var instance = INSTANCE
20 | if (instance == null) {
21 | instance = Room.databaseBuilder(
22 | context.applicationContext,
23 | NoteDatabase::class.java,
24 | "Note_database"
25 | )
26 | .allowMainThreadQueries()
27 | .build()
28 | INSTANCE = instance
29 | }
30 | return instance
31 | }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
15 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/aboutScreen/AboutTopBar.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.aboutScreen
2 |
3 | import androidx.compose.material3.CenterAlignedTopAppBar
4 | import androidx.compose.material3.Icon
5 | import androidx.compose.material3.IconButton
6 | import androidx.compose.material3.Text
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.res.painterResource
9 | import androidx.compose.ui.res.stringResource
10 | import androidx.compose.ui.text.font.Font
11 | import androidx.compose.ui.text.font.FontFamily
12 | import com.swancompany.journal.R
13 | import com.swancompany.journal.data.models.NoteModel
14 | import com.swancompany.journal.ui.presentation.addNoteScreen.AddNoteViewModel
15 |
16 | @Composable
17 | fun AboutTopBar(
18 | navigateBack: () -> Unit,
19 | ) {
20 | CenterAlignedTopAppBar(
21 | title = {
22 | Text(
23 | stringResource(R.string.about),
24 | fontFamily = FontFamily(Font(R.font.playfair_display_regular)),
25 | )
26 | },
27 | navigationIcon = {
28 | IconButton(onClick = { navigateBack() }) {
29 | Icon(painterResource(R.drawable.ic_baseline_arrow_back_ios_24),
30 | contentDescription = "logo")
31 | }
32 | },
33 | )
34 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Journal
2 | > Check out Simple Android Notepad app
3 |
4 |
5 |
6 |
7 | # :camera: Screenshots :camera:
8 | 
9 |
10 |
11 |
12 |
13 | # :rocket: Tech Stack :rocket:
14 | This project takes advantage of the best practises of common libraries and tools in Android.
15 | * [Kotlin](https://kotlinlang.org/)
16 | * [Jetpack Compose](https://developer.android.com/jetpack)
17 | * [Room](https://developer.android.com/training/data-storage/room) - for saving data in a local database
18 | * [Jetpack libraries](https://developer.android.com/jetpack):
19 | * [Navigation component](https://developer.android.com/topic/libraries/architecture/navigation/) - in-app navigation
20 | * [Lifecycle](https://developer.android.com/topic/libraries/architecture/lifecycle) - perform an action when lifecycle state changes
21 | * [ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel) - store and manage UI-related data in a lifecycle conscious way
22 |
23 |
24 |
25 |
26 |
27 |
28 | # Support this app by giving it a :star:
29 |
30 |
31 |
32 |
33 |
34 | # :balance_scale: License :balance_scale:
35 |
36 | [](https://badges.mit-license.org)
37 |
38 | - **[MIT license](LICENSE)**
39 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/updateNoteScreen/UpdateNoteViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.updateNoteScreen
2 |
3 | import android.app.Application
4 | import androidx.lifecycle.AndroidViewModel
5 | import com.swancompany.journal.domain.NoteRepository
6 | import androidx.compose.runtime.getValue
7 | import androidx.compose.runtime.mutableStateOf
8 | import androidx.compose.runtime.setValue
9 | import androidx.lifecycle.ViewModel
10 | import androidx.lifecycle.viewModelScope
11 | import com.swancompany.journal.data.models.NoteModel
12 | import kotlinx.coroutines.Dispatchers
13 | import kotlinx.coroutines.launch
14 |
15 |
16 | class UpdateNoteViewModel(application: Application) : AndroidViewModel(application) {
17 |
18 | private val noteRepo = NoteRepository(application)
19 | var noteModel by mutableStateOf(NoteModel(0, "", ""))
20 |
21 | fun getNoteById(noteId: Int) {
22 | viewModelScope.launch {
23 | noteRepo.getNoteByIdFromRoom(noteId).collect { response ->
24 | noteModel = response
25 | }
26 | }
27 | }
28 |
29 | fun updateNotes(noteModel: NoteModel) {
30 | viewModelScope.launch {
31 | noteRepo.updateNoteInRoom(noteModel)
32 | }
33 | }
34 |
35 | fun updateTitle(title: String) {
36 | noteModel = noteModel.copy(title = title)
37 | }
38 |
39 | fun updateNote(note: String) {
40 | noteModel = noteModel.copy(notes = note)
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/homeScreen/HomeTopBar.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.homeScreen
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.layout.*
5 | import androidx.compose.material3.*
6 | import com.swancompany.journal.R
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.Modifier
9 | import androidx.compose.ui.res.painterResource
10 | import androidx.compose.ui.res.stringResource
11 | import androidx.compose.ui.text.font.Font
12 | import androidx.compose.ui.text.font.FontFamily
13 | import androidx.compose.ui.unit.dp
14 |
15 | @Composable
16 | fun HomeTopBar(
17 | navigateToAboutScreen:()-> Unit
18 | ) {
19 | CenterAlignedTopAppBar(
20 | title = {
21 | Text(stringResource(R.string.app_name),
22 | fontFamily = FontFamily(Font(R.font.playfair_display_regular)),
23 | )
24 | },
25 | navigationIcon = {
26 | Image(
27 | painter = painterResource(id = R.drawable.ic_launcher_foreground),
28 | contentDescription = "logo",
29 | modifier = Modifier
30 | .width(100.dp)
31 | .height(100.dp)
32 | )
33 | },
34 | actions = {
35 | IconButton(onClick = {navigateToAboutScreen() }) {
36 | Icon(painterResource(
37 | id = R.drawable.about),
38 | contentDescription = "about")
39 | }
40 | }
41 | )
42 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/updateNoteScreen/UpdateNoteTopBar.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.updateNoteScreen
2 |
3 | import androidx.compose.material3.CenterAlignedTopAppBar
4 | import androidx.compose.material3.Icon
5 | import androidx.compose.material3.IconButton
6 | import androidx.compose.material3.Text
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.res.painterResource
9 | import androidx.compose.ui.text.font.Font
10 | import androidx.compose.ui.text.font.FontFamily
11 | import com.swancompany.journal.R
12 | import com.swancompany.journal.data.models.NoteModel
13 |
14 | @Composable
15 | fun UpdateNoteTopBar(
16 | viewModel: UpdateNoteViewModel,
17 | noteId: Int,
18 | navigateBack: () -> Unit,
19 | title: String,
20 | note: String,
21 | ) {
22 | CenterAlignedTopAppBar(
23 | title = { Text(
24 | text = title,
25 | fontFamily = FontFamily(Font(R.font.playfair_display_regular)),
26 | )
27 | },
28 | navigationIcon = {
29 | IconButton(onClick = { navigateBack() }) {
30 | Icon(painterResource(R.drawable.ic_baseline_clear_24),
31 | contentDescription = "back")
32 | }
33 | },
34 | actions = {
35 | IconButton(onClick = {
36 | val updateNote = NoteModel(noteId, title, note)
37 | viewModel.updateNotes(updateNote)
38 | navigateBack()
39 | }) {
40 | Icon(painterResource(id = R.drawable.ic_baseline_check_24),
41 | contentDescription = "save")
42 | }
43 | }
44 | )
45 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/addNoteScreen/AddNoteTopBar.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.addNoteScreen
2 |
3 | import androidx.compose.material3.*
4 | import com.swancompany.journal.R
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.ui.res.painterResource
7 | import androidx.compose.ui.res.stringResource
8 | import androidx.compose.ui.text.font.Font
9 | import androidx.compose.ui.text.font.FontFamily
10 | import com.swancompany.journal.data.models.NoteModel
11 |
12 | @Composable
13 | fun AddNoteTopBar(
14 | viewModel: AddNoteViewModel,
15 | navigateBack: () -> Unit,
16 | title: String,
17 | notes: String,
18 | ) {
19 | CenterAlignedTopAppBar(
20 | title = {
21 | Text(
22 | stringResource(R.string.note),
23 | fontFamily = FontFamily(Font(R.font.playfair_display_regular)),
24 | )
25 | },
26 | navigationIcon = {
27 | IconButton(onClick = { navigateBack() }) {
28 | Icon(painterResource(R.drawable.ic_baseline_clear_24),
29 | contentDescription = "logo")
30 | }
31 | },
32 | actions = {
33 | IconButton(onClick = {
34 | if (title.isNotEmpty() || notes.isNotEmpty()){
35 | val noteModel = NoteModel(id = 0, title = title, notes = notes)
36 | viewModel.insertNote(noteModel)
37 | navigateBack()
38 | }else{
39 | navigateBack()
40 | }
41 | }) {
42 | Icon(painterResource(id = R.drawable.ic_baseline_check_24),
43 | contentDescription = "Git")
44 | }
45 | }
46 | )
47 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | // Light Color
6 |
7 | val md_theme_light_primary = Color(0xFFFFD655)
8 | val md_theme_light_onPrimary = Color(0xFF292315)
9 | val md_theme_light_primaryContainer = Color(0xFFEFE7D3)
10 | val md_theme_light_onPrimaryContainer = Color(0xFF926C13)
11 |
12 | val md_theme_light_secondary = Color(0xFFE8225D)
13 | val md_theme_light_onSecondary = Color(0xFFFFFFFF)
14 | val md_theme_light_secondaryContainer = Color(0xFFFADCE5)
15 | val md_theme_light_onSecondaryContainer = Color(0xFF725207)
16 |
17 | val md_theme_light_error = Color(0xFFBA1A1A)
18 | val md_theme_light_errorContainer = Color(0xFFFFDAD6)
19 | val md_theme_light_onError = Color(0xFFFFFFFF)
20 | val md_theme_light_onErrorContainer = Color(0xFF410002)
21 |
22 | val md_theme_light_surface = Color(0xFFECDAC7)
23 | val md_theme_light_onSurface = Color(0xFF1A160F)
24 |
25 |
26 |
27 | // Dark Color
28 |
29 | val md_theme_dark_primary = Color(0xFFFFD655)
30 | val md_theme_dark_onPrimary = Color(0xFF292315)
31 | val md_theme_dark_primaryContainer = Color(0xFF4D4635)
32 | val md_theme_dark_onPrimaryContainer = Color(0xFFC5AE75)
33 |
34 | val md_theme_dark_secondary = Color(0xFFE8225D)
35 | val md_theme_dark_onSecondary = Color(0xFFFFFFFF)
36 | val md_theme_dark_secondaryContainer = Color(0xFFB8325A)
37 | val md_theme_dark_onSecondaryContainer = Color(0xFFB6AA8E)
38 |
39 |
40 | val md_theme_dark_error = Color(0xFFFFB4AB)
41 | val md_theme_dark_errorContainer = Color(0xFF93000A)
42 | val md_theme_dark_onError = Color(0xFF690005)
43 | val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6)
44 |
45 | val md_theme_dark_surface = Color(0xFF4D4635)
46 | val md_theme_dark_onSurface = Color(0xFFF1EEE9)
47 |
48 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/JournalApp.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui
2 |
3 | import androidx.compose.runtime.Composable
4 | import androidx.navigation.NavHostController
5 | import androidx.navigation.NavType.Companion.IntType
6 | import androidx.navigation.compose.NavHost
7 | import androidx.navigation.compose.composable
8 | import androidx.navigation.compose.rememberNavController
9 | import androidx.navigation.navArgument
10 | import com.swancompany.journal.ui.presentation.aboutScreen.AboutScreen
11 | import com.swancompany.journal.ui.presentation.addNoteScreen.AddNoteScreen
12 | import com.swancompany.journal.ui.presentation.homeScreen.HomeScreen
13 | import com.swancompany.journal.ui.presentation.updateNoteScreen.UpdateNoteScreen
14 |
15 | @Composable
16 | fun JournalApp(
17 | navController: NavHostController = rememberNavController(),
18 | ) {
19 | NavHost(
20 | navController = navController,
21 | startDestination = JournalAppScreens.Home.name,
22 | ) {
23 | composable(route = JournalAppScreens.Home.name) {
24 | HomeScreen(
25 | onFabClicked = { navController.navigate(JournalAppScreens.AddNotes.name) },
26 | navigateToUpdateNoteScreen = { noteId ->
27 | navController.navigate("${JournalAppScreens.UpdateNotes.name}/$noteId")
28 | },
29 | navigateToAboutScreen = {navController.navigate(JournalAppScreens.About.name)}
30 | )
31 | }
32 | composable(route = "${JournalAppScreens.UpdateNotes.name}/{noteId}",
33 | arguments = listOf(navArgument("noteId") { type = IntType })
34 | ) { backStackEntry ->
35 | val noteId = backStackEntry.arguments?.getInt("noteId") ?: 0
36 | UpdateNoteScreen(
37 | noteId = noteId,
38 | navigateBack = { navController.popBackStack() }
39 | )
40 | }
41 | composable(JournalAppScreens.AddNotes.name) {
42 | AddNoteScreen(navigateBack = { navController.popBackStack() })
43 | }
44 | composable(JournalAppScreens.About.name){
45 | AboutScreen (navigateBack = { navController.popBackStack() })
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'org.jetbrains.kotlin.android'
4 | id 'kotlin-kapt'
5 | id 'kotlin-android'
6 | }
7 |
8 | android {
9 | namespace 'com.swancompany.journal'
10 | compileSdk 33
11 |
12 | defaultConfig {
13 | applicationId "com.swancompany.journal"
14 | minSdk 27
15 | targetSdk 33
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
20 | vectorDrawables {
21 | useSupportLibrary true
22 | }
23 | }
24 |
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
29 | }
30 | }
31 | compileOptions {
32 | sourceCompatibility JavaVersion.VERSION_1_8
33 | targetCompatibility JavaVersion.VERSION_1_8
34 | }
35 | kotlinOptions {
36 | jvmTarget = '1.8'
37 | }
38 | buildFeatures {
39 | compose true
40 | }
41 | composeOptions {
42 | kotlinCompilerExtensionVersion '1.1.1'
43 | }
44 | packagingOptions {
45 | resources {
46 | excludes += '/META-INF/{AL2.0,LGPL2.1}'
47 | }
48 | }
49 | }
50 |
51 | dependencies {
52 |
53 | implementation 'androidx.core:core-ktx:1.7.0'
54 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
55 | implementation 'androidx.activity:activity-compose:1.3.1'
56 | implementation "androidx.compose.ui:ui:$compose_version"
57 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
58 | implementation 'androidx.compose.material3:material3:1.0.0-alpha02'
59 | testImplementation 'junit:junit:4.13.2'
60 | androidTestImplementation 'androidx.test.ext:junit:1.1.4'
61 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
62 | androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
63 | debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
64 | debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
65 | implementation "androidx.compose.material:material:$compose_version"
66 |
67 | //Room
68 | implementation "androidx.room:room-runtime:2.4.3"
69 | implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
70 | implementation "androidx.room:room-ktx:2.4.3"
71 | implementation "androidx.compose.runtime:runtime-livedata:1.3.2"
72 | annotationProcessor "androidx.room:room-compiler:2.4.3"
73 | kapt "androidx.room:room-compiler:2.4.3"
74 |
75 | //Navigation
76 | implementation "androidx.navigation:navigation-compose:2.6.0-alpha04"
77 |
78 | // ViewModel
79 | implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1"
80 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
81 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
82 | implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
83 | implementation "androidx.core:core-ktx:1.9.0"
84 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.theme
2 |
3 | import android.app.Activity
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material3.MaterialTheme
7 | import androidx.compose.material3.darkColorScheme
8 | import androidx.compose.material3.dynamicDarkColorScheme
9 | import androidx.compose.material3.dynamicLightColorScheme
10 | import androidx.compose.material3.lightColorScheme
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.SideEffect
13 | import androidx.compose.ui.graphics.toArgb
14 | import androidx.compose.ui.platform.LocalContext
15 | import androidx.compose.ui.platform.LocalView
16 | import androidx.core.view.ViewCompat
17 |
18 | private val LightColorScheme = lightColorScheme(
19 | primary = md_theme_light_primary,
20 | onPrimary = md_theme_light_onPrimary,
21 | primaryContainer = md_theme_light_primaryContainer,
22 | onPrimaryContainer = md_theme_light_onPrimaryContainer,
23 |
24 | secondary = md_theme_light_secondary,
25 | onSecondary = md_theme_light_onSecondary,
26 | secondaryContainer = md_theme_light_secondaryContainer,
27 | onSecondaryContainer = md_theme_light_onSecondaryContainer,
28 |
29 | error = md_theme_light_error,
30 | errorContainer = md_theme_light_errorContainer,
31 | onError = md_theme_light_onError,
32 | onErrorContainer = md_theme_light_onErrorContainer,
33 |
34 | surface = md_theme_light_surface,
35 | onSurface = md_theme_light_onSurface,
36 | )
37 |
38 |
39 | private val DarkColorScheme = darkColorScheme(
40 | primary = md_theme_dark_primary,
41 | onPrimary = md_theme_dark_onPrimary,
42 | primaryContainer = md_theme_dark_primaryContainer,
43 | onPrimaryContainer = md_theme_dark_onPrimaryContainer,
44 |
45 | secondary = md_theme_dark_secondary,
46 | onSecondary = md_theme_dark_onSecondary,
47 | secondaryContainer = md_theme_dark_secondaryContainer,
48 | onSecondaryContainer = md_theme_dark_onSecondaryContainer,
49 |
50 | error = md_theme_dark_error,
51 | errorContainer = md_theme_dark_errorContainer,
52 | onError = md_theme_dark_onError,
53 | onErrorContainer = md_theme_dark_onErrorContainer,
54 |
55 | surface = md_theme_dark_surface,
56 | onSurface = md_theme_dark_onSurface
57 | )
58 |
59 |
60 |
61 |
62 |
63 |
64 | @Composable
65 | fun JournalTheme(
66 | darkTheme: Boolean = isSystemInDarkTheme(),
67 | // Dynamic color is available on Android 12+
68 | dynamicColor: Boolean = true,
69 | content: @Composable () -> Unit
70 | ) {
71 | val colorScheme = when {
72 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
73 | val context = LocalContext.current
74 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
75 | }
76 | darkTheme -> DarkColorScheme
77 | else -> LightColorScheme
78 | }
79 | val view = LocalView.current
80 | if (!view.isInEditMode) {
81 | SideEffect {
82 | (view.context as Activity).window.statusBarColor = colorScheme.surface.toArgb()
83 | ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = !darkTheme
84 | }
85 | }
86 |
87 | MaterialTheme(
88 | colorScheme = colorScheme,
89 | typography = Typography,
90 | content = content
91 | )
92 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
11 |
14 |
19 |
24 |
27 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
49 |
54 |
59 |
62 |
63 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/addNoteScreen/AddNoteScreen.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.addNoteScreen
2 |
3 | import androidx.compose.foundation.layout.Column
4 | import androidx.compose.foundation.layout.fillMaxHeight
5 | import androidx.compose.foundation.layout.fillMaxSize
6 | import androidx.compose.foundation.layout.fillMaxWidth
7 | import androidx.compose.foundation.shape.RoundedCornerShape
8 | import androidx.compose.foundation.text.KeyboardActions
9 | import androidx.compose.foundation.text.KeyboardOptions
10 | import androidx.compose.material.*
11 | import androidx.compose.material3.MaterialTheme
12 | import androidx.compose.material3.MaterialTheme.colorScheme
13 | import androidx.compose.material3.Text
14 | import androidx.compose.runtime.*
15 | import androidx.compose.ui.Modifier
16 | import androidx.compose.ui.focus.FocusDirection
17 | import androidx.compose.ui.graphics.Color
18 | import androidx.compose.ui.platform.LocalFocusManager
19 | import androidx.compose.ui.res.colorResource
20 | import androidx.compose.ui.text.TextStyle
21 | import androidx.compose.ui.text.font.Font
22 | import androidx.compose.ui.text.font.FontFamily
23 | import androidx.compose.ui.text.input.ImeAction
24 | import androidx.compose.ui.text.input.KeyboardCapitalization
25 | import androidx.compose.ui.text.input.KeyboardType
26 | import androidx.compose.ui.unit.dp
27 | import androidx.lifecycle.viewmodel.compose.viewModel
28 | import com.swancompany.journal.R
29 |
30 | @Composable
31 | fun AddNoteScreen(
32 | navigateBack: () -> Unit,
33 | ) {
34 | val viewModel: AddNoteViewModel = viewModel()
35 | var title by remember { mutableStateOf("") }
36 | var notes by remember { mutableStateOf("") }
37 | val focusManager = LocalFocusManager.current
38 | Scaffold(
39 | topBar = { AddNoteTopBar(viewModel, navigateBack, title, notes) },
40 | backgroundColor = colorScheme.surface
41 | ) {
42 | Surface(
43 | color = colorResource(id = R.color.colorBackground),
44 | shape = RoundedCornerShape(32.dp, 32.dp)
45 | ) {
46 | Column(modifier = Modifier.fillMaxSize()
47 | ) {
48 | TextField(
49 | value = title,
50 | onValueChange = { title = it },
51 | placeholder = { Text("Title", color = colorScheme.onSurface) },
52 | textStyle = TextStyle(color = colorScheme.onSurface,
53 | fontFamily = FontFamily(Font(R.font.plus_jakarta_sans_regular)),
54 | ),
55 | modifier = Modifier.fillMaxWidth(),
56 | singleLine = true,
57 | colors = TextFieldDefaults.textFieldColors(
58 | backgroundColor = Color.Transparent,
59 | focusedIndicatorColor = Color.LightGray,
60 | unfocusedIndicatorColor = Color.Transparent,
61 | disabledIndicatorColor = Color.Transparent
62 | ),
63 | keyboardOptions = KeyboardOptions.Default.copy(
64 | capitalization = KeyboardCapitalization.Sentences,
65 | keyboardType = KeyboardType.Text,
66 | imeAction = ImeAction.Next
67 | ),
68 | keyboardActions = KeyboardActions(onNext = {
69 | focusManager.moveFocus(FocusDirection.Down) }
70 | ),
71 | )
72 | TextField(
73 | value = notes,
74 | onValueChange = { notes = it },
75 | placeholder = { Text("Notes", color = colorScheme.onSurface) },
76 | textStyle = TextStyle(color = colorScheme.onSurface,
77 | fontFamily = FontFamily(Font(R.font.plus_jakarta_sans_regular)),
78 | ),
79 | modifier = Modifier
80 | .fillMaxWidth()
81 | .fillMaxHeight(),
82 | colors = TextFieldDefaults.textFieldColors(
83 | backgroundColor = Color.Transparent,
84 | focusedIndicatorColor = Color.Transparent,
85 | unfocusedIndicatorColor = Color.Transparent,
86 | disabledIndicatorColor = Color.Transparent
87 | ),
88 | keyboardOptions = KeyboardOptions.Default.copy(
89 | capitalization = KeyboardCapitalization.Sentences,
90 | keyboardType = KeyboardType.Text,
91 | ),
92 | )
93 | }
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/updateNoteScreen/UpdateNoteScreen.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.updateNoteScreen
2 |
3 | import androidx.compose.foundation.layout.*
4 | import androidx.compose.foundation.shape.RoundedCornerShape
5 | import androidx.compose.foundation.text.KeyboardActions
6 | import androidx.compose.foundation.text.KeyboardOptions
7 | import androidx.compose.material.*
8 | import androidx.compose.material3.MaterialTheme
9 | import androidx.compose.material3.MaterialTheme.colorScheme
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.runtime.LaunchedEffect
12 | import androidx.compose.ui.Alignment
13 | import androidx.compose.ui.Modifier
14 | import androidx.compose.ui.focus.FocusDirection
15 | import androidx.compose.ui.graphics.Color
16 | import androidx.compose.ui.platform.LocalFocusManager
17 | import androidx.compose.ui.res.colorResource
18 | import androidx.compose.ui.text.TextStyle
19 | import androidx.compose.ui.text.font.Font
20 | import androidx.compose.ui.text.font.FontFamily
21 | import androidx.compose.ui.text.input.ImeAction
22 | import androidx.compose.ui.text.input.KeyboardCapitalization
23 | import androidx.compose.ui.text.input.KeyboardType
24 | import androidx.compose.ui.unit.dp
25 | import androidx.lifecycle.viewmodel.compose.viewModel
26 | import com.swancompany.journal.R
27 | import com.swancompany.journal.data.models.NoteModel
28 | import com.swancompany.journal.ui.presentation.addNoteScreen.AddNoteTopBar
29 |
30 | @Composable
31 | fun UpdateNoteScreen(
32 | noteId: Int,
33 | navigateBack: () -> Unit,
34 | ) {
35 | val viewModel: UpdateNoteViewModel = viewModel()
36 | val title = viewModel.noteModel.title
37 | val note = viewModel.noteModel.notes
38 | val focusManager = LocalFocusManager.current
39 |
40 | LaunchedEffect(Unit) {
41 | viewModel.getNoteById(noteId)
42 | }
43 | Scaffold(
44 | topBar = { UpdateNoteTopBar(viewModel, noteId, navigateBack, title, note) },
45 | backgroundColor = colorScheme.surface
46 |
47 | ) {
48 | Surface(
49 | color = colorResource(id = R.color.colorBackground),
50 | shape = RoundedCornerShape(32.dp, 32.dp)
51 | ) {
52 | Column(
53 | modifier = Modifier.fillMaxSize(),
54 | ) {
55 | TextField(
56 | value = title,
57 | onValueChange = { title -> viewModel.updateTitle(title) },
58 | placeholder = { Text(text = "Title",color = colorScheme.onSurface) },
59 | textStyle = TextStyle(
60 | color = colorScheme.onSurface,
61 | fontFamily = FontFamily(Font(R.font.plus_jakarta_sans_regular)),
62 | ),
63 | modifier = Modifier.fillMaxWidth(),
64 | singleLine = true,
65 | colors = TextFieldDefaults.textFieldColors(
66 | backgroundColor = Color.Transparent,
67 | focusedIndicatorColor = Color.LightGray,
68 | unfocusedIndicatorColor = Color.Transparent,
69 | disabledIndicatorColor = Color.Transparent
70 | ),
71 | keyboardOptions = KeyboardOptions.Default.copy(
72 | capitalization = KeyboardCapitalization.Sentences,
73 | keyboardType = KeyboardType.Text,
74 | imeAction = ImeAction.Next
75 | ),
76 | keyboardActions = KeyboardActions(onNext = {
77 | focusManager.moveFocus(FocusDirection.Down)
78 | }),
79 | )
80 |
81 | TextField(
82 | value = note,
83 | onValueChange = { note -> viewModel.updateNote(note) },
84 | placeholder = { Text(text = "Note",color = colorScheme.onSurface) },
85 | textStyle = TextStyle(color = colorScheme.onSurface,
86 | fontFamily = FontFamily(Font(R.font.plus_jakarta_sans_regular)),
87 | ),
88 | modifier = Modifier
89 | .fillMaxWidth()
90 | .fillMaxHeight(0.9f),
91 | colors = TextFieldDefaults.textFieldColors(
92 | backgroundColor = Color.Transparent,
93 | focusedIndicatorColor = Color.Transparent,
94 | unfocusedIndicatorColor = Color.Transparent,
95 | disabledIndicatorColor = Color.Transparent
96 | ),
97 | keyboardOptions = KeyboardOptions.Default.copy(
98 | capitalization = KeyboardCapitalization.Sentences,
99 | keyboardType = KeyboardType.Text,
100 | ),
101 | )
102 | }
103 | }
104 | }
105 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/aboutScreen/AboutScreen.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.aboutScreen
2 |
3 | import android.content.Intent
4 | import android.net.Uri
5 | import androidx.compose.foundation.BorderStroke
6 | import androidx.compose.foundation.Image
7 | import androidx.compose.foundation.background
8 | import androidx.compose.foundation.layout.*
9 | import androidx.compose.foundation.shape.CircleShape
10 | import androidx.compose.foundation.shape.RoundedCornerShape
11 | import androidx.compose.material.Card
12 | import androidx.compose.material.Scaffold
13 | import androidx.compose.material.Surface
14 | import androidx.compose.material3.Button
15 | import androidx.compose.material3.ButtonColors
16 | import androidx.compose.material3.ButtonDefaults
17 | import androidx.compose.material3.MaterialTheme.colorScheme
18 | import androidx.compose.material3.Text
19 | import androidx.compose.runtime.Composable
20 | import androidx.compose.ui.Alignment
21 | import androidx.compose.ui.Modifier
22 | import androidx.compose.ui.draw.alpha
23 | import androidx.compose.ui.graphics.Color
24 | import androidx.compose.ui.platform.LocalContext
25 | import androidx.compose.ui.res.colorResource
26 | import androidx.compose.ui.res.painterResource
27 | import androidx.compose.ui.res.stringResource
28 | import androidx.compose.ui.text.font.Font
29 | import androidx.compose.ui.text.font.FontFamily
30 | import androidx.compose.ui.text.style.TextAlign
31 | import androidx.compose.ui.unit.dp
32 | import androidx.compose.ui.unit.sp
33 | import androidx.core.content.ContextCompat.startActivity
34 | import com.swancompany.journal.R
35 |
36 | @Composable
37 | fun AboutScreen(
38 | navigateBack: () -> Unit,
39 | ) {
40 | val context = LocalContext.current
41 | val intentGithub = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/sushilgitter/Journal"))
42 | val intentLinkedIn = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.linkedin.com/in/kmrsushil10/"))
43 |
44 | Scaffold(
45 | topBar = { AboutTopBar(navigateBack) },
46 | backgroundColor = colorScheme.surface
47 | ) {
48 | Surface(
49 | color = colorResource(id = R.color.colorBackground),
50 | shape = RoundedCornerShape(32.dp, 32.dp)
51 | ) {
52 | Column(
53 | modifier = Modifier
54 | .fillMaxSize()
55 | .padding(20.dp, 10.dp),
56 | horizontalAlignment = Alignment.CenterHorizontally,
57 | verticalArrangement = Arrangement.Bottom
58 | ) {
59 | Image(
60 | painter = painterResource(id = R.drawable.note_logo_3),
61 | contentDescription = "logo",
62 | )
63 | Spacer(modifier = Modifier.height(20.dp))
64 | Text(
65 | modifier = Modifier.fillMaxWidth(),
66 | color = colorScheme.onSurface,
67 | textAlign = TextAlign.Center,
68 | text = "Journal",
69 | fontFamily = FontFamily(Font(R.font.playfair_display_regular)),
70 | fontSize = 40.sp
71 | )
72 | Spacer(modifier = Modifier.height(40.dp))
73 |
74 | Text(
75 | text = stringResource(id = R.string.about_me),
76 | textAlign = TextAlign.Center,
77 | color = colorScheme.onSurface,
78 | modifier = Modifier.fillMaxWidth()
79 | .padding(10.dp,0.dp),
80 | fontFamily = FontFamily(Font(R.font.playfair_display_regular))
81 | )
82 | Spacer(modifier = Modifier.height(100.dp))
83 | Button(
84 | onClick = { startActivity(context, intentGithub, null)},
85 | modifier = Modifier
86 | .fillMaxWidth()
87 | .height(60.dp),
88 | colors = ButtonDefaults.buttonColors(
89 | containerColor = Color.Black,
90 | contentColor = Color.White),
91 | shape = RoundedCornerShape(20.dp),
92 |
93 | ) {
94 | Text(
95 | text = "GitHub",
96 | fontSize = 24.sp,
97 | fontFamily = FontFamily(Font(R.font.playfair_display_regular)),
98 | modifier = Modifier.fillMaxWidth(),
99 | textAlign = TextAlign.Center
100 | )
101 | }
102 | Spacer(modifier = Modifier.height(10.dp))
103 | Button(
104 | onClick = { startActivity(context, intentLinkedIn, null) },
105 | modifier = Modifier
106 | .fillMaxWidth()
107 | .height(60.dp),
108 | colors = ButtonDefaults.buttonColors(
109 | containerColor = colorResource(id = R.color.linked_in_btn),
110 | contentColor = Color.White),
111 | shape = RoundedCornerShape(20.dp),
112 | ) {
113 | Text(
114 | text = "LinkedIn",
115 | fontSize = 24.sp,
116 | fontFamily = FontFamily(Font(R.font.playfair_display_regular)),
117 | modifier = Modifier.fillMaxWidth(),
118 | textAlign = TextAlign.Center
119 | )
120 | }
121 | Spacer(modifier = Modifier.height(20.dp))
122 | }
123 | }
124 | }
125 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/app/src/main/java/com/swancompany/journal/ui/presentation/homeScreen/HomeScreen.kt:
--------------------------------------------------------------------------------
1 | package com.swancompany.journal.ui.presentation.homeScreen
2 |
3 | import com.swancompany.journal.R
4 | import android.util.Log
5 | import androidx.compose.animation.animateColorAsState
6 | import androidx.compose.foundation.clickable
7 | import androidx.compose.foundation.lazy.LazyColumn
8 | import androidx.compose.foundation.lazy.items
9 | import androidx.compose.material3.*
10 | import androidx.compose.material3.FloatingActionButton
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.LaunchedEffect
13 | import androidx.compose.runtime.getValue
14 | import androidx.compose.ui.Alignment
15 | import androidx.compose.ui.Modifier
16 | import androidx.compose.ui.graphics.Color
17 | import androidx.compose.ui.unit.dp
18 | import androidx.compose.ui.unit.sp
19 | import androidx.lifecycle.viewmodel.compose.viewModel
20 | import com.swancompany.journal.data.models.NoteModel
21 | import androidx.compose.animation.core.animateFloatAsState
22 | import androidx.compose.foundation.BorderStroke
23 | import androidx.compose.foundation.Image
24 | import androidx.compose.foundation.background
25 | import androidx.compose.foundation.layout.*
26 | import androidx.compose.foundation.shape.RoundedCornerShape
27 | import androidx.compose.material.*
28 | import androidx.compose.material.DismissDirection.EndToStart
29 | import androidx.compose.material.DismissDirection.StartToEnd
30 | import androidx.compose.material.DismissValue.Default
31 | import androidx.compose.material.DismissValue.DismissedToEnd
32 | import androidx.compose.material.DismissValue.DismissedToStart
33 | import androidx.compose.material.Scaffold
34 | import androidx.compose.material.icons.Icons
35 | import androidx.compose.material.icons.filled.Add
36 | import androidx.compose.material.icons.filled.Delete
37 | import androidx.compose.material3.Icon
38 | import androidx.compose.material3.MaterialTheme.colorScheme
39 | import androidx.compose.material3.Text
40 | import androidx.compose.ui.draw.alpha
41 | import androidx.compose.ui.draw.scale
42 | import androidx.compose.ui.res.colorResource
43 | import androidx.compose.ui.res.painterResource
44 | import androidx.compose.ui.text.font.Font
45 | import androidx.compose.ui.text.font.FontFamily
46 | import androidx.compose.ui.text.style.TextAlign
47 | import androidx.compose.ui.tooling.preview.Preview
48 | import com.swancompany.journal.ui.theme.JournalTheme
49 |
50 | @OptIn(ExperimentalMaterialApi::class)
51 | @Composable
52 | fun HomeScreen(
53 | onFabClicked: () -> Unit,
54 | navigateToUpdateNoteScreen: (noteId: Int) -> Unit,
55 | navigateToAboutScreen: () -> Unit,
56 | ) {
57 | val viewModel: HomeViewModel = viewModel()
58 | val notesModel = viewModel.notesModel
59 | LaunchedEffect(Unit) {
60 | viewModel.getAllNotes()
61 | }
62 | Scaffold(
63 | topBar = { HomeTopBar(navigateToAboutScreen) },
64 | floatingActionButton = {
65 | FloatingActionButton(
66 | modifier = Modifier.padding(0.dp, 0.dp, 20.dp, 32.dp),
67 | onClick = { onFabClicked() },
68 | containerColor = colorScheme.secondaryContainer
69 | ) {
70 | Icon(Icons.Filled.Add,
71 | contentDescription = "add")
72 | }
73 | },
74 | backgroundColor = colorScheme.surface
75 | ) {
76 | Surface(
77 | shape = RoundedCornerShape(32.dp, 32.dp),
78 | color = colorResource(id = R.color.colorBackground)
79 | ) {
80 | LazyColumn(
81 | modifier = Modifier
82 | .fillMaxSize()
83 | .padding(0.dp, 20.dp, 0.dp, 0.dp)
84 | ) {
85 | if (notesModel.isNotEmpty()) {
86 | items(notesModel) { noteModel ->
87 | NoteSwappable(noteModel, viewModel, navigateToUpdateNoteScreen)
88 | }
89 | } else {
90 | item {
91 | ShowNoNotes()
92 | }
93 | }
94 | }
95 | }
96 | }
97 | }
98 |
99 | @ExperimentalMaterialApi
100 | @Composable
101 | fun NoteSwappable(
102 | noteModel: NoteModel,
103 | viewModel: HomeViewModel,
104 | navigateToUpdateNoteScreen: (noteId: Int) -> Unit,
105 | ) {
106 | val dismissState = rememberDismissState(
107 | confirmStateChange = {
108 | if (it == DismissedToEnd)
109 | viewModel.deleteNote(noteModel)
110 | it != DismissedToEnd
111 | }
112 | )
113 | SwipeToDismiss(directions = setOf(StartToEnd), state = dismissState, background = {
114 | val direction = dismissState.dismissDirection ?: return@SwipeToDismiss
115 | val color by animateColorAsState(
116 | when (dismissState.targetValue) {
117 | Default -> Color.LightGray
118 | DismissedToEnd -> Color.Red
119 | DismissedToStart -> return@SwipeToDismiss
120 | }
121 | )
122 | val alignment = when (direction) {
123 | StartToEnd -> Alignment.CenterStart
124 | EndToStart -> return@SwipeToDismiss
125 | }
126 | val scale by animateFloatAsState(
127 | if (dismissState.targetValue == Default) 0.75f else 1f
128 | )
129 | Box(
130 | Modifier
131 | .fillMaxSize()
132 | .background(color)
133 | .padding(horizontal = 20.dp),
134 | contentAlignment = alignment
135 | ) {
136 | Icon(
137 | Icons.Default.Delete,
138 | contentDescription = "delete",
139 | modifier = Modifier.scale(scale)
140 | )
141 | }
142 | }, dismissThresholds = {
143 | androidx.compose.material.FractionalThreshold(0.25f)
144 | }) {
145 | NotesCard(noteModel, navigateToUpdateNoteScreen)
146 | }
147 | }
148 |
149 |
150 | @Composable
151 | fun ShowNoNotes() {
152 | Column(modifier = Modifier
153 | .fillMaxSize()
154 | .padding(0.dp, 120.dp, 0.dp, 0.dp)) {
155 | Image(
156 | painter = painterResource(id = R.drawable.img),
157 | contentDescription = "empty",
158 | modifier = Modifier.fillMaxWidth(),
159 | alignment = Alignment.Center
160 | )
161 | Text(text = "Your notes will show here",
162 | modifier = Modifier.fillMaxWidth(),
163 | textAlign = TextAlign.Center
164 | )
165 | }
166 | }
167 |
168 | @Composable
169 | fun NotesCard(
170 | noteModel: NoteModel,
171 | navigateToUpdateNoteScreen: (noteId: Int) -> Unit,
172 | ) {
173 | Card(
174 | modifier = Modifier
175 | .heightIn(0.dp, 188.dp)
176 | .fillMaxWidth()
177 | .padding(20.dp, 5.dp)
178 | .clickable {
179 | navigateToUpdateNoteScreen(noteModel.id)
180 | Log.i("HomeScreen", "onCardClicked")
181 | },
182 | backgroundColor = colorScheme.surface,
183 | shape = RoundedCornerShape(24.dp)
184 | ) {
185 | Column(modifier = Modifier
186 | .fillMaxWidth()
187 | .padding(24.dp, 6.dp)
188 | ) {
189 | Text(
190 | text = noteModel.title,
191 | fontSize = 24.sp,
192 | fontFamily = FontFamily(Font(R.font.playfair_display_regular)),
193 |
194 | )
195 | Text(
196 | text = noteModel.notes,
197 | fontFamily = FontFamily(Font(R.font.plus_jakarta_sans_regular)),
198 | lineHeight = 17.sp
199 | )
200 | }
201 | }
202 | }
--------------------------------------------------------------------------------