Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions lib/widgets/add_node_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AddNodeSheet extends StatefulWidget {
}

class _AddNodeSheetState extends State<AddNodeSheet> {
int _directionEdits = 0;
bool _showTutorial = false;
bool _isCheckingTutorial = true;

Expand Down Expand Up @@ -285,11 +286,33 @@ class _AddNodeSheetState extends State<AddNodeSheet> {
const TextSpan(text: 'Directions: '),
if (directionsText.isNotEmpty)
...directionsText.split('**').asMap().entries.map((entry) {
final isEven = entry.key % 2 == 0;
return TextSpan(
text: entry.value,
style: TextStyle(
fontWeight: isEven ? FontWeight.normal : FontWeight.bold,
if (entry.key % 2 == 0) return TextSpan(text: entry.value);
// The current direction is typeable. Keyed on the value and
// an edit counter so it resyncs and drops rejected text.
return WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: SizedBox(
width: 64,
child: TextFormField(
key: ValueKey('$_directionEdits:${session.directionDegrees.round()}'),
initialValue: session.directionDegrees.round().toString(),
enabled: enableDirectionControls,
keyboardType: TextInputType.number,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
decoration: const InputDecoration(
isDense: true,
contentPadding: EdgeInsets.symmetric(vertical: 4, horizontal: 4),
border: OutlineInputBorder(),
),
onFieldSubmitted: (value) {
final degrees = int.tryParse(value);
if (degrees != null && degrees >= 0 && degrees <= 359) {
appState.updateSession(directionDeg: degrees.toDouble());
}
setState(() => _directionEdits++);
},
),
),
);
}),
Expand Down
33 changes: 28 additions & 5 deletions lib/widgets/edit_node_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class EditNodeSheet extends StatefulWidget {
}

class _EditNodeSheetState extends State<EditNodeSheet> {
int _directionEdits = 0;
bool _showTutorial = false;
bool _isCheckingTutorial = true;

Expand Down Expand Up @@ -208,11 +209,33 @@ class _EditNodeSheetState extends State<EditNodeSheet> {
const TextSpan(text: 'Directions: '),
if (directionsText.isNotEmpty)
...directionsText.split('**').asMap().entries.map((entry) {
final isEven = entry.key % 2 == 0;
return TextSpan(
text: entry.value,
style: TextStyle(
fontWeight: isEven ? FontWeight.normal : FontWeight.bold,
if (entry.key % 2 == 0) return TextSpan(text: entry.value);
// The current direction is typeable. Keyed on the value and
// an edit counter so it resyncs and drops rejected text.
return WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: SizedBox(
width: 64,
child: TextFormField(
key: ValueKey('$_directionEdits:${session.directionDegrees.round()}'),
initialValue: session.directionDegrees.round().toString(),
enabled: enableDirectionControls,
keyboardType: TextInputType.number,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
decoration: const InputDecoration(
isDense: true,
contentPadding: EdgeInsets.symmetric(vertical: 4, horizontal: 4),
border: OutlineInputBorder(),
),
onFieldSubmitted: (value) {
final degrees = int.tryParse(value);
if (degrees != null && degrees >= 0 && degrees <= 359) {
appState.updateEditSession(directionDeg: degrees.toDouble());
}
setState(() => _directionEdits++);
},
),
),
);
})
Expand Down
Loading