mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
config menus list
This commit is contained in:
parent
ce9a218df8
commit
9454c753c3
BIN
app_flowy/assets/images/avatar.jpg
Normal file
BIN
app_flowy/assets/images/avatar.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
@ -1,6 +1,7 @@
|
|||||||
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/app/app_watch_bloc.dart';
|
import 'package:app_flowy/workspace/application/app/app_watch_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/app/view_list.dart';
|
import 'package:app_flowy/workspace/presentation/app/view_list.dart';
|
||||||
|
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_size.dart';
|
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_size.dart';
|
||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
import 'package:expandable/expandable.dart';
|
import 'package:expandable/expandable.dart';
|
||||||
@ -12,7 +13,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
|
|
||||||
class AppWidget extends StatelessWidget {
|
class AppWidget extends MenuItem {
|
||||||
final App app;
|
final App app;
|
||||||
const AppWidget(this.app, {Key? key}) : super(key: key);
|
const AppWidget(this.app, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
@ -79,6 +80,9 @@ class AppWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
MenuItemType get type => MenuItemType.app;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppHeader extends StatelessWidget {
|
class AppHeader extends StatelessWidget {
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
import 'package:app_flowy/workspace/presentation/app/app_widget.dart';
|
|
||||||
import 'package:expandable/expandable.dart';
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
|
|
||||||
class AppList extends StatelessWidget {
|
|
||||||
final Option<List<App>> apps;
|
|
||||||
const AppList({required this.apps, Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return apps.fold(() {
|
|
||||||
return const Expanded(child: Text('You have no apps, create one?'));
|
|
||||||
}, (apps) {
|
|
||||||
return ExpandableTheme(
|
|
||||||
data: const ExpandableThemeData(
|
|
||||||
iconColor: Colors.blue,
|
|
||||||
useInkWell: true,
|
|
||||||
),
|
|
||||||
child: Expanded(
|
|
||||||
child: ListView(
|
|
||||||
physics: const BouncingScrollPhysics(),
|
|
||||||
children: apps.map((app) => AppWidget(app)).toList(),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,17 +2,20 @@ import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
|
|||||||
import 'package:app_flowy/workspace/application/menu/menu_watch.dart';
|
import 'package:app_flowy/workspace/application/menu/menu_watch.dart';
|
||||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
|
import 'package:app_flowy/workspace/presentation/app/app_widget.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
|
import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/widgets/menu/create_app_dialog.dart';
|
import 'package:app_flowy/workspace/presentation/widgets/menu/create_app_dialog.dart';
|
||||||
|
import 'package:app_flowy/workspace/presentation/widgets/menu/user_profile.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flowy_infra/size.dart';
|
import 'package:flowy_infra/size.dart';
|
||||||
import 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart';
|
import 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart';
|
||||||
import 'package:flowy_infra_ui/widget/error_page.dart';
|
import 'package:flowy_infra_ui/widget/error_page.dart';
|
||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
|
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
import 'app_list.dart';
|
import 'menu_list.dart';
|
||||||
|
|
||||||
class HomeMenu extends StatelessWidget {
|
class HomeMenu extends StatelessWidget {
|
||||||
final Function(HomeStackView?) pageContextChanged;
|
final Function(HomeStackView?) pageContextChanged;
|
||||||
@ -67,7 +70,7 @@ class HomeMenu extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
_renderTopBar(context),
|
_renderTopBar(context),
|
||||||
_renderAppList(context),
|
_renderMenuList(context),
|
||||||
],
|
],
|
||||||
).padding(horizontal: Insets.l),
|
).padding(horizontal: Insets.l),
|
||||||
),
|
),
|
||||||
@ -77,17 +80,19 @@ class HomeMenu extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _renderAppList(BuildContext context) {
|
Widget _renderMenuList(BuildContext context) {
|
||||||
return BlocBuilder<MenuWatchBloc, MenuWatchState>(
|
return BlocBuilder<MenuWatchBloc, MenuWatchState>(
|
||||||
builder: (context, state) => state.map(
|
builder: (context, state) {
|
||||||
initial: (_) => BlocBuilder<MenuBloc, MenuState>(
|
return state.map(
|
||||||
builder: (context, state) {
|
initial: (_) => BlocBuilder<MenuBloc, MenuState>(
|
||||||
return AppList(apps: state.apps);
|
builder: (context, s) => MenuList(
|
||||||
},
|
menuItems: menuItemsWithApps(s.apps),
|
||||||
),
|
),
|
||||||
loadApps: (s) => AppList(apps: some(s.apps)),
|
),
|
||||||
loadFail: (s) => FlowyErrorPage(s.error.toString()),
|
loadApps: (s) => MenuList(menuItems: menuItemsWithApps(some(s.apps))),
|
||||||
),
|
loadFail: (s) => FlowyErrorPage(s.error.toString()),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +109,21 @@ class HomeMenu extends StatelessWidget {
|
|||||||
child: const MenuTopBar(),
|
child: const MenuTopBar(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<MenuItem> menuItemsWithApps(Option<List<App>> someApps) {
|
||||||
|
List<MenuItem> menuItems = [
|
||||||
|
const UserProfile(),
|
||||||
|
];
|
||||||
|
|
||||||
|
// apps
|
||||||
|
List<MenuItem> appWidgets = someApps.fold(
|
||||||
|
() => [],
|
||||||
|
(apps) => apps.map((app) => AppWidget(app)).toList(),
|
||||||
|
);
|
||||||
|
|
||||||
|
menuItems.addAll(appWidgets);
|
||||||
|
return menuItems;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MenuTopBar extends StatelessWidget {
|
class MenuTopBar extends StatelessWidget {
|
||||||
@ -182,5 +202,3 @@ class NewAppButton extends StatelessWidget {
|
|||||||
), context);
|
), context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ignore: must_be_immutable
|
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
import 'package:expandable/expandable.dart';
|
||||||
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
|
import 'package:flowy_infra/time/duration.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
enum MenuItemType {
|
||||||
|
userProfile,
|
||||||
|
dashboard,
|
||||||
|
favorites,
|
||||||
|
app,
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class MenuItem extends StatelessWidget {
|
||||||
|
const MenuItem({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
MenuItemType get type;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MenuList extends StatelessWidget {
|
||||||
|
final List<MenuItem> menuItems;
|
||||||
|
const MenuList({required this.menuItems, Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ExpandableTheme(
|
||||||
|
data: ExpandableThemeData(
|
||||||
|
useInkWell: true, animationDuration: Durations.medium),
|
||||||
|
child: Expanded(
|
||||||
|
child: ListView.separated(
|
||||||
|
itemCount: menuItems.length,
|
||||||
|
separatorBuilder: (context, index) => const VSpace(10),
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return menuItems[index].build(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart';
|
||||||
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class UserProfile extends MenuItem {
|
||||||
|
const UserProfile({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 30,
|
||||||
|
height: 30,
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: const Image(image: AssetImage('assets/images/avatar.jpg')),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const HSpace(6),
|
||||||
|
const Text("nathan", style: TextStyle(fontSize: 18)),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
MenuItemType get type => MenuItemType.userProfile;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user