-
Notifications
You must be signed in to change notification settings - Fork 571
Turning textfield multiline #828
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
base: main
Are you sure you want to change the base?
Changes from all commits
cc4aa0c
ad7b3ca
adb9ea8
667651c
2763823
b093d4b
e0fce1e
477ec39
7d476f6
14f6924
626cb4c
f987c95
38764bd
aeb1c86
dff4789
b3e125d
09e8781
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -23,13 +23,102 @@ class EditEnvironmentVariablesState | |||||
final random = Random.secure(); | ||||||
late List<EnvironmentVariableModel> variableRows; | ||||||
bool isAddingRow = false; | ||||||
OverlayEntry? _overlayEntry; | ||||||
FocusNode? _currentFocusNode; | ||||||
|
||||||
@override | ||||||
void initState() { | ||||||
super.initState(); | ||||||
seed = random.nextInt(kRandMax); | ||||||
} | ||||||
|
||||||
@override | ||||||
void dispose() { | ||||||
_removeOverlay(); | ||||||
super.dispose(); | ||||||
} | ||||||
|
||||||
void _removeOverlay() { | ||||||
_overlayEntry?.remove(); | ||||||
_overlayEntry = null; | ||||||
_currentFocusNode?.removeListener(_handleOverlayFocusChange); | ||||||
_currentFocusNode = null; | ||||||
} | ||||||
|
||||||
void _handleOverlayFocusChange() { | ||||||
if (_currentFocusNode != null && !_currentFocusNode!.hasFocus) { | ||||||
_removeOverlay(); | ||||||
} | ||||||
} | ||||||
|
||||||
void _showOverlay( | ||||||
GlobalKey key, | ||||||
String text, | ||||||
TextStyle textStyle, | ||||||
ColorScheme clrScheme, | ||||||
FocusNode focusNode, | ||||||
TextEditingController controller, | ||||||
InputDecoration decoration, | ||||||
) { | ||||||
_removeOverlay(); | ||||||
|
||||||
final RenderBox renderBox = key.currentContext!.findRenderObject() as RenderBox; | ||||||
final position = renderBox.localToGlobal(Offset.zero); | ||||||
final size = renderBox.size; | ||||||
|
||||||
_currentFocusNode = focusNode; | ||||||
_currentFocusNode?.addListener(_handleOverlayFocusChange); | ||||||
|
||||||
_overlayEntry = OverlayEntry( | ||||||
builder: (context) => Positioned( | ||||||
left: position.dx, | ||||||
top: position.dy, | ||||||
width: size.width, | ||||||
child: Material( | ||||||
elevation: 8, | ||||||
borderRadius: BorderRadius.circular(8), | ||||||
child: Container( | ||||||
decoration: BoxDecoration( | ||||||
color: clrScheme.surface, | ||||||
), | ||||||
child: TextField( | ||||||
controller: controller, | ||||||
focusNode: focusNode, | ||||||
style: textStyle, | ||||||
decoration: decoration, | ||||||
maxLines: null, | ||||||
keyboardType: TextInputType.multiline, | ||||||
autofocus: true, | ||||||
onSubmitted: (_) { | ||||||
focusNode.unfocus(); | ||||||
_removeOverlay(); | ||||||
}, | ||||||
), | ||||||
), | ||||||
), | ||||||
), | ||||||
); | ||||||
|
||||||
Overlay.of(context).insert(_overlayEntry!); | ||||||
} | ||||||
|
||||||
void _onOverlayToggle( | ||||||
bool show, | ||||||
GlobalKey key, | ||||||
String text, | ||||||
TextStyle textStyle, | ||||||
ColorScheme clrScheme, | ||||||
FocusNode focusNode, | ||||||
TextEditingController controller, | ||||||
InputDecoration decoration, | ||||||
) { | ||||||
if (show) { | ||||||
_showOverlay(key, text, textStyle, clrScheme, focusNode, controller, decoration); | ||||||
} else { | ||||||
_removeOverlay(); | ||||||
} | ||||||
} | ||||||
|
||||||
void _onFieldChange(String selectedId) { | ||||||
final environment = ref.read(selectedEnvironmentModelProvider); | ||||||
final secrets = getEnvironmentSecrets(environment); | ||||||
|
@@ -67,7 +156,7 @@ class EditEnvironmentVariablesState | |||||
fixedWidth: 30, | ||||||
), | ||||||
DataColumn2( | ||||||
label: Text("Variable value"), | ||||||
label: Text(" jars value"), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The label text ' jars value' appears to be a typo and should be 'Variable value' to match the original functionality.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
), | ||||||
DataColumn2( | ||||||
label: Text(''), | ||||||
|
@@ -118,6 +207,7 @@ class EditEnvironmentVariablesState | |||||
_onFieldChange(selectedId!); | ||||||
}, | ||||||
colorScheme: Theme.of(context).colorScheme, | ||||||
onOverlayToggle: _onOverlayToggle, | ||||||
), | ||||||
), | ||||||
DataCell( | ||||||
|
@@ -146,6 +236,7 @@ class EditEnvironmentVariablesState | |||||
_onFieldChange(selectedId!); | ||||||
}, | ||||||
colorScheme: Theme.of(context).colorScheme, | ||||||
onOverlayToggle: _onOverlayToggle, | ||||||
), | ||||||
), | ||||||
DataCell( | ||||||
|
@@ -175,57 +266,63 @@ class EditEnvironmentVariablesState | |||||
}, | ||||||
); | ||||||
|
||||||
return Stack( | ||||||
children: [ | ||||||
Container( | ||||||
decoration: BoxDecoration( | ||||||
color: Theme.of(context).colorScheme.surface, | ||||||
borderRadius: kBorderRadius12, | ||||||
), | ||||||
margin: kPh10t10, | ||||||
child: Column( | ||||||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||||||
children: [ | ||||||
Expanded( | ||||||
child: Theme( | ||||||
data: Theme.of(context) | ||||||
.copyWith(scrollbarTheme: kDataTableScrollbarTheme), | ||||||
child: DataTable2( | ||||||
columnSpacing: 12, | ||||||
dividerThickness: 0, | ||||||
horizontalMargin: 0, | ||||||
headingRowHeight: 0, | ||||||
dataRowHeight: kDataTableRowHeight, | ||||||
bottomMargin: kDataTableBottomPadding, | ||||||
isVerticalScrollBarVisible: true, | ||||||
columns: columns, | ||||||
rows: dataRows, | ||||||
return GestureDetector( | ||||||
onTap: () { | ||||||
FocusScope.of(context).requestFocus(FocusNode()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creating a new FocusNode without disposal causes a resource leak. Use
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
_removeOverlay(); | ||||||
}, | ||||||
child: Stack( | ||||||
children: [ | ||||||
Container( | ||||||
decoration: BoxDecoration( | ||||||
color: Theme.of(context).colorScheme.surface, | ||||||
borderRadius: kBorderRadius12, | ||||||
), | ||||||
margin: kPh10t10, | ||||||
child: Column( | ||||||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||||||
children: [ | ||||||
Expanded( | ||||||
child: Theme( | ||||||
data: Theme.of(context) | ||||||
.copyWith(scrollbarTheme: kDataTableScrollbarTheme), | ||||||
child: DataTable2( | ||||||
columnSpacing: 12, | ||||||
dividerThickness: 0, | ||||||
horizontalMargin: 0, | ||||||
headingRowHeight: 0, | ||||||
dataRowHeight: null, | ||||||
bottomMargin: kDataTableBottomPadding, | ||||||
isVerticalScrollBarVisible: true, | ||||||
columns: columns, | ||||||
rows: dataRows, | ||||||
), | ||||||
), | ||||||
), | ||||||
), | ||||||
if (!kIsMobile) kVSpacer40, | ||||||
], | ||||||
if (!kIsMobile) kVSpacer40, | ||||||
], | ||||||
), | ||||||
), | ||||||
), | ||||||
if (!kIsMobile) | ||||||
Align( | ||||||
alignment: Alignment.bottomCenter, | ||||||
child: Padding( | ||||||
padding: kPb15, | ||||||
child: ElevatedButton.icon( | ||||||
onPressed: () { | ||||||
variableRows.add(kEnvironmentVariableEmptyModel); | ||||||
_onFieldChange(selectedId!); | ||||||
}, | ||||||
icon: const Icon(Icons.add), | ||||||
label: const Text( | ||||||
kLabelAddVariable, | ||||||
style: kTextStyleButton, | ||||||
if (!kIsMobile) | ||||||
Align( | ||||||
alignment: Alignment.bottomCenter, | ||||||
child: Padding( | ||||||
padding: kPb15, | ||||||
child: ElevatedButton.icon( | ||||||
onPressed: () { | ||||||
variableRows.add(kEnvironmentVariableEmptyModel); | ||||||
_onFieldChange(selectedId!); | ||||||
}, | ||||||
icon: const Icon(Icons.add), | ||||||
label: const Text( | ||||||
kLabelAddVariable, | ||||||
style: kTextStyleButton, | ||||||
), | ||||||
), | ||||||
), | ||||||
), | ||||||
), | ||||||
], | ||||||
], | ||||||
), | ||||||
); | ||||||
} | ||||||
} | ||||||
} |
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 readOnly and obscureText properties that were present in the original implementation. These properties should be passed to ExtendedTextField to maintain backward compatibility.
Copilot uses AI. Check for mistakes.