[MonoTouch] UITableViews made simple

Craig Dunn craig.dunn at gmail.com
Sat Nov 14 02:22:56 EST 2009


Sounds neat. In the past I would have voted for option #1 - I was in  
love with attribute decoration for a while. Now option #2 seems nicer  
because it *seems* like it would be easier to localize?
That's my first thought, anyway
cd


On 14/11/2009, at 5:28 PM, Miguel de Icaza <miguel at novell.com> wrote:

> Hey folks,
>
>    I have been thinking about writing a control that would simplify
> making configuration-like UITableView, and I am struggling between the
> Mono.Options-like model for creating the data to be debugged and a  
> setup
> with classes and attributes.
>
>    For example, this is what the code would look like using classes  
> and
> attributes, it would use Reflection over public field names to extract
> default captions and attributes to spice up the UI (icons, separators,
> parameters).
>
>    Another option would be to build it like Mono.Options, where the UI
> is constructed one item at a time and would be trivial to add event
> handlers that respond on changes (with delegates):
>
> Style 1:
>
> class SoundConfig : Configurable {
>    [Icon ("airplane.png")]
>    public bool AirplaneMode;
>
>    [Text ("Wi-Fi"), Icon ("wifi.png")]
>    public Configurable WiFi;
>
>    [Icon ("Notifications")]
>    public Configurable Notifications;
>
>    [Icon ("Silent.png")]
>    public Separator Silent;
>    public bool Vibrate;
>
>    [Icon ("Ring")]
>    public Separator Ring;
>    public bool on;
>
>    [Slider ("mute.png", "full-volume.png")]
>    public float value;
> }
>
> UIViewController Do ()
> {
>    var s = new SoundConfig () {
>        AirplaneMode = true,
>        WiFi = ...;
>        Notifications = ...;
>        Vibrate = true;
>        on = false;
>        value = -0.5;
>    }
>    return new ReflectionViewController (s);
> }
>
>
> Style 2:
> class Demo {
>    static bool airplane;
>    static string wi_fi;
>
>    void Setup ()
>    {
>
>        var settings = new SettingsViewController (){
>            { airplane_icon, airplane, "Airplane Mode", v => airplane  
> = v },
>            { wifi_icon, wi_fi, "Wi-Fi", r => return r.ToString () }
>        };
>
>
>    }
>
> }
>
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>


More information about the MonoTouch mailing list