Skip to content

Commit

Permalink
Share credentials instead of copy on iOS
Browse files Browse the repository at this point in the history
resolves #48
  • Loading branch information
maxisme committed May 1, 2021
1 parent cc05fea commit e25ab71
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 16 deletions.
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ PODS:
- "permission_handler (4.4.0+hotfix.4)":
- Flutter
- PromisesObjC (1.2.12)
- share (0.0.1):
- Flutter
- sqflite (0.0.2):
- Flutter
- FMDB (>= 2.7.5)
Expand All @@ -96,6 +98,7 @@ DEPENDENCIES:
- package_info (from `.symlinks/plugins/package_info/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
- share (from `.symlinks/plugins/share/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)

Expand Down Expand Up @@ -132,6 +135,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider/ios"
permission_handler:
:path: ".symlinks/plugins/permission_handler/ios"
share:
:path: ".symlinks/plugins/share/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
url_launcher:
Expand All @@ -158,6 +163,7 @@ SPEC CHECKSUMS:
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
permission_handler: 8278954f2382902f63f00dd8828769c0bd6d511b
PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef

Expand Down
13 changes: 10 additions & 3 deletions lib/notifications/notifications_table.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
Expand All @@ -11,6 +13,7 @@ import 'package:notifi/utils/icons.dart';
import 'package:notifi/utils/pallete.dart';
import 'package:notifi/utils/utils.dart';
import 'package:provider/provider.dart';
import 'package:share/share.dart';
import 'package:toast/toast.dart';

class NotificationTable extends StatefulWidget {
Expand Down Expand Up @@ -96,9 +99,13 @@ class NotificationTableState extends State<NotificationTable>
Container(padding: const EdgeInsets.only(top: 20.0)),
SelectableText(credentials, textAlign: TextAlign.center,
onTap: () {
Clipboard.setData(ClipboardData(text: credentials));
Toast.show('Copied $credentials', context,
gravity: Toast.BOTTOM);
if (Platform.isIOS) {
Share.share('notifi credentials: $credentials');
} else {
Clipboard.setData(ClipboardData(text: credentials));
Toast.show('Copied $credentials', context,
gravity: Toast.BOTTOM);
}
},
style: const TextStyle(
color: MyColour.red, fontWeight: FontWeight.w900))
Expand Down
35 changes: 22 additions & 13 deletions lib/screens/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import 'package:notifi/screens/utils/appbar_title.dart';
import 'package:notifi/user.dart';
import 'package:notifi/utils/icons.dart';
import 'package:notifi/utils/pallete.dart';
import 'package:notifi/utils/version.dart';
import 'package:notifi/utils/utils.dart';
import 'package:notifi/utils/version.dart';
import 'package:provider/provider.dart';
import 'package:share/share.dart';
import 'package:toast/toast.dart';
import 'package:url_launcher/url_launcher.dart';

Expand Down Expand Up @@ -77,21 +78,29 @@ class SettingsScreenState extends State<SettingsScreen> {
Consumer<User>(
builder: (BuildContext context, User user, Widget child) {
final String credentials = user.getCredentials();

SettingOption credentialsSettingWidget = SettingOption(
'Copy Credentials $credentials', Akaricons.clipboard,
onTapCallback: () {
Clipboard.setData(ClipboardData(text: credentials));
showToast('Copied $credentials', context, gravity: Toast.CENTER);
});
if (Platform.isIOS) {
credentialsSettingWidget = SettingOption(
'Share Credentials $credentials', Akaricons.clipboard,
onTapCallback: () {
Share.share('notifi credentials: $credentials');
});
}

return Column(children: <Widget>[
Container(padding: const EdgeInsets.only(top: 20.0)),
if (credentials != null)
SettingOption(
'How Do I Receive Notifications?', Akaricons.question,
onTapCallback: () async {
await openUrl('https://notifi.it?c=$credentials#how-to');
}),
SettingOption(
'Copy Credentials $credentials', Akaricons.clipboard,
onTapCallback: () {
Clipboard.setData(ClipboardData(text: credentials));
showToast('Copied $credentials', context,
gravity: Toast.CENTER);
})
'How Do I Receive Notifications?', Akaricons.question,
onTapCallback: () async {
await openUrl('https://notifi.it?c=$credentials#how-to');
}),
credentialsSettingWidget
]);
}),
SettingOption('Create New Credentials', Akaricons.arrowClockwise,
Expand Down
14 changes: 14 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
mime:
dependency: transitive
description:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
nested:
dependency: transitive
description:
Expand Down Expand Up @@ -557,6 +564,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4"
share:
dependency: "direct main"
description:
name: share
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
sky_engine:
dependency: transitive
description: flutter
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies:
package_info: ^2.0.0
path_provider: ^1.6.27
provider: ^5.0.0
share: ^2.0.1
sqflite: ^1.3.2+3
timeago: ^3.0.2
toast: ^0.1.5
Expand Down
Binary file modified test/golden-asserts/screen/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e25ab71

Please sign in to comment.