TF-4233 Correctly set current label color on edit dialog open
This commit is contained in:
@@ -47,6 +47,9 @@ class _ColorsMapWidgetState extends State<ColorsMapWidget> {
|
||||
Color(0xFF646580),
|
||||
];
|
||||
|
||||
static final Set<int> _defaultColorValues =
|
||||
_defaultColors.map((c) => c.toInt()).toSet();
|
||||
|
||||
final ValueNotifier<Color?> _selectedColor = ValueNotifier(null);
|
||||
List<Color> _colorList = <Color>[];
|
||||
|
||||
@@ -128,7 +131,14 @@ class _ColorsMapWidgetState extends State<ColorsMapWidget> {
|
||||
|
||||
void _setUpColorList() {
|
||||
final custom = widget.customColor;
|
||||
_colorList = custom != null ? [custom, ..._defaultColors] : _defaultColors;
|
||||
final hasCustom = custom != null;
|
||||
final isCustomInDefaults =
|
||||
hasCustom && _defaultColorValues.contains(custom.toInt());
|
||||
|
||||
_colorList = (hasCustom && !isCustomInDefaults)
|
||||
? [custom, ..._defaultColors]
|
||||
: _defaultColors;
|
||||
|
||||
_selectedColor.value = custom;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,13 @@ extension HandleLabelActionTypeExtension on LabelController {
|
||||
required AccountId? accountId,
|
||||
required Label label,
|
||||
}) async {
|
||||
if (accountId == null) {
|
||||
consumeState(
|
||||
Stream.value(Left(EditLabelFailure(NotFoundAccountIdException()))),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await DialogRouter().openDialogModal(
|
||||
child: CreateNewLabelModal(
|
||||
labels: labels,
|
||||
|
||||
@@ -76,6 +76,7 @@ class _CreateNewLabelModalState extends State<CreateNewLabelModal> {
|
||||
_nameInputController.text = selectedLabel.safeDisplayName;
|
||||
_nameInputFocusNode.requestFocus();
|
||||
_createLabelStateNotifier.value = true;
|
||||
_labelSelectedColorNotifier.value = _selectedColor;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user