Untitled

 avatar
unknown
dart
3 years ago
3.9 kB
2
Indexable
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:iketfaa_delivery/App/Common/Modules/Error/controller/error_controller.dart';
import 'package:iketfaa_delivery/App/Common/Modules/Splash/binding/splash_binding.dart';
import 'package:iketfaa_delivery/App/Common/Widgets/RestartMainWidget.dart';
import 'package:iketfaa_delivery/App/Common/Services/settings_service.dart';
import 'package:iketfaa_delivery/App/Common/Utilities/Constants/AppColors.dart';
import 'package:iketfaa_delivery/App/Common/Widgets/Background.dart';
import 'package:iketfaa_delivery/App/Common/Widgets/CustomButton.dart';

class ErrorView extends GetView<ErrorController> {
  @override
  Widget build(BuildContext context) {
    return Background(
      child: Scaffold(
        backgroundColor: AppColors.backgroundColor,
        body: SingleChildScrollView(
          child: Container(
            height: Get.height,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisSize: MainAxisSize.max,
              children: [
                Container(
                  width: Get.width,
                  height: Get.height * 0.35,
                  child: Column(
                    mainAxisSize: MainAxisSize.max,
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Container(
                        width: Get.width * 0.3,
                        height: Get.width * 0.3,
                        padding: const EdgeInsets.all(25.0),
                        decoration: const BoxDecoration(
                            color: AppColors.primary, shape: BoxShape.circle),
                        child: SvgPicture.asset(
                          'assets/svg/TryAgain.svg',
                        ),
                      ),
                      const SizedBox(
                        height: 20.0,
                      ),
                      Text(
                        'errorPageTitle'.tr,
                        style: Get.textTheme.headline3,
                      ),
                      const SizedBox(
                        height: 20.0,
                      ),
                      Text(
                        'errorPageMessage'.tr,
                        style: Get.textTheme.headline5!
                            .copyWith(color: AppColors.black.withOpacity(0.5)),
                      )
                    ],
                  ),
                ).marginOnly(
                  bottom: Get.height * 0.2,
                ),
                CustomButton(
                    background: AppColors.primary,
                    text: Text('errorPageTryButton'.tr,
                        style: Get.textTheme.headline6!.copyWith(
                          color: AppColors.white,
                        )),
                    borderRadius: 8.0,
                    padding: const EdgeInsets.all(12.0),
                    width: Get.width * 0.8,
                    height: Get.width * 0.15,
                    shadow: false,
                    onTap: () async {
                      await Get.deleteAll(force: true);
                      Get.reset();
                      await Get.putAsync(() => SettingsService().init());

                      SplashBinding().dependencies();

                      await Firebase.initializeApp();

                      await GetStorage.init();
                      RestartWidget.restartApp(context);
                    }).marginSymmetric(vertical: 25.0),
              ],
            ).marginSymmetric(horizontal: 10.0),
          ),
        ),
      ),
    );
  }
}