This commit is contained in:
Vandad Nahavandipoor 2022-01-07 12:47:04 +01:00
parent dd6a2ce935
commit 1f9ce466d5
4 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:mynotes/utilities/dialogs/generic_dialog.dart';
Future<void> showCannotShareEmptyNoteDialog(BuildContext context) {
return showGenericDialog<void>(
context: context,
title: 'Sharing',
content: 'You cannot share an empty note!',
optionsBuilder: () => {
'OK': null,
},
);
}

View File

@ -1,9 +1,11 @@
import 'package:flutter/material.dart';
import 'package:mynotes/services/auth/auth_service.dart';
import 'package:mynotes/utilities/dialogs/cannot_share_empty_note_dialog.dart';
import 'package:mynotes/utilities/generics/get_arguments.dart';
import 'package:mynotes/services/cloud/cloud_note.dart';
import 'package:mynotes/services/cloud/cloud_storage_exceptions.dart';
import 'package:mynotes/services/cloud/firebase_cloud_storage.dart';
import 'package:share_plus/share_plus.dart';
class CreateUpdateNoteView extends StatefulWidget {
const CreateUpdateNoteView({Key? key}) : super(key: key);
@ -92,6 +94,19 @@ class _CreateUpdateNoteViewState extends State<CreateUpdateNoteView> {
return Scaffold(
appBar: AppBar(
title: const Text('New Note'),
actions: [
IconButton(
onPressed: () async {
final text = _textController.text;
if (_note == null || text.isEmpty) {
await showCannotShareEmptyNoteDialog(context);
} else {
Share.share(text);
}
},
icon: const Icon(Icons.share),
),
],
),
body: FutureBuilder(
future: createOrGetExistingNote(context),

View File

@ -422,6 +422,48 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
share_plus:
dependency: "direct main"
description:
name: share_plus
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.4"
share_plus_linux:
dependency: transitive
description:
name: share_plus_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
share_plus_macos:
dependency: transitive
description:
name: share_plus_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
share_plus_web:
dependency: transitive
description:
name: share_plus_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
share_plus_windows:
dependency: transitive
description:
name: share_plus_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
shelf:
dependency: transitive
description:
@ -553,6 +595,62 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
url_launcher:
dependency: transitive
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.17"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.13"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.13"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
vector_math:
dependency: transitive
description:

View File

@ -41,6 +41,7 @@ dependencies:
sqflite: ^2.0.1
path_provider: ^2.0.8
path: ^1.8.0
share_plus: ^3.0.4
dev_dependencies:
flutter_test: