161 lines
5.6 KiB
Dart
161 lines
5.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:flutter_animate/flutter_animate.dart';
|
|
import '../../core/theme/app_theme.dart';
|
|
import '../../core/constants/app_constants.dart';
|
|
|
|
class OnboardingScreen extends StatefulWidget {
|
|
const OnboardingScreen({super.key});
|
|
|
|
@override
|
|
State<OnboardingScreen> createState() => _OnboardingScreenState();
|
|
}
|
|
|
|
class _OnboardingScreenState extends State<OnboardingScreen> {
|
|
final _pageController = PageController();
|
|
int _currentPage = 0;
|
|
final _storage = const FlutterSecureStorage();
|
|
|
|
final _pages = const [
|
|
_OnboardingPageData(
|
|
icon: Icons.lightbulb_outline,
|
|
title: 'Добро пожаловать в VoIdea',
|
|
description: 'Голосовой помощник для управления идеями.\nЗаписывайте, развивайте и запускайте идеи голосом.',
|
|
),
|
|
_OnboardingPageData(
|
|
icon: Icons.mic,
|
|
title: 'Голосовой ввод',
|
|
description: 'Говорите — мы записываем.\nРаспознавание речи в реальном времени.',
|
|
),
|
|
_OnboardingPageData(
|
|
icon: Icons.view_kanban,
|
|
title: 'Воронка идей',
|
|
description: 'От сырой идеи до запуска.\nУправляйте статусами и трекайте прогресс.',
|
|
),
|
|
_OnboardingPageData(
|
|
icon: Icons.groups,
|
|
title: 'Командная работа',
|
|
description: 'Рабочие пространства, голосования, комментарии.\nВсё для совместной работы.',
|
|
),
|
|
];
|
|
|
|
@override
|
|
void dispose() {
|
|
_pageController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
Future<void> _complete() async {
|
|
await _storage.write(key: AppConstants.onboardingSeenKey, value: 'true');
|
|
if (mounted) context.go('/auth/login');
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
Align(
|
|
alignment: Alignment.topRight,
|
|
child: TextButton(
|
|
onPressed: _complete,
|
|
child: const Text('Пропустить'),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: PageView.builder(
|
|
controller: _pageController,
|
|
itemCount: _pages.length,
|
|
onPageChanged: (i) => setState(() => _currentPage = i),
|
|
itemBuilder: (_, i) {
|
|
final page = _pages[i];
|
|
return Padding(
|
|
padding: const EdgeInsets.all(48),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(page.icon,
|
|
size: 80, color: VoIdeaColors.primary),
|
|
const SizedBox(height: 32),
|
|
Text(
|
|
page.title,
|
|
textAlign: TextAlign.center,
|
|
style: Theme.of(context)
|
|
.textTheme
|
|
.headlineSmall
|
|
?.copyWith(fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
page.description,
|
|
textAlign: TextAlign.center,
|
|
style: Theme.of(context)
|
|
.textTheme
|
|
.bodyLarge
|
|
?.copyWith(color: VoIdeaColors.muted),
|
|
),
|
|
],
|
|
),
|
|
).animate().fadeIn(duration: 400.ms);
|
|
},
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: List.generate(
|
|
_pages.length,
|
|
(i) => AnimatedContainer(
|
|
duration: 200.ms,
|
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
|
width: _currentPage == i ? 24 : 8,
|
|
height: 8,
|
|
decoration: BoxDecoration(
|
|
color: _currentPage == i
|
|
? VoIdeaColors.primary
|
|
: VoIdeaColors.muted.withOpacity(0.3),
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
child: ElevatedButton(
|
|
onPressed: _currentPage == _pages.length - 1
|
|
? _complete
|
|
: () => _pageController.nextPage(
|
|
duration: 300.ms,
|
|
curve: Curves.easeInOut,
|
|
),
|
|
child: Text(
|
|
_currentPage == _pages.length - 1
|
|
? 'Начать'
|
|
: 'Далее',
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _OnboardingPageData {
|
|
final IconData icon;
|
|
final String title;
|
|
final String description;
|
|
|
|
const _OnboardingPageData({
|
|
required this.icon,
|
|
required this.title,
|
|
required this.description,
|
|
});
|
|
}
|