You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.1 KiB
Dart
68 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
class LanguageSelector extends StatefulWidget {
|
|
final String currentLanguage;
|
|
final ValueChanged<String> onLanguageChanged;
|
|
final List<Map<String, String>> languages;
|
|
|
|
const LanguageSelector({
|
|
super.key,
|
|
required this.currentLanguage,
|
|
required this.onLanguageChanged,
|
|
required this.languages,
|
|
});
|
|
|
|
@override
|
|
State<LanguageSelector> createState() => _LanguageSelectorState();
|
|
}
|
|
|
|
class _LanguageSelectorState extends State<LanguageSelector> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final currentLangData = widget.languages.firstWhere(
|
|
(lang) => lang['code'] == widget.currentLanguage,
|
|
orElse: () => {'code': 'en', 'name': 'English'},
|
|
);
|
|
|
|
return Stack(clipBehavior: Clip.none, children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
color: Color(0xFFFEE9EA),
|
|
),
|
|
height: 40,
|
|
width: 93,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
InkWell(
|
|
onTap: () {
|
|
final newLanguage = widget.currentLanguage == 'ar' ? 'en' : 'ar';
|
|
widget.onLanguageChanged(newLanguage);
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.all(8),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SvgPicture.asset("assets/images/svg/language.svg", width: 24),
|
|
const SizedBox(width: 8),
|
|
Text(
|
|
currentLangData['name']?.toUpperCase() ?? 'EN',
|
|
style: const TextStyle(fontWeight: FontWeight.w500, fontFamily: 'GESSTwo', fontSize: 14, color: Color(0xFFED1C2B)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
]);
|
|
}
|
|
}
|