2023-10-23 18:35:07 +08:00
|
|
|
import 'package:appflowy/mobile/application/mobile_router.dart';
|
|
|
|
import 'package:appflowy/mobile/presentation/home/personal_folder/mobile_home_personal_folder.dart';
|
|
|
|
import 'package:appflowy/workspace/application/favorite/favorite_bloc.dart';
|
2024-03-05 13:51:03 +08:00
|
|
|
import 'package:appflowy/workspace/application/menu/sidebar_root_views_bloc.dart';
|
2023-12-31 07:29:40 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart';
|
2023-10-23 18:35:07 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
|
|
|
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
|
|
|
|
|
|
|
class MobileFolders extends StatelessWidget {
|
|
|
|
const MobileFolders({
|
|
|
|
super.key,
|
|
|
|
required this.user,
|
|
|
|
required this.workspaceSetting,
|
|
|
|
required this.showFavorite,
|
|
|
|
});
|
|
|
|
|
|
|
|
final UserProfilePB user;
|
|
|
|
final WorkspaceSettingPB workspaceSetting;
|
|
|
|
final bool showFavorite;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MultiBlocProvider(
|
|
|
|
providers: [
|
|
|
|
BlocProvider(
|
2024-03-05 13:51:03 +08:00
|
|
|
create: (_) => SidebarRootViewsBloc()
|
|
|
|
..add(
|
|
|
|
SidebarRootViewsEvent.initial(
|
|
|
|
user,
|
|
|
|
workspaceSetting.workspaceId,
|
|
|
|
),
|
|
|
|
),
|
2023-10-23 18:35:07 +08:00
|
|
|
),
|
|
|
|
BlocProvider(
|
|
|
|
create: (_) => FavoriteBloc()..add(const FavoriteEvent.initial()),
|
2023-11-14 22:33:07 +08:00
|
|
|
),
|
2023-10-23 18:35:07 +08:00
|
|
|
],
|
|
|
|
child: MultiBlocListener(
|
|
|
|
listeners: [
|
2024-03-05 13:51:03 +08:00
|
|
|
BlocListener<SidebarRootViewsBloc, SidebarRootViewState>(
|
2023-10-23 18:35:07 +08:00
|
|
|
listenWhen: (p, c) =>
|
2024-03-05 13:51:03 +08:00
|
|
|
p.lastCreatedRootView?.id != c.lastCreatedRootView?.id,
|
2023-10-23 18:35:07 +08:00
|
|
|
listener: (context, state) =>
|
2024-03-05 13:51:03 +08:00
|
|
|
context.pushView(state.lastCreatedRootView!),
|
2023-10-23 18:35:07 +08:00
|
|
|
),
|
|
|
|
],
|
|
|
|
child: Builder(
|
|
|
|
builder: (context) {
|
2024-03-05 13:51:03 +08:00
|
|
|
final menuState = context.watch<SidebarRootViewsBloc>().state;
|
2023-10-23 18:35:07 +08:00
|
|
|
return SlidableAutoCloseBehavior(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
MobilePersonalFolder(
|
|
|
|
views: menuState.views,
|
|
|
|
),
|
|
|
|
const VSpace(8.0),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|