forked from aheze/Setting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingStyles.swift
More file actions
33 lines (29 loc) · 829 Bytes
/
SettingStyles.swift
File metadata and controls
33 lines (29 loc) · 829 Bytes
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
31
32
33
//
// SettingStyles.swift
// Setting
//
// Created by A. Zheng (github.com/aheze) on 2/21/23.
// Copyright © 2023 A. Zheng. All rights reserved.
//
import SwiftUI
/**
A button style that highlights the row when tapped.
*/
public struct SettingRowButtonStyle: ButtonStyle {
@Environment(\.settingPrimaryColor) var settingPrimaryColor
public func makeBody(configuration: Configuration) -> some View {
configuration.label
.contentShape(Rectangle())
.background {
if configuration.isPressed {
settingPrimaryColor
.opacity(0.1)
}
}
}
}
public extension ButtonStyle where Self == SettingRowButtonStyle {
static var row: SettingRowButtonStyle {
SettingRowButtonStyle()
}
}