top_control_app_bar.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import 'dart:developer';
  2. import 'package:auto_route/auto_route.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:hooks_riverpod/hooks_riverpod.dart';
  5. import 'package:openapi/api.dart';
  6. class TopControlAppBar extends ConsumerWidget with PreferredSizeWidget {
  7. const TopControlAppBar({
  8. Key? key,
  9. required this.asset,
  10. required this.onMoreInfoPressed,
  11. required this.onDownloadPressed,
  12. }) : super(key: key);
  13. final AssetResponseDto asset;
  14. final Function onMoreInfoPressed;
  15. final Function onDownloadPressed;
  16. @override
  17. Widget build(BuildContext context, WidgetRef ref) {
  18. double iconSize = 18.0;
  19. return AppBar(
  20. foregroundColor: Colors.grey[100],
  21. toolbarHeight: 60,
  22. backgroundColor: Colors.black,
  23. leading: IconButton(
  24. onPressed: () {
  25. AutoRouter.of(context).pop();
  26. },
  27. icon: const Icon(
  28. Icons.arrow_back_ios_new_rounded,
  29. size: 20.0,
  30. ),
  31. ),
  32. actions: [
  33. IconButton(
  34. iconSize: iconSize,
  35. splashRadius: iconSize,
  36. onPressed: () {
  37. onDownloadPressed();
  38. },
  39. icon: const Icon(Icons.cloud_download_rounded),
  40. ),
  41. IconButton(
  42. iconSize: iconSize,
  43. splashRadius: iconSize,
  44. onPressed: () {
  45. log("favorite");
  46. },
  47. icon: asset.isFavorite
  48. ? const Icon(Icons.favorite_rounded)
  49. : const Icon(Icons.favorite_border_rounded),
  50. ),
  51. IconButton(
  52. iconSize: iconSize,
  53. splashRadius: iconSize,
  54. onPressed: () {
  55. onMoreInfoPressed();
  56. },
  57. icon: const Icon(Icons.more_horiz_rounded),
  58. )
  59. ],
  60. );
  61. }
  62. @override
  63. Size get preferredSize => const Size.fromHeight(kToolbarHeight);
  64. }