mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 22:07:57 -06:00
FEATURE move button to the scanner page
This commit is contained in:
@@ -1,17 +1,12 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
import 'package:paperless_mobile/constants.dart';
|
||||
import 'package:paperless_mobile/core/config/hive/hive_config.dart';
|
||||
import 'package:paperless_mobile/core/database/tables/global_settings.dart';
|
||||
import 'package:paperless_mobile/core/database/tables/local_user_account.dart';
|
||||
import 'package:paperless_mobile/core/repository/label_repository.dart';
|
||||
import 'package:paperless_mobile/core/type/types.dart';
|
||||
@@ -24,8 +19,6 @@ import 'package:paperless_mobile/features/labels/view/widgets/label_form_field.d
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
import 'package:paperless_mobile/helpers/message_helpers.dart';
|
||||
import 'package:paperless_mobile/helpers/permission_helpers.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class DocumentUploadResult {
|
||||
final bool success;
|
||||
@@ -82,8 +75,6 @@ class _DocumentUploadPreparationPageState extends State<DocumentUploadPreparatio
|
||||
child: LinearProgressIndicator(), preferredSize: Size.fromHeight(4.0))
|
||||
: null,
|
||||
),
|
||||
bottomNavigationBar: _buildBottomAppBar(),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
|
||||
floatingActionButton: Visibility(
|
||||
visible: MediaQuery.of(context).viewInsets.bottom == 0,
|
||||
child: FloatingActionButton.extended(
|
||||
@@ -300,30 +291,6 @@ class _DocumentUploadPreparationPageState extends State<DocumentUploadPreparatio
|
||||
}
|
||||
}
|
||||
|
||||
BlocBuilder<DocumentUploadCubit, DocumentUploadState> _buildBottomAppBar() {
|
||||
return BlocBuilder<DocumentUploadCubit, DocumentUploadState>(
|
||||
builder: (context, state) {
|
||||
return BottomAppBar(
|
||||
child: BlocBuilder<DocumentUploadCubit, DocumentUploadState>(
|
||||
builder: (context, connectivityState) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
IconButton(
|
||||
tooltip: "Save a local copy",
|
||||
icon: const Icon(Icons.download),
|
||||
onPressed: () => _onLocalSave(),
|
||||
).paddedOnly(right: 4.0),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
String _padWithExtension(String source, [String? extension]) {
|
||||
final ext = extension ?? '.pdf';
|
||||
return source.endsWith(ext) ? source : '$source$ext';
|
||||
@@ -332,27 +299,4 @@ class _DocumentUploadPreparationPageState extends State<DocumentUploadPreparatio
|
||||
String _formatFilename(String source) {
|
||||
return source.replaceAll(RegExp(r"[\W_]"), "_").toLowerCase();
|
||||
}
|
||||
|
||||
Future<void> _onLocalSave() async {
|
||||
final cubit = context.read<DocumentUploadCubit>();
|
||||
|
||||
try {
|
||||
final globalSettings = Hive.box<GlobalSettings>(HiveBoxes.globalSettings).getValue()!;
|
||||
if (Platform.isAndroid && androidInfo!.version.sdkInt <= 29) {
|
||||
final isGranted = await askForPermission(Permission.storage);
|
||||
if (!isGranted) {
|
||||
return;
|
||||
//TODO: Ask user to grant permissions
|
||||
}
|
||||
}
|
||||
final title = (_formKey.currentState?.fields[fkFileName]?.value ?? widget.filename) as String;
|
||||
|
||||
var fileName = "$title.${widget.fileExtension}";
|
||||
|
||||
await cubit.saveLocally(widget.fileBytes, fileName, globalSettings.preferredLocaleSubtag);
|
||||
} catch (error) {
|
||||
showGenericError(context, error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user