feat: expand the view automatically upon opening (#5180)

* chore: remove unused code

* feat: expand the view automatically upon opening
This commit is contained in:
Lucas.Xu 2024-04-22 16:57:51 +08:00 committed by GitHub
parent fe32079ab0
commit 0355ca5d73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 18 additions and 28 deletions

View File

@ -224,21 +224,6 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {
}
SignInState _stateFromCode(FlowyError error) {
// edge case: 429 is the rate limit error code
// since the error code and error msg are saved in the msg field,
// we need to check if the msg contains 429
final msg = error.msg;
if (msg.isNotEmpty) {
if (msg.contains('429')) {
return state.copyWith(
isSubmitting: false,
successOrFail: FlowyResult.failure(
FlowyError(msg: LocaleKeys.signIn_limitRateError.tr()),
),
);
}
}
switch (error.code) {
case ErrorCode.EmailFormatInvalid:
return state.copyWith(

View File

@ -61,9 +61,9 @@ class _SignInWithMagicLinkButtonsState
);
return;
}
if (context.read<SignInBloc>().state.isSubmitting) {
return;
}
// if (context.read<SignInBloc>().state.isSubmitting) {
// return;
// }
context.read<SignInBloc>().add(SignInEvent.signedWithMagicLink(email));
showSnackBarMessage(
context,

View File

@ -39,7 +39,7 @@ class FolderBloc extends Bloc<FolderEvent, FolderState> {
},
expandOrUnExpand: (e) async {
final isExpanded = e.isExpanded ?? !state.isExpanded;
await _setFolderExpandStatus(e.isExpanded ?? !state.isExpanded);
await _setFolderExpandStatus(isExpanded);
emit(state.copyWith(isExpanded: isExpanded));
},
);

View File

@ -52,14 +52,14 @@ class FavoriteFolder extends StatelessWidget {
isFeedback: false,
view: view,
level: 0,
onSelected: (view) {
onSelected: (view, _) {
if (HardwareKeyboard.instance.isControlPressed) {
context.read<TabsBloc>().openTab(view);
}
context.read<TabsBloc>().openPlugin(view);
},
onTertiarySelected: (view) =>
onTertiarySelected: (view, _) =>
context.read<TabsBloc>().openTab(view),
),
),

View File

@ -3,6 +3,7 @@ import 'package:appflowy/workspace/application/menu/sidebar_sections_bloc.dart';
import 'package:appflowy/workspace/application/sidebar/folder/folder_bloc.dart';
import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart';
import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';
import 'package:appflowy/workspace/application/view/view_bloc.dart';
import 'package:appflowy/workspace/presentation/home/menu/sidebar/folder/_folder_header.dart';
import 'package:appflowy/workspace/presentation/home/menu/sidebar/rename_view_dialog.dart';
import 'package:appflowy/workspace/presentation/home/menu/view/view_item.dart';
@ -84,14 +85,17 @@ class SectionFolder extends StatelessWidget {
level: 0,
leftPadding: 16,
isFeedback: false,
onSelected: (view) {
onSelected: (view, viewContext) {
if (HardwareKeyboard.instance.isControlPressed) {
context.read<TabsBloc>().openTab(view);
}
context.read<TabsBloc>().openPlugin(view);
viewContext.read<ViewBloc>().add(
const ViewEvent.setIsExpanded(true),
);
},
onTertiarySelected: (view) =>
onTertiarySelected: (view, viewContext) =>
context.read<TabsBloc>().openTab(view),
isHoverEnabled: isHoverEnabled,
),
@ -110,8 +114,8 @@ class SectionFolder extends StatelessWidget {
level: 0,
leftPadding: 16,
isFeedback: false,
onSelected: (_) {},
onTertiarySelected: (_) {},
onSelected: (_, __) {},
onTertiarySelected: (_, __) {},
isHoverEnabled: isHoverEnabled,
isPlaceholder: true,
),

View File

@ -27,7 +27,7 @@ import 'package:flowy_infra_ui/widget/flowy_tooltip.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
typedef ViewItemOnSelected = void Function(ViewPB);
typedef ViewItemOnSelected = void Function(ViewPB, BuildContext);
class ViewItem extends StatelessWidget {
const ViewItem({
@ -408,8 +408,9 @@ class _SingleInnerViewItemState extends State<SingleInnerViewItem> {
final child = GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () => widget.onSelected(widget.view),
onTertiaryTapDown: (_) => widget.onTertiarySelected?.call(widget.view),
onTap: () => widget.onSelected(widget.view, context),
onTertiaryTapDown: (_) =>
widget.onTertiarySelected?.call(widget.view, context),
child: SizedBox(
height: widget.height,
child: Padding(