Building upon #183, this PR aims to prevent inconsistency when renaming a station by preventing the "Rename" button from being pressed when the form is invalid.
Previously the rename station dialog had the potential to cause an issue on different view sizes, as it seems it only coincidentally prevented an invalid rename by covering the "Rename" button with the TextView error message. This PR disables the button when the station name is invalid.
The Form Concept
This PR introduces a new, abstract Form class, which currently is just responsible for grouping fields (although in this case the form only has a single field) and providing a structure for validating a form and firing callbacks.
A longer term vision might be to encapsulate each manual entry as a Form subclass, which can then be presented in a consistent manor (perhaps a full-screen dialog for phone-sized devices?), and also potentially encapsulate field labels & dynamically building the form views based on it's fields.
Building upon #183, this PR aims to prevent inconsistency when renaming a station by preventing the "Rename" button from being pressed when the form is invalid.
Previously the rename station dialog had the potential to cause an issue on different view sizes, as it seems it only coincidentally prevented an invalid rename by covering the "Rename" button with the
TextView
error message. This PR disables the button when the station name is invalid.The
Form
ConceptThis PR introduces a new, abstract
Form
class, which currently is just responsible for grouping fields (although in this case the form only has a single field) and providing a structure for validating a form and firing callbacks.A longer term vision might be to encapsulate each manual entry as a
Form
subclass, which can then be presented in a consistent manor (perhaps a full-screen dialog for phone-sized devices?), and also potentially encapsulate field labels & dynamically building the form views based on it's fields.The Result
https://user-images.githubusercontent.com/630/189769748-d790610f-c5c9-4435-b097-b17735df8e53.mp4
Note: