88 lines
2.7 KiB
Dart
88 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
|
import 'package:mymuseum_visitapp/app_context.dart';
|
|
import 'package:mymuseum_visitapp/constants.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class LanguageSelection extends StatefulWidget {
|
|
const LanguageSelection();
|
|
|
|
@override
|
|
_LanguageSelection createState() => _LanguageSelection();
|
|
}
|
|
|
|
class _LanguageSelection extends State<LanguageSelection> with TickerProviderStateMixin {
|
|
List<String>? languagesEnable;
|
|
double flagSize = 60;
|
|
|
|
String? selectedLanguage;
|
|
double? elementMinimizedSize;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final appContext = Provider.of<AppContext>(context);
|
|
Size size = MediaQuery.of(context).size;
|
|
print("YOLOO");
|
|
selectedLanguage = (appContext.getContext() as VisitAppContext).language;
|
|
print(selectedLanguage);
|
|
languagesEnable = ["FR", "EN", "NL", "DE"]; // TODO
|
|
//languagesEnable = (appContext.getContext() as VisitAppContext).configuration!.languages; // Todo filter language possible
|
|
print(languagesEnable);
|
|
|
|
return PopupMenuButton(
|
|
icon: Container(
|
|
height: size.height *0.07,
|
|
width: size.width *0.07,
|
|
decoration: flagDecoration(selectedLanguage!),
|
|
),
|
|
itemBuilder: (context){
|
|
int i = 0;
|
|
List<PopupMenuItem> menuItems = [];
|
|
for(var language in languagesEnable!) {
|
|
menuItems.add(PopupMenuItem<int>(
|
|
value: i,
|
|
child: Center(
|
|
child: Container(
|
|
width: size.width *0.07,
|
|
height: size.width *0.07,
|
|
decoration: flagDecoration(language),
|
|
)
|
|
),
|
|
));
|
|
i = i+1;
|
|
}
|
|
return menuItems;
|
|
},
|
|
onSelected:(value){
|
|
// TODO update App context + update local DB
|
|
if(value == 0){
|
|
print("My account menu is selected.");
|
|
}else if(value == 1){
|
|
print("Settings menu is selected.");
|
|
}else if(value == 2){
|
|
print("Logout menu is selected.");
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
flagDecoration(String language) {
|
|
return BoxDecoration(
|
|
color: kBackgroundColor,
|
|
shape: BoxShape.circle,
|
|
//border: Border.all(width: 1.5, color: kSecondGrey),
|
|
image: DecorationImage(
|
|
fit: BoxFit.contain,
|
|
image: AssetImage("assets/images/"+language+".png"),
|
|
),
|
|
boxShadow: const [
|
|
BoxShadow(
|
|
color: kSecondGrey,
|
|
spreadRadius: 0.5,
|
|
blurRadius: 5,
|
|
offset: Offset(0, 1.5), // changes position of shadow
|
|
),
|
|
],
|
|
);
|
|
}
|
|
} |