| 1 | import 'package:cake_wallet/themes/core/custom_theme_colors.dart'; |
| 2 | import 'package:flutter/material.dart'; |
| 3 | import 'package:flutter_svg/svg.dart'; |
| 4 | |
| 5 | class SyncIndicatorIcon extends StatelessWidget { |
| 6 | SyncIndicatorIcon( |
| 7 | {this.boolMode = true, |
| 8 | this.isSynced = false, |
| 9 | this.value = waiting, |
| 10 | this.size = 6.0, |
| 11 | this.showTorIcon = false}); |
| 12 | |
| 13 | final bool boolMode; |
| 14 | final bool isSynced; |
| 15 | final String value; |
| 16 | final double size; |
| 17 | final bool showTorIcon; |
| 18 | |
| 19 | static const String waiting = 'waiting'; |
| 20 | static const String actionRequired = 'action required'; |
| 21 | static const String created = 'created'; |
| 22 | static const String fetching = 'fetching'; |
| 23 | static const String finished = 'finished'; |
| 24 | static const String success = 'success'; |
| 25 | static const String complete = 'complete'; |
| 26 | static const String completed = 'completed'; |
| 27 | |
| 28 | @override |
| 29 | Widget build(BuildContext context) { |
| 30 | Color indicatorColor; |
| 31 | |
| 32 | if (boolMode) { |
| 33 | indicatorColor = isSynced ? CustomThemeColors.syncGreen : CustomThemeColors.syncYellow; |
| 34 | } else { |
| 35 | switch (value.toLowerCase()) { |
| 36 | case actionRequired: |
| 37 | indicatorColor = Theme.of(context).colorScheme.surfaceContainer; |
| 38 | break; |
| 39 | case created: |
| 40 | case finished: |
| 41 | case success: |
| 42 | case complete: |
| 43 | case completed: |
| 44 | indicatorColor = CustomThemeColors.syncGreen; |
| 45 | break; |
| 46 | case waiting: |
| 47 | case fetching: |
| 48 | default: |
| 49 | indicatorColor = Theme.of(context).colorScheme.errorContainer; |
| 50 | } |
| 51 | } |
| 52 | return Container( |
| 53 | height: size, |
| 54 | width: size, |
| 55 | decoration: showTorIcon |
| 56 | ? null |
| 57 | : BoxDecoration( |
| 58 | shape: BoxShape.circle, |
| 59 | color: indicatorColor, |
| 60 | ), |
| 61 | child: showTorIcon |
| 62 | ? SvgPicture.asset( |
| 63 | "assets/images/tor.svg", |
| 64 | color: indicatorColor, |
| 65 | ) |
| 66 | : null, |
| 67 | ); |
| 68 | } |
| 69 | } |