import 'package:flutter/material.dart'; import 'package:taafee_mobile/common/const/const.dart'; import 'package:taafee_mobile/common/widgets/button.dart'; import 'package:get/get.dart'; import 'package:taafee_mobile/core/routing/routing_manager.dart'; import 'package:taafee_mobile/features/onboarding/business_logic_layer/onboarding_controller.dart'; class Onboarding extends StatelessWidget { Onboarding({super.key}); final OnboardingController onboardingController = Get.find(); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.backGroundColor, body: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( height: Get.height * 0.7, child: PageView.builder( controller: onboardingController.pageController, itemCount: 3, onPageChanged: (value) { onboardingController.changeCurrentIndex(value); }, itemBuilder: (context, index) { return OnBoardingWidget( index: index, ).paddingSymmetric(horizontal: Get.width * 0.05); }, ), ), const SizedBox( height: 20.0, ), Obx(() { return Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SizedBox( width: Get.width * 0.05, ), ButtonWidget( onTap: () { onboardingController.setfirstTimeOpened(); RoutingManager.offAll(RouteName.register); }, title: 'skip'.tr, width: Get.width * 0.35, textColor: AppColors.textButtonColor, color: AppColors.backGroundColor, ), SizedBox( width: Get.width * 0.1, ), ButtonWidget( onTap: () { if (onboardingController.currentIndex.value < 2) { onboardingController.increaseIndex(); } else { onboardingController.setfirstTimeOpened(); RoutingManager.offAll(RouteName.register); } }, title: (!onboardingController.isLast.value) ? 'next'.tr : 'create_account'.tr, textColor: AppColors.textButtonColor, width: Get.width * 0.35, ), SizedBox( width: Get.width * 0.05, ), ], ); }) ], ), ); } } // ignore: must_be_immutable class OnBoardingWidget extends StatelessWidget { OnBoardingWidget({ super.key, required this.index, }); int index; final OnboardingController onboardingController = Get.find(); @override Widget build(BuildContext context) { return Obx( () => SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ onboardingController.picturesList[index], SizedBox( height: Get.height * 0.1, ), SingleChildScrollView( child: onboardingController.textList[index].paddingSymmetric( horizontal: Get.width * 0.1, ), ), SizedBox( height: Get.height * 0.1, ), ], ), ), ); } }