import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';

import '../../constant/box_name.dart';
import '../../controller/local/local_controller.dart';
import '../auth/login_page.dart';
import '../home/map_page_passenger.dart';

class Language extends StatelessWidget {
  const Language({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: GetBuilder<LocaleController>(
      builder: (controller) => Center(
        child: Container(
          padding: const EdgeInsets.all(15),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              Text(
                "Choose Language".tr,
                style: Theme.of(context).textTheme.headlineLarge,
              ),
              const SizedBox(height: 20),
              MyElevatedButton(
                title: 'Ar',
                onPressed: () {
                  controller.changeLang("ar");
                  box.read(BoxName.email) != null
                      ? Get.offAll(() => const MapPagePassenger())
                      : Get.offAll(() => LoginPage());
                },
              ),
              MyElevatedButton(
                title: "En",
                onPressed: () {
                  controller.changeLang("en");
                  box.read(BoxName.email) != null
                      ? Get.offAll(() => const MapPagePassenger())
                      : Get.offAll(() => LoginPage());
                },
              ),
              MyElevatedButton(
                title: "Tr",
                onPressed: () {
                  controller.changeLang("tr");
                  box.read(BoxName.email) != null
                      ? Get.offAll(() => const MapPagePassenger())
                      : Get.offAll(() => LoginPage());
                },
              ),
            ],
          ),
        ),
      ),
    ));
  }
}
