-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for customizable action colors (#1304)
* Add support for customizale action colors * Add red action color * Refactor action color settings widget
- Loading branch information
Showing
22 changed files
with
636 additions
and
95 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
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
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,45 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
|
||
class ActionColor { | ||
static const String orange = '0xFFF57C00'; // Colors.orange.shade700 | ||
static const String blue = '0xFF1976D2'; // Colors.blue.shade700 | ||
static const String purple = '0xFF7B1FA2'; // Colors.purple.shade700 | ||
static const String teal = '0xFF4DB6AC'; // Colors.teal.shade300 | ||
static const String green = '0xFF388E3C'; // Colors.green.shade700 | ||
static const String red = '0xFFD32F2F'; // Colors.red.shade700 | ||
|
||
final String colorRaw; | ||
|
||
Color get color => Color(int.parse(colorRaw)); | ||
|
||
const ActionColor.fromString({required this.colorRaw}); | ||
|
||
@override | ||
String toString() => color.value.toString(); | ||
|
||
String label(BuildContext context) { | ||
final AppLocalizations l10n = AppLocalizations.of(context)!; | ||
|
||
return switch (colorRaw) { | ||
orange => l10n.orange, | ||
blue => l10n.blue, | ||
purple => l10n.purple, | ||
teal => l10n.teal, | ||
green => l10n.green, | ||
red => l10n.red, | ||
_ => throw Exception('Unknown color'), | ||
}; | ||
} | ||
|
||
static List<ActionColor> getPossibleValues(ActionColor currentValue) { | ||
return [ | ||
currentValue.colorRaw == orange ? currentValue : const ActionColor.fromString(colorRaw: ActionColor.orange), | ||
currentValue.colorRaw == blue ? currentValue : const ActionColor.fromString(colorRaw: ActionColor.blue), | ||
currentValue.colorRaw == purple ? currentValue : const ActionColor.fromString(colorRaw: ActionColor.purple), | ||
currentValue.colorRaw == teal ? currentValue : const ActionColor.fromString(colorRaw: ActionColor.teal), | ||
currentValue.colorRaw == green ? currentValue : const ActionColor.fromString(colorRaw: ActionColor.green), | ||
currentValue.colorRaw == red ? currentValue : const ActionColor.fromString(colorRaw: ActionColor.red), | ||
]; | ||
} | ||
} |
Oops, something went wrong.