Skip to content

Commit 0623191

Browse files
Small simplifications
1 parent 0e02d07 commit 0623191

File tree

2 files changed

+25
-34
lines changed

2 files changed

+25
-34
lines changed

swmpc/Views/Content/ContentView.swift

+9-16
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ extension ContentDestination: NavigationDestination {
198198
VStack(alignment: .leading, spacing: spacing) {
199199
#if os(macOS)
200200
BackButtonView()
201+
.padding(.top, 12)
201202
.offset(y: 5)
202203
#endif
203204

@@ -227,23 +228,15 @@ extension ContentDestination: NavigationDestination {
227228
struct BackButtonView: View {
228229
@Environment(\.navigator) private var navigator
229230

230-
@State private var isHovering = false
231-
232231
var body: some View {
233-
Image(systemSymbol: .chevronBackward)
234-
.frame(width: 22, height: 22)
235-
.background(
236-
RoundedRectangle(cornerRadius: 4)
237-
.fill(isHovering ? Color(.secondarySystemFill) : .clear)
238-
)
239-
.padding(.top, 12)
240-
.animation(.interactiveSpring, value: isHovering)
241-
.onHover { value in
242-
isHovering = value
243-
}
244-
.onTapGesture {
245-
navigator.back()
246-
}
232+
Button(action: {
233+
navigator.back()
234+
}) {
235+
Image(systemSymbol: .chevronBackward)
236+
.frame(width: 22, height: 22)
237+
.contentShape(Circle())
238+
}
239+
.button()
247240
}
248241
}
249242
#endif

swmpc/Views/Content/Destinations/Rows/SongView.swift

+16-18
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,31 @@ struct SongView: View {
2626
var body: some View {
2727
HStack(spacing: 15) {
2828
Group {
29-
#if os(iOS)
30-
if mpd.status.song != song {
29+
if mpd.status.song != song {
30+
#if os(iOS)
3131
Text(String(song.track))
3232
.font(.title3)
3333
.fontWeight(.regular)
3434
.foregroundStyle(.secondary)
3535
.frame(width: 20)
36-
} else {
37-
WaveView()
38-
}
39-
#elseif os(macOS)
40-
if !isHovering, mpd.status.song != song {
41-
Text(String(song.track))
42-
.font(.title3)
43-
.fontWeight(.regular)
44-
.foregroundStyle(.secondary)
45-
.frame(width: 20)
46-
} else {
47-
if mpd.status.song == song {
48-
WaveView()
49-
} else {
36+
#elseif os(macOS)
37+
if isHovering {
5038
Image(systemSymbol: .playFill)
5139
.font(.title3)
5240
.foregroundColor(.accentColor)
41+
.transition(.opacity)
42+
43+
} else {
44+
Text(String(song.track))
45+
.font(.title3)
46+
.fontWeight(.regular)
47+
.foregroundStyle(.secondary)
48+
.frame(width: 20)
5349
}
54-
}
55-
#endif
50+
#endif
51+
} else {
52+
WaveView()
53+
}
5654
}
5755
.frame(width: 20)
5856

0 commit comments

Comments
 (0)