-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Background** This PR is designed to update update remote-control buttons so it'll be up to date with IRDB-backend **Changes** - Add new ButtonData - Add new icons - Add new screen with infrared items by long-pressing on brand **Test plan** - Open remote controls - Long press on brands to open all of it's infrareds - Select infrareds and see new ui
- Loading branch information
1 parent
bc44fe2
commit 149de2e
Showing
47 changed files
with
806 additions
and
311 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
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
10 changes: 10 additions & 0 deletions
10
...ackend/src/commonMain/kotlin/com/flipperdevices/ifrmvp/backend/model/InfraredsResponse.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 com.flipperdevices.ifrmvp.backend.model | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class InfraredsResponse( | ||
@SerialName("infrared_files") | ||
val infraredFiles: List<IfrFileModel> | ||
) |
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: 17 additions & 0 deletions
17
...rc/main/kotlin/com/flipperdevices/remotecontrols/api/InfraredsScreenDecomposeComponent.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,17 @@ | ||
package com.flipperdevices.remotecontrols.api | ||
|
||
import com.arkivanov.decompose.ComponentContext | ||
import com.flipperdevices.ui.decompose.ScreenDecomposeComponent | ||
|
||
abstract class InfraredsScreenDecomposeComponent( | ||
componentContext: ComponentContext | ||
) : ScreenDecomposeComponent(componentContext) { | ||
|
||
interface Factory { | ||
operator fun invoke( | ||
componentContext: ComponentContext, | ||
brandId: Long, | ||
onBack: () -> Unit, | ||
): InfraredsScreenDecomposeComponent | ||
} | ||
} |
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
82 changes: 82 additions & 0 deletions
82
...c/main/kotlin/com/flipperdevices/remotecontrols/impl/brands/composable/InfraredsScreen.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,82 @@ | ||
package com.flipperdevices.remotecontrols.impl.brands.composable | ||
|
||
import androidx.compose.animation.Crossfade | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.rememberLazyListState | ||
import androidx.compose.material.Scaffold | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import com.flipperdevices.ifrmvp.backend.model.IfrFileModel | ||
import com.flipperdevices.ifrmvp.core.ui.layout.shared.ErrorComposable | ||
import com.flipperdevices.ifrmvp.core.ui.layout.shared.SharedTopBar | ||
import com.flipperdevices.remotecontrols.impl.brands.composable.composable.BrandsLoadingComposable | ||
import com.flipperdevices.remotecontrols.impl.brands.composable.composable.ItemsList | ||
import com.flipperdevices.remotecontrols.impl.brands.composable.composable.alphabet.AlphabetSearchComposable | ||
import com.flipperdevices.remotecontrols.impl.brands.presentation.viewmodel.InfraredsListViewModel | ||
import kotlinx.collections.immutable.toImmutableSet | ||
import com.flipperdevices.remotecontrols.brands.impl.R as BrandsR | ||
|
||
@Composable | ||
fun InfraredsScreen( | ||
viewModel: InfraredsListViewModel, | ||
onBack: () -> Unit, | ||
onReload: () -> Unit, | ||
onClick: (IfrFileModel) -> Unit, | ||
modifier: Modifier = Modifier | ||
) { | ||
val state by viewModel.state.collectAsState() | ||
Scaffold( | ||
modifier = modifier, | ||
topBar = { | ||
SharedTopBar( | ||
title = stringResource(BrandsR.string.infrareds_title), | ||
subtitle = stringResource(BrandsR.string.brands_subtitle), | ||
onBackClick = onBack | ||
) | ||
} | ||
) { scaffoldPaddings -> | ||
Crossfade( | ||
targetState = state, | ||
modifier = Modifier.padding(scaffoldPaddings) | ||
) { model -> | ||
when (model) { | ||
InfraredsListViewModel.State.Error -> { | ||
ErrorComposable(onReload = onReload) | ||
} | ||
|
||
is InfraredsListViewModel.State.Loaded -> { | ||
val listState = rememberLazyListState() | ||
AlphabetSearchComposable( | ||
items = model.infrareds, | ||
toHeader = { it.folderName.first().uppercaseChar() }, | ||
headers = remember(model) { | ||
model.infrareds | ||
.map { it.fileName.first().uppercaseChar() } | ||
.toImmutableSet() | ||
}, | ||
listState = listState, | ||
content = { | ||
ItemsList( | ||
modifier = Modifier.weight(1f), | ||
listState = listState, | ||
items = model.infrareds, | ||
onClick = onClick, | ||
toCharSection = { it.folderName.first().uppercaseChar() }, | ||
toString = { it.folderName }, | ||
onLongClick = {} | ||
) | ||
} | ||
) | ||
} | ||
|
||
InfraredsListViewModel.State.Loading -> { | ||
BrandsLoadingComposable() | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
39 changes: 39 additions & 0 deletions
39
...ntrols/impl/brands/presentation/decompose/internal/InfraredFilesDecomposeComponentImpl.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,39 @@ | ||
package com.flipperdevices.remotecontrols.impl.brands.presentation.decompose.internal | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.arkivanov.decompose.ComponentContext | ||
import com.flipperdevices.core.di.AppGraph | ||
import com.flipperdevices.core.ui.lifecycle.viewModelWithFactory | ||
import com.flipperdevices.remotecontrols.api.InfraredsScreenDecomposeComponent | ||
import com.flipperdevices.remotecontrols.impl.brands.composable.InfraredsScreen | ||
import com.flipperdevices.remotecontrols.impl.brands.presentation.viewmodel.InfraredsListViewModel | ||
import com.flipperdevices.rootscreen.api.LocalRootNavigation | ||
import com.flipperdevices.rootscreen.model.RootScreenConfig | ||
import dagger.assisted.Assisted | ||
import dagger.assisted.AssistedInject | ||
import me.gulya.anvil.assisted.ContributesAssistedFactory | ||
|
||
@ContributesAssistedFactory(AppGraph::class, InfraredsScreenDecomposeComponent.Factory::class) | ||
class InfraredFilesDecomposeComponentImpl @AssistedInject constructor( | ||
@Assisted componentContext: ComponentContext, | ||
@Assisted private val brandId: Long, | ||
@Assisted private val onBackClick: () -> Unit, | ||
private val infraredsListViewModelFactory: InfraredsListViewModel.Factory, | ||
) : InfraredsScreenDecomposeComponent(componentContext) { | ||
|
||
@Composable | ||
override fun Render() { | ||
val viewModel = viewModelWithFactory(null) { | ||
infraredsListViewModelFactory.invoke(brandId) | ||
} | ||
val navigation = LocalRootNavigation.current | ||
InfraredsScreen( | ||
viewModel = viewModel, | ||
onBack = onBackClick, | ||
onReload = viewModel::tryLoad, | ||
onClick = { | ||
navigation.push(RootScreenConfig.ServerRemoteControl(it.id, it.folderName)) | ||
}, | ||
) | ||
} | ||
} |
Oops, something went wrong.