mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 10:28:50 +01:00
Allow hiding the activation order in toolbar btn
This commit is contained in:
parent
37bf5500e3
commit
08f372d691
2 changed files with 33 additions and 17 deletions
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:nc_photos/app_localizations.dart';
|
import 'package:nc_photos/app_localizations.dart';
|
||||||
import 'package:nc_photos/double_extension.dart';
|
import 'package:nc_photos/double_extension.dart';
|
||||||
import 'package:nc_photos/iterable_extension.dart';
|
import 'package:nc_photos/iterable_extension.dart';
|
||||||
|
import 'package:nc_photos/object_extension.dart';
|
||||||
import 'package:nc_photos/theme.dart';
|
import 'package:nc_photos/theme.dart';
|
||||||
import 'package:nc_photos/widget/image_editor/toolbar_button.dart';
|
import 'package:nc_photos/widget/image_editor/toolbar_button.dart';
|
||||||
import 'package:nc_photos/widget/stateful_slider.dart';
|
import 'package:nc_photos/widget/stateful_slider.dart';
|
||||||
|
@ -111,53 +112,63 @@ class _ColorToolbarState extends State<ColorToolbar> {
|
||||||
label: L10n.global().imageEditColorBrightness,
|
label: L10n.global().imageEditColorBrightness,
|
||||||
onPressed: _onBrightnessPressed,
|
onPressed: _onBrightnessPressed,
|
||||||
isSelected: _selectedFilter == ColorToolType.brightness,
|
isSelected: _selectedFilter == ColorToolType.brightness,
|
||||||
activationOrder:
|
activationOrder: _filters.keys
|
||||||
_filters.keys.indexOf(ColorToolType.brightness),
|
.indexOf(ColorToolType.brightness)
|
||||||
|
.run((i) => i == -1 ? null : i),
|
||||||
),
|
),
|
||||||
ToolbarButton(
|
ToolbarButton(
|
||||||
icon: Icons.contrast,
|
icon: Icons.contrast,
|
||||||
label: L10n.global().imageEditColorContrast,
|
label: L10n.global().imageEditColorContrast,
|
||||||
onPressed: _onContrastPressed,
|
onPressed: _onContrastPressed,
|
||||||
isSelected: _selectedFilter == ColorToolType.contrast,
|
isSelected: _selectedFilter == ColorToolType.contrast,
|
||||||
activationOrder: _filters.keys.indexOf(ColorToolType.contrast),
|
activationOrder: _filters.keys
|
||||||
|
.indexOf(ColorToolType.contrast)
|
||||||
|
.run((i) => i == -1 ? null : i),
|
||||||
),
|
),
|
||||||
ToolbarButton(
|
ToolbarButton(
|
||||||
icon: Icons.circle,
|
icon: Icons.circle,
|
||||||
label: L10n.global().imageEditColorWhitePoint,
|
label: L10n.global().imageEditColorWhitePoint,
|
||||||
onPressed: _onWhitePointPressed,
|
onPressed: _onWhitePointPressed,
|
||||||
isSelected: _selectedFilter == ColorToolType.whitePoint,
|
isSelected: _selectedFilter == ColorToolType.whitePoint,
|
||||||
activationOrder:
|
activationOrder: _filters.keys
|
||||||
_filters.keys.indexOf(ColorToolType.whitePoint),
|
.indexOf(ColorToolType.whitePoint)
|
||||||
|
.run((i) => i == -1 ? null : i),
|
||||||
),
|
),
|
||||||
ToolbarButton(
|
ToolbarButton(
|
||||||
icon: Icons.circle_outlined,
|
icon: Icons.circle_outlined,
|
||||||
label: L10n.global().imageEditColorBlackPoint,
|
label: L10n.global().imageEditColorBlackPoint,
|
||||||
onPressed: _onBlackPointPressed,
|
onPressed: _onBlackPointPressed,
|
||||||
isSelected: _selectedFilter == ColorToolType.blackPoint,
|
isSelected: _selectedFilter == ColorToolType.blackPoint,
|
||||||
activationOrder:
|
activationOrder: _filters.keys
|
||||||
_filters.keys.indexOf(ColorToolType.blackPoint),
|
.indexOf(ColorToolType.blackPoint)
|
||||||
|
.run((i) => i == -1 ? null : i),
|
||||||
),
|
),
|
||||||
ToolbarButton(
|
ToolbarButton(
|
||||||
icon: Icons.invert_colors,
|
icon: Icons.invert_colors,
|
||||||
label: L10n.global().imageEditColorSaturation,
|
label: L10n.global().imageEditColorSaturation,
|
||||||
onPressed: _onSaturationPressed,
|
onPressed: _onSaturationPressed,
|
||||||
isSelected: _selectedFilter == ColorToolType.saturation,
|
isSelected: _selectedFilter == ColorToolType.saturation,
|
||||||
activationOrder:
|
activationOrder: _filters.keys
|
||||||
_filters.keys.indexOf(ColorToolType.saturation),
|
.indexOf(ColorToolType.saturation)
|
||||||
|
.run((i) => i == -1 ? null : i),
|
||||||
),
|
),
|
||||||
ToolbarButton(
|
ToolbarButton(
|
||||||
icon: Icons.thermostat,
|
icon: Icons.thermostat,
|
||||||
label: L10n.global().imageEditColorWarmth,
|
label: L10n.global().imageEditColorWarmth,
|
||||||
onPressed: _onWarmthPressed,
|
onPressed: _onWarmthPressed,
|
||||||
isSelected: _selectedFilter == ColorToolType.warmth,
|
isSelected: _selectedFilter == ColorToolType.warmth,
|
||||||
activationOrder: _filters.keys.indexOf(ColorToolType.warmth),
|
activationOrder: _filters.keys
|
||||||
|
.indexOf(ColorToolType.warmth)
|
||||||
|
.run((i) => i == -1 ? null : i),
|
||||||
),
|
),
|
||||||
ToolbarButton(
|
ToolbarButton(
|
||||||
icon: Icons.colorize,
|
icon: Icons.colorize,
|
||||||
label: L10n.global().imageEditColorTint,
|
label: L10n.global().imageEditColorTint,
|
||||||
onPressed: _onTintPressed,
|
onPressed: _onTintPressed,
|
||||||
isSelected: _selectedFilter == ColorToolType.tint,
|
isSelected: _selectedFilter == ColorToolType.tint,
|
||||||
activationOrder: _filters.keys.indexOf(ColorToolType.tint),
|
activationOrder: _filters.keys
|
||||||
|
.indexOf(ColorToolType.tint)
|
||||||
|
.run((i) => i == -1 ? null : i),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:nc_photos/k.dart' as k;
|
|
||||||
import 'package:nc_photos/theme.dart';
|
import 'package:nc_photos/theme.dart';
|
||||||
|
import 'package:nc_photos/k.dart' as k;
|
||||||
|
|
||||||
|
/// Button in the image editor toolbar
|
||||||
|
///
|
||||||
|
/// If [activationOrder] != null, this button is considered activated. And if
|
||||||
|
/// [activationOrder] >= 0, a number will be drawn on top to represent its
|
||||||
|
/// current order.
|
||||||
class ToolbarButton extends StatelessWidget {
|
class ToolbarButton extends StatelessWidget {
|
||||||
const ToolbarButton({
|
const ToolbarButton({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -9,7 +14,7 @@ class ToolbarButton extends StatelessWidget {
|
||||||
required this.label,
|
required this.label,
|
||||||
required this.onPressed,
|
required this.onPressed,
|
||||||
this.isSelected = false,
|
this.isSelected = false,
|
||||||
this.activationOrder = -1,
|
this.activationOrder,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -49,13 +54,13 @@ class ToolbarButton extends StatelessWidget {
|
||||||
: AppTheme.unfocusedIconColorDark,
|
: AppTheme.unfocusedIconColorDark,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (isActivated)
|
if (isActivated && activationOrder! >= 0)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 2),
|
padding: const EdgeInsets.only(top: 2),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: Text(
|
child: Text(
|
||||||
(activationOrder + 1).toString(),
|
(activationOrder! + 1).toString(),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: isSelected
|
color: isSelected
|
||||||
|
@ -84,11 +89,11 @@ class ToolbarButton extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isActivated => activationOrder >= 0;
|
bool get isActivated => activationOrder != null;
|
||||||
|
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final String label;
|
final String label;
|
||||||
final VoidCallback? onPressed;
|
final VoidCallback? onPressed;
|
||||||
final bool isSelected;
|
final bool isSelected;
|
||||||
final int activationOrder;
|
final int? activationOrder;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue