opt. for tag
This commit is contained in:
@@ -73,6 +73,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
showRoundDialog(
|
showRoundDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
title: Text(_s.attention),
|
||||||
child: Text(_s.sureToDeleteServer(widget.spi!.name)),
|
child: Text(_s.sureToDeleteServer(widget.spi!.name)),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
@@ -151,6 +152,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
|||||||
_tags = p0;
|
_tags = p0;
|
||||||
}),
|
}),
|
||||||
s: _s,
|
s: _s,
|
||||||
|
tagSuggestions: [..._serverProvider.tags],
|
||||||
),
|
),
|
||||||
width7,
|
width7,
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ class _SSHPageState extends State<SSHPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBody() {
|
Widget _buildBody() {
|
||||||
|
final keyboardType =
|
||||||
|
isIOS ? TextInputType.emailAddress : TextInputType.visiblePassword;
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: _media.size.height -
|
height: _media.size.height -
|
||||||
_virtualKeyboardHeight -
|
_virtualKeyboardHeight -
|
||||||
@@ -104,6 +106,7 @@ class _SSHPageState extends State<SSHPage> {
|
|||||||
child: TerminalView(
|
child: TerminalView(
|
||||||
_terminal,
|
_terminal,
|
||||||
controller: _terminalController,
|
controller: _terminalController,
|
||||||
|
keyboardType: keyboardType,
|
||||||
textStyle: _terminalStyle,
|
textStyle: _terminalStyle,
|
||||||
theme: _terminalTheme,
|
theme: _terminalTheme,
|
||||||
deleteDetection: isIOS,
|
deleteDetection: isIOS,
|
||||||
|
|||||||
@@ -10,22 +10,23 @@ class TagEditor extends StatelessWidget {
|
|||||||
final List<String> tags;
|
final List<String> tags;
|
||||||
final S s;
|
final S s;
|
||||||
final void Function(List<String>)? onChanged;
|
final void Function(List<String>)? onChanged;
|
||||||
|
final void Function(String)? onTapTag;
|
||||||
|
final List<String>? tagSuggestions;
|
||||||
|
|
||||||
const TagEditor({
|
const TagEditor({
|
||||||
super.key,
|
super.key,
|
||||||
required this.tags,
|
required this.tags,
|
||||||
this.onChanged,
|
|
||||||
required this.s,
|
required this.s,
|
||||||
|
this.onChanged,
|
||||||
|
this.onTapTag,
|
||||||
|
this.tagSuggestions,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return RoundRectCard(ListTile(
|
return RoundRectCard(ListTile(
|
||||||
leading: const Icon(Icons.tag),
|
leading: const Icon(Icons.tag),
|
||||||
title: _buildTags(
|
title: _buildTags(tags),
|
||||||
tags,
|
|
||||||
_onTapDelete,
|
|
||||||
),
|
|
||||||
trailing: InkWell(
|
trailing: InkWell(
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -35,54 +36,61 @@ class TagEditor extends StatelessWidget {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onTapDelete(String tag) {
|
Widget _buildTags(List<String> tags) {
|
||||||
tags.remove(tag);
|
tagSuggestions?.removeWhere((element) => tags.contains(element));
|
||||||
onChanged?.call(tags);
|
final suggestionLen = tagSuggestions?.length ?? 0;
|
||||||
}
|
final counts = tags.length + suggestionLen + (suggestionLen == 0 ? 0 : 1);
|
||||||
|
if (counts == 0) return Text(s.tag);
|
||||||
Widget _buildTags(
|
return ConstrainedBox(constraints: BoxConstraints(maxHeight: 27), child: ListView.builder(
|
||||||
List<String> tags,
|
|
||||||
Function(String) onTagDelete,
|
|
||||||
) {
|
|
||||||
if (tags.isEmpty) return Text(s.tag);
|
|
||||||
return SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: Row(
|
itemBuilder: (context, index) {
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
if (index < tags.length) {
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
return _buildTagItem(tags[index], false);
|
||||||
children: tags.map((e) => _buildTagItem(e, onTagDelete)).toList(),
|
} else if (index > tags.length) {
|
||||||
),
|
return _buildTagItem(tagSuggestions![index - tags.length - 1], true);
|
||||||
);
|
}
|
||||||
|
return const VerticalDivider();
|
||||||
|
},
|
||||||
|
itemCount: counts,
|
||||||
|
),);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTagItem(String tag, Function(String) onTagDelete) {
|
Widget _buildTagItem(String tag, bool isAdd) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(right: 7),
|
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||||
child: Container(
|
child: GestureDetector(
|
||||||
decoration: BoxDecoration(
|
onTap: () => onTapTag?.call(tag),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20.0)),
|
child: Container(
|
||||||
color: primaryColor,
|
decoration: BoxDecoration(
|
||||||
),
|
borderRadius: const BorderRadius.all(Radius.circular(20.0)),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 3),
|
color: primaryColor,
|
||||||
child: Row(
|
),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 3),
|
||||||
children: [
|
child: Row(
|
||||||
Text(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
'#$tag',
|
children: [
|
||||||
style: const TextStyle(color: Colors.white),
|
Text(
|
||||||
),
|
'#$tag',
|
||||||
const SizedBox(width: 4.0),
|
style: const TextStyle(color: Colors.white),
|
||||||
InkWell(
|
|
||||||
child: const Icon(
|
|
||||||
Icons.cancel,
|
|
||||||
size: 14.0,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
),
|
||||||
onTap: () {
|
const SizedBox(width: 4.0),
|
||||||
onTagDelete(tag);
|
InkWell(
|
||||||
},
|
child: Icon(
|
||||||
)
|
isAdd ? Icons.add_circle : Icons.cancel,
|
||||||
],
|
size: 14.0,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
if (isAdd) {
|
||||||
|
tags.add(tag);
|
||||||
|
} else {
|
||||||
|
tags.remove(tag);
|
||||||
|
}
|
||||||
|
onChanged?.call(tags);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user