A fork of Simple Time Tracker with WearOS support. (Now integrated upstream)
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: Improve coloring to indicate if an Activity is running

Sets the toggle overlay to a dark color if the activity is stopped,
and uses a light overlay when the activity is running.

Joseph Hale (Feb 26, 2024, 10:27 PM -0700) 5f429f69 ea8b6e88

+23 -7
+23 -7
wear/src/main/java/com/example/util/simpletimetracker/presentation/components/ActivityChip.kt
··· 11 11 import androidx.compose.runtime.getValue 12 12 import androidx.compose.runtime.mutableStateOf 13 13 import androidx.compose.runtime.remember 14 - import androidx.compose.runtime.rememberCoroutineScope 15 14 import androidx.compose.runtime.setValue 16 15 import androidx.compose.ui.Modifier 16 + import androidx.compose.ui.graphics.Color 17 17 import androidx.compose.ui.semantics.contentDescription 18 18 import androidx.compose.ui.semantics.semantics 19 19 import androidx.compose.ui.text.style.TextOverflow ··· 21 21 import androidx.compose.ui.unit.dp 22 22 import androidx.wear.compose.material.SplitToggleChip 23 23 import androidx.wear.compose.material.Switch 24 + import androidx.wear.compose.material.SwitchDefaults 24 25 import androidx.wear.compose.material.Text 25 26 import androidx.wear.compose.material.ToggleChipDefaults 26 - import com.example.util.simpletimetracker.presentation.remember.rememberRPCClient 27 27 import com.example.util.simpletimetracker.presentation.theme.hexCodeToColor 28 28 import com.example.util.simpletimetracker.wearrpc.Activity 29 29 import com.example.util.simpletimetracker.wearrpc.Tag ··· 41 41 onSelectActivitySkipTagSelection: () -> Unit = {}, 42 42 onDeselectActivity: () -> Unit = {}, 43 43 ) { 44 - val coroutineScope = rememberCoroutineScope() 45 - val rpcClient = rememberRPCClient() 46 - 47 44 val briefIcon = if (activity.icon.startsWith("ic_")) { 48 45 "?" 49 46 } else { ··· 82 79 }, 83 80 colors = ToggleChipDefaults.splitToggleChipColors( 84 81 backgroundColor = color, 82 + splitBackgroundOverlayColor = if (switchChecked) { 83 + Color.White.copy(alpha = .1F) 84 + } else { 85 + Color.Black.copy(alpha = .3F) 86 + }, 85 87 ), 86 88 onCheckedChange = { 87 89 if (it) { ··· 100 102 checked = switchChecked, 101 103 enabled = true, 102 104 modifier = Modifier.semantics { 103 - this.contentDescription = 104 - if (switchChecked) "On" else "Off" 105 + this.contentDescription = if (switchChecked) "On" else "Off" 105 106 }, 107 + colors = SwitchDefaults.colors( 108 + checkedThumbColor = Color.White, 109 + checkedTrackColor = Color.White.copy(alpha = 0.5F), 110 + uncheckedThumbColor = Color.White, 111 + uncheckedTrackColor = Color.White.copy(alpha = 0.5F), 112 + ), 106 113 ) 107 114 }, 108 115 ) ··· 132 139 @Composable 133 140 fun SampleSleep() { 134 141 ActivityChip(Activity(456, "Sleeping", "🛏️", "#ABCDEF")) 142 + } 143 + 144 + @Preview() 145 + @Composable 146 + fun White() { 147 + // TODO handle the look of light colored chips 148 + // Note: A white color is only possible when using the RGB color picker. 149 + // The default color options in the phone app are mostly darker shades. 150 + ActivityChip(Activity(456, "Sleeping", "🛏️", "#FFFFFF")) 135 151 } 136 152 137 153 @Preview()