-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from jtouzy/feature/android-injection
Change screen creation pattern.
- Loading branch information
Showing
17 changed files
with
93 additions
and
63 deletions.
There are no files selected for viewing
33 changes: 2 additions & 31 deletions
33
Examples/DemoApp/androidApp/src/main/kotlin/com/jtouzy/demo/app/di/appModule.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,43 +1,14 @@ | ||
package com.jtouzy.demo.app.di | ||
|
||
import com.jtouzy.demo.app.ui.ObservableStore | ||
import com.jtouzy.demo.app.ui.characters.CharactersScreen | ||
import com.jtouzy.demo.app.ui.quote.QuoteScreen | ||
import com.jtouzy.demo.app.ui.NavigationManager | ||
import com.jtouzy.demo.cache.DataStore | ||
import com.jtouzy.demo.cache.InMemoryDataStore | ||
import com.jtouzy.demo.network.BreakingBadApi | ||
import com.jtouzy.demo.ui.Store | ||
import com.jtouzy.demo.ui.characters.CharactersPresenter | ||
import com.jtouzy.demo.ui.characters.CharactersPresenterImpl | ||
import com.jtouzy.demo.ui.characters.CharactersViewState | ||
import com.jtouzy.demo.ui.model.Character | ||
import com.jtouzy.demo.ui.quotes.QuotesPresenter | ||
import com.jtouzy.demo.ui.quotes.QuotesPresenterImpl | ||
import com.jtouzy.demo.ui.quotes.QuotesViewState | ||
import org.koin.core.parameter.parametersOf | ||
import org.koin.core.qualifier.named | ||
import org.koin.dsl.module | ||
|
||
val appModule = module { | ||
|
||
single { NavigationManager() } | ||
single { BreakingBadApi() } | ||
single<DataStore> { InMemoryDataStore(get()) } | ||
|
||
// Characters | ||
val characterQualifier = named("Characters") | ||
single<Store<CharactersViewState>>(characterQualifier) { ObservableStore(CharactersViewState.Loading) } | ||
factory<CharactersPresenter> { CharactersPresenterImpl(get(characterQualifier), get()) } | ||
factory { CharactersScreen(get(characterQualifier), get()) } | ||
|
||
// Quotes | ||
val quoteQualifier = named("Quotes") | ||
single<Store<QuotesViewState>>(quoteQualifier) { (character: Character) -> | ||
ObservableStore(QuotesViewState.Loading(character.name)) | ||
} | ||
factory<QuotesPresenter> { (character: Character) -> | ||
QuotesPresenterImpl(get(quoteQualifier) { parametersOf(character) }, get(), character) | ||
} | ||
factory { (character: Character) -> | ||
QuoteScreen(get(quoteQualifier) { parametersOf(character) }, get { parametersOf(character) }) | ||
} | ||
} |
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
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
Examples/DemoApp/androidApp/src/main/kotlin/com/jtouzy/demo/app/ui/common/ErrorScreen.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 com.jtouzy.demo.app.ui.common | ||
|
||
import androidx.compose.Composable | ||
import androidx.compose.unaryPlus | ||
import androidx.ui.core.Text | ||
import androidx.ui.layout.Center | ||
import androidx.ui.res.stringResource | ||
import com.jtouzy.demo.app.R | ||
|
||
@Composable | ||
fun ErrorScreen() { | ||
Center { | ||
Text(text = +stringResource(R.string.generic_message_error)) | ||
} | ||
} |
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
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,6 +1,8 @@ | ||
[[General]] | ||
[app_name] | ||
en = Kompose | ||
[generic_message_error] | ||
en = An error occurred | ||
|
||
[[Quotes]] | ||
[no_quotes] | ||
|
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
2 changes: 1 addition & 1 deletion
2
Examples/DemoApp/shared/src/commonMain/kotlin/com/jtouzy/demo/ui/Store.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,5 +1,5 @@ | ||
package com.jtouzy.demo.ui | ||
|
||
interface Store<T : ViewState> { | ||
var currentState: T | ||
var viewState: T | ||
} |
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
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