Skip to content

Commit 326a7f3

Browse files
committed
add hot reload and some other stuff i guess
1 parent 30f76f3 commit 326a7f3

File tree

6 files changed

+138
-23
lines changed

6 files changed

+138
-23
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ plugins {
88
alias(libs.plugins.kotlin.multiplatform)
99
alias(libs.plugins.compose.runtime)
1010
alias(libs.plugins.compose.compiler)
11+
id("org.jetbrains.compose.hot-reload") version "1.0.0-alpha10" // <- add this additionally
1112
}
1213

1314
group = "com.mfriend"

app/src/commonMain/kotlin/App.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import androidx.compose.runtime.setValue
99
import org.jetbrains.compose.ui.tooling.preview.Preview
1010

1111
expect val Platform: String
12+
1213
@Composable
13-
@Preview
1414
fun App() {
1515
var text by remember { mutableStateOf("Hello, World!") }
1616

@@ -22,3 +22,9 @@ fun App() {
2222
}
2323
}
2424
}
25+
26+
@Preview
27+
@Composable
28+
fun AppPreview() {
29+
App()
30+
}

app/src/desktopMain/kotlin/Main.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import androidx.compose.runtime.getValue
2-
import androidx.compose.runtime.setValue
31
import androidx.compose.ui.window.Window
42
import androidx.compose.ui.window.application
53

docs/tasks.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# KMMtg Improvement Tasks
2+
3+
This document contains a prioritized list of actionable improvement tasks for the KMMtg project. Each task is designed to enhance the project's architecture, code quality, or functionality.
4+
5+
## Architecture Improvements
6+
7+
1. [ ] Complete Android support in all modules
8+
- Fix Android configuration in scryfall module
9+
- Uncomment and fix Android-specific code in build.gradle.kts files
10+
- Implement Android-specific database drivers
11+
12+
2. [ ] Implement proper multiplatform support for collection-import module
13+
- Research alternatives to kotlin-csv that support iOS
14+
- Implement iOS-specific file handling
15+
16+
3. [ ] Implement a proper dependency injection framework across all modules
17+
- Standardize Koin usage across all modules
18+
- Create module definitions for each module
19+
20+
4. [ ] Implement a comprehensive error handling strategy
21+
- Standardize error types and handling across modules
22+
- Improve error messages and logging
23+
24+
5. [ ] Implement a proper user authentication and authorization system
25+
- Complete User table implementation
26+
- Add password/authentication fields
27+
- Implement token-based authentication
28+
29+
## Database Improvements
30+
31+
6. [ ] Enhance Card schema with additional attributes
32+
- Add mana cost, card type, rarity, and other important MTG card attributes
33+
- Update queries to support filtering by these attributes
34+
35+
7. [ ] Complete User-Deck relationship implementation
36+
- Uncomment and implement user_id foreign key in Deck table
37+
- Implement user-specific deck queries
38+
39+
8. [ ] Add query to update card quantity in a deck
40+
- Implement updateCardQuantityInDeck query in DeckCard.sq
41+
42+
9. [ ] Implement database migrations strategy
43+
- Add versioning to database schema
44+
- Create migration scripts for future schema changes
45+
46+
## API Improvements
47+
48+
10. [ ] Expand Scryfall API coverage
49+
- Implement additional endpoints (card by ID, random card, etc.)
50+
- Add support for advanced search parameters
51+
52+
11. [ ] Implement pagination handling for Scryfall API responses
53+
- Add support for retrieving multiple pages of results
54+
- Implement a paging mechanism for large result sets
55+
56+
12. [ ] Add caching for Scryfall API responses
57+
- Implement a caching strategy to reduce API calls
58+
- Add TTL (time-to-live) for cached responses
59+
60+
## Testing and Documentation
61+
62+
13. [ ] Implement comprehensive unit tests for all modules
63+
- Add tests for database operations
64+
- Add tests for API client
65+
- Add tests for collection import/export
66+
67+
14. [ ] Implement integration tests
68+
- Add tests for interactions between modules
69+
- Add end-to-end tests for key user flows
70+
71+
15. [ ] Add KDoc documentation to all public APIs
72+
- Document all public classes, interfaces, and functions
73+
- Include examples where appropriate
74+
75+
16. [ ] Create user documentation
76+
- Add usage examples for CLI
77+
- Document supported file formats for collection import/export
78+
79+
## Code Quality Improvements
80+
81+
17. [ ] Replace non-null assertions (!!) with proper null handling
82+
- Use Elvis operator (?:) or other null-safe approaches
83+
- Add validation to prevent null pointer exceptions
84+
85+
18. [ ] Implement proper logging throughout the application
86+
- Standardize logging approach
87+
- Add appropriate log levels for different types of messages
88+
89+
19. [ ] Add input validation for all user inputs
90+
- Validate CSV file formats
91+
- Validate deck construction rules
92+
93+
20. [ ] Implement proper exception handling
94+
- Replace generic error messages with specific ones
95+
- Add context to error messages
96+
97+
## Feature Improvements
98+
99+
21. [ ] Add support for additional collection import/export formats
100+
- Support more popular MTG collection management tools
101+
- Implement a plugin system for custom formats
102+
103+
22. [ ] Implement deck validation against format rules
104+
- Add support for checking deck legality in different formats
105+
- Implement card legality checking
106+
107+
23. [ ] Add support for card pricing information
108+
- Integrate with pricing APIs
109+
- Add price tracking for collections
110+
111+
24. [ ] Enhance CLI with more interactive features
112+
- Implement autocomplete for card names
113+
- Add visual card representation in terminal

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
kotlin = "2.2.0-RC"
2+
kotlin = "2.2.0"
33
kermit = "2.0.5"
44
arrow = "2.1.1"
55
koin = "4.0.3"

scryfall/src/commonMain/kotlin/client/ScryfallApi.kt

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ interface ScryfallApi : AutoCloseable {
3131
suspend fun setsRaise(): List<SetDto>
3232
}
3333

34-
class ScryfallApiImpl : ScryfallApi, AutoCloseable {
34+
class ScryfallApiImpl :
35+
ScryfallApi,
36+
AutoCloseable {
3537
private val client = newKtorClient()
3638

3739
context(_: Raise<ScryfallError>)
@@ -44,38 +46,33 @@ class ScryfallApiImpl : ScryfallApi, AutoCloseable {
4446
}
4547

4648
context(_: Raise<InvalidResponse>)
47-
private suspend inline fun <reified T> HttpResponse.bodyOrError(): T =
48-
catch({ body<T>() }) { t: ContentConvertException ->
49-
raise(InvalidResponse(body<String>(), T::class.simpleName ?: "unknown class", t))
50-
}
49+
private suspend inline fun <reified T> HttpResponse.bodyOrError(): T = catch({ body<T>() }) { t: ContentConvertException ->
50+
raise(InvalidResponse(body<String>(), T::class.simpleName ?: "unknown class", t))
51+
}
5152

5253
/**
5354
* Gets a single card object from the search or raises a [ScryfallErrorResponse]
5455
* If the error response doesnt fit [ScryfallErrorResponse] throws an exception
5556
*/
56-
context(_: Raise<ScryfallError>) override suspend fun cardNamedRaise(name: String): CardDto {
57-
return client.get {
58-
scryfall("$CardApiBase$FindNamed")
59-
parameter("fuzzy", name)
60-
}.responseBodyOrRaise()
61-
}
62-
57+
context(_: Raise<ScryfallError>)
58+
override suspend fun cardNamedRaise(name: String): CardDto = client.get {
59+
scryfall("$CardApiBase$FindNamed")
60+
parameter("fuzzy", name)
61+
}.responseBodyOrRaise()
6362

6463
// This NEEDS to be called or it will hold up the couroutine scope of suspend fun main
6564
override fun close() {
6665
client.close()
6766
}
6867

6968
context(_: Raise<ScryfallError>)
70-
override suspend fun searchCardRaise(searchParam: String): List<CardDto> =
71-
client.get {
72-
scryfall("$CardApiBase$Search")
73-
parameter("q", searchParam)
74-
}.responseBodyOrRaise<ListResp<CardDto>>().data
69+
override suspend fun searchCardRaise(searchParam: String): List<CardDto> = client.get {
70+
scryfall("$CardApiBase$Search")
71+
parameter("q", searchParam)
72+
}.responseBodyOrRaise<ListResp<CardDto>>().data
7573

7674
context(_: Raise<ScryfallError>)
77-
override suspend fun setsRaise(): List<SetDto> =
78-
client.get { scryfall("sets") }.responseBodyOrRaise<ListResp<SetDto>>().data
75+
override suspend fun setsRaise(): List<SetDto> = client.get { scryfall("sets") }.responseBodyOrRaise<ListResp<SetDto>>().data
7976

8077
companion object {
8178
const val ScryfallBaseUri: String = "https://api.scryfall.com"

0 commit comments

Comments
 (0)