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.
67 lines
2.1 KiB
Dart
67 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),
|
|
),
|
|
child: 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: 6),
|
|
Text(
|
|
currentLangData['name']?.toUpperCase() ?? 'EN',
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w500,
|
|
// fontFamily: 'GESSTwo',
|
|
fontFamily: (widget.currentLanguage == 'ar' ? 'Cairo' : 'Poppins'),
|
|
fontSize: 14,
|
|
color: const Color(0xFFED1C2B),
|
|
letterSpacing: 0.1),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
]);
|
|
}
|
|
}
|