@@ -41,68 +41,40 @@ class MockAssetService: AssetService {
4141 super. init ( networkService: networkService)
4242 }
4343
44- func fetchAssets( page: Int = 1 , limit: Int = 50 , albumId: String ? = nil , personId: String ? = nil ) async throws -> SearchResult {
45- // Return mock assets
46- let mockAssets = [
44+ override func fetchAssets( page: Int = 1 , limit: Int = 50 , albumId: String ? = nil , personId: String ? = nil , tagId: String ? = nil , isAllPhotos: Bool = false ) async throws -> SearchResult {
45+ // Generate different mock assets based on tagId for animation preview
46+ let baseId = tagId ?? " default "
47+ let mockAssets = ( 1 ... limit) . map { index in
4748 ImmichAsset (
48- id: " mock-asset-1 " ,
49- deviceAssetId: " mock-device-1 " ,
49+ id: " mock-asset- \( baseId ) - \( index ) " ,
50+ deviceAssetId: " mock-device- \( index ) " ,
5051 deviceId: " mock-device " ,
5152 ownerId: " mock-owner " ,
5253 libraryId: nil ,
5354 type: . image,
54- originalPath: " /mock/path1 " ,
55- originalFileName: " mock1 .jpg" ,
55+ originalPath: " /mock/path \( index ) " ,
56+ originalFileName: " mock \( index ) .jpg " ,
5657 originalMimeType: " image/jpeg " ,
5758 resized: false ,
5859 thumbhash: nil ,
59- fileModifiedAt: " 2023-01-01 " ,
60- fileCreatedAt: " 2023-01-01 " ,
61- localDateTime: " 2023-01-01 " ,
62- updatedAt: " 2023-01-01 " ,
63- isFavorite: false ,
60+ fileModifiedAt: " 2023-01- \( String ( format : " %02d " , index ) ) " ,
61+ fileCreatedAt: " 2023-01- \( String ( format : " %02d " , index ) ) " ,
62+ localDateTime: " 2023-01- \( String ( format : " %02d " , index ) ) " ,
63+ updatedAt: " 2023-01- \( String ( format : " %02d " , index ) ) " ,
64+ isFavorite: index % 3 == 0 ,
6465 isArchived: false ,
6566 isOffline: false ,
6667 isTrashed: false ,
67- checksum: " mock-checksum-1 " ,
68+ checksum: " mock-checksum- \( baseId ) - \( index ) " ,
6869 duration: nil ,
6970 hasMetadata: false ,
7071 livePhotoVideoId: nil ,
7172 people: [ ] ,
7273 visibility: " public " ,
7374 duplicateId: nil ,
7475 exifInfo: nil
75- ) ,
76- ImmichAsset (
77- id: " mock-asset-2 " ,
78- deviceAssetId: " mock-device-2 " ,
79- deviceId: " mock-device " ,
80- ownerId: " mock-owner " ,
81- libraryId: nil ,
82- type: . video,
83- originalPath: " /mock/path2 " ,
84- originalFileName: " mock2.mp4 " ,
85- originalMimeType: " video/mp4 " ,
86- resized: false ,
87- thumbhash: nil ,
88- fileModifiedAt: " 2023-01-02 " ,
89- fileCreatedAt: " 2023-01-02 " ,
90- localDateTime: " 2023-01-02 " ,
91- updatedAt: " 2023-01-02 " ,
92- isFavorite: true ,
93- isArchived: false ,
94- isOffline: false ,
95- isTrashed: false ,
96- checksum: " mock-checksum-2 " ,
97- duration: " PT1M30S " ,
98- hasMetadata: false ,
99- livePhotoVideoId: nil ,
100- people: [ ] ,
101- visibility: " public " ,
102- duplicateId: nil ,
103- exifInfo: nil
10476 )
105- ]
77+ }
10678
10779 return SearchResult (
10880 assets: mockAssets,
@@ -112,8 +84,10 @@ class MockAssetService: AssetService {
11284 }
11385
11486 override func loadImage( asset: ImmichAsset , size: String = " thumbnail " ) async throws -> UIImage ? {
115- // Fetch a random image from picsum.photos
116- let url = URL ( string: " https://picsum.photos/300/300 " ) !
87+ // Generate different colored images based on asset ID for visual variety
88+ let hash = abs ( asset. id. hashValue)
89+ let seed = hash % 1000
90+ let url = URL ( string: " https://picsum.photos/seed/ \( seed) /300/300 " ) !
11791 let ( data, _) = try await URLSession . shared. data ( from: url)
11892 return UIImage ( data: data)
11993 }
@@ -166,6 +140,33 @@ class MockAlbumService: AlbumService {
166140 order: " desc " ,
167141 startDate: " 2023-01-01 " ,
168142 endDate: " 2023-01-31 "
143+ ) ,
144+ ImmichAlbum (
145+ id: " mock-album-2 " ,
146+ albumName: " Mock Album 1 " ,
147+ description: " This is a mock album for testing " ,
148+ albumThumbnailAssetId: " mock-asset-1 " ,
149+ createdAt: " 2023-01-01 " ,
150+ updatedAt: " 2023-01-01 " ,
151+ albumUsers: [ ] ,
152+ assets: [ ] ,
153+ assetCount: 5 ,
154+ ownerId: " mock-owner " ,
155+ owner: Owner (
156+ id: " mock-owner " ,
157+ email: " mock@example.com " ,
158+ name: " Mock Owner " ,
159+ profileImagePath: " " ,
160+ profileChangedAt: " 2023-01-01 " ,
161+ avatarColor: " primary "
162+ ) ,
163+ shared: false ,
164+ hasSharedLink: false ,
165+ isActivityEnabled: true ,
166+ lastModifiedAssetTimestamp: " 2023-01-01 " ,
167+ order: " desc " ,
168+ startDate: " 2023-01-01 " ,
169+ endDate: " 2023-01-31 "
169170 )
170171 ]
171172
@@ -180,6 +181,57 @@ class MockAlbumService: AlbumService {
180181 }
181182}
182183
184+ // MARK: - Mock tag service
185+ class MockTagService : TagService {
186+ override init ( networkService: NetworkService ) {
187+ super. init ( networkService: networkService)
188+ }
189+
190+ override func fetchTags( ) async throws -> [ Tag ] {
191+ // Return mock tags
192+ let mockTags = [
193+ Tag (
194+ id: " 1 " ,
195+ name: " Nature " ,
196+ value: " nature " ,
197+ color: " green " ,
198+ createdAt: " 2023-01-01 " ,
199+ updatedAt: " 2023-01-01 " ,
200+ parentId: nil
201+ ) ,
202+ Tag (
203+ id: " 2 " ,
204+ name: " Travel " ,
205+ value: " travel " ,
206+ color: " blue " ,
207+ createdAt: " 2023-01-02 " ,
208+ updatedAt: " 2023-01-02 " ,
209+ parentId: nil
210+ ) ,
211+ Tag (
212+ id: " 3 " ,
213+ name: " Family " ,
214+ value: " family " ,
215+ color: " red " ,
216+ createdAt: " 2023-01-03 " ,
217+ updatedAt: " 2023-01-03 " ,
218+ parentId: nil
219+ ) ,
220+ Tag (
221+ id: " 4 " ,
222+ name: " Work " ,
223+ value: " work " ,
224+ color: " orange " ,
225+ createdAt: " 2023-01-04 " ,
226+ updatedAt: " 2023-01-04 " ,
227+ parentId: nil
228+ )
229+ ]
230+
231+ return mockTags
232+ }
233+ }
234+
183235// MARK: - Mock People Service
184236class MockPeopleService : PeopleService {
185237 override init ( networkService: NetworkService ) {
@@ -224,13 +276,14 @@ class MockPeopleService: PeopleService {
224276
225277// MARK: - Convenience Factory
226278class MockServiceFactory {
227- static func createMockServices( ) -> ( NetworkService , AuthenticationService , AssetService , AlbumService , PeopleService ) {
279+ static func createMockServices( ) -> ( NetworkService , AuthenticationService , AssetService , AlbumService , PeopleService , TagService ) {
228280 let networkService = MockNetworkService ( )
229281 let authService = MockAuthenticationService ( networkService: networkService)
230282 let assetService = MockAssetService ( networkService: networkService)
231283 let albumService = MockAlbumService ( networkService: networkService)
232284 let peopleService = MockPeopleService ( networkService: networkService)
285+ let tagService = MockTagService ( networkService: networkService)
233286
234- return ( networkService, authService, assetService, albumService, peopleService)
287+ return ( networkService, authService, assetService, albumService, peopleService, tagService )
235288 }
236289}
0 commit comments