-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathModeButton.swift
More file actions
30 lines (28 loc) · 1.05 KB
/
ModeButton.swift
File metadata and controls
30 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import SwiftUI
public struct ModeButton: View {
let title: String
let isSelected: Bool
let activeBackground: Color
let activeTextColor: Color
let inactiveTextColor: Color
let action: () -> Void
public var body: some View {
Button(action: action) {
Text(title)
.padding(.horizontal, 6)
.padding(.vertical, 0)
.frame(maxHeight: .infinity, alignment: .center)
.background(isSelected ? activeBackground : Color.clear)
.foregroundColor(isSelected ? activeTextColor : inactiveTextColor)
.cornerRadius(5)
.shadow(color: .black.opacity(0.05), radius: 0.375, x: 0, y: 1)
.shadow(color: .black.opacity(0.15), radius: 0.125, x: 0, y: 0.25)
.overlay(
RoundedRectangle(cornerRadius: 5)
.inset(by: -0.25)
.stroke(.black.opacity(0.02), lineWidth: 0.5)
)
}
.buttonStyle(PlainButtonStyle())
}
}