added workflow to add bookmark from share intent
This commit is contained in:
@@ -18,12 +18,23 @@ class CollectionsListPage extends StatefulWidget {
|
||||
|
||||
class _CollectionsListPageState extends State<CollectionsListPage> {
|
||||
final collections = Storage.loadCollections();
|
||||
bool addingNewBookmark = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = context.watch<SharedLinkProvider>();
|
||||
addingNewBookmark = provider.currentMapsLinkMetadata != null;
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
appBar: AppBar(
|
||||
title: addingNewBookmark ? Text('Choose Collection') : null,
|
||||
actions: [
|
||||
if (addingNewBookmark)
|
||||
TextButton(
|
||||
onPressed: () => provider.removeCurrentMapsLink(),
|
||||
child: Text('Cancel'),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: onAddButtonPressed,
|
||||
child: Icon(Icons.add),
|
||||
@@ -32,9 +43,9 @@ class _CollectionsListPageState extends State<CollectionsListPage> {
|
||||
itemBuilder: itemBuilder,
|
||||
itemCount: collections.length,
|
||||
),
|
||||
bottomSheet: provider.currentMapsLinkMetadata == null
|
||||
? null
|
||||
: BottomSheet(onClosing: () {}, builder: bottomSheetBuilder),
|
||||
// bottomSheet: provider.currentMapsLinkMetadata == null
|
||||
// ? null
|
||||
// : BottomSheet(onClosing: () {}, builder: bottomSheetBuilder),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,29 +62,34 @@ class _CollectionsListPageState extends State<CollectionsListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void onAddButtonPressed() => showDialog(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
CreateBookmarkCollectionDialog(onSavePressed: onCollectionSaved),
|
||||
);
|
||||
void onAddButtonPressed() =>
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
CreateBookmarkCollectionDialog(onSavePressed: onCollectionSaved),
|
||||
).whenComplete(() {
|
||||
if (addingNewBookmark) navigateToCollection(collections.last.id);
|
||||
});
|
||||
|
||||
void onCollectionSaved(String name) {
|
||||
collections.add(Collection(name: name));
|
||||
setState(() {});
|
||||
Storage.saveCollections(collections);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
Widget itemBuilder(BuildContext context, int index) {
|
||||
final collection = collections.elementAt(index);
|
||||
return ListTile(
|
||||
title: Text(collection.name),
|
||||
onTap: () {
|
||||
BookmarksProvider.selectedCollectionId = collection.id;
|
||||
Navigator.pushNamed(context, CollectionPage.routeName);
|
||||
},
|
||||
onTap: () => navigateToCollection(collection.id),
|
||||
);
|
||||
}
|
||||
|
||||
void navigateToCollection(int collectionId) {
|
||||
BookmarksProvider.selectedCollectionId = collectionId;
|
||||
Navigator.pushNamed(context, CollectionPage.routeName);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
|
||||
Reference in New Issue
Block a user