Fixed edit client upstreams

This commit is contained in:
Juan Gilsanz Polo 2022-10-07 18:29:23 +02:00
parent c25e3375e6
commit 1e8e0d7ff0

View file

@ -84,6 +84,10 @@ class _ClientModalState extends State<ClientModal> {
enableSafeSearch = widget.client!.safesearchEnabled; enableSafeSearch = widget.client!.safesearchEnabled;
useGlobalSettingsServices = widget.client!.useGlobalBlockedServices; useGlobalSettingsServices = widget.client!.useGlobalBlockedServices;
blockedServices = widget.client!.blockedServices; blockedServices = widget.client!.blockedServices;
upstreamServers = widget.client!.upstreams.map((e) => {
'id': uuid.v4(),
'controller': TextEditingController(text: e)
}).toList();
} }
super.initState(); super.initState();
} }
@ -584,7 +588,9 @@ class _ClientModalState extends State<ClientModal> {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width - 108, width: editMode == true
? MediaQuery.of(context).size.width - 108
: MediaQuery.of(context).size.width - 40,
child: TextFormField( child: TextFormField(
enabled: editMode, enabled: editMode,
controller: controller['controller'], controller: controller['controller'],
@ -600,13 +606,15 @@ class _ClientModalState extends State<ClientModal> {
), ),
), ),
), ),
const SizedBox(width: 20), if (editMode == true) ...[
IconButton( const SizedBox(width: 20),
onPressed: () => setState( IconButton(
() => upstreamServers = upstreamServers.where((e) => e['id'] != controller['id']).toList() onPressed: () => setState(
), () => upstreamServers = upstreamServers.where((e) => e['id'] != controller['id']).toList()
icon: const Icon(Icons.remove_circle_outline_outlined) ),
) icon: const Icon(Icons.remove_circle_outline_outlined)
)
]
], ],
), ),
), ),