| 1 | import 'package:cake_wallet/generated/i18n.dart'; |
| 2 | import 'package:cake_wallet/src/widgets/cake_image_widget.dart'; |
| 3 | import 'package:cake_wallet/themes/core/theme_extension.dart'; |
| 4 | import 'package:flutter/material.dart'; |
| 5 | import 'package:flutter_svg/flutter_svg.dart'; |
| 6 | |
| 7 | class AppsWidget extends StatelessWidget { |
| 8 | AppsWidget({ |
| 9 | this.onTap, |
| 10 | required this.title, |
| 11 | required this.subTitle, |
| 12 | this.hint, |
| 13 | this.svgPicture, |
| 14 | this.image, |
| 15 | this.icon, |
| 16 | this.onClose, |
| 17 | this.customBorder, |
| 18 | this.shadowSpread, |
| 19 | this.shadowBlur, |
| 20 | super.key, |
| 21 | this.marginV, |
| 22 | this.marginH, |
| 23 | this.isWide, |
| 24 | this.isLink, |
| 25 | this.isCake, |
| 26 | }); |
| 27 | |
| 28 | final VoidCallback? onTap; |
| 29 | final VoidCallback? onClose; |
| 30 | final String title; |
| 31 | final String subTitle; |
| 32 | final Widget? hint; |
| 33 | final SvgPicture? svgPicture; |
| 34 | final Widget? icon; |
| 35 | final String? image; |
| 36 | final double? customBorder; |
| 37 | final double? marginV; |
| 38 | final double? marginH; |
| 39 | final double? shadowSpread; |
| 40 | final double? shadowBlur; |
| 41 | final bool? isWide; |
| 42 | final bool? isLink; |
| 43 | final bool? isCake; |
| 44 | |
| 45 | @override |
| 46 | Widget build(BuildContext context) { |
| 47 | if (isWide == true) { |
| 48 | return Stack( |
| 49 | children: [ |
| 50 | Container( |
| 51 | margin: EdgeInsets.symmetric(horizontal: marginH ?? 20, vertical: marginV ?? 5), |
| 52 | width: double.infinity, |
| 53 | decoration: ShapeDecoration( |
| 54 | shape: RoundedSuperellipseBorder(borderRadius: BorderRadius.circular(18)), |
| 55 | gradient: LinearGradient( |
| 56 | colors: [ |
| 57 | context.customColors.cardGradientColorPrimary, |
| 58 | context.customColors.cardGradientColorSecondary, |
| 59 | ], |
| 60 | begin: Alignment.topCenter, |
| 61 | end: Alignment.bottomCenter, |
| 62 | ), |
| 63 | ), |
| 64 | // The card is one node; the arrow glyph's "leaves the app" meaning |
| 65 | // becomes a hint instead of an unlabeled icon. |
| 66 | child: MergeSemantics( |
| 67 | child: Semantics( |
| 68 | hint: isLink == true ? S.of(context).opens_externally : null, |
| 69 | child: TextButton( |
| 70 | onPressed: onTap, |
| 71 | style: TextButton.styleFrom( |
| 72 | shape: RoundedSuperellipseBorder( |
| 73 | borderRadius: BorderRadius.circular(18), |
| 74 | side: BorderSide( |
| 75 | width: 1.25, color: Theme.of(context).colorScheme.surfaceContainerHigh), |
| 76 | ), |
| 77 | padding: EdgeInsets.all(24), |
| 78 | ), |
| 79 | child: Column( |
| 80 | children: [ |
| 81 | Row( |
| 82 | children: [ |
| 83 | Padding( |
| 84 | padding: const EdgeInsets.only(right: 20), |
| 85 | child: ExcludeSemantics( |
| 86 | child: CakeImageWidget(imageUrl: image, height: 54, width: 54), |
| 87 | ), |
| 88 | ), |
| 89 | Expanded( |
| 90 | child: Column( |
| 91 | crossAxisAlignment: CrossAxisAlignment.start, |
| 92 | children: [ |
| 93 | Row( |
| 94 | spacing: 6.0, |
| 95 | children: [ |
| 96 | Text( |
| 97 | title, |
| 98 | style: Theme.of(context).textTheme.titleMedium?.copyWith( |
| 99 | color: Theme.of(context).colorScheme.onSurface, |
| 100 | fontWeight: FontWeight.w800, |
| 101 | fontSize: 20, |
| 102 | ), |
| 103 | softWrap: true, |
| 104 | ), |
| 105 | isCake == true |
| 106 | ? ExcludeSemantics( |
| 107 | child: CakeImageWidget( |
| 108 | imageUrl: "assets/new-ui/cakelabs-icon.svg", |
| 109 | color: Theme.of(context) |
| 110 | .colorScheme |
| 111 | .onSurfaceVariant), |
| 112 | ) |
| 113 | : SizedBox(), |
| 114 | ], |
| 115 | ), |
| 116 | SizedBox(height: 5), |
| 117 | Text( |
| 118 | subTitle, |
| 119 | style: Theme.of(context).textTheme.bodySmall?.copyWith( |
| 120 | color: Theme.of(context).colorScheme.onSurfaceVariant, |
| 121 | fontWeight: FontWeight.w500, |
| 122 | ), |
| 123 | softWrap: true, |
| 124 | ), |
| 125 | ], |
| 126 | ), |
| 127 | ), |
| 128 | ExcludeSemantics( |
| 129 | child: Icon( |
| 130 | isLink == true ? Icons.arrow_outward : Icons.arrow_forward_ios, |
| 131 | color: Theme.of(context).colorScheme.onSurfaceVariant, |
| 132 | size: 20, |
| 133 | ), |
| 134 | ) |
| 135 | ], |
| 136 | ), |
| 137 | if (hint != null) ...[ |
| 138 | SizedBox(height: 10), |
| 139 | hint!, |
| 140 | ] |
| 141 | ], |
| 142 | ), |
| 143 | ), |
| 144 | ), |
| 145 | ), |
| 146 | ), |
| 147 | if (onClose != null) |
| 148 | Positioned( |
| 149 | top: 10, |
| 150 | right: 10, |
| 151 | // Label the icon-only button without adding a visible tooltip. |
| 152 | child: MergeSemantics( |
| 153 | child: Semantics( |
| 154 | label: S.of(context).close, |
| 155 | child: IconButton( |
| 156 | icon: Icon(Icons.close), |
| 157 | onPressed: onClose, |
| 158 | //color: Theme.of(context).colorScheme.onSurface, |
| 159 | ), |
| 160 | ), |
| 161 | ), |
| 162 | ), |
| 163 | ], |
| 164 | ); |
| 165 | } else { |
| 166 | return Stack(); |
| 167 | } |
| 168 | } |
| 169 | } |