-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite LineColor to be a mapper (#73)
- Loading branch information
1 parent
cb6cb1d
commit 563277b
Showing
13 changed files
with
337 additions
and
155 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
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
43 changes: 0 additions & 43 deletions
43
web/status-history/src/main/java/net/twisterrob/travel/statushistory/viewmodel/LineColor.kt
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...us-history/src/main/java/net/twisterrob/travel/statushistory/viewmodel/LineColorsModel.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,9 @@ | ||
package net.twisterrob.travel.statushistory.viewmodel | ||
|
||
import net.twisterrob.blt.model.Line | ||
|
||
class LineColorsModel( | ||
val line: Line, | ||
val foregroundColor: Int, | ||
val backgroundColor: Int, | ||
) |
20 changes: 20 additions & 0 deletions
20
...tory/src/main/java/net/twisterrob/travel/statushistory/viewmodel/LineColorsModelMapper.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,20 @@ | ||
package net.twisterrob.travel.statushistory.viewmodel | ||
|
||
import jakarta.inject.Inject | ||
import net.twisterrob.blt.model.Line | ||
import net.twisterrob.blt.model.LineColors | ||
|
||
class LineColorsModelMapper @Inject constructor( | ||
private val colors: LineColors, | ||
) { | ||
|
||
@OptIn(ExperimentalStdlibApi::class) | ||
fun map(): List<LineColorsModel> = | ||
Line.entries.map { line -> | ||
LineColorsModel( | ||
line = line, | ||
foregroundColor = line.getForeground(colors), | ||
backgroundColor = line.getBackground(colors), | ||
) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...tory/src/main/java/net/twisterrob/travel/statushistory/viewmodel/LineStatusModelMapper.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 net.twisterrob.travel.statushistory.viewmodel | ||
|
||
import jakarta.inject.Inject | ||
|
||
class LineStatusModelMapper @Inject constructor( | ||
private val resultChangeModelMapper: ResultChangeModelMapper, | ||
private val lineColorsModelMapper: LineColorsModelMapper, | ||
) { | ||
|
||
fun map(changes: List<Changes>): LineStatusModel = | ||
LineStatusModel( | ||
changes.map(resultChangeModelMapper::map), | ||
lineColorsModelMapper.map() | ||
) | ||
} |
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
...ry/src/main/java/net/twisterrob/travel/statushistory/viewmodel/ResultChangeModelMapper.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
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.