-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notebook and children page in drawer
- Loading branch information
1 parent
84f465f
commit b807aba
Showing
11 changed files
with
197 additions
and
74 deletions.
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
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
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,64 @@ | ||
part of 'drawer.dart'; | ||
|
||
class _NoteChildrenView extends StatefulWidget { | ||
final SourcedModel<Notebook?>? notebook; | ||
final Multihash? parent; | ||
|
||
const _NoteChildrenView({ | ||
this.parent, | ||
this.notebook, | ||
}); | ||
|
||
@override | ||
State<_NoteChildrenView> createState() => _NoteChildrenViewState(); | ||
} | ||
|
||
class _NoteChildrenViewState extends State<_NoteChildrenView> { | ||
late final SourcedPagingController<Note> _controller; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
_controller = SourcedPagingController( | ||
context.read<FlowCubit>(), | ||
); | ||
_controller.addFetchListener((source, service, offset, limit) async { | ||
final notebook = widget.notebook; | ||
if (notebook != null && notebook.source != source) return []; | ||
return service.note?.getNotes( | ||
offset: offset, | ||
limit: limit, | ||
parent: widget.parent, | ||
notebook: notebook?.source == source ? notebook?.model?.id : null, | ||
); | ||
}); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
super.dispose(); | ||
_controller.dispose(); | ||
} | ||
|
||
@override | ||
void didUpdateWidget(covariant _NoteChildrenView oldWidget) { | ||
super.didUpdateWidget(oldWidget); | ||
if (oldWidget.parent != widget.parent) { | ||
_controller.refresh(); | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return PagedListView( | ||
pagingController: _controller, | ||
builderDelegate: buildMaterialPagedDelegate<SourcedModel<Note>>( | ||
_controller, | ||
(ctx, item, index) => ListTile( | ||
title: Text(item.model.name), | ||
), | ||
), | ||
); | ||
} | ||
} |
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 @@ | ||
part of 'drawer.dart'; | ||
|
||
class _NotebooksView extends StatefulWidget { | ||
final SourcedModel<Notebook?>? model; | ||
|
||
const _NotebooksView({ | ||
this.model, | ||
}); | ||
|
||
@override | ||
State<_NotebooksView> createState() => _NotebooksViewState(); | ||
} | ||
|
||
class _NotebooksViewState extends State<_NotebooksView> { | ||
late final SourcedPagingController<Notebook> _controller; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
_controller = SourcedPagingController( | ||
context.read<FlowCubit>(), | ||
); | ||
_controller.addFetchListener((source, service, offset, limit) async { | ||
return []; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return PagedListView( | ||
pagingController: _controller, | ||
builderDelegate: buildMaterialPagedDelegate<SourcedModel<Notebook>>( | ||
_controller, | ||
(ctx, item, index) => ListTile( | ||
title: Text(item.model.name), | ||
), | ||
), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.