mirror of
https://github.com/izzy2lost/RetroArch.git
synced 2026-03-26 16:42:27 -07:00
7379d33801
This puts the History and Favorites playlists (up to five items each) in the Top Shelf menu. In order for this to be enabled you must build it yourself and change the app identifiers for the TV app and Top Shelf extension, and add both of them to an app group.
44 lines
1.7 KiB
Objective-C
44 lines
1.7 KiB
Objective-C
//
|
|
// ContentProvider.m
|
|
// RetroArchTopShelfExtension
|
|
//
|
|
// Created by Eric Warmenhoven on 2/17/24.
|
|
// Copyright © 2024 RetroArch. All rights reserved.
|
|
//
|
|
|
|
#import "ContentProvider.h"
|
|
|
|
@implementation ContentProvider
|
|
|
|
- (void)loadTopShelfContentWithCompletionHandler:(void (^) (id<TVTopShelfContent> content))completionHandler
|
|
{
|
|
NSUserDefaults *ud = [[NSUserDefaults alloc] initWithSuiteName:kRetroArchAppGroup];
|
|
|
|
NSDictionary *contentDict = [ud objectForKey:@"topshelf"];
|
|
|
|
NSMutableArray *collections = [NSMutableArray arrayWithCapacity:[contentDict count]];
|
|
for (NSString *key in [contentDict allKeys])
|
|
{
|
|
NSArray *contentArray = [contentDict objectForKey:key];
|
|
NSMutableArray *items = [NSMutableArray arrayWithCapacity:[contentArray count]];
|
|
|
|
for (NSDictionary *item in contentArray)
|
|
{
|
|
TVTopShelfSectionedItem *tsitem = [[TVTopShelfSectionedItem alloc] initWithIdentifier:item[@"id"]];
|
|
tsitem.title = item[@"title"];
|
|
[tsitem setImageURL:[NSURL URLWithString:item[@"img"]] forTraits:(TVTopShelfItemImageTraitScreenScale1x | TVTopShelfItemImageTraitScreenScale2x)];
|
|
[tsitem setImageShape:TVTopShelfSectionedItemImageShapeSquare];
|
|
[tsitem setDisplayAction:[[TVTopShelfAction alloc] initWithURL:[NSURL URLWithString:item[@"play"]]]];
|
|
[items addObject:tsitem];
|
|
}
|
|
|
|
TVTopShelfItemCollection<TVTopShelfSectionedItem *> *collection = [[TVTopShelfItemCollection alloc] initWithItems:items];
|
|
collection.title = key;
|
|
[collections addObject:collection];
|
|
}
|
|
TVTopShelfSectionedContent *content = [[TVTopShelfSectionedContent alloc] initWithSections:collections];
|
|
completionHandler(content);
|
|
}
|
|
|
|
@end
|