Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
7.4 kB
4
Indexable
Never
Widget build(BuildContext context) {
  return WillPopScope(
    onWillPop: () async {
      backClick();
      return false;
    },
    child: Scaffold(
      resizeToAvoidBottomInset: false,
      body: SizedBox(
        height: double.infinity,
        width: double.infinity,
        child: PageView.builder(
          controller: _controller,
          onPageChanged: (value) {
            selectedPage.value = value;
          },
          itemCount: DataFile.introList.length,
          itemBuilder: (context, index) {
            ModelIntro introModel = DataFile.introList[index];

            BoxDecoration lightThemeDecoration = const BoxDecoration(
              color: AppColors.backgroundColorLight,
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(70.0),
                topRight: Radius.circular(70.0),
              ),
            );

            BoxDecoration darkThemeDecoration = const BoxDecoration(
              color: AppColors.backgroundColorDark,
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(70.0),
                topRight: Radius.circular(70.0),
              ),
            );

            return Stack(
              alignment: Alignment.bottomCenter,
              children: [
                Column(
                  children: [
                    Expanded(
                      flex: 3, // Zwiększenie proporcji przestrzeni dla obrazu
                      child: Container(
                        alignment: Alignment.center,
                        color: introModel.color,
                        child: AspectRatio(
                          aspectRatio: 1, // Utrzymuje proporcje obrazu
                          child: getAssetImage(
                            introModel.image ?? "",
                            FetchPixels.getPixelWidth(700),
                            FetchPixels.getPixelHeight(500),
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      flex: 2, // Zmniejszenie proporcji przestrzeni dla dolnych elementów
                      child: Container(
                        decoration: Theme.of(context).brightness == Brightness.light
                            ? lightThemeDecoration
                            : darkThemeDecoration,
                        width: FetchPixels.getPixelWidth(double.infinity),
                        height: FetchPixels.getPixelHeight(400),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            SizedBox(
                              width: FetchPixels.getPixelHeight(400),
                              child: Text(
                                introModel.title ?? "",
                                textAlign: TextAlign.center,
                                style: Theme.of(context).brightness ==
                                        Brightness.light
                                    ? AppTextStyles.extraLargeTextLight
                                    : AppTextStyles.extraLargeTextDark,
                              ),
                            ),
                            getVerSpace(FetchPixels.getPixelHeight(15)),
                            getPaddingWidget(
                              EdgeInsets.symmetric(
                                  horizontal: FetchPixels.getPixelWidth(20)),
                              SizedBox(
                                width: FetchPixels.getPixelHeight(400),
                                child: Text(
                                  introModel.description ?? "",
                                  textAlign: TextAlign.center,
                                  style: Theme.of(context).brightness ==
                                          Brightness.light
                                      ? AppTextStyles.mediumTextLight
                                      : AppTextStyles.mediumTextDark,
                                ),
                              ),
                            ),
                            getVerSpace(FetchPixels.getPixelHeight(25)),
                            DotsIndicator(
                              dotsCount: DataFile.introList.length,
                              position: index.toDouble().round(),
                              decorator: DotsDecorator(
                                activeColor: Theme.of(context).brightness ==
                                        Brightness.light
                                    ? AppColors.primaryColor
                                    : AppColors.secondaryColorDark,
                                color: Theme.of(context).brightness ==
                                        Brightness.light
                                    ? AppColors.secondaryColor
                                    : AppColors.tertiaryColorDark,
                                size: Size.square(
                                    FetchPixels.getPixelHeight(10)),
                                activeSize: Size.square(
                                    FetchPixels.getPixelHeight(15)),
                                spacing: EdgeInsets.symmetric(
                                    horizontal: FetchPixels.getPixelWidth(7)),
                              ),
                            ),
                            getVerSpace(FetchPixels.getPixelHeight(25)),
                            ElevatedButton(
                              onPressed: () {
                                if (index == DataFile.introList.length - 1) {
                                  Helper.sendToNext(
                                      context, const LoginScreen());
                                } else {
                                  _controller.animateToPage(
                                    index + 1,
                                    duration:
                                        const Duration(milliseconds: 250),
                                    curve: Curves.easeInSine,
                                  );
                                }
                              },
                              child: Text(
                                AppLocalizations.of(context)!.next,
                              ),
                            ),
                            getVerSpace(FetchPixels.getPixelHeight(10)),
                            TextButton(
                              onPressed: () {
                                                          if (index != 2) {
                                    Helper.sendToNext(
                                        context, const LoginScreen());
                                  }
                                },
                                child: index == 2
                                    ? Container()
                                    : Text(
                                        AppLocalizations.of(context)!.skip,
                                      ),
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              );
            },
          ),
        ),
      ),
    );
  }
}
Leave a Comment