Skip to content

Commit d9dbec8

Browse files
committed
Design pass 1.
1 parent 8fb0239 commit d9dbec8

12 files changed

Lines changed: 386 additions & 145 deletions

‎Snapper/Features/AlbumDetail/AlbumDetailView.swift‎

Lines changed: 72 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct AlbumDetailView: View {
2121
.stretchable()
2222

2323
VStack(alignment: .leading, spacing: Padding.xxl) {
24-
AlbumHeader(entry: entry, size: .lg)
24+
AlbumHeaderSection(entry: entry)
2525
AlbumDetailSection(entry: entry, showMetadata: showMetadata)
2626
AlbumTrackSection(tracks: vm.tracks)
2727
}
@@ -59,35 +59,45 @@ private struct AlbumCover: View {
5959
}
6060
}
6161

62+
private struct AlbumHeaderSection: View {
63+
let entry: AlbumEntry
64+
65+
var body: some View {
66+
HStack(alignment: .top) {
67+
AlbumHeader(entry: entry, size: .large)
68+
69+
Spacer()
70+
71+
Icon(systemName: "star.fill", size: 24)
72+
.foregroundStyle(.accent)
73+
.symbolEffect(.bounce.up, options: .speed(2), value: entry.isFavorited)
74+
.opacity(entry.isFavorited ? 1 : 0)
75+
}
76+
}
77+
}
78+
6279
private struct AlbumDetailSection: View {
6380
let entry: AlbumEntry
6481
let showMetadata: Bool
6582

6683
var body: some View {
67-
VStack(alignment: .leading, spacing: Padding.xl) {
68-
SectionHeader("About")
69-
Section {
70-
VStack(spacing: Spacing.sm) {
71-
if let label = entry.labels.first {
72-
AlbumDetailRow("Label", label)
73-
Divider()
74-
}
75-
76-
if let year = entry.year?.description {
77-
AlbumDetailRow("Released", year)
78-
Divider()
79-
}
84+
ThemeSection {
85+
Section("About") {
86+
if let label = entry.labels.first {
87+
LabeledContent("Label", value: label)
88+
}
8089

81-
if showMetadata {
82-
AlbumDetailRow("Recognized", entry.selectedAt.abbreviated)
83-
Divider()
90+
if let year = entry.year?.description {
91+
LabeledContent("Released", value: year)
92+
}
8493

85-
LocationSection(entry: entry)
86-
.frame(minHeight: 12)
87-
}
94+
if showMetadata {
95+
LabeledContent("Recognized", value: entry.selectedAt.abbreviated)
96+
LocationSection(entry: entry)
8897
}
8998
}
9099
}
100+
.labeledContentStyle(.withThemeFont)
91101
}
92102
}
93103

@@ -105,13 +115,12 @@ private struct LocationSection: View {
105115
var body: some View {
106116
switch entry.locationStatus {
107117
case .pending:
108-
HStack {
109-
Text("Location").font(.sligoilMicroBold(.subheadline))
110-
Spacer()
118+
LabeledContent {
111119
ProgressView()
120+
.controlSize(.small)
121+
} label: {
122+
Text("Location")
112123
}
113-
.foregroundStyle(.themePrimaryInverted)
114-
.opacity(0.625)
115124

116125
case .captured:
117126
if let location = entry.location {
@@ -121,23 +130,16 @@ private struct LocationSection: View {
121130
accuracyRadius: entry.locationHorizontalAccuracy,
122131
)
123132
} label: {
124-
Group {
125-
if (entry.locationHorizontalAccuracy ?? 0) >= 1_000 {
126-
Text("Approximate Location")
127-
} else {
128-
Text("Location")
129-
}
130-
}
131-
.font(.sligoilMicroBold(.subheadline))
133+
Text("Location")
134+
.font(.sligoilMicroBold(.subheadline))
132135
}
133136
.disclosureGroupStyle(.plain)
134-
.opacity(0.625)
135137
} else {
136-
AlbumDetailRow("Location", "No Location")
138+
LabeledContent("Location", value: "No Location")
137139
}
138140

139141
case .denied, .unavailable:
140-
AlbumDetailRow("Location", "No Location")
142+
LabeledContent("Location", value: "No Location")
141143
}
142144
}
143145
}
@@ -153,8 +155,8 @@ private struct MapView: View {
153155
Map(position: $position) {
154156
if let accuracyRadius, accuracyRadius > 0 {
155157
MapCircle(center: location.coordinate, radius: accuracyRadius)
156-
.foregroundStyle(.themeBlue.opacity(0.15))
157-
.stroke(.themeBlue.opacity(0.55), lineWidth: 1)
158+
.foregroundStyle(.themeBlue.opacity(0.25))
159+
.stroke(.themeBlue.opacity(0.5), lineWidth: 1)
158160
}
159161
Marker("Location", coordinate: location.coordinate)
160162
}
@@ -193,43 +195,26 @@ private struct MapView: View {
193195
}
194196
}
195197

196-
private struct AlbumDetailRow: View {
197-
let key: String
198-
let value: String
199-
200-
init(_ key: String, _ value: String) {
201-
self.key = key
202-
self.value = value
203-
}
204-
205-
var body: some View {
206-
HStack {
207-
Text(key).font(.sligoilMicroBold(.subheadline))
208-
Spacer()
209-
Text(value).font(.sligoilMicro(.subheadline))
210-
}
211-
.foregroundStyle(.themePrimaryInverted)
212-
.opacity(0.625)
213-
}
214-
}
215-
216198
private struct AlbumTrackSection: View {
217199
let tracks: [AlbumTrack]
218200

219201
var body: some View {
220-
VStack(alignment: .leading, spacing: Padding.xl) {
221-
SectionHeader("Tracks")
222-
Section {
223-
if tracks.isEmpty {
202+
ThemeSection {
203+
if tracks.isEmpty {
204+
Section("Tracks") {
224205
ProgressView()
225-
} else {
226-
VStack(spacing: Spacing.sm) {
227-
ForEach(tracks.enumerated(), id: \.offset) { i, track in
228-
AlbumTrackRow(track)
229-
if i < tracks.count - 1 {
230-
Divider()
231-
}
232-
}
206+
}
207+
} else {
208+
Section {
209+
ForEach(tracks) { track in
210+
AlbumTrackRow(track: track)
211+
}
212+
} header: {
213+
Text("Tracks")
214+
} footer: {
215+
let anyPreview = tracks.contains { $0.previewUrl != nil }
216+
if anyPreview {
217+
Text("Tracks provided courtesy of iTunes.")
233218
}
234219
}
235220
}
@@ -242,10 +227,6 @@ private struct AlbumTrackRow: View {
242227

243228
let track: AlbumTrack
244229

245-
init(_ track: AlbumTrack) {
246-
self.track = track
247-
}
248-
249230
var body: some View {
250231
let isPlaying = track.title == player.preview?.title
251232

@@ -257,41 +238,28 @@ private struct AlbumTrackRow: View {
257238
: await player.play(url, title: track.title)
258239
}
259240
} label: {
260-
HStack {
261-
Group {
262-
if track.previewUrl == nil {
263-
Image(systemName: "play.slash")
264-
} else {
265-
PlaybackIndicator(isPlaying: isPlaying, progress: player.progress)
241+
LabeledContent {
242+
Text(track.duration ?? "N/A")
243+
} label: {
244+
HStack(spacing: Spacing.sm) {
245+
Group {
246+
if track.previewUrl == nil {
247+
Icon(systemName: "play.slash")
248+
} else {
249+
PlaybackIndicator(isPlaying: isPlaying, progress: player.progress)
250+
}
266251
}
267-
}
268-
.frame(width: 24)
269-
270-
Text(track.title)
271-
.font(.sligoilMicroBold(.subheadline))
272-
.minimumScaleFactor(0.75)
273-
.lineLimit(1)
274-
275-
Spacer()
252+
.frame(width: 24)
276253

277-
Text(track.duration ?? "N/A")
278-
.font(.sligoilMicro(.subheadline))
254+
Text(track.title)
255+
.lineLimit(1)
256+
}
279257
}
280-
.contentShape(.rect)
281258
}
282259
.buttonStyle(.plain)
283-
.allowsHitTesting(track.previewUrl != nil)
284-
// .disabled(track.previewUrl == nil)
285-
.foregroundStyle(
286-
isPlaying
287-
? .accent
288-
: .themePrimaryInverted
289-
)
290-
.animation(
291-
.easeInOut(duration: 0.25),
292-
value: isPlaying,
293-
)
294-
.opacity(0.625)
260+
.labeledContentStyle(.withThemeFont(isActive: isPlaying))
261+
.animation(.easeInOut, value: isPlaying)
262+
.disabled(track.previewUrl == nil)
295263
}
296264
}
297265

‎Snapper/Features/AlbumHistory/AlbumHistoryView.swift‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,22 @@ private struct AlbumHistoryContent: View {
116116
}
117117
}
118118
} label: {
119+
// TODO(dmoncada): figure out proper way to tint button.
119120
Image(systemName: "ellipsis")
121+
.frame(
122+
width: 32,
123+
height: 32,
124+
)
125+
.foregroundStyle(
126+
vm.favoritesOnly
127+
? .themePrimary
128+
: .themePrimaryInverted
129+
)
130+
.background {
131+
if vm.favoritesOnly {
132+
Circle().fill(.tint)
133+
}
134+
}
120135
}
121136
}
122137
}
Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,55 @@
11
import SwiftUI
22

33
struct AlbumHeader: View {
4-
enum Size {
5-
case sm, lg
6-
}
7-
8-
init(entry: AlbumEntry, size: Size = .sm) {
4+
init(entry: AlbumEntry, size: ControlSize = .small) {
95
self.init(
106
title: entry.title,
117
artist: entry.artist,
128
size: size,
139
)
1410
}
1511

16-
init(title: String, artist: String, size: Size = .sm) {
12+
init(title: String, artist: String, size: ControlSize = .small) {
1713
self.title = title
1814
self.artist = artist
1915
self.size = size
2016
}
2117

2218
private let title: String
2319
private let artist: String
24-
private let size: Size
25-
26-
private let styles: [Size: (Font.TextStyle, Font.TextStyle)] = [
27-
.sm: (.caption, .caption2),
28-
.lg: (.headline, .subheadline),
29-
]
20+
private let size: ControlSize
3021

3122
var body: some View {
32-
let (titleStyle, artistStyle) = styles[size] ?? (.caption, .caption2)
33-
34-
VStack(alignment: .leading, spacing: Spacing.xs) {
23+
LabeledContent {
24+
Text(artist)
25+
} label: {
3526
Text(title)
36-
.font(.sligoilMicroBold(titleStyle))
37-
.foregroundStyle(.themePrimaryInverted)
27+
}
28+
.labeledContentStyle(.albumHeader(controlSize: size))
29+
}
30+
}
3831

39-
Text(artist)
40-
.font(.sligoilMicro(artistStyle))
41-
.foregroundStyle(.accent)
32+
#if DEBUG
33+
private struct TestAlbumHeader: View {
34+
var body: some View {
35+
HStack(spacing: 32) {
36+
AlbumHeader(title: "Galore", artist: "Dragonette", size: .large)
37+
AlbumHeader(title: "Galore", artist: "Dragonette", size: .small)
4238
}
39+
.padding()
40+
.frame(maxWidth: .infinity)
41+
}
42+
}
43+
44+
#Preview {
45+
VStack(spacing: 0) {
46+
TestAlbumHeader()
47+
.background(.themePrimary)
48+
.environment(\.colorScheme, .light)
49+
50+
TestAlbumHeader()
51+
.background(.themePrimary)
52+
.environment(\.colorScheme, .dark)
4353
}
4454
}
55+
#endif

‎Snapper/UI/Components/PlaybackIndicator.swift‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ struct PlaybackIndicator: View {
2424

2525
#if DEBUG
2626
#Preview {
27-
PlaybackIndicator(isPlaying: true, progress: 0.5)
28-
.frame(width: 24)
27+
@Previewable @State var isPlaying = false
28+
29+
Button {
30+
isPlaying.toggle()
31+
} label: {
32+
PlaybackIndicator(isPlaying: isPlaying, progress: 0.5)
33+
.frame(width: 24)
34+
}
2935
}
3036
#endif

‎Snapper/UI/Components/SectionHeader.swift‎

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)