view_widget.dart 998 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import 'package:app_flowy/startup/startup.dart';
  2. import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
  3. import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
  4. import 'package:flutter/material.dart';
  5. class ViewWidget extends StatelessWidget {
  6. final View view;
  7. final Widget icon;
  8. const ViewWidget({Key? key, required this.view, required this.icon})
  9. : super(key: key);
  10. @override
  11. Widget build(BuildContext context) {
  12. return InkWell(onTap: _openView(context), child: buildContent());
  13. }
  14. Row buildContent() {
  15. return Row(
  16. children: [
  17. icon,
  18. const SizedBox(
  19. width: 4,
  20. ),
  21. Text(
  22. view.name,
  23. textAlign: TextAlign.start,
  24. style: const TextStyle(fontSize: 15),
  25. )
  26. ],
  27. );
  28. }
  29. Function() _openView(BuildContext context) {
  30. return () {
  31. final stackView = stackViewFromView(view);
  32. getIt<HomePageStack>().setStackView(stackView);
  33. };
  34. }
  35. }