Files
Siro/siro_driver/lib/views/lang/languages.dart
2026-06-09 08:40:31 +03:00

146 lines
4.5 KiB
Dart
Executable File

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:siro_driver/views/home/Captin/home_captain/home_captin.dart';
import '../../constant/finance_design_system.dart';
import '../../controller/local/local_controller.dart';
class Language extends StatelessWidget {
const Language({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text('Choose Language'.tr),
border: null,
),
child: Material(
// Wrap SafeArea with Material widget
child: SafeArea(
child: GetBuilder<LocaleController>(
builder: (controller) => Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildHeader(),
const SizedBox(height: 20),
Expanded(
child: ListView(
physics: const BouncingScrollPhysics(),
children: [
_buildLanguageButton(
'العربية', 'ar', controller, context, 'AR'),
_buildLanguageButton(
'English', 'en', controller, context, 'EN'),
],
),
),
],
),
),
),
),
),
),
);
}
Widget _buildHeader() {
return Padding(
padding: const EdgeInsets.only(top: 20, bottom: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Language Options'.tr,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: CupertinoColors.black, // Or your theme primary color
),
textAlign: TextAlign.start,
),
const SizedBox(height: 8),
Text(
'Select your preferred language for the app interface.',
style: TextStyle(
fontSize: 16,
color: CupertinoColors.secondaryLabel,
),
textAlign: TextAlign.start,
),
],
),
);
}
Widget _buildLanguageButton(String title, String langCode,
LocaleController controller, BuildContext context, String flagIcon) {
return Container(
margin: const EdgeInsets.only(bottom: 12),
decoration: BoxDecoration(
color: CupertinoColors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.03),
spreadRadius: 1,
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
leading: Container(
width: 44,
height: 44,
decoration: BoxDecoration(
color: FinanceDesignSystem.primaryDark.withOpacity(0.05),
borderRadius: BorderRadius.circular(12),
),
alignment: Alignment.center,
child: Text(
flagIcon,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: FinanceDesignSystem.primaryDark,
),
),
),
title: Text(
title,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
),
),
trailing: const Icon(CupertinoIcons.chevron_forward,
color: CupertinoColors.inactiveGray),
onTap: () async {
controller.changeLang(langCode);
showCupertinoDialog(
context: context,
builder: (context) => CupertinoAlertDialog(
title: Text('You should restart app to change language'.tr),
actions: [
CupertinoDialogAction(
child: Text('Ok'.tr),
onPressed: () {
Get.offAll(() => HomeCaptain());
},
),
],
),
);
},
),
);
}
}