-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Product page: notify when there are pending operations (#5947)
* Product page: notify when there are pending operations * Fix warning
- Loading branch information
Showing
9 changed files
with
166 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:flutter/painting.dart'; | ||
|
||
/// Code from https://stackoverflow.com/questions/58360989 | ||
extension ColorExtension on Color { | ||
Color darken([double amount = .1]) { | ||
assert(amount >= 0 && amount <= 1); | ||
|
||
final HSLColor hsl = HSLColor.fromColor(this); | ||
final HSLColor hslDark = | ||
hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0)); | ||
|
||
return hslDark.toColor(); | ||
} | ||
|
||
Color lighten([double amount = .1]) { | ||
assert(amount >= 0 && amount <= 1); | ||
|
||
final HSLColor hsl = HSLColor.fromColor(this); | ||
final HSLColor hslLight = | ||
hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0)); | ||
|
||
return hslLight.toColor(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/smooth_app/lib/pages/product/product_page/new_product_page_loading_indicator.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:smooth_app/helpers/color_extension.dart'; | ||
import 'package:smooth_app/pages/product/product_page/new_product_page.dart'; | ||
import 'package:smooth_app/resources/app_animations.dart'; | ||
import 'package:smooth_app/themes/theme_provider.dart'; | ||
import 'package:smooth_app/widgets/smooth_banner.dart'; | ||
|
||
class ProductPageLoadingIndicator extends StatelessWidget { | ||
const ProductPageLoadingIndicator({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final AppLocalizations appLocalizations = AppLocalizations.of(context); | ||
|
||
final bool lightTheme = context.lightTheme(); | ||
final Color color = context.watch<ProductPageCompatibility>().color ?? | ||
(lightTheme ? Colors.grey : Colors.grey[600]!); | ||
|
||
return SmoothBanner( | ||
icon: CloudUploadAnimation( | ||
size: MediaQuery.sizeOf(context).width * 0.10, | ||
), | ||
iconAlignment: AlignmentDirectional.center, | ||
iconBackgroundColor: color, | ||
title: appLocalizations.product_page_pending_operations_banner_title, | ||
titleColor: lightTheme ? null : Colors.white, | ||
contentBackgroundColor: | ||
lightTheme ? color.lighten(0.6) : color.darken(0.3), | ||
contentColor: lightTheme ? null : Colors.grey[200], | ||
topShadow: true, | ||
content: appLocalizations.product_page_pending_operations_banner_message, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters