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

149 lines
4.5 KiB
Dart
Raw Normal View History

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';
2020-11-29 20:07:46 +00:00
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
2020-12-08 19:26:51 +00:00
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
2020-12-06 07:28:31 +00:00
import 'package:selfprivacy/utils/route_transitions/basic.dart';
2020-11-29 20:07:46 +00:00
2020-12-30 14:13:25 +00:00
class OnboardingPage extends StatefulWidget {
2021-01-06 17:35:57 +00:00
const OnboardingPage({Key key, @required this.nextPage}) : super(key: key);
2020-11-29 20:07:46 +00:00
2021-01-06 17:35:57 +00:00
final Widget nextPage;
2020-12-30 14:13:25 +00:00
@override
_OnboardingPageState createState() => _OnboardingPageState();
}
class _OnboardingPageState extends State<OnboardingPage> {
PageController pageController = PageController();
@override
void initState() {
super.initState();
}
2020-11-29 20:07:46 +00:00
@override
Widget build(BuildContext context) {
2020-12-06 07:28:31 +00:00
return SafeArea(
child: Scaffold(
2020-12-30 14:13:25 +00:00
body: PageView(
controller: pageController,
children: [
_withPadding(firstPage()),
_withPadding(secondPage()),
],
),
),
);
}
Widget _withPadding(Widget child) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 15,
),
child: child,
);
}
Widget firstPage() {
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 30),
BrandText.h2(
'Цифровая независимость и приватность, доступная каждому'),
SizedBox(height: 20),
BrandText.body2(
'Почта и мессенджер с открытым исходным кодом на вашем личном сервере под вашим полным контролем.'),
Flexible(
child: Center(
child: Image.asset(
2021-02-17 16:20:09 +00:00
_fileName(
context: context,
path: 'assets/images/onboarding',
fileExtention: 'png',
fileName: 'onboarding1',
),
2020-12-30 14:13:25 +00:00
),
),
2020-12-06 07:28:31 +00:00
),
2020-12-30 14:13:25 +00:00
BrandButton.rised(
onPressed: () {
pageController.animateToPage(
1,
duration: Duration(milliseconds: 300),
curve: Curves.easeIn,
);
},
title: 'Далее',
),
SizedBox(height: 30),
],
),
);
}
Widget secondPage() {
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height,
),
child: Column(
children: [
SizedBox(height: 30),
BrandText.h2('Для работы понадобятся ваши аккаунты'),
SizedBox(height: 20),
BrandText.body2(
'Для максимальноей приватности и независимости SelfPrivacy не использует свои серверы. \n \n Если у вас нет домена, аккаунтов на Hetzner, AWS и Clouflare, мы поможем их создать и подключить.'),
SizedBox(height: 20),
Center(
child: Image.asset(
2021-02-17 16:20:09 +00:00
_fileName(
context: context,
path: 'assets/images/onboarding',
fileExtention: 'png',
fileName: 'logos_line',
),
2020-12-30 14:13:25 +00:00
),
),
Flexible(
child: Center(
child: Image.asset(
2021-02-17 16:20:09 +00:00
_fileName(
context: context,
path: 'assets/images/onboarding',
fileExtention: 'png',
fileName: 'onboarding2',
),
2020-12-06 07:28:31 +00:00
),
2020-12-30 14:13:25 +00:00
),
2020-12-06 07:28:31 +00:00
),
2020-12-30 14:13:25 +00:00
BrandButton.rised(
onPressed: () {
2021-01-06 17:35:57 +00:00
context.read<AppSettingsCubit>().turnOffOnboarding();
2020-12-30 14:13:25 +00:00
Navigator.of(context)
2021-01-06 17:35:57 +00:00
.pushReplacement(materialRoute(widget.nextPage));
2020-12-30 14:13:25 +00:00
},
title: 'Понял',
),
SizedBox(height: 30),
],
2020-12-03 16:52:53 +00:00
),
);
}
}
2021-02-17 16:20:09 +00:00
String _fileName({
@required BuildContext context,
@required String path,
@required String fileName,
@required String fileExtention,
}) {
var theme = Theme.of(context);
var isDark = theme.brightness == Brightness.dark;
return '$path/$fileName${isDark ? '-dark' : '-light'}.$fileExtention';
}