9 Commits

Author SHA1 Message Date
4970836c60 Revert "added hive package"
This reverts commit 90539932ec.
2025-09-19 01:03:02 +02:00
90539932ec added hive package 2025-09-18 21:10:07 +02:00
69c00cca3e set initialRoute to the collections view 2025-09-18 21:09:57 +02:00
603060fe58 added classes for collections and bookmarks 2025-09-18 21:09:28 +02:00
ef9a369df1 simple collections page without logic 2025-09-18 20:56:58 +02:00
651e52485c added dialog for creating bookmark collections 2025-09-18 18:47:39 +02:00
fbec875334 added linter rules 2025-09-18 17:50:54 +02:00
56e277593d Implemented receiving intent on android side 2025-09-18 17:41:02 +02:00
0502d82509 switched flutter package for resolving android intents 2025-09-17 22:30:05 +02:00
11 changed files with 153 additions and 55 deletions

View File

@@ -1,28 +1,6 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
prefer_single_quotes: true
prefer_relative_imports: true

View File

@@ -27,18 +27,8 @@
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*"/>
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="www.maps.google.com" />
<data android:scheme="https"
android:host="www.maps.app.goog.le" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->

View File

@@ -1,5 +1,44 @@
package com.example.maps_bookmarks
import android.content.Intent
import android.os.Bundle
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
class MainActivity : FlutterActivity()
class MainActivity: FlutterActivity() {
private var sharedText: String? = null
private val CHANNEL = "app.channel.shared.data"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
handleIntent(intent)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
handleIntent(intent)
}
private fun handleIntent(intent: Intent) {
val action = intent.action
val type = intent.type
if (Intent.ACTION_SEND == action && "text/plain" == type) {
sharedText = intent.getStringExtra(Intent.EXTRA_TEXT)
}
}
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
.setMethodCallHandler { call, result ->
if (call.method == "getSharedText") {
result.success(sharedText)
sharedText = null
} else {
result.notImplemented()
}
}
}
}

View File

@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip

View File

@@ -1,19 +1,21 @@
import 'package:flutter/material.dart';
import 'pages/collections_page.dart';
void main() {
runApp(const MyApp());
runApp(const MapsBookmarks());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
class MapsBookmarks extends StatelessWidget {
const MapsBookmarks({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
initialRoute: CollectionsPage.routeName,
routes: {CollectionsPage.routeName: (context) => const CollectionsPage()},
);
}
}

13
lib/model/bookmark.dart Normal file
View File

@@ -0,0 +1,13 @@
import 'package:hive/hive.dart';
class Bookmark extends HiveObject {
Bookmark({required this.name, required this.link});
factory Bookmark.fromJson(Map<String, dynamic> json) =>
Bookmark(name: json['name'] as String, link: json['link'] as String);
String link;
String name;
Map<String, dynamic> toJson() => {'name': name, 'link': link};
}

12
lib/model/collection.dart Normal file
View File

@@ -0,0 +1,12 @@
import 'package:hive/hive.dart';
class Collection extends HiveObject {
Collection({required this.name});
factory Collection.fromJson(Map<String, dynamic> json) =>
Collection(name: json['name'] as String);
String name;
Map<String, dynamic> toJson() => {'name': name};
}

View File

@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import '../widgets/create_bookmark_collection_dialog.dart';
class CollectionsPage extends StatefulWidget {
const CollectionsPage({super.key});
static const String routeName = '/collections';
@override
State<CollectionsPage> createState() => _CollectionsPageState();
}
class _CollectionsPageState extends State<CollectionsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
floatingActionButton: FloatingActionButton(
onPressed: () => showDialog(
context: context,
builder: (context) => CreateBookmarkCollectionDialog(),
),
child: Icon(Icons.add),
),
body: ListView(),
);
}
void onAddButtonPressed() => showDialog(
context: context,
builder: (context) => CreateBookmarkCollectionDialog(),
);
}

View File

@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class CreateBookmarkCollectionDialog extends StatelessWidget {
const CreateBookmarkCollectionDialog({super.key});
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text('Create Collection'),
content: TextField(
autofocus: true,
maxLines: 1,
maxLength: 50,
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[a-zA-Z0-9äöüÄÖÜß\s]')),
FilteringTextInputFormatter.deny(RegExp(r'\s\s+')),
],
decoration: InputDecoration(
labelText: 'Collection Name',
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
),
),
actions: [
FloatingActionButton(onPressed: () {}, child: Icon(Icons.save)),
],
);
}
}

View File

@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
android_intent_plus:
dependency: "direct main"
description:
name: android_intent_plus
sha256: "14a9f94c5825a528e8c38ee89a33dbeba947efbbf76f066c174f4f3ae4f48feb"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
async:
dependency: transitive
description:
@@ -139,22 +147,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
plugin_platform_interface:
platform:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
name: platform
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
receive_sharing_intent:
dependency: "direct main"
description:
name: receive_sharing_intent
sha256: ec76056e4d258ad708e76d85591d933678625318e411564dcb9059048ca3a593
url: "https://pub.dev"
source: hosted
version: "1.8.1"
version: "3.1.6"
sky_engine:
dependency: transitive
description: flutter

View File

@@ -13,7 +13,7 @@ dependencies:
sdk: flutter
cupertino_icons: ^1.0.8
receive_sharing_intent: ^1.8.1
android_intent_plus: ^6.0.0
dev_dependencies:
flutter_test: