Skip to content

Commit

Permalink
Remove callback and redo logic to have real tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
oas004 committed Oct 9, 2024
1 parent eb12c5c commit e2342e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ fun TrackingScreen(
state = state,
onActivityLaunchedOnceCheckedChanged = viewModel::onActivityLaunchedOnceCheckedChanged,
onSetupCompletedCheckedChanged = viewModel::onSetupCompletedCheckedChanged,
onTileCheckedChanged = viewModel::onTileCheckedChanged,
onComplicationCheckedChanged = viewModel::onComplicationCheckedChanged,
onDisplayInfoClicked = onDisplayInfoClicked,
columnState = columnState,
Expand All @@ -69,7 +68,6 @@ fun TrackingScreen(
state: TrackingScreenUiState,
onActivityLaunchedOnceCheckedChanged: (Boolean) -> Unit,
onSetupCompletedCheckedChanged: (Boolean) -> Unit,
onTileCheckedChanged: () -> Unit,
onComplicationCheckedChanged: (complication: String, Boolean) -> Unit,
onDisplayInfoClicked: (info: String) -> Unit,
columnState: ScalingLazyColumnState,
Expand Down Expand Up @@ -140,7 +138,7 @@ fun TrackingScreen(
)
SplitToggleChip(
checked = tileEntry.value,
onCheckedChanged = { onTileCheckedChanged() },
onCheckedChanged = { /* NO-OP */ },
label = tileEntry.key,
onClick = { onDisplayInfoClicked(info) },
toggleControl = ToggleChipToggleControl.Switch,
Expand Down Expand Up @@ -196,7 +194,6 @@ fun TrackingScreenPreview() {
),
onActivityLaunchedOnceCheckedChanged = { },
onSetupCompletedCheckedChanged = { },
onTileCheckedChanged = { },
onComplicationCheckedChanged = { _, _ -> },
onDisplayInfoClicked = { },
columnState = rememberResponsiveColumnState(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ class TrackingScreenViewModel
private val wearDataLayerAppHelper: WearDataLayerAppHelper,
) : ViewModel() {

private val fakeTileList = listOf("Tile1", "Tile2")
private val realTileList = listOf(
"com.google.android.horologist.datalayer.sample.SampleTileService"
)
private val fakeComplicationList = listOf("Comp1", "Comp2")

private var initializeCalled = false

private val _uiState = MutableStateFlow<TrackingScreenUiState>(TrackingScreenUiState.Idle)
public val uiState: StateFlow<TrackingScreenUiState> = _uiState
private val executor = Dispatchers.Default.asExecutor()

@MainThread
fun initialize() {
Expand All @@ -60,7 +61,7 @@ class TrackingScreenViewModel
TrackingScreenUiState.Loading,
is TrackingScreenUiState.Loaded,
-> {
val tilesMap = fakeTileList.associateWith { tile ->
val tilesMap = realTileList.associateWith { tile ->
surfacesInfo.tilesList.any { it.name == tile }
}

Expand Down Expand Up @@ -102,12 +103,6 @@ class TrackingScreenViewModel
}
}

fun onTileCheckedChanged() {
viewModelScope.launch {
wearDataLayerAppHelper.updateInstalledTiles(executor)
}
}

fun onComplicationCheckedChanged(complication: String, checked: Boolean) {
viewModelScope.launch {
if (checked) {
Expand Down

0 comments on commit e2342e8

Please sign in to comment.