refactoring
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'pages/bookmarks_page.dart';
|
import 'pages/collection_page.dart';
|
||||||
import 'pages/collections_page.dart';
|
import 'pages/collections_list_page.dart';
|
||||||
import 'service/shared_link_provider.dart';
|
import 'service/shared_link_provider.dart';
|
||||||
import 'service/storage.dart';
|
import 'service/storage.dart';
|
||||||
import 'service/share_intent_service.dart';
|
import 'service/share_intent_service.dart';
|
||||||
@@ -64,10 +64,10 @@ class _MapsBookmarksState extends State<MapsBookmarks>
|
|||||||
navigatorKey: _navigatorKey,
|
navigatorKey: _navigatorKey,
|
||||||
theme: lightTheme,
|
theme: lightTheme,
|
||||||
darkTheme: darkTheme,
|
darkTheme: darkTheme,
|
||||||
initialRoute: CollectionsPage.routeName,
|
initialRoute: CollectionsListPage.routeName,
|
||||||
routes: {
|
routes: {
|
||||||
CollectionsPage.routeName: (context) => const CollectionsPage(),
|
CollectionsListPage.routeName: (context) => const CollectionsListPage(),
|
||||||
BookmarksPage.routeName: (context) => const BookmarksPage(),
|
CollectionPage.routeName: (context) => const CollectionPage(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
|
|||||||
import '../service/bookmarks_provider.dart';
|
import '../service/bookmarks_provider.dart';
|
||||||
import '../service/storage.dart';
|
import '../service/storage.dart';
|
||||||
|
|
||||||
class BookmarksPage extends StatelessWidget {
|
class CollectionPage extends StatelessWidget {
|
||||||
const BookmarksPage({super.key});
|
const CollectionPage({super.key});
|
||||||
|
|
||||||
static const String routeName = '/bookmarks';
|
static const String routeName = '/bookmarks';
|
||||||
|
|
||||||
@@ -1,24 +1,27 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../model/collection.dart';
|
import '../model/collection.dart';
|
||||||
import '../service/bookmarks_provider.dart';
|
import '../service/bookmarks_provider.dart';
|
||||||
|
import '../service/shared_link_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';
|
import 'collection_page.dart';
|
||||||
|
|
||||||
class CollectionsPage extends StatefulWidget {
|
class CollectionsListPage extends StatefulWidget {
|
||||||
const CollectionsPage({super.key});
|
const CollectionsListPage({super.key});
|
||||||
static const String routeName = '/collections';
|
static const String routeName = '/collections';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CollectionsPage> createState() => _CollectionsPageState();
|
State<CollectionsListPage> createState() => _CollectionsListPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CollectionsPageState extends State<CollectionsPage> {
|
class _CollectionsListPageState extends State<CollectionsListPage> {
|
||||||
final collections = Storage.loadCollections();
|
final collections = Storage.loadCollections();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final provider = context.watch<SharedLinkProvider>();
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(),
|
appBar: AppBar(),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
@@ -29,6 +32,22 @@ class _CollectionsPageState extends State<CollectionsPage> {
|
|||||||
itemBuilder: itemBuilder,
|
itemBuilder: itemBuilder,
|
||||||
itemCount: collections.length,
|
itemCount: collections.length,
|
||||||
),
|
),
|
||||||
|
bottomSheet: provider.currentMapsLinkMetadata == null
|
||||||
|
? null
|
||||||
|
: BottomSheet(onClosing: () {}, builder: bottomSheetBuilder),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget bottomSheetBuilder(BuildContext context) {
|
||||||
|
final titleTextFieldController = TextEditingController(
|
||||||
|
text: context
|
||||||
|
.read<SharedLinkProvider>()
|
||||||
|
.currentMapsLinkMetadata!
|
||||||
|
.placeName,
|
||||||
|
);
|
||||||
|
return SizedBox(
|
||||||
|
height: 200,
|
||||||
|
child: TextField(controller: titleTextFieldController),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +69,7 @@ class _CollectionsPageState extends State<CollectionsPage> {
|
|||||||
title: Text(collection.name),
|
title: Text(collection.name),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
BookmarksProvider.selectedCollectionId = collection.id;
|
BookmarksProvider.selectedCollectionId = collection.id;
|
||||||
Navigator.pushNamed(context, BookmarksPage.routeName);
|
Navigator.pushNamed(context, CollectionPage.routeName);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
22
pubspec.lock
22
pubspec.lock
@@ -124,10 +124,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: http
|
name: http
|
||||||
sha256: bb2ce4590bc2667c96f318d68cac1b5a7987ec819351d32b1c987239a815e007
|
sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.0"
|
version: "1.6.0"
|
||||||
http_parser:
|
http_parser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -188,10 +188,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
version: "1.17.0"
|
||||||
metadata_fetch:
|
metadata_fetch:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -276,18 +276,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_android
|
name: shared_preferences_android
|
||||||
sha256: a2608114b1ffdcbc9c120eb71a0e207c71da56202852d4aab8a5e30a82269e74
|
sha256: "83af5c682796c0f7719c2bbf74792d113e40ae97981b8f266fa84574573556bc"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.12"
|
version: "2.4.18"
|
||||||
shared_preferences_foundation:
|
shared_preferences_foundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_foundation
|
name: shared_preferences_foundation
|
||||||
sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03"
|
sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.4"
|
version: "2.5.6"
|
||||||
shared_preferences_linux:
|
shared_preferences_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -377,10 +377,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
|
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.6"
|
version: "0.7.7"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -423,4 +423,4 @@ packages:
|
|||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.9.2 <4.0.0"
|
dart: ">=3.9.2 <4.0.0"
|
||||||
flutter: ">=3.29.0"
|
flutter: ">=3.35.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user