refactor(mobile): Use switch expression when possible (#15852)

refactor: Use `switch` expression when possible

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Damiano Ferrari 2025-02-02 22:46:46 +01:00 committed by GitHub
parent 4efacfbb91
commit 96a6cc20b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 219 additions and 374 deletions

View file

@ -36,32 +36,19 @@ class AppLogPage extends HookConsumerWidget {
);
}
Widget buildLeadingIcon(LogLevel level) {
switch (level) {
case LogLevel.INFO:
return colorStatusIndicator(context.primaryColor);
case LogLevel.SEVERE:
return colorStatusIndicator(Colors.redAccent);
Widget buildLeadingIcon(LogLevel level) => switch (level) {
LogLevel.INFO => colorStatusIndicator(context.primaryColor),
LogLevel.SEVERE => colorStatusIndicator(Colors.redAccent),
LogLevel.WARNING => colorStatusIndicator(Colors.orangeAccent),
_ => colorStatusIndicator(Colors.grey),
};
case LogLevel.WARNING:
return colorStatusIndicator(Colors.orangeAccent);
default:
return colorStatusIndicator(Colors.grey);
}
}
getTileColor(LogLevel level) {
switch (level) {
case LogLevel.INFO:
return Colors.transparent;
case LogLevel.SEVERE:
return Colors.redAccent.withOpacity(0.25);
case LogLevel.WARNING:
return Colors.orangeAccent.withOpacity(0.25);
default:
return context.primaryColor.withOpacity(0.1);
}
}
Color getTileColor(LogLevel level) => switch (level) {
LogLevel.INFO => Colors.transparent,
LogLevel.SEVERE => Colors.redAccent.withOpacity(0.25),
LogLevel.WARNING => Colors.orangeAccent.withOpacity(0.25),
_ => context.primaryColor.withOpacity(0.1),
};
return Scaffold(
appBar: AppBar(