home_top_bar.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import 'package:app_flowy/workspace/domain/image.dart';
  2. import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
  3. import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
  4. import 'package:flowy_infra_ui/widget/rounded_button.dart';
  5. import 'package:flowy_infra_ui/widget/spacing.dart';
  6. import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pbenum.dart';
  7. import 'package:flutter/material.dart';
  8. class HomeTopBar extends StatelessWidget {
  9. final HomeStackView view;
  10. const HomeTopBar({Key? key, required this.view}) : super(key: key);
  11. @override
  12. Widget build(BuildContext context) {
  13. return SizedBox(
  14. height: HomeSizes.topBarHeight,
  15. child: Container(
  16. decoration: BoxDecoration(
  17. border: Border(
  18. bottom: BorderSide(width: 0.5, color: Colors.grey.shade300),
  19. ),
  20. ),
  21. child: Padding(
  22. padding:
  23. EdgeInsets.symmetric(horizontal: HomeInsets.topBarTitlePadding),
  24. child: Row(
  25. crossAxisAlignment: CrossAxisAlignment.center,
  26. children: [
  27. HomeTitle(title: view.title, type: view.type),
  28. const Spacer(),
  29. _renderShareButton(),
  30. _renderMoreButton(),
  31. ],
  32. ),
  33. ),
  34. ),
  35. );
  36. }
  37. Widget _renderShareButton() {
  38. return RoundedTextButton(
  39. title: 'Share',
  40. height: 30,
  41. width: 60,
  42. fontSize: 12,
  43. borderRadius: BorderRadius.circular(6),
  44. color: Colors.lightBlue,
  45. press: () {},
  46. );
  47. }
  48. Widget _renderMoreButton() {
  49. return SizedBox(
  50. width: 24,
  51. child: IconButton(
  52. icon: const Icon(Icons.more_vert),
  53. iconSize: 12,
  54. alignment: Alignment.center,
  55. onPressed: () {},
  56. ),
  57. );
  58. }
  59. }
  60. class HomeTitle extends StatelessWidget {
  61. final String title;
  62. final ViewType type;
  63. const HomeTitle({
  64. Key? key,
  65. required this.title,
  66. required this.type,
  67. }) : super(key: key);
  68. @override
  69. Widget build(BuildContext context) {
  70. return Flexible(
  71. child: Row(
  72. children: [
  73. Image(
  74. fit: BoxFit.scaleDown,
  75. width: 15,
  76. height: 15,
  77. image: assetImageForViewType(type)),
  78. const HSpace(6),
  79. Text(
  80. title,
  81. overflow: TextOverflow.fade,
  82. softWrap: false,
  83. style: const TextStyle(fontSize: 16),
  84. ),
  85. ],
  86. ),
  87. );
  88. }
  89. }