tangled
alpha
login
or
join now
teal.fm
/
teal
110
fork
atom
Your music, beautifully tracked. All yours. (coming soon)
teal.fm
teal-fm
atproto
110
fork
atom
overview
issues
pulls
pipelines
attempt a styles fix
authored by
Natalie
and committed by
Natalie B.
1 year ago
9fd851bd
511363e3
-142
1 changed file
expand all
collapse all
unified
split
apps
amethyst
lib
oldStamp.tsx
-142
apps/amethyst/lib/oldStamp.tsx
···
1
1
-
import { View, ScrollView, TouchableOpacity, Image, Modal } from "react-native";
2
2
-
import { useState } from "react";
3
3
-
import { Text } from "../components/ui/text";
4
4
-
import { Icon } from "@/lib/icons/iconWithClassName";
5
5
-
import { Check } from "lucide-react-native";
6
1
import { Record as PlayRecord } from "@teal/lexicons/src/types/fm/teal/alpha/feed/play";
7
7
-
import React from "react";
8
2
9
3
// MusicBrainz API Types
10
4
export interface MusicBrainzArtistCredit {
···
85
79
return [];
86
80
}
87
81
}
88
88
-
89
89
-
export function SearchResult({
90
90
-
result,
91
91
-
onSelectTrack,
92
92
-
isSelected,
93
93
-
selectedRelease,
94
94
-
onReleaseSelect,
95
95
-
}: SearchResultProps) {
96
96
-
const [showReleaseModal, setShowReleaseModal] = useState<boolean>(false);
97
97
-
98
98
-
const currentRelease = selectedRelease || result.releases?.[0];
99
99
-
100
100
-
return (
101
101
-
<TouchableOpacity
102
102
-
onPress={() => {
103
103
-
onSelectTrack(
104
104
-
isSelected
105
105
-
? null
106
106
-
: {
107
107
-
...result,
108
108
-
selectedRelease: currentRelease, // Pass the selected release with the track
109
109
-
},
110
110
-
);
111
111
-
}}
112
112
-
className={`p-4 mb-2 rounded-lg ${
113
113
-
isSelected ? "bg-primary/20" : "bg-secondary/10"
114
114
-
}`}
115
115
-
>
116
116
-
<View className="flex-row justify-between items-center gap-2">
117
117
-
<Image
118
118
-
className="w-16 h-16 rounded-lg bg-gray-500/50"
119
119
-
source={{
120
120
-
uri: `https://coverartarchive.org/release/${currentRelease?.id}/front-250`,
121
121
-
}}
122
122
-
/>
123
123
-
<View className="flex-1">
124
124
-
<Text className="font-bold text-sm">{result.title}</Text>
125
125
-
<Text className="text-sm text-gray-600">
126
126
-
{result["artist-credit"]?.[0]?.artist?.name ?? "Unknown Artist"}
127
127
-
</Text>
128
128
-
129
129
-
{/* Release Selector Button */}
130
130
-
{result.releases && result.releases?.length > 0 && (
131
131
-
<TouchableOpacity
132
132
-
onPress={() => setShowReleaseModal(true)}
133
133
-
className="p-1 bg-secondary/10 rounded-lg flex md:flex-row items-start md:gap-1"
134
134
-
>
135
135
-
<Text className="text-sm text-gray-500">Release:</Text>
136
136
-
<Text className="text-sm" numberOfLines={1}>
137
137
-
{currentRelease?.title}
138
138
-
{currentRelease?.date ? ` (${currentRelease.date})` : ""}
139
139
-
{currentRelease?.country ? ` - ${currentRelease.country}` : ""}
140
140
-
</Text>
141
141
-
</TouchableOpacity>
142
142
-
)}
143
143
-
</View>
144
144
-
{/* Existing icons */}
145
145
-
{/* <Link href={`https://musicbrainz.org/recording/${result.id}`}>
146
146
-
<View className="bg-primary/40 rounded-full p-1">
147
147
-
<Icon icon={Brain} size={20} />
148
148
-
</View>
149
149
-
</Link> */}
150
150
-
{isSelected ? (
151
151
-
<View className="bg-primary rounded-full p-1">
152
152
-
<Icon icon={Check} size={20} />
153
153
-
</View>
154
154
-
) : (
155
155
-
<View className="border-2 border-secondary rounded-full p-3"></View>
156
156
-
)}
157
157
-
</View>
158
158
-
159
159
-
{/* Release Selection Modal */}
160
160
-
<Modal
161
161
-
visible={showReleaseModal}
162
162
-
transparent={true}
163
163
-
animationType="slide"
164
164
-
onRequestClose={() => setShowReleaseModal(false)}
165
165
-
>
166
166
-
<View className="flex-1 justify-end bg-black/50">
167
167
-
<View className="bg-background rounded-t-3xl">
168
168
-
<View className="p-4 border-b border-gray-200">
169
169
-
<Text className="text-lg font-bold text-center">
170
170
-
Select Release
171
171
-
</Text>
172
172
-
<TouchableOpacity
173
173
-
className="absolute right-4 top-4"
174
174
-
onPress={() => setShowReleaseModal(false)}
175
175
-
>
176
176
-
<Text className="text-primary">Done</Text>
177
177
-
</TouchableOpacity>
178
178
-
</View>
179
179
-
180
180
-
<ScrollView className="max-h-[50vh]">
181
181
-
{result.releases?.map((release) => (
182
182
-
<TouchableOpacity
183
183
-
key={release.id}
184
184
-
className={`p-4 border-b border-gray-100 ${
185
185
-
selectedRelease?.id === release.id ? "bg-primary/10" : ""
186
186
-
}`}
187
187
-
onPress={() => {
188
188
-
onReleaseSelect(result.id, release);
189
189
-
setShowReleaseModal(false);
190
190
-
}}
191
191
-
>
192
192
-
<Text className="font-medium">{release.title}</Text>
193
193
-
<View className="flex-row gap-2">
194
194
-
{release.date && (
195
195
-
<Text className="text-sm text-gray-500">
196
196
-
{release.date}
197
197
-
</Text>
198
198
-
)}
199
199
-
{release.country && (
200
200
-
<Text className="text-sm text-gray-500">
201
201
-
{release.country}
202
202
-
</Text>
203
203
-
)}
204
204
-
{release.status && (
205
205
-
<Text className="text-sm text-gray-500">
206
206
-
{release.status}
207
207
-
</Text>
208
208
-
)}
209
209
-
</View>
210
210
-
{release.disambiguation && (
211
211
-
<Text className="text-sm text-gray-400 italic">
212
212
-
{release.disambiguation}
213
213
-
</Text>
214
214
-
)}
215
215
-
</TouchableOpacity>
216
216
-
))}
217
217
-
</ScrollView>
218
218
-
</View>
219
219
-
</View>
220
220
-
</Modal>
221
221
-
</TouchableOpacity>
222
222
-
);
223
223
-
}