import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../../../app/app.dart';
import 'controller.dart';

class ChangeLanguage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Material(
      color: ThemeColor.white,
      child: GetX<LanguageController>(
        init: LanguageController(),
        builder: (lc) => SafeArea(
          child: Scaffold(
            appBar: CustomAppbarWidget(
              leading: AppBarBackBtn(),
              elevation: 2,
            ),
            body: Container(
              padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.h),
              child: SingleChildScrollView(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    AppTheme.appSizeDivider20H,
                    Text('change_lang'.tr, style: AppTheme.headerStyle),
                    AppTheme.appSizeDivider20H,
                    AppTheme.appColorDivider,
                    AppTheme.appSizeDivider20H,
                    Column(
                      children: lc.languages
                          .map(
                            (language) => Column(
                              children: [
                                RadioListTile(
                                  contentPadding: EdgeInsets.zero,
                                  value: language.id,
                                  groupValue: lc.groupValue.value,
                                  onChanged: (_) => lc.onChangeLanguage(language),
                                  title: Row(
                                    // mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                    children: [
                                      Image.asset(
                                        'assets/flags/${language.icon}',
                                        height: 20.h,
                                        width: 20.w,
                                      ),
                                      SizedBox(width: 12),
                                      Text(
                                        language.language,
                                        style: AppTheme.radioListTxtStyle,
                                      ),
                                    ],
                                  ),
                                ),
                                AppTheme.appColorDivider,
                              ],
                            ),
                          )
                          .toList(),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
