added launch in maps functionality
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<application
|
||||
android:label="maps_bookmarks"
|
||||
android:name="${applicationName}"
|
||||
@@ -46,5 +47,10 @@
|
||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme="https" />
|
||||
</intent>
|
||||
<package android:name="com.google.android.apps.maps" />
|
||||
</queries>
|
||||
</manifest>
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import '../model/bookmark.dart';
|
||||
import '../service/bookmarks_provider.dart';
|
||||
import '../service/storage.dart';
|
||||
import '../service/url_launcher.dart';
|
||||
import '../widgets/create_bookmark_dialog.dart';
|
||||
|
||||
class CollectionPage extends StatefulWidget {
|
||||
@@ -15,31 +16,6 @@ class CollectionPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CollectionPageState extends State<CollectionPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (BookmarksProvider.selectedCollectionId == null) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
final bookmarks = Storage.loadBookmarksForCollection(
|
||||
BookmarksProvider.selectedCollectionId!,
|
||||
);
|
||||
|
||||
final collection = Storage.loadCollections().firstWhere(
|
||||
(c) => c.id == BookmarksProvider.selectedCollectionId,
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(collection.name)),
|
||||
body: ListView(
|
||||
children: bookmarks.map((e) => ListTile(title: Text(e.name))).toList(),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: onAddButtonPressed,
|
||||
child: Icon(Icons.add),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onAddButtonPressed() => showDialog(
|
||||
context: context,
|
||||
builder: (context) => CreateBookmarkDialog(
|
||||
@@ -52,4 +28,37 @@ class _CollectionPageState extends State<CollectionPage> {
|
||||
Storage.addBookmark(bookmark);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
Widget bookmarkListBuilder(BuildContext context, Bookmark bookmark) {
|
||||
return ListTile(
|
||||
title: Text(bookmark.name),
|
||||
onTap: () => launchUrlFromString(bookmark.link),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (BookmarksProvider.selectedCollectionId == null) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
final bookmarks = Storage.loadBookmarksForCollection(
|
||||
BookmarksProvider.selectedCollectionId!,
|
||||
);
|
||||
final collection = Storage.loadCollections().firstWhere(
|
||||
(c) => c.id == BookmarksProvider.selectedCollectionId,
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(collection.name)),
|
||||
body: ListView.builder(
|
||||
itemBuilder: (context, index) =>
|
||||
bookmarkListBuilder(context, bookmarks.elementAt(index)),
|
||||
itemCount: bookmarks.length,
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: onAddButtonPressed,
|
||||
child: Icon(Icons.add),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
8
lib/service/url_launcher.dart
Normal file
8
lib/service/url_launcher.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
Future<void> launchUrlFromString(String url) async {
|
||||
final Uri uri = Uri.parse(url);
|
||||
if (!await launchUrl(uri, mode: LaunchMode.externalApplication)) {
|
||||
throw Exception('Could not launch $url');
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class CreateBookmarkDialog extends StatelessWidget {
|
||||
maxLength: 50,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(
|
||||
RegExp(r'[a-zA-Z0-9äöüÄÖÜß\s]'),
|
||||
RegExp(r'[a-zA-Z0-9äöüÄÖÜß\s/:\.]'),
|
||||
),
|
||||
FilteringTextInputFormatter.deny(RegExp(r'\s\s+')),
|
||||
],
|
||||
|
||||
64
pubspec.lock
64
pubspec.lock
@@ -389,6 +389,70 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
url_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: url_launcher
|
||||
sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.2"
|
||||
url_launcher_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
sha256: "767344bf3063897b5cf0db830e94f904528e6dd50a6dfaf839f0abf509009611"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.28"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_ios
|
||||
sha256: cfde38aa257dae62ffe79c87fab20165dfdf6988c1d31b58ebf59b9106062aad
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.6"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_linux
|
||||
sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.2"
|
||||
url_launcher_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_macos
|
||||
sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.5"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_platform_interface
|
||||
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
url_launcher_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_web
|
||||
sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
url_launcher_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_windows
|
||||
sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.5"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -17,6 +17,7 @@ dependencies:
|
||||
shared_preferences: ^2.3.2
|
||||
provider: ^6.1.5+1
|
||||
metadata_fetch: ^0.4.2
|
||||
url_launcher: ^6.3.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user