Skip to content

Commit c898cfa

Browse files
committed
feat(theme): multiple changes to components and style.
1 parent 977b7d7 commit c898cfa

23 files changed

Lines changed: 189 additions & 463 deletions

‎Snapper/Features/AlbumDetail/AlbumDetailView.swift‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ private struct AlbumHeaderSection: View {
7272
@Bindable var album = album
7373

7474
HStack(alignment: .top) {
75-
AlbumHeader(title: album.title, artist: album.artist, size: .large)
75+
LabeledContent(album.artist, value: album.title)
76+
.labeledContentStyle(.albumHeader)
77+
.controlSize(.large)
7678

7779
Spacer()
7880

@@ -291,32 +293,26 @@ private struct AlbumTrackRow: View {
291293
}
292294
} label: {
293295
HStack(spacing: Spacing.sm) {
294-
HStack(spacing: Spacing.sm) {
295-
ProgressView(value: player.progress)
296-
.progressViewStyle(.playback(isPlaying: isPlaying))
297-
298-
// Text(track.position)
296+
ProgressView(value: player.progress)
297+
.progressViewStyle(.playback(isPlaying: isPlaying))
298+
.opacity(isPlaying ? 1 : 0.625)
299299

300+
LabeledContent {
301+
Text(track.duration)
302+
} label: {
300303
Text(track.title)
301-
.lineLimit(1)
304+
// .lineLimit(1)
302305
}
303-
.font(.sligoilMicroBold(.subheadline))
304-
305-
Spacer()
306-
307-
Text(track.duration)
308-
.font(.sligoilMicro(.subheadline))
306+
.labeledContentStyle(.withThemeFont(isActive: isPlaying))
309307
}
310308
.contentShape(.rect)
311309
.foregroundStyle(
312310
isPlaying
313311
? .accent
314312
: .themePrimaryInverted
315313
)
316-
.opacity(isPlaying ? 1 : 0.625)
317314
}
318315
.buttonStyle(.plain)
319-
.labeledContentStyle(.withThemeFont(isActive: isPlaying))
320316
.animation(.easeInOut, value: isPlaying)
321317
.disabled(track.previewUrl == nil)
322318
}
@@ -331,8 +327,8 @@ import SwiftData
331327
if let album = albums.first {
332328
NavigationStack {
333329
AlbumDetailView(album: album)
330+
.environment(AlbumDetailViewModel())
334331
.environment(\.previewPlayer, .live)
335-
.environment(AlbumDetailViewModel(apiClient: .live))
336332
}
337333
} else {
338334
ProgressView()

‎Snapper/Features/AlbumDetail/AlbumDetailViewModel.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ extension ApiClient {
6161
try await resolveTracks(
6262
// discogsId: album.id,
6363
discogsId: album.discogsId,
64-
albumTitle: album.title,
65-
albumArtist: album.artist,
64+
// albumTitle: album.title,
65+
// albumArtist: album.artist,
6666
barcode: album.barcode.first,
6767
)
6868
}

‎Snapper/Features/AlbumDetail/AlbumDetailWithActions.swift‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ struct AlbumDetailWithActions: View {
77
let onDelete: (Album) -> Void
88

99
var body: some View {
10+
@Bindable var album = album
11+
1012
AlbumDetailView(album: album)
1113
.toolbar {
1214
ToolbarItem(placement: .topBarTrailing) {
1315
Menu {
14-
FavoriteButton(album: album)
16+
FavoriteButton(isFavorite: $album.isFavorite)
1517
DeleteButton {
1618
router.alertItem = AlertDestination(
1719
title: "Delete Album?",

‎Snapper/Features/AlbumHistory/AlbumHistoryCard.swift‎

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,27 @@ struct AlbumHistoryCard: View {
99
.roundedOutline(lineWidth: LineWidth.sm)
1010

1111
HStack(alignment: .center) {
12-
AlbumHeader(title: album.title, artist: album.artist)
12+
LabeledContent(album.artist, value: album.title)
1313
.frame(maxWidth: .infinity, alignment: .leading)
14-
// .minimumScaleFactor(0.75)
14+
.labeledContentStyle(.albumHeader)
15+
.controlSize(.small)
1516
.lineLimit(1)
1617

1718
Spacer()
1819

19-
Icon(systemName: "star.fill")
20+
Image(systemName: "heart.fill")
2021
.favoriteIconStyle(isFavorite: album.isFavorite)
22+
.opacity(album.isFavorite ? 1 : 0)
2123

22-
Text((album.selectedAt.shortRelative(to: .now)))
24+
Text(album.selectedAt.shortRelative(to: .now))
2325
.badgeStyle()
2426
.controlSize(.mini)
2527
}
26-
.frame(height: 40)
28+
.padding(.vertical, Padding.sm)
2729
}
2830
}
2931
}
3032

31-
struct FavoriteIconStyle: ViewModifier {
32-
let isFavorite: Bool
33-
34-
func body(content: Content) -> some View {
35-
content
36-
.foregroundStyle(.accent)
37-
.symbolEffect(
38-
.bounce.up,
39-
options: .speed(2),
40-
value: isFavorite,
41-
)
42-
.opacity(isFavorite ? 1 : 0)
43-
}
44-
}
45-
46-
extension View {
47-
func favoriteIconStyle(isFavorite: Bool) -> some View {
48-
modifier(FavoriteIconStyle(isFavorite: isFavorite))
49-
}
50-
}
51-
5233
private struct AlbumCover: View {
5334
let url: URL?
5435

@@ -71,38 +52,57 @@ private struct AlbumCover: View {
7152
import SwiftData
7253

7354
private struct TestHistoryCard: View {
74-
let album1: Album
75-
let album2: Album
55+
let album: Album
7656

7757
var body: some View {
78-
HStack {
79-
Button {
80-
album1.isFavorite.toggle()
81-
} label: {
82-
AlbumHistoryCard(album: album1)
83-
.contentShape(.rect)
84-
}
58+
Button {
59+
album.isFavorite.toggle()
60+
} label: {
61+
AlbumHistoryCard(album: album)
62+
.contentShape(.rect)
63+
}
64+
}
65+
}
8566

86-
Spacer()
67+
#Preview("Single Column", traits: .withSampleData) {
68+
@Previewable @Query(sort: \Album.selectedAt) var albums: [Album]
8769

88-
Button {
89-
album2.isFavorite.toggle()
90-
} label: {
91-
AlbumHistoryCard(album: album2)
92-
.contentShape(.rect)
70+
if albums.isEmpty {
71+
ProgressView()
72+
} else {
73+
ScrollView {
74+
WithColorSchemes {
75+
LazyVGrid(columns: [.init(.flexible())]) {
76+
TestHistoryCard(album: albums[0])
77+
}
78+
.padding()
9379
}
9480
}
95-
.buttonStyle(.plain)
9681
}
9782
}
9883

99-
#Preview(traits: .withSampleData) {
84+
#Preview("Double Column", traits: .withSampleData) {
85+
@Previewable @Environment(\.dynamicTypeSize) var dynamicTypeSize
86+
10087
@Previewable @Query(sort: \Album.selectedAt) var albums: [Album]
10188

89+
var columns: [GridItem] {
90+
[
91+
dynamicTypeSize.isAccessibilitySize
92+
? GridItem(.flexible(minimum: 160))
93+
: GridItem(.adaptive(minimum: 160))
94+
]
95+
}
96+
10297
if albums.count > 1 {
103-
WithColorSchemes {
104-
TestHistoryCard(album1: albums[0], album2: albums[1])
98+
ScrollView {
99+
WithColorSchemes {
100+
LazyVGrid(columns: columns) {
101+
TestHistoryCard(album: albums[0])
102+
TestHistoryCard(album: albums[1])
103+
}
105104
.padding()
105+
}
106106
}
107107
} else {
108108
ProgressView()

‎Snapper/Features/AlbumHistory/AlbumHistoryView.swift‎

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,6 @@ import SwiftData
22
import SwiftUI
33

44
struct HistoryView: View {
5-
/*
6-
@Environment(\.modelContext) private var context
7-
8-
var body: some View {
9-
AlbumHistoryContent(context: context)
10-
}
11-
}
12-
13-
private struct AlbumHistoryContent: View {
14-
@Environment(Router.self) private var router
15-
16-
@State private var vm: AlbumHistoryViewModel
17-
@State private var path = NavigationPath()
18-
19-
init(context: ModelContext) {
20-
_vm = State(initialValue: AlbumHistoryViewModel(context: context))
21-
}
22-
*/
23-
245
@Environment(AlbumHistoryViewModel.self) private var vm
256
@Environment(Router.self) private var router
267

@@ -37,14 +18,16 @@ private struct AlbumHistoryContent: View {
3718
isSelecting: vm.isSelecting,
3819
onOpen: { path.append($0) },
3920
) { album, isSelected in
21+
@Bindable var album = album
22+
4023
AlbumSelectableCard(
4124
album: album,
4225
isSelecting: vm.isSelecting,
4326
isSelected: isSelected,
4427
)
4528
.contextMenu {
4629
if vm.isSelecting == false {
47-
FavoriteButton(album: album)
30+
FavoriteButton(isFavorite: $album.isFavorite)
4831
DeleteButton {
4932
router.alertItem = AlertDestination(
5033
title: "Delete Album?",
@@ -195,6 +178,7 @@ private struct AlbumHistoryToolbar: ToolbarContent {
195178
}
196179
.withAlertDestination($router.alertItem)
197180
.environment(AlbumHistoryViewModel(context: context))
181+
.environment(AlbumDetailViewModel(apiClient: .live))
198182
.environment(\.previewPlayer, .live)
199183
.environment(router)
200184
}

‎Snapper/Features/AlbumHistory/AlbumSelectableCard.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ struct AlbumSelectableCard: View {
2323
if isSelecting {
2424
Group {
2525
if isSelected {
26-
Icon(systemName: "checkmark.circle.fill")
26+
Image(systemName: "checkmark.circle.fill")
2727
.transition(.symbolEffect(.drawOn, options: .speed(0.75)))
2828
.foregroundStyle(.selection)
2929
} else {
30-
Icon(systemName: "circle")
30+
Image(systemName: "circle")
3131
.foregroundStyle(.secondary)
3232
}
3333
}

‎Snapper/Features/AlbumSearch/AlbumCandidateRow.swift‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ struct AlbumCandidateRow: View {
99
HStack {
1010
AlbumThumbnail(url: album.thumbnailUrl)
1111

12-
AlbumHeader(title: album.title, artist: album.artist)
13-
// .minimumScaleFactor(0.75)
12+
LabeledContent(album.artist, value: album.title)
13+
.labeledContentStyle(.albumHeader)
14+
.controlSize(.small)
1415
.lineLimit(1)
1516

1617
Spacer()

‎Snapper/Features/AlbumSearch/AlbumScanFlowModel.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class AlbumScanFlowModel {
1919

2020
private let apiClient: any ApiClient
2121

22+
// init(apiClient: any ApiClient = .null) {
2223
init(apiClient: any ApiClient = .live) {
2324
self.apiClient = apiClient
2425
}

‎Snapper/Features/AlbumSearch/AlbumSearchView.swift‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ struct HomeView: View {
2121
VStack(spacing: Spacing.sm) {
2222
HStack(spacing: Spacing.sm) {
2323
PhotoPickerButton("Pick", onData: onData) { _ in }
24-
.frame(width: 100)
2524

2625
Button("Snap") { isPresented = true }
2726
.buttonStyle(.large)
2827
}
2928

30-
/*
31-
SearchField(text: $searchText, placeholder: "Or search by artist, album")
32-
.keyboardType(.webSearch)
33-
*/
34-
3529
TextField(text: $searchText) {
3630
Text("Or search by artist, album")
3731
}

‎Snapper/Services/Playback/PreviewPlayer.swift‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ private struct TestPreviewPlayer: View {
267267
var body: some View {
268268
if titles.count == urls.count {
269269
VStack {
270-
ForEach(Array(zip(titles, urls)).enumerated(), id: \.offset) { _, pair in
271-
let (title, url) = pair
270+
ForEach(Array(zip(titles, urls)), id: \.1) { title, url in
272271
let isPlaying = title == player.preview?.title
273272

274273
LabeledContent(title) {

0 commit comments

Comments
 (0)