added bookmarks page
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'pages/bookmarks_page.dart';
|
||||||
import 'pages/collections_page.dart';
|
import 'pages/collections_page.dart';
|
||||||
import 'service/storage.dart';
|
import 'service/storage.dart';
|
||||||
|
|
||||||
@@ -18,7 +19,10 @@ class MapsBookmarks extends StatelessWidget {
|
|||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||||
),
|
),
|
||||||
initialRoute: CollectionsPage.routeName,
|
initialRoute: CollectionsPage.routeName,
|
||||||
routes: {CollectionsPage.routeName: (context) => const CollectionsPage()},
|
routes: {
|
||||||
|
CollectionsPage.routeName: (context) => const CollectionsPage(),
|
||||||
|
BookmarksPage.routeName: (context) => const BookmarksPage(),
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
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 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../model/collection.dart';
|
import '../model/collection.dart';
|
||||||
|
import '../service/bookmarks_provider.dart';
|
||||||
import '../service/storage.dart';
|
import '../service/storage.dart';
|
||||||
import '../widgets/create_bookmark_collection_dialog.dart';
|
import '../widgets/create_bookmark_collection_dialog.dart';
|
||||||
|
import 'bookmarks_page.dart';
|
||||||
|
|
||||||
class CollectionsPage extends StatefulWidget {
|
class CollectionsPage extends StatefulWidget {
|
||||||
const CollectionsPage({super.key});
|
const CollectionsPage({super.key});
|
||||||
@@ -43,6 +45,13 @@ class _CollectionsPageState extends State<CollectionsPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget itemBuilder(BuildContext context, int index) {
|
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);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
lib/service/bookmarks_provider.dart
Normal file
3
lib/service/bookmarks_provider.dart
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class BookmarksProvider {
|
||||||
|
static int? selectedCollectionId;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user