Skip to content

Commit

Permalink
Use Koin get() instead of inject() in composables
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Sep 24, 2022
1 parent 41347ca commit 4ba39f2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import nl.ndat.tvlauncher.data.repository.AppRepository
import nl.ndat.tvlauncher.ui.component.card.AppCard
import org.koin.androidx.compose.inject
import org.koin.androidx.compose.get

@Composable
fun AppCardRow() {
val appRepository: AppRepository by inject()
val appRepository: AppRepository = get()
val apps by appRepository.getApps().collectAsState(initial = emptyList())

CardRow {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import nl.ndat.tvlauncher.data.model.ChannelType
import nl.ndat.tvlauncher.data.repository.AppRepository
import nl.ndat.tvlauncher.data.repository.ChannelRepository
import nl.ndat.tvlauncher.ui.component.card.ChannelProgramCard
import org.koin.androidx.compose.inject
import org.koin.androidx.compose.get

@Composable
fun ChannelProgramCardRow(
channel: Channel,
) {
val channelRepository: ChannelRepository by inject()
val appRepository: AppRepository by inject()
val channelRepository: ChannelRepository = get()
val appRepository: AppRepository = get()
val programs by channelRepository.getProgramsByChannel(channel).collectAsState(initial = emptyList())

var app by remember { mutableStateOf<App?>(null) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import nl.ndat.tvlauncher.data.repository.ChannelRepository
import nl.ndat.tvlauncher.ui.component.row.AppCardRow
import nl.ndat.tvlauncher.ui.component.row.ChannelProgramCardRow
import nl.ndat.tvlauncher.ui.toolbar.Toolbar
import org.koin.androidx.compose.inject

@Composable
fun LauncherPage() {
Expand All @@ -39,7 +38,7 @@ fun LauncherPage() {

@Composable
fun ChannelProgramCardRows() {
val channelRepository: ChannelRepository by inject()
val channelRepository: ChannelRepository = get()
val channels by channelRepository.getChannels().collectAsState(initial = emptyList())

for (channel in channels) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/kotlin/nl/ndat/tvlauncher/ui/toolbar/Toolbar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import nl.ndat.tvlauncher.data.model.ToolbarLocation
import nl.ndat.tvlauncher.data.repository.PreferenceRepository
import org.koin.androidx.compose.inject
import org.koin.androidx.compose.get

@Composable
fun Toolbar(
modifier: Modifier = Modifier,
) {
val preferenceRepository by inject<PreferenceRepository>()
val preferenceRepository = get<PreferenceRepository>()
val location by preferenceRepository.toolbarLocation.collectAsState()

Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import nl.ndat.tvlauncher.R
import nl.ndat.tvlauncher.data.repository.InputRepository
import org.koin.androidx.compose.inject
import org.koin.androidx.compose.get

@Composable
fun ToolbarInputsButton() {
val context = LocalContext.current
val inputRepository: InputRepository by inject()
val inputRepository: InputRepository = get()
val inputs by inputRepository.getInputs().collectAsState(initial = emptyList())

// TODO: When toolbar is configurable this should be removed
Expand Down

0 comments on commit 4ba39f2

Please sign in to comment.