2023-02-23 14:49:14 +00:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2020-11-29 20:07:46 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-05-15 15:36:00 +00:00
|
|
|
import 'package:selfprivacy/config/app_controller/inherited_app_controller.dart';
|
2024-02-08 11:59:52 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/onboarding/views/views.dart';
|
2023-02-23 14:49:14 +00:00
|
|
|
import 'package:selfprivacy/ui/router/router.dart';
|
2020-11-29 20:07:46 +00:00
|
|
|
|
2023-03-22 11:38:18 +00:00
|
|
|
@RoutePage()
|
2020-12-30 14:13:25 +00:00
|
|
|
class OnboardingPage extends StatefulWidget {
|
2023-02-23 14:49:14 +00:00
|
|
|
const OnboardingPage({super.key});
|
2020-11-29 20:07:46 +00:00
|
|
|
|
2020-12-30 14:13:25 +00:00
|
|
|
@override
|
2022-05-25 12:21:56 +00:00
|
|
|
State<OnboardingPage> createState() => _OnboardingPageState();
|
2020-12-30 14:13:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class _OnboardingPageState extends State<OnboardingPage> {
|
|
|
|
PageController pageController = PageController();
|
|
|
|
|
|
|
|
@override
|
2024-02-08 11:59:52 +00:00
|
|
|
void dispose() {
|
|
|
|
pageController.dispose();
|
|
|
|
super.dispose();
|
2020-12-30 14:13:25 +00:00
|
|
|
}
|
|
|
|
|
2024-02-08 11:59:52 +00:00
|
|
|
Future<void> scrollTo(final int targetView) => pageController.animateToPage(
|
|
|
|
targetView,
|
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
curve: Curves.easeInOutCubicEmphasized,
|
2022-06-05 22:40:34 +00:00
|
|
|
);
|
2020-12-30 14:13:25 +00:00
|
|
|
|
2024-02-08 11:59:52 +00:00
|
|
|
@override
|
|
|
|
Widget build(final BuildContext context) => Material(
|
|
|
|
child: PageView(
|
|
|
|
controller: pageController,
|
2022-06-05 22:40:34 +00:00
|
|
|
children: [
|
2024-02-08 11:59:52 +00:00
|
|
|
OnboardingFirstView(
|
|
|
|
onProceed: () => scrollTo(1),
|
2022-06-05 22:40:34 +00:00
|
|
|
),
|
2024-02-08 11:59:52 +00:00
|
|
|
OnboardingSecondView(
|
|
|
|
onProceed: () {
|
2024-05-15 15:36:00 +00:00
|
|
|
InheritedAppController.of(context)
|
|
|
|
.setShouldShowOnboarding(false);
|
2023-02-23 14:49:14 +00:00
|
|
|
context.router.replaceAll([
|
|
|
|
const RootRoute(),
|
|
|
|
const InitializingRoute(),
|
|
|
|
]);
|
2022-06-05 22:40:34 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2020-12-03 16:52:53 +00:00
|
|
|
}
|