2021-07-22 18:04:24 +08:00
|
|
|
import 'package:app_flowy/startup/startup.dart';
|
2021-07-26 16:35:51 +08:00
|
|
|
import 'package:app_flowy/workspace/domain/image.dart';
|
2021-07-22 18:04:24 +08:00
|
|
|
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
2021-07-27 09:11:53 +08:00
|
|
|
import 'package:app_flowy/workspace/presentation/app/app_widget.dart';
|
2021-07-26 15:25:30 +08:00
|
|
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
2021-07-22 17:06:53 +08:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2021-07-27 14:38:51 +08:00
|
|
|
import 'package:flowy_infra_ui/style_widget/styled_icon_button.dart';
|
2021-07-27 11:54:59 +08:00
|
|
|
import 'package:flowy_infra_ui/style_widget/styled_hover.dart';
|
2021-07-22 17:06:53 +08:00
|
|
|
|
|
|
|
class ViewWidget extends StatelessWidget {
|
|
|
|
final View view;
|
2021-07-26 15:25:30 +08:00
|
|
|
const ViewWidget({Key? key, required this.view}) : super(key: key);
|
2021-07-22 17:06:53 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-07-27 09:11:53 +08:00
|
|
|
return InkWell(
|
|
|
|
onTap: _openView(context),
|
2021-07-27 11:54:59 +08:00
|
|
|
child: StyledHover(
|
|
|
|
color: Colors.grey.shade300,
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
builder: (context, onHover) => _render(context, onHover),
|
2021-07-27 09:11:53 +08:00
|
|
|
),
|
|
|
|
);
|
2021-07-22 17:06:53 +08:00
|
|
|
}
|
|
|
|
|
2021-07-27 11:54:59 +08:00
|
|
|
Widget _render(BuildContext context, bool onHover) {
|
|
|
|
const double width = 20;
|
|
|
|
List<Widget> children = [
|
|
|
|
Image(
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
width: width,
|
|
|
|
height: width,
|
|
|
|
image: assetImageForViewType(view.viewType)),
|
|
|
|
const HSpace(6),
|
|
|
|
Text(
|
|
|
|
view.name,
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
style: const TextStyle(fontSize: 15),
|
|
|
|
),
|
|
|
|
];
|
|
|
|
|
|
|
|
if (onHover) {
|
|
|
|
children.add(const Spacer());
|
|
|
|
|
|
|
|
children.add(Align(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: StyledMore(
|
|
|
|
width: width,
|
|
|
|
onPressed: () {},
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
final padding = EdgeInsets.only(
|
|
|
|
left: AppWidgetSize.expandedPadding,
|
|
|
|
top: 5,
|
|
|
|
bottom: 5,
|
|
|
|
right: 5,
|
|
|
|
);
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
padding: padding,
|
2021-07-27 14:38:51 +08:00
|
|
|
child: Row(children: children),
|
2021-07-22 17:06:53 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-07-22 18:04:24 +08:00
|
|
|
Function() _openView(BuildContext context) {
|
2021-07-22 17:06:53 +08:00
|
|
|
return () {
|
2021-07-22 18:04:24 +08:00
|
|
|
final stackView = stackViewFromView(view);
|
|
|
|
getIt<HomePageStack>().setStackView(stackView);
|
2021-07-22 17:06:53 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|