170 lines
6.3 KiB
Dart
170 lines
6.3 KiB
Dart
import 'package:ef/ef.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:vbvs_app/common/util/FitTool.dart';
|
|
import 'package:vbvs_app/common/util/MyUtils.dart';
|
|
import 'package:vbvs_app/controller/mh_controller/message_controller.dart';
|
|
|
|
import 'package:vbvs_app/controller/mh_controller/mh_language_controller.dart';
|
|
|
|
class LanguagePage extends GetView<MHLanguageController> {
|
|
// @override
|
|
// _LanguagePageState createState() => _LanguagePageState();
|
|
// }
|
|
MHLanguageController controller = Get.find();
|
|
BoxConstraints? bodysize;
|
|
// List<String> languageList = [
|
|
// '简体中文',
|
|
// '繁體中文',
|
|
// 'English',
|
|
// ];
|
|
// final Map<String, String> languageMap = {
|
|
// '简体中文': 'zh_CN',
|
|
// '繁體中文': 'zh_TW',
|
|
// 'English': 'en_US',
|
|
// };
|
|
|
|
// class _LanguagePageState extends State<LanguagePage> {
|
|
RxBool checkboxValue = false.obs;
|
|
RxString? selectLanguage = ''.obs;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return LayoutBuilder(builder: (context, cc) {
|
|
bodysize = cc;
|
|
return GestureDetector(
|
|
onTap: () {
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
},
|
|
child: Container(
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('assets/images/new_background.png'), // 本地图片
|
|
fit: BoxFit.fill, // 填满整个 Container
|
|
),
|
|
),
|
|
child: Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.transparent,
|
|
iconTheme: const IconThemeData(color: Colors.white),
|
|
automaticallyImplyLeading: false,
|
|
titleSpacing: 0,
|
|
title: SizedBox(
|
|
width: double.infinity,
|
|
height: 180.rpx,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
// 中间居中的标题
|
|
Text(
|
|
'切换语言'.tr,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 30.rpx,
|
|
),
|
|
),
|
|
// 左侧图标
|
|
Positioned(
|
|
left: 0.rpx,
|
|
child: returnIconButtomNew,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
centerTitle: false,
|
|
),
|
|
body: SafeArea(
|
|
top: true,
|
|
child: Padding(
|
|
padding: EdgeInsets.only(
|
|
top: 30.rpx, left: 30.rpx, right: 30.rpx),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Color(0XFF003058),
|
|
borderRadius: BorderRadius.circular(16.rpx)),
|
|
child: Padding(
|
|
padding: EdgeInsets.only(
|
|
left: 40.rpx,
|
|
top: 20.rpx,
|
|
bottom: 20.rpx,
|
|
right: 30.rpx),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
ListView.builder(
|
|
padding: EdgeInsets.zero,
|
|
shrinkWrap: true,
|
|
scrollDirection: Axis.vertical,
|
|
itemCount: controller.languageList.length,
|
|
itemBuilder:
|
|
(BuildContext context, int index) {
|
|
return _buildItem(context, index,
|
|
controller.languageList[index]);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
))))),
|
|
));
|
|
});
|
|
}
|
|
|
|
Widget _buildItem(BuildContext context, int index, MHLanguageModel model) {
|
|
return GestureDetector(
|
|
onTap: () {
|
|
controller.selectLanguage.value = model;
|
|
},
|
|
child: Container(
|
|
height: bodysize!.maxHeight * 0.055,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
model.language_name ?? "",
|
|
style: TextStyle(color: Colors.white, fontSize: 30.rpx),
|
|
),
|
|
Obx(() {
|
|
double h = 33.rpx;
|
|
bool check = controller.selectLanguage.value?.language_code ==
|
|
model.language_code;
|
|
|
|
return Container(
|
|
height: 33.rpx,
|
|
child: AspectRatio(
|
|
aspectRatio: 1,
|
|
child: Center(
|
|
child: Container(
|
|
height: h,
|
|
width: h,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(h / 2),
|
|
border: Border.all(
|
|
width: check ? 1 : 0.5,
|
|
color: Color(0xFFC8CBD2),
|
|
),
|
|
),
|
|
child: check
|
|
? Center(
|
|
child: ClipOval(
|
|
child: Container(
|
|
width: h * 0.6,
|
|
height: h * 0.6,
|
|
color: const Color(0xFF6BFDAC),
|
|
),
|
|
),
|
|
)
|
|
: null,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
],
|
|
),
|
|
)
|
|
// width: bodysize!.maxWidth * 1,
|
|
|
|
);
|
|
}
|
|
}
|