|
1 | 1 | package love.forte.simbot.codegen.gen.view |
2 | 2 |
|
| 3 | +import androidx.compose.foundation.background |
3 | 4 | import androidx.compose.foundation.BorderStroke |
4 | 5 | import androidx.compose.foundation.interaction.MutableInteractionSource |
5 | 6 | import androidx.compose.foundation.interaction.collectIsPressedAsState |
@@ -142,50 +143,86 @@ private fun PreviewButton( |
142 | 143 | val interactionSource = remember { MutableInteractionSource() } |
143 | 144 | val isPressed by interactionSource.collectIsPressedAsState() |
144 | 145 |
|
145 | | - OutlinedButton( |
146 | | - enabled = enabled, |
147 | | - onClick = onClick, |
148 | | - modifier = modifier |
149 | | - .height( |
150 | | - when (windowSize) { |
151 | | - WindowSize.Mobile -> 64.dp |
152 | | - else -> 56.dp |
153 | | - } |
154 | | - ) |
155 | | - .shadow( |
156 | | - elevation = if (isPressed) 0.dp else 2.dp, |
157 | | - shape = RoundedCornerShape(12.dp), |
158 | | - spotColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.3f) |
| 146 | + Box(modifier = modifier) { |
| 147 | + OutlinedButton( |
| 148 | + enabled = enabled, |
| 149 | + onClick = onClick, |
| 150 | + modifier = Modifier |
| 151 | + .fillMaxWidth() |
| 152 | + .height( |
| 153 | + when (windowSize) { |
| 154 | + WindowSize.Mobile -> 64.dp |
| 155 | + else -> 56.dp |
| 156 | + } |
| 157 | + ) |
| 158 | + .shadow( |
| 159 | + elevation = if (isPressed) 0.dp else 2.dp, |
| 160 | + shape = RoundedCornerShape(12.dp), |
| 161 | + spotColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.3f) |
| 162 | + ), |
| 163 | + shape = RoundedCornerShape(12.dp), |
| 164 | + interactionSource = interactionSource, |
| 165 | + colors = ButtonDefaults.outlinedButtonColors( |
| 166 | + containerColor = MaterialTheme.colorScheme.surface, |
| 167 | + contentColor = MaterialTheme.colorScheme.primary, |
| 168 | + disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant, |
| 169 | + disabledContentColor = MaterialTheme.colorScheme.onSurfaceVariant |
159 | 170 | ), |
160 | | - shape = RoundedCornerShape(12.dp), |
161 | | - interactionSource = interactionSource, |
162 | | - colors = ButtonDefaults.outlinedButtonColors( |
163 | | - containerColor = MaterialTheme.colorScheme.surface, |
164 | | - contentColor = MaterialTheme.colorScheme.primary, |
165 | | - disabledContainerColor = MaterialTheme.colorScheme.surfaceVariant, |
166 | | - disabledContentColor = MaterialTheme.colorScheme.onSurfaceVariant |
167 | | - ), |
168 | | - border = BorderStroke( |
169 | | - width = 2.dp, |
170 | | - color = if (enabled) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.outlineVariant |
171 | | - ) |
172 | | - ) { |
173 | | - Row( |
174 | | - verticalAlignment = Alignment.CenterVertically, |
175 | | - horizontalArrangement = Arrangement.Center |
176 | | - ) { |
177 | | - Icon( |
178 | | - Icons.Default.Visibility, |
179 | | - contentDescription = "预览", |
180 | | - modifier = Modifier.size(20.dp) |
181 | | - ) |
182 | | - Spacer(modifier = Modifier.width(8.dp)) |
183 | | - Text( |
184 | | - "预览", |
185 | | - fontSize = if (windowSize == WindowSize.Mobile) 16.sp else 16.sp, |
186 | | - fontWeight = FontWeight.Medium |
| 171 | + border = BorderStroke( |
| 172 | + width = 2.dp, |
| 173 | + color = if (enabled) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.outlineVariant |
187 | 174 | ) |
| 175 | + ) { |
| 176 | + Row( |
| 177 | + verticalAlignment = Alignment.CenterVertically, |
| 178 | + horizontalArrangement = Arrangement.Center |
| 179 | + ) { |
| 180 | + Icon( |
| 181 | + Icons.Default.Visibility, |
| 182 | + contentDescription = "预览", |
| 183 | + modifier = Modifier.size(20.dp) |
| 184 | + ) |
| 185 | + Spacer(modifier = Modifier.width(8.dp)) |
| 186 | + Text( |
| 187 | + "预览", |
| 188 | + fontSize = if (windowSize == WindowSize.Mobile) 16.sp else 16.sp, |
| 189 | + fontWeight = FontWeight.Medium |
| 190 | + ) |
| 191 | + } |
188 | 192 | } |
| 193 | + |
| 194 | + // Beta 标记 |
| 195 | + BetaBadge( |
| 196 | + modifier = Modifier |
| 197 | + .align(Alignment.TopEnd) |
| 198 | + .offset(x = 4.dp, y = (-4).dp) |
| 199 | + ) |
| 200 | + } |
| 201 | +} |
| 202 | + |
| 203 | +/** |
| 204 | + * Beta 标记组件 |
| 205 | + */ |
| 206 | +@Composable |
| 207 | +private fun BetaBadge( |
| 208 | + modifier: Modifier = Modifier |
| 209 | +) { |
| 210 | + Box( |
| 211 | + modifier = modifier |
| 212 | + .size(width = 32.dp, height = 18.dp) |
| 213 | + .background( |
| 214 | + color = androidx.compose.ui.graphics.Color(0xFFFF6B35), // 橙红色背景 |
| 215 | + shape = RoundedCornerShape(6.dp) |
| 216 | + ), |
| 217 | + contentAlignment = Alignment.Center |
| 218 | + ) { |
| 219 | + Text( |
| 220 | + text = "Beta", |
| 221 | + color = androidx.compose.ui.graphics.Color.White, |
| 222 | + fontSize = 10.sp, |
| 223 | + fontWeight = FontWeight.Bold, |
| 224 | + style = MaterialTheme.typography.labelSmall |
| 225 | + ) |
189 | 226 | } |
190 | 227 | } |
191 | 228 |
|
|
0 commit comments