Skip to content

Commit

Permalink
チャンネルのハイライトを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Jan 4, 2024
1 parent d3aa4de commit 4a93614
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/view/channels_page/channel_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,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:flutter_riverpod/flutter_riverpod.dart';
Expand All @@ -23,16 +24,19 @@ 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: const Text("チャンネル"),
bottom: const TabBar(tabs: [
Tab(child: Text("チャンネル情報")),
Tab(child: Text("タイムライン"))
]),
bottom: const TabBar(
tabs: [
Tab(text: "チャンネル情報"),
Tab(text: "タイムライン"),
Tab(text: "ハイライト"),
],
),
),
body: TabBarView(
children: [
Expand All @@ -43,6 +47,10 @@ class ChannelDetailPage extends ConsumerWidget {
Padding(
padding: const EdgeInsets.only(left: 10, right: 10),
child: ChannelTimeline(channelId: channelId)),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: ChannelHighlight(channelId: channelId),
),
],
),
floatingActionButton: FloatingActionButton(
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 4a93614

Please sign in to comment.