home_header_widget.dart 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import 'dart:ui';
  2. import 'package:flutter/material.dart';
  3. import 'package:photos/ui/viewer/search/search_widget.dart';
  4. class HomeHeaderWidget extends StatefulWidget {
  5. final Widget centerWidget;
  6. const HomeHeaderWidget({required this.centerWidget, Key? key})
  7. : super(key: key);
  8. @override
  9. State<HomeHeaderWidget> createState() => _HomeHeaderWidgetState();
  10. }
  11. class _HomeHeaderWidgetState extends State<HomeHeaderWidget> {
  12. @override
  13. Widget build(BuildContext context) {
  14. final hasNotch = window.viewPadding.top > 65;
  15. return Padding(
  16. padding: EdgeInsets.fromLTRB(4, hasNotch ? 4 : 8, 4, 4),
  17. child: Row(
  18. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  19. children: [
  20. IconButton(
  21. visualDensity: const VisualDensity(horizontal: -2, vertical: -2),
  22. onPressed: () {
  23. Scaffold.of(context).openDrawer();
  24. },
  25. splashColor: Colors.transparent,
  26. icon: const Icon(
  27. Icons.menu_outlined,
  28. ),
  29. ),
  30. AnimatedSwitcher(
  31. duration: const Duration(milliseconds: 250),
  32. child: widget.centerWidget,
  33. ),
  34. const SearchIconWidget(),
  35. ],
  36. ),
  37. );
  38. }
  39. }