YSSettingLanguage.dart 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_wallet/base/YSBase.dart';
  3. import 'package:flutter_wallet/generated/l10n.dart';
  4. import 'package:flutter_wallet/tools/YSColors.dart';
  5. import 'package:flutter_wallet/tools/YSLoadData.dart';
  6. import 'package:flutter_wallet/tools/YSTools.dart';
  7. class YSSettingLanguage extends StatefulWidget {
  8. const YSSettingLanguage({Key? key}) : super(key: key);
  9. @override
  10. YSSettingLanguageState createState() => YSSettingLanguageState();
  11. }
  12. class YSSettingLanguageState extends State<YSSettingLanguage> {
  13. final List _list = [
  14. {'title':'中文','type':'zh'},
  15. {'title':'English','type':'en'},
  16. {'title':'日本語','type':'ja'},
  17. {'title':'Русский','type':'ru'},
  18. {'title':'Français','type':'fr'},
  19. {'title':'한국인','type':'ko'}
  20. ];
  21. @override
  22. Widget build(BuildContext context) {
  23. return YSBase(
  24. ysTitle: S.current.YUYANSHEZHI,
  25. ysChild: Container(
  26. width: ysWidth(context),
  27. color: YSColors.containColor(context),
  28. child: ListView.separated(
  29. itemBuilder: (context,index){
  30. Map item = _list[index];
  31. bool isChoose = item['type']==YSUserRecord().language;
  32. return GestureDetector(
  33. onTap: (){
  34. setState(() {
  35. YSUserRecord().language = item['type'];
  36. });
  37. YSLanguage().changeLanguage(context, item['type']);
  38. YSSharedPreferences.setStringValue('language', item['type']);
  39. },
  40. behavior: HitTestBehavior.opaque,
  41. child: Padding(
  42. padding: EdgeInsets.only(top: hsp(15),bottom: hsp(15)),
  43. child: Row(
  44. children: [
  45. Expanded(child: Text(item['title'],style: YSColors.contentStyle(context),)),
  46. if(isChoose)Icon(Icons.check_circle,size: hsp(20),color: YSColors.iconColor(context),)
  47. ],
  48. ),
  49. ),
  50. );
  51. },
  52. separatorBuilder: (context,index){
  53. return Divider(height: hsp(1),color: YSColors.lineColor(context),);
  54. },
  55. itemCount: _list.length,
  56. shrinkWrap: true,
  57. physics: const NeverScrollableScrollPhysics(),
  58. padding: EdgeInsets.only(left: hsp(15),right: hsp(15)),
  59. ),
  60. ),
  61. );
  62. }
  63. }