An open-source cross-platform alternative to AirDrop
feat: add language page
Tien Do Nambc6a91ce9fcb
diff --git a/assets/CHANGELOG.md b/assets/CHANGELOG.mdindex ab431311..fe6f5248 100644--- a/assets/CHANGELOG.md+++ b/assets/CHANGELOG.md@@ -1,7 +1,8 @@## 1.7.0 (2023-)- feat: received file history-- feat: add unencrypted HTTP mode+- feat: add unencrypted HTTP mode (for debugging)+- feat: separate language settings page- feat: message input is horizontally scrollable when multiline is unselected- feat: open message normally in QuickSave mode (instead of saving it into a file)- feat(windows): use "Microsoft YaHei UI" font in Windows which works better with Chinese charactersdiff --git a/lib/pages/language_page.dart b/lib/pages/language_page.dartnew file mode 100644index 00000000..aeecced4--- /dev/null+++ b/lib/pages/language_page.dart@@ -0,0 +1,58 @@+import 'package:flutter/material.dart';+import 'package:flutter_riverpod/flutter_riverpod.dart';+import 'package:localsend_app/gen/strings.g.dart';+import 'package:localsend_app/provider/settings_provider.dart';+import 'package:localsend_app/widget/responsive_list_view.dart';++class LanguagePage extends ConsumerWidget {+ const LanguagePage({Key? key}) : super(key: key);++ @override+ Widget build(BuildContext context, WidgetRef ref) {+ final t = Translations.of(context);+ final activeLocale = ref.watch(settingsProvider.select((s) => s.locale));+ return Scaffold(+ appBar: AppBar(+ title: Text(t.settingsTab.general.language),+ ),+ body: ResponsiveListView(+ padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 20),+ children: [+ ...[+ null,+ ...AppLocale.values,+ ].map((locale) {+ return ListTile(+ onTap: () async {+ await ref.read(settingsProvider.notifier).setLocale(locale);+ if (locale == null) {+ LocaleSettings.useDeviceLocale();+ } else {+ LocaleSettings.setLocale(locale);+ }+ },+ title: Row(+ children: [+ Flexible(+ child: Text(locale?.humanName ?? t.settingsTab.general.languageOptions.system),+ ),+ if (locale == activeLocale)+ ...[+ const SizedBox(width: 10),+ const Icon(Icons.check_circle, color: Colors.green),+ ],+ ],+ ),+ );+ }),+ ],+ ),+ );+ }+}++extension AppLocaleExt on AppLocale {+ String get humanName {+ return LocaleSettings.instance.translationMap[this]!.locale;+ }+}diff --git a/lib/pages/tabs/settings_tab.dart b/lib/pages/tabs/settings_tab.dartindex 129232e6..f835098b 100644--- a/lib/pages/tabs/settings_tab.dart+++ b/lib/pages/tabs/settings_tab.dart@@ -5,6 +5,7 @@ import 'package:localsend_app/constants.dart';import 'package:localsend_app/gen/strings.g.dart';import 'package:localsend_app/pages/about_page.dart';import 'package:localsend_app/pages/changelog_page.dart';+import 'package:localsend_app/pages/language_page.dart';import 'package:localsend_app/provider/network/server_provider.dart';import 'package:localsend_app/provider/settings_provider.dart';import 'package:localsend_app/provider/version_provider.dart';@@ -78,30 +79,22 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {),_SettingsEntry(label: t.settingsTab.general.language,- child: CustomDropdownButton<AppLocale?>(- value: settings.locale,- items: [- DropdownMenuItem(- value: null,- alignment: Alignment.center,- child: Text(t.settingsTab.general.languageOptions.system),- ),- ...AppLocale.values.map((locale) {- return DropdownMenuItem(- value: locale,- alignment: Alignment.center,- child: Text(locale.humanName, textAlign: TextAlign.center),- );- }),- ],- onChanged: (locale) async {- await ref.read(settingsProvider.notifier).setLocale(locale);- if (locale == null) {- LocaleSettings.useDeviceLocale();- } else {- LocaleSettings.setLocale(locale);- }+ child: TextButton(+ style: TextButton.styleFrom(+ backgroundColor: Theme.of(context).inputDecorationTheme.fillColor,+ shape: RoundedRectangleBorder(borderRadius: Theme.of(context).inputDecorationTheme.borderRadius),+ foregroundColor: Theme.of(context).colorScheme.onSurface,+ ),+ onPressed: () {+ context.push(() => const LanguagePage());},+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 5),+ child: Text(+ settings.locale?.humanName ?? t.settingsTab.general.languageOptions.system,+ style: Theme.of(context).textTheme.subtitle1,+ ),+ ),),),if (checkPlatformIsDesktop()) ...[@@ -314,9 +307,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {},),AnimatedCrossFade(- crossFadeState: settings.port != defaultPort- ? CrossFadeState.showSecond- : CrossFadeState.showFirst,+ crossFadeState: settings.port != defaultPort ? CrossFadeState.showSecond : CrossFadeState.showFirst,duration: const Duration(milliseconds: 200),alignment: Alignment.topLeft,firstChild: Container(),@@ -478,9 +469,3 @@ extension on ThemeMode {}}}--extension on AppLocale {- String get humanName {- return LocaleSettings.instance.translationMap[this]!.locale;- }-}