Skip to content
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

Show border for layout tab while focused #25

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions lib/tag_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class TagEditor<T> extends StatefulWidget {
this.itemHighlightColor,
this.useDefaultHighlight = true,
this.enableFocusAfterEnter = true,
this.enableBorder = false,
this.onSelectOptionAction})
: super(key: key);

Expand Down Expand Up @@ -131,6 +132,9 @@ class TagEditor<T> extends StatefulWidget {
final OnDeleteTagAction? onDeleteTagAction;
final OnFocusTagAction? onFocusTagAction;

/// Enable border layout tab
final bool enableBorder;

/// [TextField]'s properties.
///
/// Please refer to [TextField] documentation.
Expand Down Expand Up @@ -617,16 +621,22 @@ class TagsEditorState<T> extends State<TagEditor<T>> {
))
: widget.inputDecoration;

final borderSize =
widget.borderSize ?? ((_isFocused || widget.enableBorder) ? 1 : 0.5);
var borderColor = Colors.transparent;
if (widget.enableBorder) {
borderColor = widget.enableBorderColor ?? Colors.transparent;
}
if (_isFocused) {
borderColor = widget.focusedBorderColor ?? Colors.transparent;
}
final borderRadius = widget.borderRadius ?? 0;

final tagEditorArea = Container(
padding: widget.padding ?? EdgeInsets.zero,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(widget.borderRadius ?? 0)),
border: Border.all(
width: widget.borderSize ?? (_isFocused ? 1 : 0.5),
color: _isFocused
? widget.focusedBorderColor ?? Colors.transparent
: widget.enableBorderColor ?? Colors.transparent),
borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
border: Border.all(width: borderSize, color: borderColor),
color: widget.backgroundColor ?? Colors.transparent),
child: TagLayout(
delegate: TagEditorLayoutDelegate(
Expand Down