Skip to content

Commit

Permalink
Merge pull request #10 from vicajilau/develop
Browse files Browse the repository at this point in the history
Release 2.8.0
  • Loading branch information
vicajilau authored Jul 28, 2023
2 parents e146aad + 3e3a548 commit ec6b182
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 92 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ app.*.map.json
# Secure INF
*.env
**/firebase_app_id_file.json
**/google-services.json
**/GoogleService-Info.plist
**/app/google-services.json
**/Runner/GoogleService-Info.plist
1 change: 0 additions & 1 deletion assets/strings/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"content_home_screen_dialog": "Do you want to load the file(s) from disk or from the document scanner?",
"load": "LOAD",
"scan": "SCAN",
"document_generated_with_drag_pdf": "Document Generated With Drag PDF",
"size_subtitle": "in size",
"removed_toast": "Removed file:",
"generate_file_error_title": "ERROR",
Expand Down
1 change: 0 additions & 1 deletion assets/strings/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"content_home_screen_dialog": "¿Desea cargar los archivos desde el disco o desde el escaner de documentos?",
"load": "CARGAR",
"scan": "ESCANEAR",
"document_generated_with_drag_pdf": "Documento Generado con DragPDF",
"size_subtitle": "de tamaño",
"removed_toast": "Fichero borrado:",
"generate_file_error_title": "ERROR",
Expand Down
3 changes: 3 additions & 0 deletions lib/components/file_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class FileRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
child: ListTile(
leading: FileTypeIcon(file: file),
title: Text(file.getName()),
Expand Down
4 changes: 3 additions & 1 deletion lib/helper/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AppRouter {
late final Map<String, WidgetBuilder> routes;

AppRouter.init() {
if (PlatformDetails.isMobile) {
if (PlatformDetail.isMobile) {
routes = getMobileRoutes();
} else {
routes = getDesktopRoutes();
Expand All @@ -22,6 +22,7 @@ class AppRouter {
"/": (context) => const SplashScreenMobile(),
"/home": (context) => const HomeScreenMobile(),
"/pdf_viewer_screen": (context) => const PDFViewerScreen(),
"/preview_document_screen": (context) => const PreviewDocumentScreen(),
"/create_signature_screen": (context) => const CreateSignatureScreen(),
"/loading": (context) => const LoadingScreen(),
};
Expand All @@ -33,6 +34,7 @@ class AppRouter {
"/": (context) => const SplashScreenDesktop(),
"/home": (context) => const HomeScreenDesktop(),
"/pdf_viewer_screen": (context) => const PDFViewerScreen(),
"/preview_document_screen": (context) => const PreviewDocumentScreen(),
"/create_signature_screen": (context) => const CreateSignatureScreen(),
};
}
Expand Down
17 changes: 12 additions & 5 deletions lib/helper/utils.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:easy_image_viewer/easy_image_viewer.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:mell_pdf/helper/helpers.dart';

import '../model/models.dart';
import 'package:mell_pdf/model/models.dart';

class Utils {
static const nameOfFinalFile = 'Preview Document.pdf';
static const nameOfFinalFile = 'Generated by DragPDF.pdf';

static void printInDebug(Object? object) {
if (kDebugMode) {
Expand Down Expand Up @@ -61,11 +60,19 @@ class Utils {
return image?.width ?? 0;
}

static bool isFinalFile(FileRead file) =>
file.getName() == Utils.nameOfFinalFile;

static void openFileProperly(BuildContext context, FileRead file) {
switch (file.getExtensionType()) {
case SupportedFileType.pdf:
Utils.printInDebug("Opened PDF file: ${file.getFile().path}");
Navigator.pushNamed(context, "/pdf_viewer_screen", arguments: file);

isFinalFile(file)
? Navigator.pushNamed(context, "/preview_document_screen",
arguments: file)
: Navigator.pushNamed(context, "/pdf_viewer_screen",
arguments: file);
break;
case SupportedFileType.png:
_openImage(context, file);
Expand Down
10 changes: 10 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:ui';

import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
Expand All @@ -18,6 +19,7 @@ Future<void> initializeApp() async {
}

Future loadSecureInf() async => await dotenv.load(fileName: ".env");

Future loadFirebase() async {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
Expand All @@ -30,7 +32,15 @@ Future loadFirebase() async {
FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
return true;
};
// Force disable Crashlytics collection while doing every day development.
if (kDebugMode) {
await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(
false); // Temporarily toggle this to true if you want to test crash reporting in your app.
print(
"Analytic state: ${FirebaseCrashlytics.instance.isCrashlyticsCollectionEnabled}");
}
}

Future prepareApp() async {
await AppSession.singleton.fileHelper.loadLocalPath();
AppSession.singleton.fileHelper.emptyLocalDocumentFolder();
Expand Down
2 changes: 1 addition & 1 deletion lib/model/file_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class FileManager {
Future<FileRead?> scanDocument() async {
FileRead? fileRead;
List<String>? paths = await CunningDocumentScanner.getPictures();
if (paths != null) {
if (paths != null && paths.isNotEmpty) {
final pdf = pw.Document();
File file;
for (String path in paths) {
Expand Down
8 changes: 8 additions & 0 deletions lib/view/mobile/home_screen_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:mell_pdf/common/colors/colors_app.dart';
import 'package:mell_pdf/common/localization/localization.dart';
import 'package:mell_pdf/components/components.dart';
import 'package:mell_pdf/model/enums/loader_of.dart';

import '../../helper/dialogs/custom_dialog.dart';
import '../../helper/helpers.dart';
import '../../view_model/home_view_model.dart';
Expand Down Expand Up @@ -150,8 +151,15 @@ class _HomeScreenMobileState extends State<HomeScreenMobile>
),
body: viewModel.thereAreFilesLoaded()
? ReorderableListView.builder(
proxyDecorator: (child, index, animation) =>
ColorFiltered(
colorFilter: ColorFilter.mode(
Colors.blueAccent.withOpacity(0.2),
BlendMode.srcATop),
child: child),
itemCount:
viewModel.getMergeableFilesList().numberOfFiles(),
padding: const EdgeInsets.all(8),
onReorderStart: (int value) =>
HapticFeedback.mediumImpact(),
itemBuilder: (context, position) {
Expand Down
73 changes: 0 additions & 73 deletions lib/view/pdf_viewer_screen.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import 'package:flutter/material.dart';
import 'package:mell_pdf/common/localization/localization.dart';
import 'package:mell_pdf/model/models.dart';
import 'package:pdfx/pdfx.dart';
import 'package:share_plus/share_plus.dart';

import '../helper/dialogs/custom_dialog.dart';
import '../helper/utils.dart';

class PDFViewerScreen extends StatelessWidget {
const PDFViewerScreen({Key? key}) : super(key: key);
Expand All @@ -20,78 +15,10 @@ class PDFViewerScreen extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: Text(file.getName()),
actions: isFinalFile(file)
? [
// IconButton(
// onPressed: () => showDialog<String>(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// title: Text(Localization.of(context)
// .string('signature_title_alert')),
// content: Text(Localization.of(context)
// .string('signature_subtitle_alert')),
// actions: [
// TextButton(
// onPressed: () {
// Navigator.pop(context);
// },
// child: Text(Localization.of(context)
// .string('signature_sign_alert')),
// ),
// TextButton(
// onPressed: () async {
// Navigator.pop(context, 'Scan');
// Navigator.pushNamed(
// context, "/create_signature_screen",
// arguments: file);
// },
// child: Text(Localization.of(context)
// .string('signature_create_alert')),
// ),
// TextButton(
// onPressed: () => Navigator.pop(context, 'Cancel'),
// child: Text(
// Localization.of(context).string('cancel'), // Cancel
// style: const TextStyle(color: ColorsApp.kMainColor),
// ),
// )
// ],
// ),
// ),
// icon: const Icon(Icons.create),
// ),
IconButton(
onPressed: () async {
try {
await Share.shareXFiles(
[XFile(file.getFile().path)],
text: Localization.of(context)
.string('document_generated_with_drag_pdf'),
sharePositionOrigin: Rect.fromLTRB(
MediaQuery.of(context).size.width - 300,
0,
0,
MediaQuery.of(context).size.height - 300),
); // Document Generated With Drag PDF
} catch (error) {
CustomDialog.showError(
context: context,
error: error,
titleLocalized: 'share_file_error_title',
subtitleLocalized: 'share_file_error_subtitle',
buttonTextLocalized: 'accept',
);
}
},
icon: const Icon(Icons.share))
]
: null,
),
body: PdfViewPinch(
controller: pdfPinchController,
),
);
}

bool isFinalFile(FileRead file) => file.getName() == Utils.nameOfFinalFile;
}
93 changes: 93 additions & 0 deletions lib/view/preview_document_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import 'package:flutter/material.dart';
import 'package:mell_pdf/model/models.dart';
import 'package:pdfx/pdfx.dart';
import 'package:share_plus/share_plus.dart';

import '../helper/dialogs/custom_dialog.dart';

class PreviewDocumentScreen extends StatefulWidget {
const PreviewDocumentScreen({super.key});

@override
State<PreviewDocumentScreen> createState() => _PreviewDocumentScreenState();
}

class _PreviewDocumentScreenState extends State<PreviewDocumentScreen> {
@override
Widget build(BuildContext context) {
final file = ModalRoute.of(context)!.settings.arguments as FileRead;
final pdfPinchController = PdfControllerPinch(
document: PdfDocument.openFile(file.getFile().path),
);

return Scaffold(
appBar: AppBar(
title: const Text("DRAG PDF"),
actions: [
// IconButton(
// onPressed: () => showDialog<String>(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// title: Text(
// Localization.of(context).string('signature_title_alert')),
// content: Text(Localization.of(context)
// .string('signature_subtitle_alert')),
// actions: [
// TextButton(
// onPressed: () {
// Navigator.pop(context); // TODO
// },
// child: Text(Localization.of(context)
// .string('signature_sign_alert')),
// ),
// TextButton(
// onPressed: () async {
// Navigator.pop(context, 'Scan');
// Navigator.pushNamed(context, "/create_signature_screen",
// arguments: file);
// },
// child: Text(Localization.of(context)
// .string('signature_create_alert')),
// ),
// TextButton(
// onPressed: () => Navigator.pop(context, 'Cancel'),
// child: Text(
// Localization.of(context).string('cancel'),
// style: const TextStyle(color: ColorsApp.kMainColor),
// ),
// )
// ],
// ),
// ),
// icon: const Icon(Icons.create),
// ),
IconButton(
onPressed: () async {
try {
await Share.shareXFiles(
[XFile(file.getFile().path)],
sharePositionOrigin: Rect.fromLTRB(
MediaQuery.of(context).size.width - 300,
0,
0,
MediaQuery.of(context).size.height - 300),
); // Document Generated With Drag PDF
} catch (error) {
CustomDialog.showError(
context: context,
error: error,
titleLocalized: 'share_file_error_title',
subtitleLocalized: 'share_file_error_subtitle',
buttonTextLocalized: 'accept',
);
}
},
icon: const Icon(Icons.share))
],
),
body: PdfViewPinch(
controller: pdfPinchController,
),
);
}
}
1 change: 1 addition & 0 deletions lib/view/views.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export 'package:mell_pdf/view/desktop/splash_screen_desktop.dart';
export 'package:mell_pdf/view/mobile/home_screen_mobile.dart';
export 'package:mell_pdf/view/mobile/splash_screen_mobile.dart';
export 'package:mell_pdf/view/pdf_viewer_screen.dart';
export 'package:mell_pdf/view/preview_document_screen.dart';
12 changes: 6 additions & 6 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ packages:
dependency: "direct main"
description:
name: file_picker
sha256: b1729fc96627dd44012d0a901558177418818d6bd428df59dcfeb594e5f66432
sha256: "21145c9c268d54b1f771d8380c195d2d6f655e0567dc1ca2f9c134c02c819e0a"
url: "https://pub.dev"
source: hosted
version: "5.3.2"
version: "5.3.3"
file_selector_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -657,10 +657,10 @@ packages:
dependency: "direct main"
description:
name: platform_detail
sha256: "0448a70383f824102c127beeb8cddca685af135561f318364d6e92b9feba31bb"
sha256: cf4bfc19dc8dcc1edd817201c59d4f58f45754ada8f769f0c627dfb5874ac882
url: "https://pub.dev"
source: hosted
version: "2.2.0"
version: "3.0.1"
plugin_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -862,10 +862,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: dfdf0136e0aa7a1b474ea133e67cb0154a0acd2599c4f3ada3b49d38d38793ee
sha256: f2add6fa510d3ae152903412227bda57d0d5a8da61d2c39c1fb022c9429a41c0
url: "https://pub.dev"
source: hosted
version: "5.0.5"
version: "5.0.6"
win32_registry:
dependency: transitive
description:
Expand Down
Loading

0 comments on commit ec6b182

Please sign in to comment.