mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 02:18: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/double_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/widget/image_editor/toolbar_button.dart';
|
||||
import 'package:nc_photos/widget/stateful_slider.dart';
|
||||
|
@ -111,53 +112,63 @@ class _ColorToolbarState extends State<ColorToolbar> {
|
|||
label: L10n.global().imageEditColorBrightness,
|
||||
onPressed: _onBrightnessPressed,
|
||||
isSelected: _selectedFilter == ColorToolType.brightness,
|
||||
activationOrder:
|
||||
_filters.keys.indexOf(ColorToolType.brightness),
|
||||
activationOrder: _filters.keys
|
||||
.indexOf(ColorToolType.brightness)
|
||||
.run((i) => i == -1 ? null : i),
|
||||
),
|
||||
ToolbarButton(
|
||||
icon: Icons.contrast,
|
||||
label: L10n.global().imageEditColorContrast,
|
||||
onPressed: _onContrastPressed,
|
||||
isSelected: _selectedFilter == ColorToolType.contrast,
|
||||
activationOrder: _filters.keys.indexOf(ColorToolType.contrast),
|
||||
activationOrder: _filters.keys
|
||||
.indexOf(ColorToolType.contrast)
|
||||
.run((i) => i == -1 ? null : i),
|
||||
),
|
||||
ToolbarButton(
|
||||
icon: Icons.circle,
|
||||
label: L10n.global().imageEditColorWhitePoint,
|
||||
onPressed: _onWhitePointPressed,
|
||||
isSelected: _selectedFilter == ColorToolType.whitePoint,
|
||||
activationOrder:
|
||||
_filters.keys.indexOf(ColorToolType.whitePoint),
|
||||
activationOrder: _filters.keys
|
||||
.indexOf(ColorToolType.whitePoint)
|
||||
.run((i) => i == -1 ? null : i),
|
||||
),
|
||||
ToolbarButton(
|
||||
icon: Icons.circle_outlined,
|
||||
label: L10n.global().imageEditColorBlackPoint,
|
||||
onPressed: _onBlackPointPressed,
|
||||
isSelected: _selectedFilter == ColorToolType.blackPoint,
|
||||
activationOrder:
|
||||
_filters.keys.indexOf(ColorToolType.blackPoint),
|
||||
activationOrder: _filters.keys
|
||||
.indexOf(ColorToolType.blackPoint)
|
||||
.run((i) => i == -1 ? null : i),
|
||||
),
|
||||
ToolbarButton(
|
||||
icon: Icons.invert_colors,
|
||||
label: L10n.global().imageEditColorSaturation,
|
||||
onPressed: _onSaturationPressed,
|
||||
isSelected: _selectedFilter == ColorToolType.saturation,
|
||||
activationOrder:
|
||||
_filters.keys.indexOf(ColorToolType.saturation),
|
||||
activationOrder: _filters.keys
|
||||
.indexOf(ColorToolType.saturation)
|
||||
.run((i) => i == -1 ? null : i),
|
||||
),
|
||||
ToolbarButton(
|
||||
icon: Icons.thermostat,
|
||||
label: L10n.global().imageEditColorWarmth,
|
||||
onPressed: _onWarmthPressed,
|
||||
isSelected: _selectedFilter == ColorToolType.warmth,
|
||||
activationOrder: _filters.keys.indexOf(ColorToolType.warmth),
|
||||
activationOrder: _filters.keys
|
||||
.indexOf(ColorToolType.warmth)
|
||||
.run((i) => i == -1 ? null : i),
|
||||
),
|
||||
ToolbarButton(
|
||||
icon: Icons.colorize,
|
||||
label: L10n.global().imageEditColorTint,
|
||||
onPressed: _onTintPressed,
|
||||
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),
|
||||
],
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
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 {
|
||||
const ToolbarButton({
|
||||
Key? key,
|
||||
|
@ -9,7 +14,7 @@ class ToolbarButton extends StatelessWidget {
|
|||
required this.label,
|
||||
required this.onPressed,
|
||||
this.isSelected = false,
|
||||
this.activationOrder = -1,
|
||||
this.activationOrder,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -49,13 +54,13 @@ class ToolbarButton extends StatelessWidget {
|
|||
: AppTheme.unfocusedIconColorDark,
|
||||
),
|
||||
),
|
||||
if (isActivated)
|
||||
if (isActivated && activationOrder! >= 0)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Text(
|
||||
(activationOrder + 1).toString(),
|
||||
(activationOrder! + 1).toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isSelected
|
||||
|
@ -84,11 +89,11 @@ class ToolbarButton extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
bool get isActivated => activationOrder >= 0;
|
||||
bool get isActivated => activationOrder != null;
|
||||
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final VoidCallback? onPressed;
|
||||
final bool isSelected;
|
||||
final int activationOrder;
|
||||
final int? activationOrder;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue