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