| 1 | import 'dart:ui'; |
| 2 | import 'package:cake_wallet/entities/main_actions.dart'; |
| 3 | import 'package:cake_wallet/themes/core/theme_extension.dart'; |
| 4 | import 'package:flutter/material.dart'; |
| 5 | import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; |
| 6 | import 'package:cake_wallet/src/screens/dashboard/widgets/action_button.dart'; |
| 7 | import 'package:flutter_mobx/flutter_mobx.dart'; |
| 8 | |
| 9 | class NavigationDock extends StatelessWidget { |
| 10 | const NavigationDock({ |
| 11 | required this.dashboardViewModel, |
| 12 | }); |
| 13 | |
| 14 | final DashboardViewModel dashboardViewModel; |
| 15 | |
| 16 | @override |
| 17 | Widget build(BuildContext context) { |
| 18 | return Positioned( |
| 19 | child: Observer( |
| 20 | builder: (_) { |
| 21 | return Container( |
| 22 | height: 84, |
| 23 | alignment: Alignment.bottomCenter, |
| 24 | child: Container( |
| 25 | decoration: BoxDecoration( |
| 26 | borderRadius: BorderRadius.circular(50), |
| 27 | ), |
| 28 | margin: const EdgeInsets.only(left: 8, right: 8, bottom: 16), |
| 29 | child: ClipRRect( |
| 30 | borderRadius: BorderRadius.circular(50), |
| 31 | child: BackdropFilter( |
| 32 | filter: ImageFilter.blur(sigmaX: 50, sigmaY: 50), |
| 33 | child: Container( |
| 34 | decoration: BoxDecoration( |
| 35 | borderRadius: BorderRadius.circular(50.0), |
| 36 | color: Theme.of(context).colorScheme.surfaceContainer, |
| 37 | ), |
| 38 | padding: const EdgeInsets.symmetric(horizontal: 8), |
| 39 | child: ClipRect( |
| 40 | child: Row( |
| 41 | mainAxisSize: MainAxisSize.min, |
| 42 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 43 | crossAxisAlignment: CrossAxisAlignment.center, |
| 44 | children: MainActions.all |
| 45 | .where((element) => element.canShow?.call(dashboardViewModel) ?? true) |
| 46 | .map( |
| 47 | (action) => Expanded( |
| 48 | child: Semantics( |
| 49 | button: true, |
| 50 | enabled: (action.isEnabled?.call(dashboardViewModel) ?? true), |
| 51 | child: ActionButton( |
| 52 | key: action.key, |
| 53 | image: Image.asset( |
| 54 | action.image, |
| 55 | height: 24, |
| 56 | width: 24, |
| 57 | color: Theme.of(context).colorScheme.primary, |
| 58 | ), |
| 59 | title: action.name(context), |
| 60 | onClick: (action.isEnabled?.call(dashboardViewModel) ?? true) |
| 61 | ? () async => |
| 62 | await action.onTap(context, dashboardViewModel) |
| 63 | : null, |
| 64 | textColor: action.isEnabled?.call(dashboardViewModel) ?? true |
| 65 | ? null |
| 66 | : Theme.of(context).colorScheme.onSurface, |
| 67 | ), |
| 68 | ), |
| 69 | ), |
| 70 | ) |
| 71 | .toList(), |
| 72 | ), |
| 73 | ), |
| 74 | ), |
| 75 | ), |
| 76 | ), |
| 77 | ), |
| 78 | ); |
| 79 | }, |
| 80 | ), |
| 81 | ); |
| 82 | } |
| 83 | } |