Fix paddings for Mode switching.

This commit is contained in:
Dain Nilsson 2022-09-07 10:36:12 +02:00
parent 4b8b481418
commit f02781b6b6
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8

View File

@ -236,45 +236,49 @@ class _ManagementScreenState extends ConsumerState<ManagementScreen> {
@override
Widget build(BuildContext context) {
var canSave = false;
final child =
ref.watch(managementStateProvider(widget.deviceData.node.path)).when(
loading: () => const AppLoadingScreen(),
error: (error, _) => Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
error.toString(),
textAlign: TextAlign.center,
),
],
final child = ref
.watch(managementStateProvider(widget.deviceData.node.path))
.when(
loading: () => const AppLoadingScreen(),
error: (error, _) => Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
error.toString(),
textAlign: TextAlign.center,
),
),
data: (info) {
bool hasConfig = info.version.major > 4;
if (hasConfig) {
canSave = _enabled[Transport.usb] != 0 &&
!_mapEquals(
_enabled,
info.config.enabledCapabilities,
);
} else {
canSave = _interfaces != 0 &&
_interfaces !=
UsbInterface.forCapabilites(widget.deviceData.info
.config.enabledCapabilities[Transport.usb] ??
0);
}
return Column(
children: [
hasConfig
? _buildCapabilitiesForm(context, ref, info)
: _buildModeForm(context, ref, info),
],
);
},
],
),
),
data: (info) {
bool hasConfig = info.version.major > 4;
if (hasConfig) {
canSave = _enabled[Transport.usb] != 0 &&
!_mapEquals(
_enabled,
info.config.enabledCapabilities,
);
} else {
canSave = _interfaces != 0 &&
_interfaces !=
UsbInterface.forCapabilites(widget.deviceData.info.config
.enabledCapabilities[Transport.usb] ??
0);
}
return Column(
children: [
hasConfig
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 18.0),
child: _buildCapabilitiesForm(context, ref, info),
)
: _buildModeForm(context, ref, info),
],
);
},
);
return ResponsiveDialog(
title: Text(AppLocalizations.of(context)!.mgmt_toggle_applications),
@ -284,10 +288,7 @@ class _ManagementScreenState extends ConsumerState<ManagementScreen> {
child: Text(AppLocalizations.of(context)!.mgmt_save),
),
],
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 18.0),
child: child,
),
child: child,
);
}
}