|
@@ -2,10 +2,14 @@ import 'package:flutter/material.dart';
|
|
import 'package:photos/theme/colors.dart';
|
|
import 'package:photos/theme/colors.dart';
|
|
import 'package:photos/theme/ente_theme.dart';
|
|
import 'package:photos/theme/ente_theme.dart';
|
|
|
|
|
|
|
|
+enum IconButtonType {
|
|
|
|
+ primary,
|
|
|
|
+ secondary,
|
|
|
|
+ rounded,
|
|
|
|
+}
|
|
|
|
+
|
|
class IconButtonWidget extends StatefulWidget {
|
|
class IconButtonWidget extends StatefulWidget {
|
|
- final bool isPrimary;
|
|
|
|
- final bool isSecondary;
|
|
|
|
- final bool isRounded;
|
|
|
|
|
|
+ final IconButtonType iconButtonType;
|
|
final IconData icon;
|
|
final IconData icon;
|
|
final bool disableGestureDetector;
|
|
final bool disableGestureDetector;
|
|
final VoidCallback? onTap;
|
|
final VoidCallback? onTap;
|
|
@@ -14,9 +18,7 @@ class IconButtonWidget extends StatefulWidget {
|
|
final Color? iconColor;
|
|
final Color? iconColor;
|
|
const IconButtonWidget({
|
|
const IconButtonWidget({
|
|
required this.icon,
|
|
required this.icon,
|
|
- this.isPrimary = false,
|
|
|
|
- this.isSecondary = false,
|
|
|
|
- this.isRounded = false,
|
|
|
|
|
|
+ required this.iconButtonType,
|
|
this.disableGestureDetector = false,
|
|
this.disableGestureDetector = false,
|
|
this.onTap,
|
|
this.onTap,
|
|
this.defaultColor,
|
|
this.defaultColor,
|
|
@@ -41,13 +43,12 @@ class _IconButtonWidgetState extends State<IconButtonWidget> {
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
- if (!widget.isPrimary && !widget.isRounded && !widget.isSecondary) {
|
|
|
|
- return const SizedBox.shrink();
|
|
|
|
- }
|
|
|
|
final colorTheme = getEnteColorScheme(context);
|
|
final colorTheme = getEnteColorScheme(context);
|
|
iconStateColor ??
|
|
iconStateColor ??
|
|
(iconStateColor = widget.defaultColor ??
|
|
(iconStateColor = widget.defaultColor ??
|
|
- (widget.isRounded ? colorTheme.fillFaint : null));
|
|
|
|
|
|
+ (widget.iconButtonType == IconButtonType.rounded
|
|
|
|
+ ? colorTheme.fillFaint
|
|
|
|
+ : null));
|
|
return widget.disableGestureDetector
|
|
return widget.disableGestureDetector
|
|
? _iconButton(colorTheme)
|
|
? _iconButton(colorTheme)
|
|
: GestureDetector(
|
|
: GestureDetector(
|
|
@@ -72,7 +73,7 @@ class _IconButtonWidgetState extends State<IconButtonWidget> {
|
|
child: Icon(
|
|
child: Icon(
|
|
widget.icon,
|
|
widget.icon,
|
|
color: widget.iconColor ??
|
|
color: widget.iconColor ??
|
|
- (widget.isSecondary
|
|
|
|
|
|
+ (widget.iconButtonType == IconButtonType.secondary
|
|
? colorTheme.strokeMuted
|
|
? colorTheme.strokeMuted
|
|
: colorTheme.strokeBase),
|
|
: colorTheme.strokeBase),
|
|
size: 24,
|
|
size: 24,
|
|
@@ -85,7 +86,9 @@ class _IconButtonWidgetState extends State<IconButtonWidget> {
|
|
final colorTheme = getEnteColorScheme(context);
|
|
final colorTheme = getEnteColorScheme(context);
|
|
setState(() {
|
|
setState(() {
|
|
iconStateColor = widget.pressedColor ??
|
|
iconStateColor = widget.pressedColor ??
|
|
- (widget.isRounded ? colorTheme.fillMuted : colorTheme.fillFaint);
|
|
|
|
|
|
+ (widget.iconButtonType == IconButtonType.rounded
|
|
|
|
+ ? colorTheme.fillMuted
|
|
|
|
+ : colorTheme.fillFaint);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|