selfprivacy.org.app/lib/ui/pages/onboarding/onboarding.dart

51 lines
1.4 KiB
Dart
Raw Normal View History

import 'package:auto_route/auto_route.dart';
2020-11-29 20:07:46 +00:00
import 'package:flutter/material.dart';
2021-01-06 17:35:57 +00:00
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
import 'package:selfprivacy/ui/pages/onboarding/views/views.dart';
import 'package:selfprivacy/ui/router/router.dart';
2020-11-29 20:07:46 +00:00
@RoutePage()
2020-12-30 14:13:25 +00:00
class OnboardingPage extends StatefulWidget {
const OnboardingPage({super.key});
2020-11-29 20:07:46 +00:00
2020-12-30 14:13:25 +00:00
@override
State<OnboardingPage> createState() => _OnboardingPageState();
2020-12-30 14:13:25 +00:00
}
class _OnboardingPageState extends State<OnboardingPage> {
PageController pageController = PageController();
@override
void dispose() {
pageController.dispose();
super.dispose();
2020-12-30 14:13:25 +00:00
}
Future<void> scrollTo(final int targetView) => pageController.animateToPage(
targetView,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOutCubicEmphasized,
);
2020-12-30 14:13:25 +00:00
@override
Widget build(final BuildContext context) => Material(
child: PageView(
controller: pageController,
children: [
OnboardingFirstView(
onProceed: () => scrollTo(1),
),
OnboardingSecondView(
onProceed: () {
context.read<AppSettingsCubit>().turnOffOnboarding();
context.router.replaceAll([
const RootRoute(),
const InitializingRoute(),
]);
},
),
],
),
);
2020-12-03 16:52:53 +00:00
}