| 323 | // MARK: - Compact Button |
| 324 | |
| 325 | struct CompactButtonStyle: ButtonStyle { |
| 326 | var isReady: Bool = false |
| 327 | var foreground: Color? = nil |
| 328 | var borderColor: Color? = nil |
| 329 | var height: CGFloat = 34 |
| 330 | |
| 331 | func makeBody(configuration: Configuration) -> some View { |
| 332 | CompactButton( |
| 333 | configuration: configuration, |
| 334 | isReady: self.isReady, |
| 335 | foreground: self.foreground, |
| 336 | borderColor: self.borderColor, |
| 337 | height: self.height |
| 338 | ) |
| 339 | } |
| 340 | |
| 341 | private struct CompactButton: View { |
| 342 | @Environment(\.theme) private var theme |
| 343 | @State private var isHovered = false |
| 344 | let configuration: ButtonStyle.Configuration |
| 345 | let isReady: Bool |
| 346 | let foreground: Color? |
| 347 | let borderColor: Color? |
| 348 | let height: CGFloat |
| 349 | |
| 350 | private var shape: RoundedRectangle { |
| 351 | RoundedRectangle(cornerRadius: self.theme.metrics.corners.sm, style: .continuous) |
| 352 | } |
| 353 | |
| 354 | var body: some View { |
| 355 | let border = self.borderColor ?? (self.isReady ? self.theme.palette.accent : self.theme.palette.cardBorder) |
| 356 | let foregroundColor = self.foreground ?? self.theme.palette.primaryText |
| 357 | let borderOpacity = self.borderColor == nil |
| 358 | ? (self.isHovered ? 0.56 : 0.38) |
| 359 | : (self.isHovered ? 0.64 : 0.48) |
| 360 | |
| 361 | self.configuration.label |
| 362 | .fontWeight(.medium) |
| 363 | .padding(.horizontal, self.theme.metrics.spacing.md) |
| 364 | .frame(height: self.height) |
| 365 | .foregroundStyle(foregroundColor) |
| 366 | .background(self.theme.materials.card, in: self.shape) |
| 367 | .background( |
| 368 | self.shape |
| 369 | .fill(self.theme.palette.cardBackground) |
| 370 | .overlay( |
| 371 | self.shape.stroke( |
| 372 | border.opacity(borderOpacity), |
| 373 | lineWidth: 1 |
| 374 | ) |
| 375 | ) |
| 376 | ) |
| 377 | .shadow( |
| 378 | color: border.opacity(self.isHovered ? 0.18 : 0.06), |
| 379 | radius: self.isHovered ? 4 : 1.5, |
| 380 | x: 0, |
| 381 | y: self.isHovered ? 1 : 0.5 |
| 382 | ) |
no outgoing calls
no test coverage detected