Iteration 2 added the "Message" dialog type along with a bunch of properties corresponding to the different parts of a dialog -
Title,
PositiveText,
NegativeText,
CancelText - and the standard developer
Tag property. I decided to defer implementation of an Icon property until a later stage, as I wanted to introduce a
Style property for the Android version that was similar to the IOS
Style property, which would take a little more work than I wanted to put into this iteration.
I'd already decided to use the CustomLayoutDialog object to show the dialogs, leveraging the standard dialog elements and leaving me to focus on the content of the custom panel in the centre of the dialog. Unfortunately, the Android and IOS objects are implemented differently ...
- Android has a Dialog_Ready event for the developer to populate a panel, while IOS accepts a panel on the Initialize event;
- Android's dialog sizing is explicit with a .SetSize method, while IOS takes dimensions from the panel passed during initialize
... which lead to quite a complex block of layout/positioning code in my
ShowAsync method. In order to get the sizing correct, I leveraged a
SizeToFit code module from an earlier project. And then to avoid problems with very long messages - should they truncate? ellipsize? - I opted for neither and wrapped the multi-line
Message label in a ScrollView.
In line with allowing CharSequence/AttributedText objects in the
Message itself, I also added code to support their use on the buttons - both CustomLayoutDialog objects support a
GetButton method, and I wrapped setting the button text in it's own utility routine to hide the IOS dependency on NativeObject.
I wanted this class to behave similarly to the CustomLayoutDialog class when returning the result of the dialog (which button was pressed), so this iteration also introduced
Initialize parameters to support a callback event with the ability to adjust the callback event name (the same as most other callback implementations).
Finally, I discovered that the previous iteration's implementation of
DialogType constants wasn't going to work, as I was wanting to use the constants in the
Initialize sub, but at the point of object initialization, the constants themselves had not been initialized. In OO terms, I needed "class constants" but B4A/B4i only supported "instance constants" - the solution was to move the constants into the
Process_Globals sub of a code module.
I then ported to IOS, as before
https://www.b4x.com/android/forum/t...lass-with-input-validation.84984/#post-539363
This iteration took a little longer than expected, mostly due to the amount of time I spent figuring out how to code the layout logic. But now it's done, I think I've built a solid foundation for the introduction of input views in the next iterations.