Skip to content

Commit

Permalink
Merge pull request #174 from lamarios/feature/add_shorts_to_channels
Browse files Browse the repository at this point in the history
add shorts to channel view
  • Loading branch information
lamarios authored May 14, 2023
2 parents de109ab + e431150 commit b9dc316
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,10 @@
"@searchHistoryLimitDescription": {
"description": "Settings label for search history limit description"
},
"shorts": "Shorts",
"@shorts": {
"description": "Youtube shorts"
},
"searchSortRelevance": "Relevance",
"@searchSortRelevance": {
"description": "Sort search by relevance"
Expand Down
8 changes: 8 additions & 0 deletions lib/service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const GET_COMMENTS = '/api/v1/comments/:id';
const GET_CHANNEL = '/api/v1/channels/:id';
const GET_CHANNEL_VIDEOS = '/api/v1/channels/:id/videos';
const GET_CHANNEL_STREAMS = '/api/v1/channels/:id/streams';
const GET_CHANNEL_SHORTS = '/api/v1/channels/:id/shorts';
const GET_SPONSOR_SEGMENTS = 'https://sponsor.ajay.app/api/skipSegments?videoID=:id';
const GET_USER_PLAYLISTS = '/api/v1/auth/playlists';
const POST_USER_PLAYLIST = '/api/v1/auth/playlists';
Expand Down Expand Up @@ -367,6 +368,13 @@ class Service {
return VideosWithContinuation.fromJson(handleResponse(response));
}

Future<VideosWithContinuation> getChannelShorts(String channelId, String? continuation) async {
Uri uri = buildUrl(GET_CHANNEL_SHORTS, pathParams: {':id': channelId}, query: {'continuation': continuation});
final response = await http.get(uri, headers: {'Content-Type': 'application/json; charset=utf-16'});

return VideosWithContinuation.fromJson(handleResponse(response));
}

Future<List<Playlist>> getUserPlaylists() async {
var currentlySelectedServer = db.getCurrentlySelectedServer();

Expand Down
6 changes: 6 additions & 0 deletions lib/views/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class ChannelViewState extends State<ChannelView> with TickerProviderStateMixin
destinations: <Widget>[
NavigationDestination(icon: const Icon(Icons.info), label: locals.info),
NavigationDestination(icon: const Icon(Icons.play_arrow), label: locals.videos),
NavigationDestination(icon: const Icon(Icons.videocam), label: locals.shorts),
NavigationDestination(icon: const Icon(Icons.stream), label: locals.streams),
NavigationDestination(icon: const Icon(Icons.playlist_play), label: locals.playlists)
],
Expand Down Expand Up @@ -125,6 +126,11 @@ class ChannelViewState extends State<ChannelView> with TickerProviderStateMixin
channel: _.channel!,
getVideos: service.getChannelVideos,
),
ChannelVideosView(
key: const ValueKey('shorts'),
channel: _.channel!,
getVideos: service.getChannelShorts,
),
ChannelVideosView(
key: const ValueKey('streams'),
channel: _.channel!,
Expand Down
8 changes: 8 additions & 0 deletions lib/views/tv/tvChannelView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ class TvChannelView extends StatelessWidget {
),
),
TvHorizontalVideoList(paginatedVideoList: ContinuationList<VideoInList>((continuation) => service.getChannelVideos(_.channel?.authorId ?? '', continuation))),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Text(
locals.shorts,
style: textTheme.titleLarge,
),
),
TvHorizontalVideoList(paginatedVideoList: ContinuationList<VideoInList>((continuation) => service.getChannelShorts(_.channel?.authorId ?? '', continuation))),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Text(
Expand Down

0 comments on commit b9dc316

Please sign in to comment.