1+ /*
2+ * Copyright 2025 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117package com.example.compose.snippets.components
218
319import android.graphics.drawable.Icon
@@ -14,20 +30,19 @@ import androidx.compose.material3.IconButton
1430import androidx.compose.material3.Text
1531import androidx.compose.runtime.Composable
1632import androidx.compose.runtime.LaunchedEffect
33+ import androidx.compose.runtime.getValue
34+ import androidx.compose.runtime.mutableIntStateOf
35+ import androidx.compose.runtime.mutableStateOf
1736import androidx.compose.runtime.remember
1837import androidx.compose.runtime.rememberUpdatedState
1938import androidx.compose.runtime.saveable.rememberSaveable
39+ import androidx.compose.runtime.setValue
2040import androidx.compose.ui.Alignment
2141import androidx.compose.ui.Modifier
22- import androidx.compose.ui.graphics.vector.ImageVector
42+ import androidx.compose.ui.res.painterResource
2343import androidx.compose.ui.tooling.preview.Preview
24- import kotlinx.coroutines.delay
25- import androidx.compose.runtime.getValue
26- import androidx.compose.runtime.setValue
27- import androidx.compose.runtime.mutableStateOf
28- import androidx.compose.runtime.mutableIntStateOf
2944import com.example.compose.snippets.R
30- import androidx.compose.ui.res.painterResource
45+ import kotlinx.coroutines.delay
3146
3247// [START android_compose_components_togglebuttonexample]
3348@Preview
@@ -74,7 +89,7 @@ fun MomentaryIconButton(
7489 interactionSource = interactionSource
7590 ) {
7691 Icon (
77- painter = if (isPressed) painterResource(id = selectedImage) else painterResource(id = unselectedImage) ,
92+ painter = if (isPressed) painterResource(id = selectedImage) else painterResource(id = unselectedImage),
7893 contentDescription = contentDescription,
7994 )
8095 }
0 commit comments