Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paintroid-450 : Add share menu option in paint view #49

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ PODS:
- SDWebImage (5.13.1):
- SDWebImage/Core (= 5.13.1)
- SDWebImage/Core (5.13.1)
- share (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
Expand All @@ -78,6 +80,7 @@ DEPENDENCIES:
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- share (from `.symlinks/plugins/share/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
Expand Down Expand Up @@ -111,6 +114,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
share:
:path: ".symlinks/plugins/share/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
Expand All @@ -133,11 +138,12 @@ SPEC CHECKSUMS:
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
SDWebImage: fb26a455eeda4c7a55e4dcb6172dbb258af7a4ca
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b

PODFILE CHECKSUM: a62623f56f2d1d0e85a4a3c73509cd2832d5c86f

COCOAPODS: 1.14.3
COCOAPODS: 1.15.0
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import 'package:l10n/l10n.dart';
import 'package:oxidized/oxidized.dart';
import 'package:toast/toast.dart';
import 'package:workspace_screen/workspace_screen.dart';
import 'package:share/share.dart';

enum OverflowMenuOption {
fullscreen,
saveImage,
saveProject,
loadImage,
newImage;
newImage,
share;

String localizedLabel(BuildContext context) {
final localizations = AppLocalizations.of(context);
Expand All @@ -28,6 +30,8 @@ enum OverflowMenuOption {
return localizations.newImage;
case OverflowMenuOption.saveProject:
return localizations.saveProject;
case OverflowMenuOption.share:
return localizations.share;
}
}
}
Expand All @@ -48,11 +52,11 @@ class _OverflowMenuState extends ConsumerState<OverflowMenu> {
onSelected: _handleSelectedOption,
itemBuilder: (BuildContext context) => OverflowMenuOption.values
.map((option) => PopupMenuItem(
value: option,
child: Text(
option.localizedLabel(context),
style: TextThemes.menuItem,
)))
value: option,
child: Text(
option.localizedLabel(context),
style: TextThemes.menuItem,
)))
.toList(),
);
}
Expand All @@ -75,6 +79,9 @@ class _OverflowMenuState extends ConsumerState<OverflowMenu> {
case OverflowMenuOption.newImage:
ioHandler.newImage(context, this);
break;
case OverflowMenuOption.share:
_shareContent();
break;
}
}

Expand Down Expand Up @@ -114,7 +121,7 @@ class _OverflowMenuState extends ConsumerState<OverflowMenu> {
final fileService = ref.watch(IFileService.provider);
final fileName = '${imageData.name}.${imageData.format.extension}';
final fileExists =
await fileService.checkIfFileExistsInApplicationDirectory(fileName);
await fileService.checkIfFileExistsInApplicationDirectory(fileName);

if (fileExists) {
final overWriteCanceled = await _showOverwriteDialog();
Expand All @@ -132,6 +139,14 @@ class _OverflowMenuState extends ConsumerState<OverflowMenu> {
return true;
}



void _shareContent() {

Share.share('Check out this great app!');
Lenkomotive marked this conversation as resolved.
Show resolved Hide resolved
}


Future<void> _saveProject() async {
final imageData = await showSaveImageDialog(context, true);

Expand All @@ -151,7 +166,7 @@ class _OverflowMenuState extends ConsumerState<OverflowMenu> {
final savedProject = await ioHandler.saveProject(catrobatImageData);
if (savedProject != null) {
String? imagePreview =
await ioHandler.getPreviewPath(catrobatImageData);
await ioHandler.getPreviewPath(catrobatImageData);
Project projectNew = Project(
name: catrobatImageData.name,
path: savedProject.path,
Expand Down
1 change: 1 addition & 0 deletions packages/features/workspace_screen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
toast: ^0.3.0
image: ^3.2.0
oxidized: ^5.2.0
share: ^2.0.4

# Internal packages
component_library:
Expand Down
13 changes: 8 additions & 5 deletions packages/l10n/lib/src/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ abstract class AppLocalizations {
}

static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();
_AppLocalizationsDelegate();

/// A list of this localizations delegate along with the default localizations
/// delegates.
Expand All @@ -82,7 +82,7 @@ abstract class AppLocalizations {
/// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
<LocalizationsDelegate<dynamic>>[
<LocalizationsDelegate<dynamic>>[
delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
Expand Down Expand Up @@ -145,6 +145,9 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Layers'**
String get layers;


String get share;
}

class _AppLocalizationsDelegate
Expand Down Expand Up @@ -173,7 +176,7 @@ AppLocalizations lookupAppLocalizations(Locale locale) {

throw FlutterError(
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.');
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.');
}
3 changes: 3 additions & 0 deletions packages/l10n/lib/src/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get saveProject => 'Save project';

@override
String get share => 'Share';

@override
String get tools => 'Tools';

Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.27.7"
share:
dependency: transitive
description:
name: share
sha256: "97e6403f564ed1051a01534c2fc919cb6e40ea55e60a18ec23cee6e0ce19f4be"
url: "https://pub.dev"
source: hosted
version: "2.0.4"
shared_preferences:
dependency: "direct main"
description:
Expand Down