mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 00:07:49 -06:00
WIP - Replaced get_it + injectable with Provider
This commit is contained in:
@@ -2,7 +2,6 @@ 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';
|
||||
import 'package:paperless_mobile/features/settings/view/widgets/language_selection_setting.dart';
|
||||
@@ -26,84 +25,81 @@ class _ApplicationIntroSlideshowState extends State<ApplicationIntroSlideshow> {
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: BlocProvider.value(
|
||||
value: getIt<ApplicationSettingsCubit>(),
|
||||
child: IntroductionScreen(
|
||||
globalBackgroundColor: Theme.of(context).canvasColor,
|
||||
showDoneButton: true,
|
||||
next: Text(S.of(context).onboardingNextButtonLabel),
|
||||
done: Text(S.of(context).onboardingDoneButtonLabel),
|
||||
onDone: () => Navigator.pop(context),
|
||||
dotsDecorator: DotsDecorator(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
activeColor: Theme.of(context).colorScheme.primary,
|
||||
activeSize: const Size(16.0, 8.0),
|
||||
activeShape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25.0)),
|
||||
child: IntroductionScreen(
|
||||
globalBackgroundColor: Theme.of(context).canvasColor,
|
||||
showDoneButton: true,
|
||||
next: Text(S.of(context).onboardingNextButtonLabel),
|
||||
done: Text(S.of(context).onboardingDoneButtonLabel),
|
||||
onDone: () => Navigator.pop(context),
|
||||
dotsDecorator: DotsDecorator(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
activeColor: Theme.of(context).colorScheme.primary,
|
||||
activeSize: const Size(16.0, 8.0),
|
||||
activeShape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(25.0)),
|
||||
),
|
||||
),
|
||||
pages: [
|
||||
PageViewModel(
|
||||
titleWidget: Text(
|
||||
"Always right at your fingertip",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
image: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image(
|
||||
image: AssetImages.organizeDocuments.image,
|
||||
),
|
||||
),
|
||||
bodyWidget: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(
|
||||
"Organizing documents was never this easy",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
pages: [
|
||||
PageViewModel(
|
||||
titleWidget: Text(
|
||||
"Always right at your fingertip",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
image: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image(
|
||||
image: AssetImages.organizeDocuments.image,
|
||||
PageViewModel(
|
||||
titleWidget: Text(
|
||||
"Accessible only by you",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
image: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image(image: AssetImages.secureDocuments.image),
|
||||
),
|
||||
bodyWidget: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(
|
||||
"Secure your documents with biometric authentication and client certificates",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
bodyWidget: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(
|
||||
"Organizing documents was never this easy",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
PageViewModel(
|
||||
titleWidget: Text(
|
||||
"Accessible only by you",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
image: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image(image: AssetImages.secureDocuments.image),
|
||||
),
|
||||
bodyWidget: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(
|
||||
"Secure your documents with biometric authentication and client certificates",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
PageViewModel(
|
||||
titleWidget: Text(
|
||||
"You're almost done",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
PageViewModel(
|
||||
titleWidget: Text(
|
||||
"You're almost done",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
image: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image(image: AssetImages.success.image),
|
||||
),
|
||||
bodyWidget: Column(
|
||||
children: const [
|
||||
BiometricAuthenticationSetting(),
|
||||
LanguageSelectionSetting(),
|
||||
ThemeModeSetting(),
|
||||
],
|
||||
),
|
||||
image: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image(image: AssetImages.success.image),
|
||||
),
|
||||
],
|
||||
),
|
||||
bodyWidget: Column(
|
||||
children: const [
|
||||
BiometricAuthenticationSetting(),
|
||||
LanguageSelectionSetting(),
|
||||
ThemeModeSetting(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_mobile/di_initializer.dart';
|
||||
import 'package:paperless_mobile/features/login/services/authentication_service.dart';
|
||||
import 'package:paperless_mobile/features/settings/bloc/application_settings_cubit.dart';
|
||||
import 'package:paperless_mobile/features/settings/model/application_settings_state.dart';
|
||||
import 'package:paperless_mobile/util.dart';
|
||||
|
||||
class BiometricAuthenticationIntroSlide extends StatefulWidget {
|
||||
const BiometricAuthenticationIntroSlide({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<BiometricAuthenticationIntroSlide> createState() =>
|
||||
_BiometricAuthenticationIntroSlideState();
|
||||
}
|
||||
|
||||
class _BiometricAuthenticationIntroSlideState
|
||||
extends State<BiometricAuthenticationIntroSlide> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//TODO: INTL
|
||||
return BlocBuilder<ApplicationSettingsCubit, ApplicationSettingsState>(
|
||||
builder: (context, settings) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Configure Biometric Authentication",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(
|
||||
"It is highly recommended to additionally secure your local data. Do you want to enable biometric authentication?",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.fingerprint,
|
||||
size: 48,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 32,
|
||||
),
|
||||
Builder(builder: (context) {
|
||||
if (settings.isLocalAuthenticationEnabled) {
|
||||
return ElevatedButton.icon(
|
||||
icon: Icon(
|
||||
Icons.done,
|
||||
color: Colors.green,
|
||||
),
|
||||
label: Text("Enabled"),
|
||||
onPressed: null,
|
||||
);
|
||||
}
|
||||
return ElevatedButton(
|
||||
child: Text("Enable"),
|
||||
onPressed: () {
|
||||
final settings =
|
||||
BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
.state;
|
||||
getIt<LocalAuthenticationService>()
|
||||
.authenticateLocalUser(
|
||||
"Please authenticate to secure Paperless Mobile")
|
||||
.then((isEnabled) {
|
||||
if (!isEnabled) {
|
||||
showSnackBar(context,
|
||||
"Could not set up biometric authentication. Please try again or skip for now.");
|
||||
return;
|
||||
}
|
||||
BlocProvider.of<ApplicationSettingsCubit>(context)
|
||||
.setIsBiometricAuthenticationEnabled(true);
|
||||
});
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user