-
Notifications
You must be signed in to change notification settings - Fork 603
Added color field in environment model and ui #922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,5 @@ | ||||||||
| import 'dart:ui'; | ||||||||
|
|
||||||||
| import 'package:apidash/consts.dart'; | ||||||||
| import 'package:apidash/providers/providers.dart'; | ||||||||
| import 'package:apidash/utils/file_utils.dart'; | ||||||||
|
|
@@ -104,11 +106,12 @@ class EnvironmentsStateNotifier | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| void addEnvironment() { | ||||||||
| void addEnvironment({Color? color}) { | ||||||||
| final id = getNewUuid(); | ||||||||
| final newEnvironmentModel = EnvironmentModel( | ||||||||
| id: id, | ||||||||
| values: [], | ||||||||
| color: color??kGlobalColor | ||||||||
| ); | ||||||||
| state = { | ||||||||
| ...state!, | ||||||||
|
|
@@ -124,12 +127,13 @@ class EnvironmentsStateNotifier | |||||||
|
|
||||||||
| void updateEnvironment( | ||||||||
| String id, { | ||||||||
| String? name, | ||||||||
| String? name, Color? color, | ||||||||
|
||||||||
| String? name, Color? color, | |
| String? name, | |
| Color? color, |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,5 @@ | ||||||
| import 'dart:math'; | ||||||
|
||||||
| import 'dart:math'; | |
| import 'dart:math' show Random; |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The showEnvColorPickerDialog function lacks documentation. Consider adding a doc comment explaining its purpose and parameters:
/// Shows a dialog for selecting an environment color from a predefined palette.
///
/// The dialog displays the available colors from [kEnvColors] with hover effects
/// and updates the environment's color when a selection is made.
void showEnvColorPickerDialog(| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ class SidebarEnvironmentCard extends StatelessWidget { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.isGlobal = false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.isActive = false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.color, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.selectedId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.editRequestId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.setActive, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -27,6 +28,7 @@ class SidebarEnvironmentCard extends StatelessWidget { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| final bool isGlobal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final bool isActive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String? name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final Color? color; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String? selectedId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final String? editRequestId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final void Function(bool?)? setActive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -41,8 +43,8 @@ class SidebarEnvironmentCard extends StatelessWidget { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| @override | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Widget build(BuildContext context) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final colorScheme = Theme.of(context).colorScheme; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final Color color = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isGlobal ? colorScheme.secondaryContainer : colorScheme.surface; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final colorDot = color; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final colorDot = color; | |
| final colorDot = color; |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Inconsistent formatting: The opening brace should be on the same line as the Row widget. Additionally, the Container widget parameters should follow consistent indentation. Current code has width and height on the same line but other properties on separate lines.
| Container(width: 8, | |
| height: 8, | |
| decoration: BoxDecoration( | |
| shape: BoxShape.circle, | |
| color: colorDot), | |
| margin: kPe8, | |
| ), | |
| Text( | |
| nm, | |
| softWrap: false, | |
| overflow: TextOverflow.fade, | |
| ), | |
| Container( | |
| width: 8, | |
| height: 8, | |
| decoration: BoxDecoration( | |
| shape: BoxShape.circle, | |
| color: colorDot, | |
| ), | |
| margin: kPe8, | |
| ), | |
| Text( | |
| nm, | |
| softWrap: false, | |
| overflow: TextOverflow.fade, | |
| ), |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,11 +10,13 @@ class EnvironmentPopupMenu extends StatelessWidget { | |||||
| this.value, | ||||||
| this.options, | ||||||
| this.onChanged, | ||||||
| this.color | ||||||
|
||||||
| this.color | |
| this.color, |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Missing trailing comma after the closing parenthesis on line 35. This would improve formatting consistency. The line should end with a comma after the closing parenthesis of getEnvironmentTitle(e.name).clip(30).
| )) ?? | |
| ,)) ?? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| enum EnvironmentVariableType { variable, secret } | ||
|
|
||
| const kGlobalColor = Colors.blue; |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,5 @@ | ||||||||||
| import 'dart:ui'; | ||||||||||
|
|
||||||||||
| import 'package:freezed_annotation/freezed_annotation.dart'; | ||||||||||
| import '../consts.dart'; | ||||||||||
|
|
||||||||||
|
|
@@ -15,6 +17,7 @@ class EnvironmentModel with _$EnvironmentModel { | |||||||||
| required String id, | ||||||||||
| @Default("") String name, | ||||||||||
| @Default([]) List<EnvironmentVariableModel> values, | ||||||||||
| @ColorConverter() @Default(kGlobalColor) Color color | ||||||||||
|
||||||||||
| @ColorConverter() @Default(kGlobalColor) Color color | |
| @ColorConverter() @Default(kGlobalColor) Color color, |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed from const to non-const unnecessarily. Since kEnvironmentVariableEmptyModel is a constant expression with literal values, it should remain const for compile-time optimization. The removal of const here appears to be unintended.
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The ColorConverter class lacks documentation. Consider adding a doc comment explaining its purpose, such as:
/// Converts between Flutter's [Color] type and an integer representation for JSON serialization.
/// Uses ARGB32 format for storage.
class ColorConverter implements JsonConverter<Color, int> {| /// Converts between Flutter's [Color] type and an integer representation for JSON serialization. | |
| /// Uses ARGB32 format for storage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after the null coalescing operator. Should be
color ?? kGlobalColorinstead ofcolor??kGlobalColorfor better code readability and consistency.