133 lines
4.4 KiB
Dart
133 lines
4.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:Tripz/views/widgets/elevated_btn.dart';
|
|
|
|
import '../../controller/local/local_controller.dart';
|
|
import '../home/map_page_passenger.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: SafeArea(
|
|
child: GetBuilder<LocaleController>(
|
|
builder: (controller) => Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
children: [
|
|
_buildHeader(),
|
|
const SizedBox(height: 20),
|
|
Expanded(
|
|
child: ListView(
|
|
physics: const BouncingScrollPhysics(),
|
|
children: [
|
|
_buildLanguageButton(
|
|
'العربية', 'ar', controller, context),
|
|
_buildLanguageButton(
|
|
'English', 'en', controller, context),
|
|
_buildLanguageButton(
|
|
'Türkçe', 'tr', controller, context),
|
|
_buildLanguageButton(
|
|
'Français', 'fr', controller, context),
|
|
_buildLanguageButton(
|
|
'Italiano', 'it', controller, context),
|
|
_buildLanguageButton(
|
|
'Deutsch', 'de', controller, context),
|
|
_buildLanguageButton(
|
|
'Ελληνικά', 'el', controller, context),
|
|
_buildLanguageButton(
|
|
'Español', 'es', controller, context),
|
|
_buildLanguageButton(
|
|
'فارسی', 'fa', controller, context),
|
|
_buildLanguageButton('中文', 'zh', controller, context),
|
|
_buildLanguageButton(
|
|
'Русский', 'ru', controller, context),
|
|
_buildLanguageButton(
|
|
'हिन्दी', 'hi', controller, context),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildHeader() {
|
|
return Container(
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
gradient: const LinearGradient(
|
|
colors: [Color(0xFF2196F3), Color(0xFF1976D2)],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: CupertinoColors.systemBlue.withOpacity(0.2),
|
|
blurRadius: 10,
|
|
offset: const Offset(0, 4),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
children: [
|
|
const Icon(
|
|
CupertinoIcons.globe,
|
|
color: CupertinoColors.white,
|
|
size: 48,
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
'Choose Language'.tr,
|
|
style: const TextStyle(
|
|
color: CupertinoColors.white,
|
|
fontSize: 22,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildLanguageButton(String title, String langCode,
|
|
LocaleController controller, BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
child: MyElevatedButton(
|
|
title: title,
|
|
onPressed: () 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(() => MapPagePassenger());
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
));
|
|
}
|
|
}
|