Skip to content

Commit

Permalink
fix: launch review 0.5.8 (#5367)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xazin committed May 21, 2024
1 parent b7bc847 commit b2978e0
Show file tree
Hide file tree
Showing 19 changed files with 365 additions and 145 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import '../../shared/util.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('MoreViewActions', () {
testWidgets('can duplicate and delete from menu', (tester) async {
await tester.initializeAppFlowy();
await tester.tapAnonymousSignInButton();
await tester.pumpAndSettle();

final pageFinder = find.byType(ViewItem);
expect(pageFinder, findsNWidgets(1));

// Duplicate
await tester.openMoreViewActions();
await tester.duplicateByMoreViewActions();

expect(pageFinder, findsNWidgets(2));

// Delete
await tester.openMoreViewActions();
await tester.deleteByMoreViewActions();

expect(pageFinder, findsNWidgets(1));
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import 'document_copy_and_paste_test.dart' as document_copy_and_paste_test;
import 'document_create_and_delete_test.dart'
as document_create_and_delete_test;
import 'document_option_action_test.dart' as document_option_action_test;
import 'document_inline_page_reference_test.dart'
as document_inline_page_reference_test;
import 'document_more_actions_test.dart' as document_more_actions_test;
import 'document_text_direction_test.dart' as document_text_direction_test;
import 'document_with_cover_image_test.dart' as document_with_cover_image_test;
import 'document_with_database_test.dart' as document_with_database_test;
Expand All @@ -16,8 +19,6 @@ import 'document_with_inline_page_test.dart' as document_with_inline_page_test;
import 'document_with_outline_block_test.dart' as document_with_outline_block;
import 'document_with_toggle_list_test.dart' as document_with_toggle_list_test;
import 'edit_document_test.dart' as document_edit_test;
import 'document_inline_page_reference_test.dart'
as document_inline_page_reference_test;

void startTesting() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Expand All @@ -38,4 +39,5 @@ void startTesting() {
document_option_action_test.main();
document_with_image_block_test.main();
document_inline_page_reference_test.main();
document_more_actions_test.main();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'package:appflowy/core/config/kv.dart';
import 'package:appflowy/core/config/kv_keys.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
Expand All @@ -22,15 +27,13 @@ import 'package:appflowy/workspace/presentation/notifications/widgets/flowy_tab.
import 'package:appflowy/workspace/presentation/notifications/widgets/notification_button.dart';
import 'package:appflowy/workspace/presentation/notifications/widgets/notification_tab_bar.dart';
import 'package:appflowy/workspace/presentation/settings/shared/settings_body.dart';
import 'package:appflowy/workspace/presentation/widgets/more_view_actions/more_view_actions.dart';
import 'package:appflowy/workspace/presentation/widgets/more_view_actions/widgets/common_view_action.dart';
import 'package:appflowy/workspace/presentation/widgets/view_title_bar.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra_ui/widget/buttons/primary_button.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

import 'emoji.dart';
Expand Down Expand Up @@ -564,6 +567,44 @@ extension CommonOperations on WidgetTester {
);
await tapButton(button);
}

Future<void> openMoreViewActions() async {
final button = find.byType(MoreViewActions);
await tap(button);
await pumpAndSettle();
}

/// Presses on the Duplicate ViewAction in the [MoreViewActions] popup.
///
/// [openMoreViewActions] must be called beforehand!
///
Future<void> duplicateByMoreViewActions() async {
final button = find.descendant(
of: find.byType(ListView),
matching: find.byWidgetPredicate(
(widget) =>
widget is ViewAction && widget.type == ViewActionType.duplicate,
),
);
await tap(button);
await pump();
}

/// Presses on the Delete ViewAction in the [MoreViewActions] popup.
///
/// [openMoreViewActions] must be called beforehand!
///
Future<void> deleteByMoreViewActions() async {
final button = find.descendant(
of: find.byType(ListView),
matching: find.byWidgetPredicate(
(widget) =>
widget is ViewAction && widget.type == ViewActionType.delete,
),
);
await tap(button);
await pump();
}
}

extension SettingsFinder on CommonFinders {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class FontPickerScreen extends StatelessWidget {
}

class LanguagePickerPage extends StatefulWidget {
const LanguagePickerPage({
super.key,
});
const LanguagePickerPage({super.key});

@override
State<LanguagePickerPage> createState() => _LanguagePickerPageState();
Expand All @@ -43,7 +41,6 @@ class _LanguagePickerPageState extends State<LanguagePickerPage> {
@override
void initState() {
super.initState();

availableFonts = _availableFonts;
}

Expand Down Expand Up @@ -90,7 +87,6 @@ class _FontSelectorState extends State<FontSelector> {
@override
void initState() {
super.initState();

availableFonts = _availableFonts;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:appflowy/plugins/base/emoji/emoji_picker_header.dart';
import 'package:appflowy/plugins/base/emoji/emoji_search_bar.dart';
import 'package:appflowy/plugins/base/emoji/emoji_skin_tone.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_emoji_mart/flutter_emoji_mart.dart';
Expand Down Expand Up @@ -83,7 +84,9 @@ class _FlowyEmojiPickerState extends State<FlowyEmojiPicker> {
},
itemBuilder: (context, emojiId, emoji, callback) {
return FlowyIconButton(
iconPadding: const EdgeInsets.all(2.0),
iconPadding: PlatformExtension.isWindows
? const EdgeInsets.only(bottom: 2.0)
: const EdgeInsets.all(2),
icon: FlowyText(
emoji,
fontSize: 28.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ typedef WorkspaceSettingNotifyValue
class UserWorkspaceListener {
UserWorkspaceListener();

PublishNotifier<WorkspaceSettingNotifyValue>? _settingChangedNotifier =
final PublishNotifier<WorkspaceSettingNotifyValue> _settingChangedNotifier =
PublishNotifier();

FolderNotificationListener? _listener;
Expand All @@ -122,7 +122,7 @@ class UserWorkspaceListener {
void Function(WorkspaceSettingNotifyValue)? onSettingUpdated,
}) {
if (onSettingUpdated != null) {
_settingChangedNotifier?.addPublishListener(onSettingUpdated);
_settingChangedNotifier.addPublishListener(onSettingUpdated);
}

// The "current-workspace" is predefined in the backend. Do not try to
Expand All @@ -140,22 +140,18 @@ class UserWorkspaceListener {
switch (ty) {
case FolderNotification.DidUpdateWorkspaceSetting:
result.fold(
(payload) => _settingChangedNotifier?.value =
(payload) => _settingChangedNotifier.value =
FlowyResult.success(WorkspaceSettingPB.fromBuffer(payload)),
(error) =>
_settingChangedNotifier?.value = FlowyResult.failure(error),
(error) => _settingChangedNotifier.value = FlowyResult.failure(error),
);
break;

default:
break;
}
}

Future<void> stop() async {
await _listener?.stop();

_settingChangedNotifier?.dispose();
_settingChangedNotifier = null;
_settingChangedNotifier.dispose();
}
}
5 changes: 5 additions & 0 deletions frontend/appflowy_flutter/lib/util/theme_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:flutter/material.dart';

extension IsLightMode on ThemeData {
bool get isLightMode => brightness == Brightness.light;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ extension TimeFormatter on UserTimeFormatPB {
}

final _toFormat = {
UserTimeFormatPB.TwelveHour: DateFormat.Hm(),
UserTimeFormatPB.TwentyFourHour: DateFormat.jm(),
UserTimeFormatPB.TwentyFourHour: DateFormat.Hm(),
UserTimeFormatPB.TwelveHour: DateFormat.jm(),
};
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ class WorkspaceSettingsBloc
?.role ??
AFRolePB.Guest;

emit(state.copyWith(members: members, myRole: role));
emit(
state.copyWith(
workspace: currentWorkspaceInList,
members: members,
myRole: role,
),
);
} catch (e) {
Log.error('Failed to get or create current workspace');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class _WorkspaceIconState extends State<WorkspaceIcon> {
child: EmojiText(
emoji: widget.workspace.icon,
fontSize: widget.iconSize,
lineHeight: 1,
),
)
: Container(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'package:appflowy/env/cloud_env.dart';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/base/icon/icon_picker.dart';
Expand Down Expand Up @@ -78,46 +79,46 @@ class _SettingsAccountViewState extends State<SettingsAccountView> {
],
),

// Enable when/if we need change email feature
// // Only show change email if the user is authenticated and not using local auth
// if (isAuthEnabled &&
// state.userProfile.authenticator != AuthenticatorPB.Local) ...[
// const SettingsCategorySpacer(),
// SettingsCategory(
// title: LocaleKeys.settings_accountPage_email_title.tr(),
// children: [
// SingleSettingAction(
// label: state.userProfile.email,
// buttonLabel: LocaleKeys
// .settings_accountPage_email_actions_change
// .tr(),
// onPressed: () => SettingsAlertDialog(
// title: LocaleKeys
// .settings_accountPage_email_actions_change
// .tr(),
// confirmLabel: LocaleKeys.button_save.tr(),
// confirm: () {
// context.read<SettingsUserViewBloc>().add(
// SettingsUserEvent.updateUserEmail(
// _emailController.text,
// ),
// );
// Navigator.of(context).pop();
// },
// children: [
// SettingsInputField(
// label: LocaleKeys.settings_accountPage_email_title
// .tr(),
// value: state.userProfile.email,
// hideActions: true,
// textController: _emailController,
// ),
// ],
// ).show(context),
// ),
// ],
// ),
// ],
// Only show email if the user is authenticated and not using local auth
if (isAuthEnabled &&
state.userProfile.authenticator != AuthenticatorPB.Local) ...[
SettingsCategory(
title: LocaleKeys.settings_accountPage_email_title.tr(),
children: [
FlowyText.regular(state.userProfile.email),
// Enable when/if we need change email feature
// SingleSettingAction(
// label: state.userProfile.email,
// buttonLabel: LocaleKeys
// .settings_accountPage_email_actions_change
// .tr(),
// onPressed: () => SettingsAlertDialog(
// title: LocaleKeys
// .settings_accountPage_email_actions_change
// .tr(),
// confirmLabel: LocaleKeys.button_save.tr(),
// confirm: () {
// context.read<SettingsUserViewBloc>().add(
// SettingsUserEvent.updateUserEmail(
// _emailController.text,
// ),
// );
// Navigator.of(context).pop();
// },
// children: [
// SettingsInputField(
// label: LocaleKeys.settings_accountPage_email_title
// .tr(),
// value: state.userProfile.email,
// hideActions: true,
// textController: _emailController,
// ),
// ],
// ).show(context),
// ),
],
),
],

/// Enable when we have change password feature and 2FA
// const SettingsCategorySpacer(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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/startup/tasks/rust_sdk.dart';
import 'package:appflowy/util/theme_extension.dart';
import 'package:appflowy/workspace/application/settings/setting_file_importer_bloc.dart';
import 'package:appflowy/workspace/application/settings/settings_location_cubit.dart';
import 'package:appflowy/workspace/presentation/home/toast.dart';
Expand Down Expand Up @@ -55,6 +56,9 @@ class SettingsManageDataView extends StatelessWidget {
actions: [
if (state.mapOrNull(didReceivedPath: (_) => true) == true)
SettingAction(
tooltip: LocaleKeys
.settings_manageDataPage_dataStorage_actions_resetTooltip
.tr(),
icon: const FlowySvg(FlowySvgs.restore_s),
label: LocaleKeys.settings_common_reset.tr(),
onPressed: () => SettingsAlertDialog(
Expand Down Expand Up @@ -375,6 +379,8 @@ class _CurrentPathState extends State<_CurrentPath> {

@override
Widget build(BuildContext context) {
final isLM = Theme.of(context).isLightMode;

return Column(
children: [
Row(
Expand All @@ -392,7 +398,9 @@ class _CurrentPathState extends State<_CurrentPath> {
maxLines: 2,
overflow: TextOverflow.ellipsis,
decoration: isHovering ? TextDecoration.underline : null,
color: const Color(0xFF005483),
color: isLM
? const Color(0xFF005483)
: Theme.of(context).colorScheme.primary,
),
),
),
Expand Down

0 comments on commit b2978e0

Please sign in to comment.