211 lines
7.2 KiB
Dart
211 lines
7.2 KiB
Dart
import 'package:business_panel/core/config/app_colors.dart';
|
|
import 'package:business_panel/domain/entities/onboarding_entity.dart';
|
|
import 'package:business_panel/gen/assets.gen.dart';
|
|
import 'package:business_panel/presentation/auth/bloc/auth_bloc.dart';
|
|
import 'package:business_panel/presentation/pages/login_page.dart';
|
|
import 'package:business_panel/presentation/widgets/onboarding_indicator_painter.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
final List<OnboardingEntity> onboardingPages = [
|
|
OnboardingEntity(
|
|
imagePath: Assets.images.rectangle1.path,
|
|
title: 'قدم بزن و تخفیف بگیر',
|
|
description:
|
|
' کافیه موقع حرکت در شهر، موقعیتیاب (GPS) گوشیتو روشن کنی تا تخفیفهای اطرافت رو دریافت کنی. بدون نیاز به جستجو، توی Proxibuy، خود تخفیفها به سمتت میان!',
|
|
),
|
|
OnboardingEntity(
|
|
imagePath: Assets.images.rectangle2M.path,
|
|
title: 'همیشه یه پیشنهاد خوب نزدیکته',
|
|
description:
|
|
'با اعلانهای لحظهای، همیشه از نزدیکترین تخفیفها و پیشنهادهای ویژه باخبر باش. هوشمند بخر، هوشمند زندگی کن!',
|
|
),
|
|
OnboardingEntity(
|
|
imagePath: Assets.images.rectangle3M.path,
|
|
title: ' پیشنهادهای لحظهای، تجربهای نو از خرید',
|
|
description:
|
|
'Proxibuy همیشه باهاته؛ چه در مسیر رفتن به خونه، چه در مسیر کافه مورد علاقهات. همین الان خریدت رو هوشمندتر کن!',
|
|
),
|
|
OnboardingEntity(
|
|
imagePath: Assets.images.rectangle4.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: (_) => 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: SvgPicture.asset(Assets.icons.backArrow, width: 25),
|
|
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: SvgPicture.asset(
|
|
Assets.icons.ellipse1,
|
|
width: 60,
|
|
),
|
|
),
|
|
),
|
|
Center(
|
|
child: GestureDetector(
|
|
onTap: _onArrowTap,
|
|
child: SvgPicture.asset(
|
|
Assets.icons.arrowRight2,
|
|
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,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|