added collections page
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
// main.dart
|
||||
import 'package:flutter/material.dart';
|
||||
import 'pages/bookmarks_page.dart';
|
||||
import 'pages/collections_page.dart';
|
||||
import 'service/storage.dart';
|
||||
import 'service/share_intent_service.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -9,12 +11,70 @@ void main() async {
|
||||
runApp(const MapsBookmarks());
|
||||
}
|
||||
|
||||
class MapsBookmarks extends StatelessWidget {
|
||||
class MapsBookmarks extends StatefulWidget {
|
||||
const MapsBookmarks({super.key});
|
||||
|
||||
@override
|
||||
State<MapsBookmarks> createState() => _MapsBookmarksState();
|
||||
}
|
||||
|
||||
class _MapsBookmarksState extends State<MapsBookmarks>
|
||||
with WidgetsBindingObserver {
|
||||
final ShareIntentService _shareIntentService = ShareIntentService();
|
||||
final GlobalKey<NavigatorState> _navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
// Check for shared content on app start
|
||||
_checkForSharedContent();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
// Check for shared content when app resumes
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
_checkForSharedContent();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _checkForSharedContent() async {
|
||||
final sharedText = await _shareIntentService.getSharedText();
|
||||
|
||||
if (sharedText != null && mounted) {
|
||||
// Validate it's a Google Maps link
|
||||
if (_shareIntentService.isGoogleMapsLink(sharedText)) {
|
||||
final metadata = _shareIntentService.extractMetadata(sharedText);
|
||||
_handleSharedMapsLink(metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _handleSharedMapsLink(MapsLinkMetadata metadata) {
|
||||
// Navigate to the appropriate page or show a dialog
|
||||
// You can customize this based on your app's flow
|
||||
|
||||
// Option 1: Navigate to collections page with data
|
||||
_navigatorKey.currentState?.pushNamed(
|
||||
CollectionsPage.routeName,
|
||||
arguments: metadata,
|
||||
);
|
||||
|
||||
// Option 2: Show a dialog to select collection and save
|
||||
// This would be implemented based on your UI requirements
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
navigatorKey: _navigatorKey,
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user