-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrating more work from Save parameter page (#125)
- Loading branch information
Showing
5 changed files
with
148 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:parameter_page/widgets/page_persistence_state_indicator_widget.dart'; | ||
|
||
class PageTitleWidget extends StatelessWidget { | ||
final TextEditingController controller = TextEditingController(); | ||
|
||
final String title; | ||
|
||
final bool editing; | ||
|
||
final PagePersistenceState persistenceState; | ||
|
||
final Function(String) onTitleUpdate; | ||
|
||
PageTitleWidget( | ||
{super.key, | ||
required this.title, | ||
required this.editing, | ||
required this.persistenceState, | ||
required this.onTitleUpdate}) { | ||
controller.text = title; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
key: const Key("page_title"), | ||
child: editing ? _buildEditor() : _buildReadOnly()); | ||
} | ||
|
||
Widget _buildReadOnly() { | ||
return Row(children: [ | ||
Text(title), | ||
const SizedBox(width: 8.0), | ||
PagePersistenceStateIndicatorWidget(persistenceState: persistenceState) | ||
]); | ||
} | ||
|
||
Widget _buildEditor() { | ||
return Row(children: [ | ||
Expanded( | ||
child: TextField( | ||
key: const Key("page_title_textfield"), | ||
maxLines: 1, | ||
minLines: 1, | ||
controller: controller, | ||
onTapOutside: (PointerDownEvent event) => | ||
onTitleUpdate.call(controller.text), | ||
)) | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters