refactoring

This commit is contained in:
2025-12-08 23:32:29 +01:00
parent 7211560b8d
commit eddf2acbde
4 changed files with 43 additions and 24 deletions

View File

@@ -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(),
},
);
}

View File

@@ -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';

View File

@@ -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);
},
);
}