-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9ff2a1
commit 2a6ce00
Showing
14 changed files
with
277 additions
and
77 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
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 |
---|---|---|
@@ -1,41 +1,53 @@ | ||
part of 'drawer.dart'; | ||
|
||
class _NotebooksView extends StatefulWidget { | ||
class _NotebooksView extends StatelessWidget { | ||
final SourcedModel<Notebook?>? model; | ||
|
||
const _NotebooksView({ | ||
this.model, | ||
}); | ||
|
||
@override | ||
State<_NotebooksView> createState() => _NotebooksViewState(); | ||
Widget build(BuildContext context) { | ||
return SelectTile( | ||
source: model?.source, | ||
onChanged: (model) {}, | ||
onModelFetch: (source, service, id) async => | ||
service.note?.getNotebook(id), | ||
title: AppLocalizations.of(context).notebooks, | ||
leadingBuilder: (context, model) => PhosphorIcon( | ||
model.model == null ? PhosphorIconsLight.book : PhosphorIconsFill.book, | ||
), | ||
dialogBuilder: (context, model) => NotebookDialog( | ||
source: model?.source, | ||
notebook: model?.model, | ||
create: model?.model == null, | ||
), | ||
selectBuilder: (context, model) => _NotebooksSelectDialog( | ||
selected: model?.toIdentifierModel(), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _NotebooksViewState extends State<_NotebooksView> { | ||
late final SourcedPagingController<Notebook> _controller; | ||
class _NotebooksSelectDialog extends StatelessWidget { | ||
final SourcedModel<Multihash>? selected; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
_controller = SourcedPagingController( | ||
context.read<FlowCubit>(), | ||
); | ||
_controller.addFetchListener((source, service, offset, limit) async { | ||
return []; | ||
}); | ||
} | ||
const _NotebooksSelectDialog({ | ||
this.selected, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return PagedListView( | ||
pagingController: _controller, | ||
builderDelegate: buildMaterialPagedDelegate<SourcedModel<Notebook>>( | ||
_controller, | ||
(ctx, item, index) => ListTile( | ||
title: Text(item.model.name), | ||
), | ||
return SelectDialog( | ||
onFetch: (source, service, search, offset, limit) async => | ||
service.note?.getNotebooks( | ||
offset: offset, | ||
limit: limit, | ||
search: search, | ||
), | ||
title: AppLocalizations.of(context).notebooks, | ||
selected: selected, | ||
); | ||
} | ||
} |
Oops, something went wrong.