-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
383 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
.../app/academy/notes/NotesAppApplication.kt → ...kotlin/app/academy/NotesAppApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...seApp/src/androidMain/kotlin/app/academy/data/local/NotesDatabaseDriverFactory.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package app.academy.data.local | ||
|
||
import android.content.Context | ||
import app.cash.sqldelight.db.SqlDriver | ||
import app.cash.sqldelight.driver.android.AndroidSqliteDriver | ||
import com.app.academy.notes.database.NotesDatabase | ||
|
||
actual class NotesDatabaseDriverFactory(private val context: Context) { | ||
actual fun createDriver(): SqlDriver = AndroidSqliteDriver( | ||
schema = NotesDatabase.Schema, | ||
context = context, | ||
name = DatabaseDriverConstants.DATABASE_NAME | ||
) | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
composeApp/src/androidMain/kotlin/app/academy/di/AppModule.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package app.academy.di | ||
|
||
import android.content.Context | ||
import app.academy.data.DefaultNotesRepository | ||
import app.academy.data.local.NotesDatabaseDriverFactory | ||
import app.academy.data.local.datasource.DefaultLocalNotesDataSource | ||
import app.architect.notes.data.NotesRepository | ||
import com.app.academy.notes.database.NotesDatabase | ||
import kotlinx.coroutines.Dispatchers | ||
|
||
actual class AppModule(context: Context) { | ||
|
||
private val database by lazy { | ||
val driver = NotesDatabaseDriverFactory(context).createDriver() | ||
NotesDatabase(driver) | ||
} | ||
|
||
/** | ||
* Provides an implementation of [NotesRepository] | ||
*/ | ||
actual fun provideNotesRepository(): NotesRepository { | ||
val localNotesDataSource = DefaultLocalNotesDataSource( | ||
database = database, | ||
ioDispatcher = Dispatchers.IO | ||
) | ||
return DefaultNotesRepository(localNotesDataSource = localNotesDataSource) | ||
} | ||
|
||
|
||
/** | ||
* Used to provide an instance of [DispatchersProvider] | ||
*/ | ||
actual fun provideDispatchersProvider(): DispatchersProviderList { | ||
return DispatchersProviderList( | ||
ioDispatcher = Dispatchers.IO, | ||
defaultDispatcher = Dispatchers.Default, | ||
mainDispatcher = Dispatchers.Main | ||
) | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
composeApp/src/androidMain/kotlin/app/academy/di/DispatchersProvider.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package app.academy.di | ||
|
||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.Dispatchers | ||
|
||
actual object DispatchersProvider { | ||
actual val io: CoroutineDispatcher = Dispatchers.IO | ||
} |
18 changes: 6 additions & 12 deletions
18
...lin/com/app/academy/notes/MainActivity.kt → .../kotlin/app/academy/notes/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
package com.app.academy.notes | ||
package app.academy.notes | ||
|
||
import com.app.academy.App | ||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import app.academy.NotesAppApplication | ||
import app.academy.ui.App | ||
|
||
class MainActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
val application = this.application as NotesAppApplication | ||
val appModule = application.appModule | ||
setContent { | ||
App() | ||
App(appModule) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun AppAndroidPreview() { | ||
App() | ||
} |
8 changes: 8 additions & 0 deletions
8
composeApp/src/androidMain/kotlin/app/academy/utils/NativeStateFlow.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package app.academy.utils | ||
|
||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
/** | ||
* A cross platform implementation of [StateFlow]. | ||
*/ | ||
actual class NativeStateFlow<T> actual constructor(source: StateFlow<T>) : StateFlow<T> by source |
10 changes: 10 additions & 0 deletions
10
composeApp/src/androidMain/kotlin/app/academy/utils/Platform.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package app.academy.utils | ||
|
||
class AndroidPlatform : Platform { | ||
override val name: String | ||
get() = "Android" | ||
} | ||
|
||
actual fun getPlatform(): Platform { | ||
return AndroidPlatform() | ||
} |
8 changes: 8 additions & 0 deletions
8
composeApp/src/androidMain/kotlin/app/academy/utils/UUID.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package app.academy.utils | ||
|
||
/** | ||
* A class that is used to generate a unique UUID (Universally Unique Identifier) string. | ||
*/ | ||
actual object UUID { | ||
actual fun randomUUIDString(): String = java.util.UUID.randomUUID().toString() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 8 additions & 9 deletions
17
...tect/notes/data/DefaultNotesRepository.kt → ...pp/academy/data/DefaultNotesRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...p/architect/notes/data/NotesRepository.kt → ...otlin/app/academy/data/NotesRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../data/local/NotesDatabaseDriverFactory.kt → .../data/local/NotesDatabaseDriverFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package app.architect.notes.data.local | ||
package app.academy.data.local | ||
|
||
import app.cash.sqldelight.db.SqlDriver | ||
|
||
|
8 changes: 4 additions & 4 deletions
8
...datasource/DefaultLocalNotesDataSource.kt → ...datasource/DefaultLocalNotesDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
.../local/datasource/LocalNotesDataSource.kt → .../local/datasource/LocalNotesDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.