-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #328 from tacko-o/role_timeline
ロールタイムラインタブを追加できるように #327
- Loading branch information
Showing
11 changed files
with
203 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ app.*.map.json | |
|
||
# builder | ||
**/node_modules/ | ||
**/build/ | ||
|
||
# Release | ||
/private_keys/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:miria/repository/socket_timeline_repository.dart'; | ||
import 'package:misskey_dart/misskey_dart.dart'; | ||
|
||
class RoleTimelineRepository extends SocketTimelineRepository { | ||
RoleTimelineRepository( | ||
super.misskey, | ||
super.noteRepository, | ||
super.globalNotificationRepository, | ||
super.generalSettingsRepository, | ||
super.tabSetting, | ||
super.mainStreamRepository, | ||
super.accountRepository, | ||
super.emojiRepository, | ||
); | ||
|
||
@override | ||
SocketController createSocketController({ | ||
required void Function(Note note) onReceived, | ||
required FutureOr<void> Function(String id, TimelineReacted reaction) | ||
onReacted, | ||
required FutureOr<void> Function(String id, TimelineVoted vote) onVoted, | ||
}) { | ||
return misskey.roleTimelineStream( | ||
roleId: tabSetting.roleId!, | ||
onNoteReceived: onReceived, | ||
onReacted: onReacted, | ||
onVoted: onVoted, | ||
); | ||
} | ||
|
||
@override | ||
Future<Iterable<Note>> requestNotes({String? untilId}) async { | ||
return await misskey.roles.notes(RolesNotesRequest( | ||
roleId: tabSetting.roleId!, | ||
limit: 30, | ||
untilId: untilId, | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
lib/view/settings_page/tab_settings_page/role_select_dialog.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:miria/model/account.dart'; | ||
import 'package:miria/providers.dart'; | ||
import 'package:miria/view/common/account_scope.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:misskey_dart/misskey_dart.dart'; | ||
|
||
class RoleSelectDialog extends ConsumerStatefulWidget { | ||
final Account account; | ||
|
||
const RoleSelectDialog({super.key, required this.account}); | ||
|
||
@override | ||
ConsumerState<ConsumerStatefulWidget> createState() => | ||
RoleSelectDialogState(); | ||
} | ||
|
||
class RoleSelectDialogState extends ConsumerState<RoleSelectDialog> { | ||
final roles = <RolesListResponse>[]; | ||
|
||
@override | ||
void didChangeDependencies() { | ||
super.didChangeDependencies(); | ||
Future(() async { | ||
final rolesList = await ref | ||
.read(misskeyProvider(widget.account)) | ||
.roles | ||
.list(); | ||
roles | ||
..clear() | ||
..addAll(rolesList); | ||
setState(() {}); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AccountScope( | ||
account: widget.account, | ||
child: AlertDialog( | ||
title: const Text("ロール選択"), | ||
content: SizedBox( | ||
width: MediaQuery.of(context).size.width * 0.8, | ||
height: MediaQuery.of(context).size.height * 0.8, | ||
child: SingleChildScrollView( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
"ロール", | ||
style: Theme.of(context).textTheme.titleMedium, | ||
), | ||
ListView.builder( | ||
shrinkWrap: true, | ||
physics: const NeverScrollableScrollPhysics(), | ||
itemCount: roles.length, | ||
itemBuilder: (context, index) { | ||
return ListTile( | ||
onTap: () { | ||
Navigator.of(context).pop(roles[index]); | ||
}, | ||
title: Text(roles[index].name)); | ||
}), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.