4
4
package com.tailscale.ipn.ui.view
5
5
6
6
import androidx.annotation.StringRes
7
+ import androidx.compose.foundation.background
7
8
import androidx.compose.foundation.clickable
8
9
import androidx.compose.foundation.focusable
9
10
import androidx.compose.foundation.interaction.MutableInteractionSource
10
11
import androidx.compose.foundation.layout.Box
11
12
import androidx.compose.foundation.layout.RowScope
12
13
import androidx.compose.foundation.layout.padding
13
14
import androidx.compose.foundation.layout.width
15
+ import androidx.compose.foundation.shape.CircleShape
14
16
import androidx.compose.material.icons.Icons
15
17
import androidx.compose.material.icons.automirrored.filled.ArrowBack
16
18
import androidx.compose.material.icons.filled.CheckCircle
@@ -24,10 +26,14 @@ import androidx.compose.material3.TopAppBar
24
26
import androidx.compose.material3.ripple
25
27
import androidx.compose.runtime.Composable
26
28
import androidx.compose.runtime.LaunchedEffect
29
+ import androidx.compose.runtime.mutableStateOf
27
30
import androidx.compose.runtime.remember
28
31
import androidx.compose.ui.Modifier
32
+ import androidx.compose.ui.draw.clip
29
33
import androidx.compose.ui.focus.FocusRequester
30
34
import androidx.compose.ui.focus.focusRequester
35
+ import androidx.compose.ui.focus.onFocusChanged
36
+ import androidx.compose.ui.graphics.Color
31
37
import androidx.compose.ui.res.stringResource
32
38
import androidx.compose.ui.unit.dp
33
39
import com.tailscale.ipn.ui.theme.topAppBar
@@ -77,23 +83,32 @@ fun Header(
77
83
78
84
@Composable
79
85
fun BackArrow (action : () -> Unit , focusRequester : FocusRequester ) {
80
- val modifier =
86
+ val isFocused = remember { mutableStateOf(false ) }
87
+
88
+ val boxModifier =
81
89
if (isAndroidTV()) {
82
90
Modifier .focusRequester(focusRequester)
83
- .focusable() // Ensure the composable can receive focus
91
+ .clip(CircleShape ) // Ensure both the focus and click area are circular
92
+ .background(
93
+ if (isFocused.value) MaterialTheme .colorScheme.surface else Color .Transparent ,
94
+ )
95
+ .onFocusChanged { focusState -> isFocused.value = focusState.isFocused }
96
+ .focusable()
84
97
} else {
85
98
Modifier
86
99
}
87
100
88
- Box (modifier = modifier.padding(start = 8 .dp, end = 8 .dp)) {
101
+ val iconModifier =
102
+ Modifier .clickable(
103
+ interactionSource = remember { MutableInteractionSource () },
104
+ indication = ripple(bounded = false , radius = 24 .dp),
105
+ onClick = action)
106
+
107
+ Box (modifier = boxModifier.padding(start = 8 .dp, end = 8 .dp)) {
89
108
Icon (
90
109
Icons .AutoMirrored .Filled .ArrowBack ,
91
110
contentDescription = " Go back to the previous screen" ,
92
- modifier =
93
- Modifier .clickable(
94
- interactionSource = remember { MutableInteractionSource () },
95
- indication = ripple(bounded = true ),
96
- onClick = action))
111
+ modifier = iconModifier)
97
112
}
98
113
}
99
114
0 commit comments