✨ Implement search in ports tab
This commit is contained in:
@ -15,6 +15,9 @@ class PortsTab extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PortsTabState extends State<PortsTab> {
|
class _PortsTabState extends State<PortsTab> {
|
||||||
|
final searchController = TextEditingController();
|
||||||
|
String searchText = "";
|
||||||
|
|
||||||
void onEditPort(mixer.Port port) {
|
void onEditPort(mixer.Port port) {
|
||||||
CreatePortDialog().show(context, widget.sendAction, port, false);
|
CreatePortDialog().show(context, widget.sendAction, port, false);
|
||||||
}
|
}
|
||||||
@ -48,48 +51,75 @@ class _PortsTabState extends State<PortsTab> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [...widget.mixerState.inputs, ...widget.mixerState.outputs]
|
children: [
|
||||||
.indexed
|
TextField(
|
||||||
.map(
|
decoration: InputDecoration(
|
||||||
(elem) => Card(
|
prefixIcon: const Icon(Icons.search),
|
||||||
child: ListTile(
|
suffixIcon: IconButton(
|
||||||
leading: (elem.$1 >= widget.mixerState.inputs.length)
|
icon: const Icon(Icons.clear),
|
||||||
? const Icon(Icons.speaker_outlined)
|
onPressed: () {
|
||||||
: const Icon(Icons.mic_none_outlined),
|
setState(() {
|
||||||
title: Text(elem.$2.name),
|
searchController.text = "";
|
||||||
subtitle: Text('Backend: ${elem.$2.properties.backend}'),
|
searchText = "";
|
||||||
trailing: PopupMenuButton<MenuAction>(
|
});
|
||||||
tooltip: "More Options",
|
},
|
||||||
onSelected: (MenuAction item) {
|
),
|
||||||
switch (item) {
|
labelText: 'Search',
|
||||||
case MenuAction.edit:
|
border: const OutlineInputBorder(),
|
||||||
onEditPort(elem.$2);
|
),
|
||||||
case MenuAction.delete:
|
onChanged: (val) {
|
||||||
onDeletePort(elem.$2);
|
setState(() {
|
||||||
}
|
searchText = val;
|
||||||
},
|
});
|
||||||
itemBuilder: (BuildContext context) =>
|
},
|
||||||
<PopupMenuEntry<MenuAction>>[
|
controller: searchController),
|
||||||
const PopupMenuItem<MenuAction>(
|
const SizedBox(height: 10),
|
||||||
value: MenuAction.edit,
|
...[...widget.mixerState.inputs, ...widget.mixerState.outputs]
|
||||||
child: ListTile(
|
.indexed
|
||||||
leading: Icon(Icons.mode_edit),
|
.where((elem) {
|
||||||
title: Text('Edit'),
|
return elem.$2.name
|
||||||
),
|
.toLowerCase()
|
||||||
|
.contains(searchText.toLowerCase());
|
||||||
|
}).map(
|
||||||
|
(elem) => Card(
|
||||||
|
child: ListTile(
|
||||||
|
leading: (elem.$1 >= widget.mixerState.inputs.length)
|
||||||
|
? const Icon(Icons.speaker_outlined)
|
||||||
|
: const Icon(Icons.mic_none_outlined),
|
||||||
|
title: Text(elem.$2.name),
|
||||||
|
subtitle: Text('Backend: ${elem.$2.properties.backend}'),
|
||||||
|
trailing: PopupMenuButton<MenuAction>(
|
||||||
|
tooltip: "More Options",
|
||||||
|
onSelected: (MenuAction item) {
|
||||||
|
switch (item) {
|
||||||
|
case MenuAction.edit:
|
||||||
|
onEditPort(elem.$2);
|
||||||
|
case MenuAction.delete:
|
||||||
|
onDeletePort(elem.$2);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
itemBuilder: (BuildContext context) =>
|
||||||
|
<PopupMenuEntry<MenuAction>>[
|
||||||
|
const PopupMenuItem<MenuAction>(
|
||||||
|
value: MenuAction.edit,
|
||||||
|
child: ListTile(
|
||||||
|
leading: Icon(Icons.mode_edit),
|
||||||
|
title: Text('Edit'),
|
||||||
),
|
),
|
||||||
const PopupMenuItem<MenuAction>(
|
),
|
||||||
value: MenuAction.delete,
|
const PopupMenuItem<MenuAction>(
|
||||||
child: ListTile(
|
value: MenuAction.delete,
|
||||||
leading: Icon(Icons.delete),
|
child: ListTile(
|
||||||
title: Text('Delete'),
|
leading: Icon(Icons.delete),
|
||||||
),
|
title: Text('Delete'),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
.toList(),
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user