Skip to content

Commit

Permalink
Merge branch 'lint/channel-highlight' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Jan 4, 2024
2 parents c016106 + 55205ca commit 14b18fd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/view/channels_page/channel_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:miria/model/account.dart';
import 'package:miria/providers.dart';
import 'package:miria/router/app_router.dart';
import 'package:miria/view/channels_page/channel_detail_info.dart';
import 'package:miria/view/channels_page/channel_highlight.dart';
import 'package:miria/view/channels_page/channel_timeline.dart';
import 'package:miria/view/common/account_scope.dart';
import 'package:misskey_dart/misskey_dart.dart';
Expand All @@ -24,16 +25,17 @@ class ChannelDetailPage extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
return DefaultTabController(
length: 2,
length: 3,
child: AccountScope(
account: account,
child: Scaffold(
appBar: AppBar(
title: Text(S.of(context).channel),
bottom: TabBar(
tabs: [
Tab(child: Text(S.of(context).channelInformation)),
Tab(child: Text(S.of(context).timeline)),
Tab(text: S.of(context).channelInformation),
Tab(text: S.of(context).timeline),
Tab(text: S.of(context).highlight),
],
),
),
Expand All @@ -49,6 +51,10 @@ class ChannelDetailPage extends ConsumerWidget {
padding: const EdgeInsets.only(left: 10, right: 10),
child: ChannelTimeline(channelId: channelId),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: ChannelHighlight(channelId: channelId),
),
],
),
floatingActionButton: account.hasToken
Expand Down
42 changes: 42 additions & 0 deletions lib/view/channels_page/channel_highlight.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:miria/providers.dart';
import 'package:miria/view/common/account_scope.dart';
import 'package:miria/view/common/misskey_notes/misskey_note.dart';
import 'package:miria/view/common/pushable_listview.dart';
import 'package:misskey_dart/misskey_dart.dart';

class ChannelHighlight extends ConsumerWidget {
final String channelId;
const ChannelHighlight({
super.key,
required this.channelId,
});

@override
Widget build(BuildContext context, WidgetRef ref) {
final account = AccountScope.of(context);
return PushableListView<Note>(
initializeFuture: () async {
final response = await ref
.read(misskeyProvider(account))
.notes
.featured(NotesFeaturedRequest(channelId: channelId));
ref.read(notesProvider(account)).registerAll(response);
return response.toList();
},
nextFuture: (lastItem, _) async {
final response =
await ref.read(misskeyProvider(account)).notes.featured(
NotesFeaturedRequest(
channelId: channelId,
untilId: lastItem.id,
),
);
ref.read(notesProvider(account)).registerAll(response);
return response.toList();
},
itemBuilder: (context, note) => MisskeyNote(note: note),
);
}
}

0 comments on commit 14b18fd

Please sign in to comment.