mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-07 09:15:49 -06:00
Precached asset images
This commit is contained in:
19
lib/core/global/asset_images.dart
Normal file
19
lib/core/global/asset_images.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum AssetImages {
|
||||
headacheDocuments("images/documents_headache.png"),
|
||||
organizeDocuments("images/organize_documents.png"),
|
||||
secureDocuments("images/secure_documents.png"),
|
||||
success("images/success.png");
|
||||
|
||||
final String relativePath;
|
||||
const AssetImages(String relativePath)
|
||||
: relativePath = "assets/$relativePath";
|
||||
|
||||
Image get image => Image.asset(
|
||||
relativePath,
|
||||
key: ObjectKey("assetimage_$relativePath"),
|
||||
);
|
||||
|
||||
void load(context) => precacheImage(image.image, context);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:introduction_screen/introduction_screen.dart';
|
||||
import 'package:paperless_mobile/core/global/asset_images.dart';
|
||||
import 'package:paperless_mobile/di_initializer.dart';
|
||||
import 'package:paperless_mobile/features/settings/bloc/application_settings_cubit.dart';
|
||||
import 'package:paperless_mobile/features/settings/view/widgets/biometric_authentication_setting.dart';
|
||||
@@ -8,9 +9,19 @@ import 'package:paperless_mobile/features/settings/view/widgets/language_selecti
|
||||
import 'package:paperless_mobile/features/settings/view/widgets/theme_mode_setting.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
|
||||
class ApplicationIntroSlideshow extends StatelessWidget {
|
||||
class ApplicationIntroSlideshow extends StatefulWidget {
|
||||
const ApplicationIntroSlideshow({super.key});
|
||||
|
||||
@override
|
||||
State<ApplicationIntroSlideshow> createState() =>
|
||||
_ApplicationIntroSlideshowState();
|
||||
}
|
||||
|
||||
class _ApplicationIntroSlideshowState extends State<ApplicationIntroSlideshow> {
|
||||
Image organizeImage = AssetImages.organizeDocuments.image;
|
||||
Image secureImage = AssetImages.secureDocuments.image;
|
||||
Image successImage = AssetImages.success.image;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
@@ -26,8 +37,8 @@ class ApplicationIntroSlideshow extends StatelessWidget {
|
||||
dotsDecorator: DotsDecorator(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
activeColor: Theme.of(context).colorScheme.primary,
|
||||
activeSize: Size(16.0, 8.0),
|
||||
activeShape: RoundedRectangleBorder(
|
||||
activeSize: const Size(16.0, 8.0),
|
||||
activeShape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25.0)),
|
||||
),
|
||||
),
|
||||
@@ -39,7 +50,7 @@ class ApplicationIntroSlideshow extends StatelessWidget {
|
||||
),
|
||||
image: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image.asset("assets/images/organize_documents.png"),
|
||||
child: organizeImage,
|
||||
),
|
||||
bodyWidget: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
@@ -59,7 +70,7 @@ class ApplicationIntroSlideshow extends StatelessWidget {
|
||||
),
|
||||
image: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image.asset("assets/images/secure_documents.png"),
|
||||
child: secureImage,
|
||||
),
|
||||
bodyWidget: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
@@ -79,7 +90,7 @@ class ApplicationIntroSlideshow extends StatelessWidget {
|
||||
),
|
||||
image: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image.asset("assets/images/success.png"),
|
||||
child: successImage,
|
||||
),
|
||||
bodyWidget: Column(
|
||||
children: const [
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||
import 'package:paperless_mobile/core/bloc/connectivity_cubit.dart';
|
||||
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/di_initializer.dart';
|
||||
import 'package:paperless_mobile/features/app_intro/application_intro_slideshow.dart';
|
||||
@@ -125,9 +126,12 @@ class AuthenticationWrapper extends StatefulWidget {
|
||||
|
||||
class _AuthenticationWrapperState extends State<AuthenticationWrapper> {
|
||||
@override
|
||||
void initState() {
|
||||
void didChangeDependencies() {
|
||||
FlutterNativeSplash.remove();
|
||||
super.initState();
|
||||
for (var element in AssetImages.values) {
|
||||
element.load(context);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -144,6 +148,9 @@ class _AuthenticationWrapperState extends State<AuthenticationWrapper> {
|
||||
final bool showIntroSlider =
|
||||
authState.isAuthenticated && !authState.wasLoginStored;
|
||||
if (showIntroSlider) {
|
||||
for (final img in AssetImages.values) {
|
||||
img.load(context);
|
||||
}
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
|
||||
Reference in New Issue
Block a user