added bookmarks page
This commit is contained in:
35
lib/pages/bookmarks_page.dart
Normal file
35
lib/pages/bookmarks_page.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../service/bookmarks_provider.dart';
|
||||
import '../service/storage.dart';
|
||||
|
||||
class BookmarksPage extends StatelessWidget {
|
||||
const BookmarksPage({super.key});
|
||||
|
||||
static const String routeName = '/bookmarks';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (BookmarksProvider.selectedCollectionId == null) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
final bookmarks = Storage.loadBookmarksForCollection(
|
||||
BookmarksProvider.selectedCollectionId!,
|
||||
);
|
||||
|
||||
BookmarksProvider.selectedCollectionId == null;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
Storage.loadCollections()
|
||||
.firstWhere((c) => c.id == BookmarksProvider.selectedCollectionId)
|
||||
.name,
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
children: bookmarks.map((e) => ListTile(title: Text(e.name))).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../model/collection.dart';
|
||||
import '../service/bookmarks_provider.dart';
|
||||
import '../service/storage.dart';
|
||||
import '../widgets/create_bookmark_collection_dialog.dart';
|
||||
import 'bookmarks_page.dart';
|
||||
|
||||
class CollectionsPage extends StatefulWidget {
|
||||
const CollectionsPage({super.key});
|
||||
@@ -43,6 +45,13 @@ class _CollectionsPageState extends State<CollectionsPage> {
|
||||
}
|
||||
|
||||
Widget itemBuilder(BuildContext context, int index) {
|
||||
return ListTile(title: Text(collections.elementAt(index).name));
|
||||
final collection = collections.elementAt(index);
|
||||
return ListTile(
|
||||
title: Text(collection.name),
|
||||
onTap: () {
|
||||
BookmarksProvider.selectedCollectionId = collection.id;
|
||||
Navigator.pushNamed(context, BookmarksPage.routeName);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user