mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 06:07:57 -06:00
Changed file directories, added clear storage setting, updated readme w/ Google Play reference
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:encrypted_shared_preferences/encrypted_shared_preferences.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@@ -11,6 +13,9 @@ import 'package:paperless_mobile/core/bloc/global_error_cubit.dart';
|
||||
import 'package:paperless_mobile/core/bloc/label_bloc_provider.dart';
|
||||
import 'package:paperless_mobile/core/global/asset_images.dart';
|
||||
import 'package:paperless_mobile/core/global/http_self_signed_certificate_override.dart';
|
||||
import 'package:paperless_mobile/core/logic/error_code_localization_mapper.dart';
|
||||
import 'package:paperless_mobile/core/service/file_service.dart';
|
||||
import 'package:paperless_mobile/core/util.dart';
|
||||
import 'package:paperless_mobile/di_initializer.dart';
|
||||
import 'package:paperless_mobile/features/app_intro/application_intro_slideshow.dart';
|
||||
import 'package:paperless_mobile/features/documents/bloc/documents_cubit.dart';
|
||||
@@ -39,8 +44,10 @@ void main() async {
|
||||
|
||||
configureDependencies();
|
||||
// Remove temporarily downloaded files.
|
||||
(await getTemporaryDirectory()).deleteSync(recursive: true);
|
||||
|
||||
(await FileService.temporaryDirectory).deleteSync(recursive: true);
|
||||
if (kDebugMode) {
|
||||
_printDeviceInformation();
|
||||
}
|
||||
kPackageInfo = await PackageInfo.fromPlatform();
|
||||
// Load application settings and stored authentication data
|
||||
getIt<ConnectivityCubit>().initialize();
|
||||
@@ -50,6 +57,17 @@ void main() async {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
void _printDeviceInformation() async {
|
||||
final tempPath = await FileService.temporaryDirectory;
|
||||
log('[DEVICE INFO] Temporary ${tempPath.absolute}');
|
||||
final docsPath = await FileService.documentsDirectory;
|
||||
log('[DEVICE INFO] Documents ${docsPath?.absolute}');
|
||||
final downloadPath = await FileService.downloadsDirectory;
|
||||
log('[DEVICE INFO] Download ${downloadPath?.absolute}');
|
||||
final scanPath = await FileService.scanDirectory;
|
||||
log('[DEVICE INFO] Scan ${scanPath?.absolute}');
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@@ -190,37 +208,44 @@ class _AuthenticationWrapperState extends State<AuthenticationWrapper> {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider.value(
|
||||
value: getIt<GlobalErrorCubit>(),
|
||||
child: SafeArea(
|
||||
top: true,
|
||||
left: false,
|
||||
right: false,
|
||||
bottom: false,
|
||||
child: BlocConsumer<AuthenticationCubit, AuthenticationState>(
|
||||
listener: (context, authState) {
|
||||
final bool showIntroSlider =
|
||||
authState.isAuthenticated && !authState.wasLoginStored;
|
||||
if (showIntroSlider) {
|
||||
for (final img in AssetImages.values) {
|
||||
img.load(context);
|
||||
child: BlocListener<GlobalErrorCubit, GlobalErrorState>(
|
||||
listener: (context, state) {
|
||||
if (state.hasError) {
|
||||
showSnackBar(context, translateError(context, state.error!.code));
|
||||
}
|
||||
},
|
||||
child: SafeArea(
|
||||
top: true,
|
||||
left: false,
|
||||
right: false,
|
||||
bottom: false,
|
||||
child: BlocConsumer<AuthenticationCubit, AuthenticationState>(
|
||||
listener: (context, authState) {
|
||||
final bool showIntroSlider =
|
||||
authState.isAuthenticated && !authState.wasLoginStored;
|
||||
if (showIntroSlider) {
|
||||
for (final img in AssetImages.values) {
|
||||
img.load(context);
|
||||
}
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ApplicationIntroSlideshow(),
|
||||
fullscreenDialog: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ApplicationIntroSlideshow(),
|
||||
fullscreenDialog: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, authentication) {
|
||||
if (authentication.isAuthenticated) {
|
||||
return const LabelBlocProvider(
|
||||
child: HomePage(),
|
||||
);
|
||||
} else {
|
||||
return const LoginPage();
|
||||
}
|
||||
},
|
||||
},
|
||||
builder: (context, authentication) {
|
||||
if (authentication.isAuthenticated) {
|
||||
return const LabelBlocProvider(
|
||||
child: HomePage(),
|
||||
);
|
||||
} else {
|
||||
return const LoginPage();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user