|
278 | 278 | </div> |
279 | 279 | <div> |
280 | 280 | <h2 class="text-2xl sm:text-3xl font-bold font-cartoon text-amber-800 cartoon-text">Featured Episodes</h2> |
281 | | - <p class="text-amber-900 font-comic text-base sm:text-lg font-semibold">Randomly selected classics that never get old! 🎭</p> |
| 281 | + <p class="text-amber-900 font-comic text-base sm:text-lg font-semibold">Selected classics that never get old! 🎭</p> |
282 | 282 | </div> |
283 | 283 | </div> |
284 | 284 | <div class="flex items-center space-x-3"> |
285 | 285 | <button @onclick="RefreshFeaturedEpisodes" |
286 | 286 | class="px-4 sm:px-6 py-2 sm:py-3 text-xs sm:text-sm bg-tom-blue text-white rounded-2xl font-bold font-comic hover:bg-tom-dark-blue transition-colors cartoon-rounded"> |
287 | 287 | 🔄 Refresh Featured |
288 | 288 | </button> |
289 | | - <span class="hidden sm:inline text-sm text-amber-800 font-comic bg-cartoon-yellow px-3 py-1 rounded-full font-semibold">Random Selection</span> |
290 | 289 | <div class="w-3 h-3 bg-cartoon-red rounded-full animate-pulse cartoon-rounded"></div> |
291 | 290 | </div> |
292 | 291 | </div> |
|
349 | 348 |
|
350 | 349 | <!-- Filter Options --> |
351 | 350 | <div class="flex flex-wrap items-center gap-2 sm:gap-3"> |
352 | | - <button class="px-4 sm:px-6 py-2 sm:py-3 text-xs sm:text-sm bg-tom-blue text-white rounded-2xl font-bold font-comic hover:bg-tom-dark-blue transition-colors cartoon-rounded"> |
| 351 | + <button @onclick="@(() => ApplyFilter("All"))" |
| 352 | + class="@GetFilterButtonClass("All")"> |
353 | 353 | All |
354 | 354 | </button> |
355 | | - <button class="px-4 sm:px-6 py-2 sm:py-3 text-xs sm:text-sm bg-soft-blue text-amber-800 rounded-2xl font-bold font-comic hover:bg-cartoon-yellow transition-colors border-2 border-amber-800 cartoon-rounded"> |
| 355 | + <button @onclick="@(() => ApplyFilter("Classic"))" |
| 356 | + class="@GetFilterButtonClass("Classic")"> |
356 | 357 | Classic |
357 | 358 | </button> |
358 | | - <button class="px-4 sm:px-6 py-2 sm:py-3 text-xs sm:text-sm bg-soft-blue text-amber-800 rounded-2xl font-bold font-comic hover:bg-cartoon-yellow transition-colors border-2 border-amber-800 cartoon-rounded"> |
| 359 | + <button @onclick="@(() => ApplyFilter("Modern"))" |
| 360 | + class="@GetFilterButtonClass("Modern")"> |
359 | 361 | Modern |
360 | 362 | </button> |
361 | 363 | </div> |
362 | 364 | </div> |
363 | 365 |
|
364 | 366 | <!-- All Videos Grid --> |
365 | 367 | <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-4 sm:gap-6"> |
366 | | - @foreach (var item in StateService.CurrentVideos) |
| 368 | + @foreach (var item in filteredVideos) |
367 | 369 | { |
368 | 370 | <Thumbnail VideoModel="@item"/> |
369 | 371 | } |
|
377 | 379 | @code |
378 | 380 | { |
379 | 381 | private string heroSearchTerm = string.Empty; |
| 382 | + private string activeFilter = "All"; |
| 383 | + private IEnumerable<Video> filteredVideos = Enumerable.Empty<Video>(); |
380 | 384 |
|
381 | 385 | public void GoTOPage(Video video) |
382 | 386 | { |
|
472 | 476 | await StateService.RefreshFeaturedVideosAsync(StateService.CurrentVideos, 10); |
473 | 477 | } |
474 | 478 |
|
| 479 | + private void ApplyFilter(string filter) |
| 480 | + { |
| 481 | + activeFilter = filter; |
| 482 | + |
| 483 | + if (!StateService.CurrentVideos.Any()) |
| 484 | + { |
| 485 | + filteredVideos = Enumerable.Empty<Video>(); |
| 486 | + return; |
| 487 | + } |
| 488 | + |
| 489 | + var videos = StateService.CurrentVideos.ToList(); |
| 490 | + |
| 491 | + switch (filter) |
| 492 | + { |
| 493 | + case "All": |
| 494 | + // Sequential order (by ID) |
| 495 | + filteredVideos = videos.OrderBy(v => int.Parse(v.Id)).ToList(); |
| 496 | + break; |
| 497 | + case "Classic": |
| 498 | + // Random order |
| 499 | + var random = new Random(); |
| 500 | + filteredVideos = videos.OrderBy(x => random.Next()).ToList(); |
| 501 | + break; |
| 502 | + case "Modern": |
| 503 | + // Inverse order (newest first) |
| 504 | + filteredVideos = videos.OrderByDescending(v => int.Parse(v.Id)).ToList(); |
| 505 | + break; |
| 506 | + default: |
| 507 | + filteredVideos = videos; |
| 508 | + break; |
| 509 | + } |
| 510 | + |
| 511 | + StateHasChanged(); |
| 512 | + } |
| 513 | + |
| 514 | + private string GetFilterButtonClass(string filter) |
| 515 | + { |
| 516 | + return activeFilter == filter |
| 517 | + ? "px-4 sm:px-6 py-2 sm:py-3 text-xs sm:text-sm bg-tom-blue text-white rounded-2xl font-bold font-comic hover:bg-tom-dark-blue transition-colors cartoon-rounded" |
| 518 | + : "px-4 sm:px-6 py-2 sm:py-3 text-xs sm:text-sm bg-soft-blue text-amber-800 rounded-2xl font-bold font-comic hover:bg-cartoon-yellow transition-colors border-2 border-amber-800 cartoon-rounded"; |
| 519 | + } |
| 520 | + |
475 | 521 | protected override async Task OnInitializedAsync() |
476 | 522 | { |
477 | 523 | StateService.OnStateChanged += StateHasChanged; |
|
486 | 532 |
|
487 | 533 | // Set random featured videos |
488 | 534 | await StateService.RefreshFeaturedVideosAsync(videos, 10); |
| 535 | + |
| 536 | + // Apply initial filter (All - sequential order) |
| 537 | + ApplyFilter("All"); |
489 | 538 | } |
490 | 539 | finally |
491 | 540 | { |
|
0 commit comments