204 lines
6.9 KiB
Dart
204 lines
6.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:proxibuy/presentation/auth/bloc/auth_bloc.dart';
|
|
import 'package:proxibuy/presentation/pages/login_page.dart';
|
|
import '../../core/config/app_colors.dart';
|
|
import '../../core/gen/assets.gen.dart';
|
|
import '../../domain/entities/onboarding_entity.dart';
|
|
import '../widgets/onboarding_indicator_painter.dart';
|
|
|
|
final List<OnboardingEntity> onboardingPages = [
|
|
OnboardingEntity(
|
|
imagePath: Assets.images.onboarding1.path,
|
|
title: 'قدم بزن و تخفیف بگیر',
|
|
description:
|
|
' کافیه موقع حرکت در شهر، موقعیتیاب (GPS) گوشیتو روشن کنی تا تخفیفهای اطرافت رو دریافت کنی. بدون نیاز به جستجو، توی Proxibuy، خود تخفیفها به سمتت میان!',
|
|
),
|
|
OnboardingEntity(
|
|
imagePath: Assets.images.onboarding2.path,
|
|
title: 'همیشه یه پیشنهاد خوب نزدیکته',
|
|
description:
|
|
'با اعلانهای لحظهای، همیشه از نزدیکترین تخفیفها و پیشنهادهای ویژه باخبر باش. هوشمند بخر، هوشمند زندگی کن!',
|
|
),
|
|
OnboardingEntity(
|
|
imagePath: Assets.images.onboarding3.path,
|
|
title: ' پیشنهادهای لحظهای، تجربهای نو از خرید',
|
|
description:
|
|
'Proxibuy همیشه باهاته؛ چه در مسیر رفتن به خونه، چه در مسیر کافه مورد علاقهات. همین الان خریدت رو هوشمندتر کن!',
|
|
),
|
|
OnboardingEntity(
|
|
imagePath: Assets.images.onboarding4.path,
|
|
title: 'دنیایی از تخفیفهای اطرافت رو کشف کن',
|
|
description:
|
|
'میصرفه یه اپ هوشمنده که کمکت میکنه وقتی توی شهر حرکت میکنی، از تخفیفهای اطرافت باخبر شی و به صرفهتر خرید کنی.',
|
|
),
|
|
];
|
|
|
|
class OnboardingPage extends StatefulWidget {
|
|
const OnboardingPage({super.key});
|
|
|
|
@override
|
|
State<OnboardingPage> createState() => _OnboardingPageState();
|
|
}
|
|
|
|
class _OnboardingPageState extends State<OnboardingPage> {
|
|
final PageController _pageController = PageController();
|
|
int _currentPage = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_pageController.addListener(() {
|
|
if (_pageController.page != null) {
|
|
setState(() {
|
|
_currentPage = _pageController.page!.round();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_pageController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _onArrowTap() {
|
|
if (_currentPage < onboardingPages.length - 1) {
|
|
_pageController.nextPage(
|
|
duration: const Duration(milliseconds: 400),
|
|
curve: Curves.easeInOut,
|
|
);
|
|
} else {
|
|
Navigator.of(context).pushReplacement(
|
|
MaterialPageRoute(
|
|
builder:
|
|
(context) => BlocProvider(
|
|
create: (context) => AuthBloc(),
|
|
child: const LoginPage(),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Stack(
|
|
children: [
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: PageView.builder(
|
|
controller: _pageController,
|
|
itemCount: onboardingPages.length,
|
|
itemBuilder: (context, index) {
|
|
final page = onboardingPages[index];
|
|
return Image.asset(
|
|
page.imagePath,
|
|
fit: BoxFit.cover,
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
|
|
if (_currentPage > 0)
|
|
Positioned(
|
|
top: 50,
|
|
left: 10,
|
|
child: IconButton(
|
|
icon: Assets.icons.backArrow.svg(width: 28),
|
|
onPressed: () {
|
|
_pageController.previousPage(
|
|
duration: const Duration(milliseconds: 400),
|
|
curve: Curves.easeInOut,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 250,
|
|
left: 0,
|
|
right: 0,
|
|
child: SizedBox(
|
|
width: 80,
|
|
height: 80,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
SizedBox(
|
|
width: 80,
|
|
height: 80,
|
|
child: CustomPaint(
|
|
painter: OnboardingIndicatorPainter(
|
|
pageCount: onboardingPages.length,
|
|
currentPage: _currentPage,
|
|
activeColor: AppColors.primary,
|
|
inactiveColor: AppColors.unselected,
|
|
),
|
|
),
|
|
),
|
|
Stack(
|
|
children: [
|
|
Center(
|
|
child: GestureDetector(
|
|
onTap: _onArrowTap,
|
|
child: Assets.icons.ellipse1.svg(width: 60),
|
|
),
|
|
),
|
|
Center(
|
|
child: GestureDetector(
|
|
onTap: _onArrowTap,
|
|
child: Assets.icons.arrowRight2.svg(width: 45),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 90,
|
|
left: 24,
|
|
right: 24,
|
|
child: Column(
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
onboardingPages[_currentPage].title,
|
|
textAlign: TextAlign.right,
|
|
style: Theme.of(
|
|
context,
|
|
).textTheme.headlineSmall?.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 18,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
onboardingPages[_currentPage].description,
|
|
textAlign: TextAlign.right,
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
|
// ignore: deprecated_member_use
|
|
color: Colors.white.withOpacity(0.8),
|
|
fontSize: 16,
|
|
height: 1.5,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|