fix: settings page minor issues (#6354)

This commit is contained in:
Lucas 2024-09-19 13:40:08 +08:00 committed by GitHub
parent da03f40d29
commit aa06c78b68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 93 additions and 43 deletions

View File

@ -3,6 +3,7 @@ import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/shared/appflowy_cache_manager.dart';
import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/util/share_log_files.dart';
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
import 'package:appflowy/workspace/application/settings/appflowy_cloud_urls_bloc.dart';
import 'package:appflowy/workspace/application/settings/settings_dialog_bloc.dart';
import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';
@ -14,7 +15,6 @@ import 'package:appflowy/workspace/presentation/settings/pages/settings_plan_vie
import 'package:appflowy/workspace/presentation/settings/pages/settings_shortcuts_view.dart';
import 'package:appflowy/workspace/presentation/settings/pages/settings_workspace_view.dart';
import 'package:appflowy/workspace/presentation/settings/shared/settings_category.dart';
import 'package:appflowy/workspace/presentation/settings/shared/settings_category_spacer.dart';
import 'package:appflowy/workspace/presentation/settings/widgets/feature_flags/feature_flag_page.dart';
import 'package:appflowy/workspace/presentation/settings/widgets/members/workspace_member_page.dart';
import 'package:appflowy/workspace/presentation/settings/widgets/settings_menu.dart';
@ -26,6 +26,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:toastification/toastification.dart';
import 'widgets/setting_cloud.dart';
@ -167,22 +168,35 @@ class _SimpleSettingsDialogState extends State<SimpleSettingsDialog> {
@override
Widget build(BuildContext context) {
context.watch<AppearanceSettingsCubit>();
return FlowyDialog(
width: MediaQuery.of(context).size.width * 0.7,
constraints: const BoxConstraints(maxWidth: 784, minWidth: 564),
child: const Padding(
padding: EdgeInsets.all(24.0),
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// header
FlowyText(
LocaleKeys.signIn_settings.tr(),
fontSize: 36.0,
fontWeight: FontWeight.w600,
),
const VSpace(18.0),
// language
_LanguageSettings(),
SettingsCategorySpacer(),
const _LanguageSettings(),
const VSpace(22.0),
// self-host cloud
_SelfHostSettings(),
SettingsCategorySpacer(),
const _SelfHostSettings(),
const VSpace(22.0),
// support
_SupportSettings(),
const _SupportSettings(),
],
),
),
@ -232,17 +246,33 @@ class _SelfHostSettingsState extends State<_SelfHostSettings> {
return SettingsCategory(
title: LocaleKeys.settings_menu_cloudAppFlowySelfHost.tr(),
children: [
SizedBox(
height: 48,
child: FlowyTextField(
controller: textController,
autoFocus: false,
textStyle: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
Row(
children: [
Expanded(
child: SizedBox(
height: 36,
child: FlowyTextField(
controller: textController,
autoFocus: false,
textStyle: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
),
hintText: 'https://beta.appflowy.cloud',
onEditingComplete: _saveSelfHostUrl,
),
),
),
onEditingComplete: _saveSelfHostUrl,
),
const HSpace(12.0),
Container(
height: 36,
constraints: const BoxConstraints(minWidth: 78),
child: OutlinedRoundedButton(
text: LocaleKeys.button_save.tr(),
onTap: _saveSelfHostUrl,
),
),
],
),
],
);
@ -251,16 +281,33 @@ class _SelfHostSettingsState extends State<_SelfHostSettings> {
void _saveSelfHostUrl() {
final url = textController.text;
if (url.isEmpty) {
showToastNotification(
context,
message: LocaleKeys.settings_menu_pleaseInputValidURL.tr(),
type: ToastificationType.error,
);
return;
}
validateUrl(url).fold(
(url) async {
showToastNotification(
context,
message: LocaleKeys.settings_menu_changeUrl.tr(args: [url]),
);
Navigator.of(context).pop();
await useSelfHostedAppFlowyCloudWithURL(url);
await runAppFlowy();
},
(err) => Log.error(err),
(err) {
showToastNotification(
context,
message: LocaleKeys.settings_menu_pleaseInputValidURL.tr(),
type: ToastificationType.error,
);
Log.error(err);
},
);
}
}
@ -280,11 +327,14 @@ class _SupportSettings extends StatelessWidget {
LocaleKeys.workspace_errorActions_exportLogFiles.tr(),
),
const Spacer(),
OutlinedRoundedButton(
text: LocaleKeys.settings_files_export.tr(),
onTap: () {
shareLogFiles(context);
},
ConstrainedBox(
constraints: const BoxConstraints(minWidth: 78),
child: OutlinedRoundedButton(
text: LocaleKeys.settings_files_export.tr(),
onTap: () {
shareLogFiles(context);
},
),
),
],
),
@ -295,19 +345,22 @@ class _SupportSettings extends StatelessWidget {
LocaleKeys.settings_files_clearCache.tr(),
),
const Spacer(),
OutlinedRoundedButton(
text: LocaleKeys.button_clear.tr(),
onTap: () async {
await getIt<FlowyCacheManager>().clearAllCache();
if (context.mounted) {
showToastNotification(
context,
message: LocaleKeys
.settings_manageDataPage_cache_dialog_successHint
.tr(),
);
}
},
ConstrainedBox(
constraints: const BoxConstraints(minWidth: 78),
child: OutlinedRoundedButton(
text: LocaleKeys.button_clear.tr(),
onTap: () async {
await getIt<FlowyCacheManager>().clearAllCache();
if (context.mounted) {
showToastNotification(
context,
message: LocaleKeys
.settings_manageDataPage_cache_dialog_successHint
.tr(),
);
}
},
),
),
],
),

View File

@ -25,8 +25,6 @@ PODS:
- FlutterMacOS
- local_notifier (0.1.0):
- FlutterMacOS
- open_file_mac (0.0.1):
- FlutterMacOS
- package_info_plus (0.0.1):
- FlutterMacOS
- path_provider_foundation (0.0.1):
@ -68,7 +66,6 @@ DEPENDENCIES:
- hotkey_manager (from `Flutter/ephemeral/.symlinks/plugins/hotkey_manager/macos`)
- irondash_engine_context (from `Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos`)
- local_notifier (from `Flutter/ephemeral/.symlinks/plugins/local_notifier/macos`)
- open_file_mac (from `Flutter/ephemeral/.symlinks/plugins/open_file_mac/macos`)
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
@ -111,8 +108,6 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/irondash_engine_context/macos
local_notifier:
:path: Flutter/ephemeral/.symlinks/plugins/local_notifier/macos
open_file_mac:
:path: Flutter/ephemeral/.symlinks/plugins/open_file_mac/macos
package_info_plus:
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
path_provider_foundation:
@ -148,7 +143,6 @@ SPEC CHECKSUMS:
hotkey_manager: c32bf0bfe8f934b7bc17ab4ad5c4c142960b023c
irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478
local_notifier: e9506bc66fc70311e8bc7291fb70f743c081e4ff
open_file_mac: 0e554648e2a87ce59e9438e3e5ca3e552e90d89a
package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979

View File

@ -91,6 +91,7 @@ class OutlinedRoundedButton extends StatelessWidget {
text: FlowyText.regular(
text,
lineHeight: 1.0,
textAlign: TextAlign.center,
),
onTap: onTap,
),

View File

@ -953,6 +953,8 @@
"selfHostStart": "If you don't have a server, please refer to the",
"selfHostContent": "document",
"selfHostEnd": "for guidance on how to self-host your own server",
"pleaseInputValidURL": "Please input a valid URL",
"changeUrl": "Change self-hosted url to {}",
"cloudURLHint": "Input the base URL of your server",
"cloudWSURL": "Websocket URL",
"cloudWSURLHint": "Input the websocket address of your server",