基本完成APP的所有页面中的语言切换支持的开发和设计
This commit is contained in:
@@ -5,6 +5,8 @@ import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/components/BannerCarousel.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/locale_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/presentation/bloc/my_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/repository/my_repository.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/usecases/updatename_usecase.dart';
|
||||
@@ -80,10 +82,10 @@ class MyPage extends StatelessWidget {
|
||||
|
||||
Widget _buildFunctionList(BuildContext context) {
|
||||
final items = [
|
||||
{'icon': Icons.play_arrow, 'title': '操作视频', 'url': 'https://www.satabot.com/Support/index.html'},
|
||||
{'icon': Icons.car_rental, 'title': '租赁服务', 'url': 'https://www.satabot.com/Leasing.html'},
|
||||
{'icon': Icons.help_outline, 'title': '帮助与支持', 'url': 'https://www.satabot.com/support/index.html'},
|
||||
{'icon': Icons.policy, 'title': '售后政策', 'url': 'https://www.satabot.com/Aftersales-Service.html'},
|
||||
{'icon': Icons.play_arrow, 'title_key': 'my.operation_video', 'url': 'https://www.satabot.com/Support/index.html'},
|
||||
{'icon': Icons.car_rental, 'title_key': 'my.rental_service', 'url': 'https://www.satabot.com/Leasing.html'},
|
||||
{'icon': Icons.help_outline, 'title_key': 'my.help_support', 'url': 'https://www.satabot.com/support/index.html'},
|
||||
{'icon': Icons.policy, 'title_key': 'my.after_sales_policy', 'url': 'https://www.satabot.com/Aftersales-Service.html'},
|
||||
];
|
||||
|
||||
return Container(
|
||||
@@ -103,7 +105,7 @@ class MyPage extends StatelessWidget {
|
||||
final item = items[index];
|
||||
return ListTile(
|
||||
leading: Icon(item['icon'] as IconData),
|
||||
title: Text(item['title'] as String),
|
||||
title: Text(AppLocalizations.of(context).translate(item['title_key'] as String)),
|
||||
trailing: Icon(Icons.arrow_forward),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => WebViewPage(url: item['url'] as String)));
|
||||
@@ -113,10 +115,50 @@ class MyPage extends StatelessWidget {
|
||||
),
|
||||
// 分割线
|
||||
Divider(height: 1, color: Colors.grey.withOpacity(0.3)),
|
||||
|
||||
// 🔥 语言切换
|
||||
BlocBuilder<LocaleCubit, Locale>(
|
||||
builder: (context, locale) {
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.language, color: Colors.black),
|
||||
title: Text(AppLocalizations.of(context).translate('my.language'), style: TextStyle(color: Colors.black)),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => context.read<LocaleCubit>().setLocale(const Locale('zh', 'CN')),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('my.chinese'),
|
||||
style: TextStyle(
|
||||
color: locale.languageCode == 'zh' ? Colors.blue : Colors.grey,
|
||||
fontWeight: locale.languageCode == 'zh' ? FontWeight.bold : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
TextButton(
|
||||
onPressed: () => context.read<LocaleCubit>().setLocale(const Locale('en', 'US')),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('my.english'),
|
||||
style: TextStyle(
|
||||
color: locale.languageCode == 'en' ? Colors.blue : Colors.grey,
|
||||
fontWeight: locale.languageCode == 'en' ? FontWeight.bold : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
// 分割线
|
||||
Divider(height: 1, color: Colors.grey.withOpacity(0.3)),
|
||||
|
||||
// 退出登录按钮
|
||||
ListTile(
|
||||
leading: const Icon(Icons.logout, color: Colors.black),
|
||||
title: Text('退出登录', style: TextStyle(color: Colors.black)),
|
||||
title: Text(AppLocalizations.of(context).translate('login.logout'), style: TextStyle(color: Colors.black)),
|
||||
trailing: Icon(Icons.exit_to_app, color: Colors.black),
|
||||
onTap: () async {
|
||||
await GetIt.I<UserStorage>().deleteUser();
|
||||
|
||||
Reference in New Issue
Block a user