| 1 | import 'package:auto_size_text/auto_size_text.dart'; |
| 2 | import 'package:flutter/material.dart'; |
| 3 | |
| 4 | class DesktopActionButton extends StatelessWidget { |
| 5 | final String image; |
| 6 | final String title; |
| 7 | final bool canShow; |
| 8 | final bool isEnabled; |
| 9 | final Function() onTap; |
| 10 | |
| 11 | const DesktopActionButton({ |
| 12 | Key? key, |
| 13 | required this.title, |
| 14 | required this.image, |
| 15 | required this.onTap, |
| 16 | bool? canShow, |
| 17 | bool? isEnabled, |
| 18 | }) : this.isEnabled = isEnabled ?? true, |
| 19 | this.canShow = canShow ?? true, |
| 20 | super(key: key); |
| 21 | |
| 22 | @override |
| 23 | Widget build(BuildContext context) { |
| 24 | return MouseRegion( |
| 25 | cursor: SystemMouseCursors.click, |
| 26 | child: Padding( |
| 27 | padding: const EdgeInsets.fromLTRB(8, 0, 8, 8), |
| 28 | child: GestureDetector( |
| 29 | onTap: onTap, |
| 30 | child: Container( |
| 31 | padding: EdgeInsets.symmetric(vertical: 25), |
| 32 | width: double.infinity, |
| 33 | decoration: BoxDecoration( |
| 34 | borderRadius: BorderRadius.circular(15.0), |
| 35 | color: Theme.of(context).colorScheme.surfaceContainer, |
| 36 | ), |
| 37 | child: Center( |
| 38 | child: Row( |
| 39 | mainAxisSize: MainAxisSize.min, |
| 40 | children: [ |
| 41 | Image.asset( |
| 42 | image, |
| 43 | height: 30, |
| 44 | width: 30, |
| 45 | color: isEnabled |
| 46 | ? Theme.of(context).colorScheme.onPrimaryContainer |
| 47 | : Theme.of(context).colorScheme.onSurfaceVariant, |
| 48 | ), |
| 49 | const SizedBox(width: 10), |
| 50 | AutoSizeText( |
| 51 | title, |
| 52 | style: Theme.of(context).textTheme.bodyMedium!.copyWith( |
| 53 | fontSize: 24, |
| 54 | fontWeight: FontWeight.bold, |
| 55 | color: isEnabled |
| 56 | ? Theme.of(context).colorScheme.onPrimaryContainer |
| 57 | : Theme.of(context).colorScheme.onSurfaceVariant, |
| 58 | height: 1, |
| 59 | ), |
| 60 | maxLines: 1, |
| 61 | textAlign: TextAlign.center, |
| 62 | ) |
| 63 | ], |
| 64 | ), |
| 65 | ), |
| 66 | ), |
| 67 | ), |
| 68 | ), |
| 69 | ); |
| 70 | } |
| 71 | } |