2024-08-04 11:48:25 +03:00
|
|
|
import 'package:gap/gap.dart';
|
2024-09-06 22:07:50 +03:00
|
|
|
import 'package:rain/app/data/db.dart';
|
|
|
|
import 'package:rain/app/ui/geolocation.dart';
|
|
|
|
import 'package:rain/app/ui/widgets/button.dart';
|
2023-06-17 20:57:57 +03:00
|
|
|
import 'package:rain/main.dart';
|
2023-12-29 21:18:59 +03:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
2023-06-17 20:57:57 +03:00
|
|
|
|
2023-12-29 21:18:59 +03:00
|
|
|
class OnBording extends StatefulWidget {
|
|
|
|
const OnBording({super.key});
|
2023-06-17 20:57:57 +03:00
|
|
|
|
|
|
|
@override
|
2023-12-29 21:18:59 +03:00
|
|
|
State<OnBording> createState() => _OnBordingState();
|
2023-06-17 20:57:57 +03:00
|
|
|
}
|
|
|
|
|
2023-12-29 21:18:59 +03:00
|
|
|
class _OnBordingState extends State<OnBording> {
|
|
|
|
late PageController pageController;
|
|
|
|
int pageIndex = 0;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
pageController = PageController(initialPage: 0);
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
pageController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
void onBoardHome() {
|
|
|
|
settings.onboard = true;
|
|
|
|
isar.writeTxnSync(() => isar.settings.putSync(settings));
|
2025-03-15 23:40:48 +03:00
|
|
|
Get.off(
|
|
|
|
() => const SelectGeolocation(isStart: true),
|
|
|
|
transition: Transition.downToUp,
|
|
|
|
);
|
2023-12-29 21:18:59 +03:00
|
|
|
}
|
|
|
|
|
2023-06-17 20:57:57 +03:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2024-08-03 18:55:26 +03:00
|
|
|
appBar: AppBar(),
|
2023-06-17 20:57:57 +03:00
|
|
|
body: SafeArea(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2023-12-29 21:18:59 +03:00
|
|
|
Expanded(
|
|
|
|
child: PageView.builder(
|
|
|
|
controller: pageController,
|
|
|
|
itemCount: data.length,
|
|
|
|
onPageChanged: (index) {
|
|
|
|
setState(() {
|
|
|
|
pageIndex = index;
|
|
|
|
});
|
|
|
|
},
|
2025-03-15 23:40:48 +03:00
|
|
|
itemBuilder:
|
|
|
|
(context, index) => OnboardContent(
|
|
|
|
image: data[index].image,
|
|
|
|
title: data[index].title,
|
|
|
|
description: data[index].description,
|
|
|
|
),
|
2023-06-17 20:57:57 +03:00
|
|
|
),
|
|
|
|
),
|
2023-12-29 21:18:59 +03:00
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
...List.generate(
|
2025-03-15 23:40:48 +03:00
|
|
|
data.length,
|
|
|
|
(index) => Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
|
|
|
child: DotIndicator(isActive: index == pageIndex),
|
|
|
|
),
|
|
|
|
),
|
2023-12-29 21:18:59 +03:00
|
|
|
],
|
|
|
|
),
|
2023-06-17 20:57:57 +03:00
|
|
|
Padding(
|
2023-12-29 21:18:59 +03:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
2023-06-17 20:57:57 +03:00
|
|
|
child: MyTextButton(
|
2023-12-29 21:18:59 +03:00
|
|
|
buttonName:
|
|
|
|
pageIndex == data.length - 1 ? 'start'.tr : 'next'.tr,
|
|
|
|
onPressed: () {
|
|
|
|
pageIndex == data.length - 1
|
|
|
|
? onBoardHome()
|
|
|
|
: pageController.nextPage(
|
2025-03-15 23:40:48 +03:00
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
curve: Curves.ease,
|
|
|
|
);
|
2023-06-17 20:57:57 +03:00
|
|
|
},
|
|
|
|
),
|
2025-03-15 23:40:48 +03:00
|
|
|
),
|
2023-06-17 20:57:57 +03:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-12-29 21:18:59 +03:00
|
|
|
|
|
|
|
class DotIndicator extends StatelessWidget {
|
2025-03-15 23:40:48 +03:00
|
|
|
const DotIndicator({super.key, this.isActive = false});
|
2023-12-29 21:18:59 +03:00
|
|
|
|
|
|
|
final bool isActive;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AnimatedContainer(
|
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
height: 8,
|
|
|
|
width: 8,
|
|
|
|
decoration: BoxDecoration(
|
2025-03-15 23:40:48 +03:00
|
|
|
color:
|
|
|
|
isActive
|
|
|
|
? context.theme.colorScheme.secondary
|
|
|
|
: context.theme.colorScheme.secondaryContainer,
|
2023-12-29 21:18:59 +03:00
|
|
|
shape: BoxShape.circle,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Onboard {
|
|
|
|
final String image, title, description;
|
|
|
|
|
|
|
|
Onboard({
|
|
|
|
required this.image,
|
|
|
|
required this.title,
|
|
|
|
required this.description,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
final List<Onboard> data = [
|
|
|
|
Onboard(
|
2025-03-15 23:40:48 +03:00
|
|
|
image: 'assets/icons/Rain.png',
|
|
|
|
title: 'name'.tr,
|
|
|
|
description: 'description'.tr,
|
|
|
|
),
|
2023-12-29 21:18:59 +03:00
|
|
|
Onboard(
|
2025-03-15 23:40:48 +03:00
|
|
|
image: 'assets/icons/Design.png',
|
|
|
|
title: 'name2'.tr,
|
|
|
|
description: 'description2'.tr,
|
|
|
|
),
|
2023-12-29 21:18:59 +03:00
|
|
|
Onboard(
|
2025-03-15 23:40:48 +03:00
|
|
|
image: 'assets/icons/Team.png',
|
|
|
|
title: 'name3'.tr,
|
|
|
|
description: 'description3'.tr,
|
|
|
|
),
|
2023-12-29 21:18:59 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
class OnboardContent extends StatelessWidget {
|
|
|
|
const OnboardContent({
|
|
|
|
super.key,
|
|
|
|
required this.image,
|
|
|
|
required this.title,
|
|
|
|
required this.description,
|
|
|
|
});
|
|
|
|
final String image, title, description;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
2025-03-15 23:40:48 +03:00
|
|
|
Image.asset(image, scale: 5),
|
2023-12-29 21:18:59 +03:00
|
|
|
Text(
|
|
|
|
title,
|
2025-03-15 23:40:48 +03:00
|
|
|
style: context.textTheme.titleLarge?.copyWith(
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
2023-12-29 21:18:59 +03:00
|
|
|
),
|
2024-08-04 11:48:25 +03:00
|
|
|
const Gap(10),
|
2023-12-29 21:18:59 +03:00
|
|
|
SizedBox(
|
|
|
|
width: 300,
|
|
|
|
child: Text(
|
|
|
|
description,
|
|
|
|
style: context.textTheme.labelLarge?.copyWith(fontSize: 14),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|