//
// Triple Play - utilities for use in PlayN-based games
// Copyright (c) 2011-2013, Three Rings Design, Inc. - All rights reserved.
// http://github.com/threerings/tripleplay/blob/master/LICENSE

package tripleplay.platform;

import playn.core.Image;
import playn.ios.IOSPlatform;
import tripleplay.ui.Field;

/**
 * Implements iOS-specific TriplePlay services.
 */
public class IOSTPPlatform extends TPPlatform
{
    /** Registers the IOS TriplePlay platform. */
    public static IOSTPPlatform register (IOSPlatform platform) {
        IOSTPPlatform instance = new IOSTPPlatform(platform);
        TPPlatform.register(instance);
        return instance;
    }

    /** The iOS platform with which this TPPlatform was registered. */
    public final IOSPlatform platform;

    @Override public boolean hasNativeTextFields () {
        return true;
    }

    @Override public NativeTextField createNativeTextField (Field.Native field) {
        if (field.resolveStyle(Field.MULTILINE))
            return new IOSNativeTextField.MultiLine(_fieldHandler, null, field);
        return new IOSNativeTextField.SingleLine(_fieldHandler, null, field);
    }

    @Override public NativeTextField refresh (NativeTextField previous) {
        return ((IOSNativeTextField)previous).refresh();
    }

    @Override public ImageOverlay createImageOverlay (Image image) {
        return new IOSImageOverlay(image);
    }

    private IOSTPPlatform (IOSPlatform platform) {
        this.platform = platform;
        _fieldHandler = new IOSTextFieldHandler(this);
    }

    protected final IOSTextFieldHandler _fieldHandler;
}

@@ -942,18 +942,22 @@
         
-if
+return
  (field.
@@ -985,17 +985,18 @@
 LTILINE)
-)
+ ?
 %0A       
@@ -992,39 +992,32 @@
 ) ?%0A            
-return 
 new IOSNativeTex
@@ -1056,25 +1056,26 @@
 null, field)
-;
+ :
 %0A        ret
@@ -1063,38 +1063,35 @@
 ield) :%0A        
-return
+   
  new IOSNativeTe
@@ -1136,16 +1136,27 @@
 , field)
+).refresh()
 ;%0A    %7D%0A

Make sure new ios native fields get styles too.