Untitled

mail@pastecode.io avatar
unknown
dart
a year ago
5.3 kB
1
Indexable
Never
import 'package:centro/app/modules/Common/onBoarding/onBoardingWidgets/clipped_container.dart';
import 'package:centro/app/utilities/constants/app_colors.dart';
import 'package:centro/app/utilities/routing/app_pages.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import '../controllers/on_boarding_controller.dart';

class OnBoardingTwoView extends GetView<OnBoardingController> {
  const OnBoardingTwoView({super.key});

  @override
  Widget build(BuildContext context) {
    Get.put(OnBoardingController());
    // SignInBinding().dependencies();
    return Scaffold(
      backgroundColor: AppColors.backgroundColor,
      body: WillPopScope(
        onWillPop: () async => false,
        child: Directionality(
          textDirection: TextDirection.ltr,
          child: Stack(
            children: [
              PageView.builder(
                controller: controller.pageController,
                itemCount: controller.contents.length,
                onPageChanged: (int index) {
                  controller.currentIndex.value = index;
                },
                itemBuilder: (_, i) {
                  return Stack(
                    children: [
                      Obx(
                        () => ClippedContainer(
                            image: AssetImage(controller.contents[i].image!)),
                      ),
                      Center(
                        child: Column(
                          children: [
                            Padding(
                              padding: EdgeInsets.only(top: Get.height * 0.05),
                              child: SvgPicture.asset('assets/icons/logo.svg',
                                  height: Get.height * 0.032),
                            ),
                            SizedBox(
                              height: Get.height * 0.44,
                            ),
                            Text(controller.contents[i].title!,
                                textAlign: TextAlign.center,
                                style: Get.textTheme.headline2!
                                    .copyWith(color: AppColors.black)),
                            SizedBox(height: Get.height * 0.05),
                            Padding(
                              padding: EdgeInsets.only(
                                  right: Get.width * 0.13,
                                  left: Get.width * 0.13),
                              child: Text(controller.contents[i].discription!,
                                  textAlign: TextAlign.center,
                                  style: Get.textTheme.headline6!
                                      .copyWith(color: AppColors.black)),
                            ),
                            SizedBox(
                              height: Get.height * 0.115,
                            ),
                          ],
                        ),
                      ),
                    ],
                  );
                },
              ),
              Column(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Obx(
                    () => Container(
                      margin: EdgeInsets.only(bottom: Get.width * 0.03),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: List.generate(
                          controller.contents.length,
                          (index) => buildDot(index, context),
                        ),
                      ),
                    ),
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.end,
                    children: [
                      Image.asset('assets/images/CornerTriangle.png'),
                      Padding(
                          padding: EdgeInsets.only(
                              right: Get.width * 0.07,
                              bottom: Get.width * 0.022),
                          child: TextButton(
                            onPressed: () => Get.toNamed(AppRoutes.login),
                            child: Text(
                              'get started'.tr,
                              style: Get.textTheme.headline5?.copyWith(
                                  color: AppColors.primary,
                                  decoration: TextDecoration.underline),
                            ),
                          ))
                    ],
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }

  Container buildDot(int index, BuildContext context) {
    return Container(
      height: 10,
      width: 10,
      margin: const EdgeInsets.only(right: 13),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20),
          color: controller.currentIndex.value == index
              ? AppColors.primary
              : AppColors.primaryBG),
    );
  }
}