Skip to content

Commit

Permalink
Improved layout of field widget properties menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Sep 30, 2023
1 parent 2e1c6ef commit b7019fa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 34 deletions.
12 changes: 5 additions & 7 deletions lib/widgets/dialog_widgets/dialog_toggle_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ class DialogToggleSwitch extends StatefulWidget {
final Function(bool value) onToggle;
final bool initialValue;
final String? label;
final double maxWidth;

const DialogToggleSwitch({
super.key,
this.initialValue = false,
this.maxWidth = 75,
this.label,
required this.onToggle,
});
Expand All @@ -31,19 +29,19 @@ class _DialogToggleSwitchState extends State<DialogToggleSwitch> {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 4.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
border: Border.all(color: Theme.of(context).colorScheme.outline),
),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
constraints: BoxConstraints(maxWidth: widget.maxWidth),
Flexible(
child: Text(widget.label ?? '', textAlign: TextAlign.center),
),
const SizedBox(width: 5),
Switch(
onChanged: (value) {
widget.onToggle.call(value);
Expand Down
64 changes: 37 additions & 27 deletions lib/widgets/nt4_widgets/multi-topic/field_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,42 +130,52 @@ class FieldWidget extends StatelessWidget with NT4Widget {
initialValue: field!.game,
),
const SizedBox(height: 5),
DialogTextInput(
onSubmit: (value) {
double? newWidth = double.tryParse(value);
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
mainAxisSize: MainAxisSize.max,
children: [
Flexible(
child: DialogTextInput(
onSubmit: (value) {
double? newWidth = double.tryParse(value);

if (newWidth == null) {
return;
}
robotWidthMeters = newWidth;
refresh();
},
formatter: FilteringTextInputFormatter.allow(RegExp(r"[0-9.]")),
label: 'Robot Width (meters)',
initialText: robotWidthMeters.toString(),
),
const SizedBox(height: 5),
DialogTextInput(
onSubmit: (value) {
double? newLength = double.tryParse(value);
if (newWidth == null) {
return;
}
robotWidthMeters = newWidth;
refresh();
},
formatter: FilteringTextInputFormatter.allow(RegExp(r"[0-9.]")),
label: 'Robot Width (meters)',
initialText: robotWidthMeters.toString(),
),
),
const SizedBox(width: 5),
Flexible(
child: DialogTextInput(
onSubmit: (value) {
double? newLength = double.tryParse(value);

if (newLength == null) {
return;
}
robotLengthMeters = newLength;
refresh();
},
formatter: FilteringTextInputFormatter.allow(RegExp(r"[0-9.]")),
label: 'Robot Length (meters)',
initialText: robotLengthMeters.toString(),
if (newLength == null) {
return;
}
robotLengthMeters = newLength;
refresh();
},
formatter: FilteringTextInputFormatter.allow(RegExp(r"[0-9.]")),
label: 'Robot Length (meters)',
initialText: robotLengthMeters.toString(),
),
),
],
),
const SizedBox(height: 5),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
mainAxisSize: MainAxisSize.max,
children: [
Flexible(
child: DialogToggleSwitch(
maxWidth: 95,
label: 'Show Non-Robot Objects',
initialValue: showOtherObjects,
onToggle: (value) {
Expand Down

0 comments on commit b7019fa

Please sign in to comment.