Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2917e71db1 | |||
| b06858c602 |
@@ -72,7 +72,7 @@ class _CollectionPageState extends State<CollectionPage> {
|
|||||||
selected: selected,
|
selected: selected,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
onCancelSelectionPressed();
|
deselectBookmark();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
} else if (selectedBookmarkId != -1 && !selected) {
|
} else if (selectedBookmarkId != -1 && !selected) {
|
||||||
selectedBookmarkId = bookmark.id;
|
selectedBookmarkId = bookmark.id;
|
||||||
@@ -131,7 +131,7 @@ class _CollectionPageState extends State<CollectionPage> {
|
|||||||
bottomNavigationBar: selectedBookmarkId > 0
|
bottomNavigationBar: selectedBookmarkId > 0
|
||||||
? ListItemActionsWidget(
|
? ListItemActionsWidget(
|
||||||
onDeletePressed: onDeleteBookmarkPressed,
|
onDeletePressed: onDeleteBookmarkPressed,
|
||||||
onCancelPressed: onCancelSelectionPressed,
|
onCancelPressed: deselectBookmark,
|
||||||
onEditPressed: () => editBookmark(
|
onEditPressed: () => editBookmark(
|
||||||
bookmarks.firstWhere(
|
bookmarks.firstWhere(
|
||||||
(element) => element.id == selectedBookmarkId,
|
(element) => element.id == selectedBookmarkId,
|
||||||
@@ -158,8 +158,6 @@ class _CollectionPageState extends State<CollectionPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onCancelSelectionPressed() => deselectBookmark();
|
|
||||||
|
|
||||||
void onDeleteBookmarkPressed() {
|
void onDeleteBookmarkPressed() {
|
||||||
Storage.deleteBookmarkById(
|
Storage.deleteBookmarkById(
|
||||||
selectedBookmarkId,
|
selectedBookmarkId,
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import '../model/collection.dart';
|
|||||||
import '../service/bookmarks_provider.dart';
|
import '../service/bookmarks_provider.dart';
|
||||||
import '../service/shared_link_provider.dart';
|
import '../service/shared_link_provider.dart';
|
||||||
import '../service/storage.dart';
|
import '../service/storage.dart';
|
||||||
|
import '../widgets/collection_page_widgets/list_item_actions_widget.dart'
|
||||||
|
show ListItemActionsWidget;
|
||||||
import '../widgets/create_bookmark_collection_dialog.dart';
|
import '../widgets/create_bookmark_collection_dialog.dart';
|
||||||
import 'collection_page.dart';
|
import 'collection_page.dart';
|
||||||
import 'search_page.dart' show SearchPage;
|
import 'search_page.dart' show SearchPage;
|
||||||
@@ -23,6 +25,7 @@ class CollectionsListPage extends StatefulWidget {
|
|||||||
class _CollectionsListPageState extends State<CollectionsListPage> {
|
class _CollectionsListPageState extends State<CollectionsListPage> {
|
||||||
bool addingNewBookmark = false;
|
bool addingNewBookmark = false;
|
||||||
var bookmarkCountMap = <int, int>{};
|
var bookmarkCountMap = <int, int>{};
|
||||||
|
int selectedCollectionId = -1;
|
||||||
|
|
||||||
Widget bottomSheetBuilder(BuildContext context) {
|
Widget bottomSheetBuilder(BuildContext context) {
|
||||||
final titleTextFieldController = TextEditingController(
|
final titleTextFieldController = TextEditingController(
|
||||||
@@ -52,11 +55,27 @@ class _CollectionsListPageState extends State<CollectionsListPage> {
|
|||||||
BuildContext context,
|
BuildContext context,
|
||||||
Collection collection,
|
Collection collection,
|
||||||
) {
|
) {
|
||||||
|
final selected = selectedCollectionId == collection.id;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(collection.name),
|
title: Text(collection.name),
|
||||||
onTap: () => navigateToCollection(collection.id),
|
onTap: () {
|
||||||
onLongPress: () => onEditCollection(collection),
|
if (selected) {
|
||||||
|
deselectCollection();
|
||||||
|
setState(() {});
|
||||||
|
} else if (selectedCollectionId != -1 && !selected) {
|
||||||
|
selectedCollectionId = collection.id;
|
||||||
|
setState(() {});
|
||||||
|
} else {
|
||||||
|
navigateToCollection(collection.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: () => addingNewBookmark
|
||||||
|
? null
|
||||||
|
: setState(() {
|
||||||
|
selectedCollectionId = collection.id;
|
||||||
|
}),
|
||||||
leading: const Icon(Icons.list_rounded),
|
leading: const Icon(Icons.list_rounded),
|
||||||
|
selected: selected,
|
||||||
trailing: Text(
|
trailing: Text(
|
||||||
bookmarkCountMap[collection.id]?.toString() ?? '0',
|
bookmarkCountMap[collection.id]?.toString() ?? '0',
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
@@ -74,13 +93,8 @@ class _CollectionsListPageState extends State<CollectionsListPage> {
|
|||||||
builder: (context) => CreateBookmarkCollectionDialog(
|
builder: (context) => CreateBookmarkCollectionDialog(
|
||||||
selectedCollection: selectedCollection,
|
selectedCollection: selectedCollection,
|
||||||
onSavePressed: onCollectionSaved,
|
onSavePressed: onCollectionSaved,
|
||||||
onDeletePressed: () {
|
|
||||||
Storage.deleteCollection(
|
|
||||||
selectedCollection,
|
|
||||||
).whenComplete(() => setState(() {}));
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
).whenComplete(deselectCollection);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -89,54 +103,105 @@ class _CollectionsListPageState extends State<CollectionsListPage> {
|
|||||||
addingNewBookmark =
|
addingNewBookmark =
|
||||||
Provider.of<SharedLinkProvider>(context).currentMapsLinkMetadata !=
|
Provider.of<SharedLinkProvider>(context).currentMapsLinkMetadata !=
|
||||||
null;
|
null;
|
||||||
return Scaffold(
|
return PopScope(
|
||||||
appBar: AppBar(
|
canPop: selectedCollectionId == -1,
|
||||||
title: addingNewBookmark
|
onPopInvokedWithResult: (didPop, result) {
|
||||||
? Text(AppLocalizations.of(context)!.chooseCollection)
|
if (didPop == false) deselectCollection();
|
||||||
: Text(AppLocalizations.of(context)!.collections),
|
},
|
||||||
actions: [
|
child: Scaffold(
|
||||||
if (addingNewBookmark)
|
appBar: AppBar(
|
||||||
TextButton(
|
title: addingNewBookmark
|
||||||
onPressed: () => Provider.of<SharedLinkProvider>(
|
? Text(AppLocalizations.of(context)!.chooseCollection)
|
||||||
context,
|
: Text(AppLocalizations.of(context)!.collections),
|
||||||
listen: false,
|
actions: [
|
||||||
).removeCurrentMapsLink(),
|
if (addingNewBookmark)
|
||||||
child: Text(AppLocalizations.of(context)!.cancel),
|
TextButton(
|
||||||
)
|
onPressed: () => Provider.of<SharedLinkProvider>(
|
||||||
else
|
context,
|
||||||
IconButton(
|
listen: false,
|
||||||
onPressed: () =>
|
).removeCurrentMapsLink(),
|
||||||
Navigator.of(context).pushNamed(SearchPage.routeName),
|
child: Text(AppLocalizations.of(context)!.cancel),
|
||||||
icon: Icon(Icons.search_rounded),
|
)
|
||||||
),
|
else
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
Navigator.of(context).pushNamed(SettingsPage.routeName),
|
Navigator.of(context).pushNamed(SearchPage.routeName),
|
||||||
icon: Icon(Icons.settings_rounded),
|
icon: Icon(Icons.search_rounded),
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: onAddButtonPressed,
|
|
||||||
child: Icon(Icons.add),
|
|
||||||
),
|
|
||||||
body: collections.isNotEmpty
|
|
||||||
? Center(
|
|
||||||
child: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width * 0.9,
|
|
||||||
child: ListView.separated(
|
|
||||||
itemBuilder: (context, index) => collectionsListItemBuilder(
|
|
||||||
context,
|
|
||||||
collections.elementAt(index),
|
|
||||||
),
|
|
||||||
itemCount: collections.length,
|
|
||||||
separatorBuilder: (context, index) => SizedBox(height: 10),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
if (!addingNewBookmark)
|
||||||
: Center(
|
IconButton(
|
||||||
child: Text(AppLocalizations.of(context)!.tipCreateCollections),
|
onPressed: () =>
|
||||||
),
|
Navigator.of(context).pushNamed(SettingsPage.routeName),
|
||||||
|
icon: Icon(Icons.settings_rounded),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
bottomNavigationBar: addingNewBookmark
|
||||||
|
? Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadiusGeometry.circular(12),
|
||||||
|
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
),
|
||||||
|
height: 100,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsetsGeometry.fromLTRB(
|
||||||
|
MediaQuery.of(context).size.width * 0.05,
|
||||||
|
15,
|
||||||
|
MediaQuery.of(context).size.width * 0.05,
|
||||||
|
MediaQuery.of(context).viewInsets.bottom,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
Provider.of<SharedLinkProvider>(
|
||||||
|
context,
|
||||||
|
).currentMapsLinkMetadata!.placeName,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: selectedCollectionId > 0
|
||||||
|
? ListItemActionsWidget(
|
||||||
|
onDeletePressed: onDeleteCollectionPressed,
|
||||||
|
onCancelPressed: deselectCollection,
|
||||||
|
onEditPressed: () => onEditCollection(
|
||||||
|
collections.firstWhere(
|
||||||
|
(element) => element.id == selectedCollectionId,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: onAddButtonPressed,
|
||||||
|
child: Icon(Icons.add),
|
||||||
|
),
|
||||||
|
body: collections.isNotEmpty
|
||||||
|
? Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.9,
|
||||||
|
child: ListView.separated(
|
||||||
|
itemBuilder: (context, index) => collectionsListItemBuilder(
|
||||||
|
context,
|
||||||
|
collections.elementAt(index),
|
||||||
|
),
|
||||||
|
itemCount: collections.length,
|
||||||
|
separatorBuilder: (context, index) => SizedBox(height: 10),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Center(
|
||||||
|
child: Text(AppLocalizations.of(context)!.tipCreateCollections),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onDeleteCollectionPressed() {
|
||||||
|
Storage.deleteCollectionById(
|
||||||
|
selectedCollectionId,
|
||||||
|
).whenComplete(() => deselectCollection());
|
||||||
|
}
|
||||||
|
|
||||||
|
void deselectCollection() {
|
||||||
|
selectedCollectionId = -1;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,6 +163,13 @@ class Storage {
|
|||||||
await saveCollections(collections);
|
await saveCollections(collections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<void> deleteCollectionById(int collectionId) async {
|
||||||
|
final collections = loadCollections();
|
||||||
|
await deleteCollection(
|
||||||
|
collections.firstWhere((collection) => collection.id == collectionId),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static Map<String, int> getStats() {
|
static Map<String, int> getStats() {
|
||||||
final statsJson = _prefs.getString(_statsKey) ?? '{}';
|
final statsJson = _prefs.getString(_statsKey) ?? '{}';
|
||||||
final stats = jsonDecode(statsJson) as Map<String, dynamic>;
|
final stats = jsonDecode(statsJson) as Map<String, dynamic>;
|
||||||
|
|||||||
+8
-8
@@ -29,10 +29,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
|
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.0"
|
version: "1.4.1"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -257,18 +257,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
|
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.17"
|
version: "0.12.19"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
|
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.11.1"
|
version: "0.13.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -510,10 +510,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
|
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.7"
|
version: "0.7.10"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
Reference in New Issue
Block a user