diff --git a/UICatalog/.classpath b/UICatalog/.classpath
index 668d6ccf..d64599e5 100644
--- a/UICatalog/.classpath
+++ b/UICatalog/.classpath
@@ -1,9 +1,7 @@
-
-
-
+
diff --git a/UICatalog/.project b/UICatalog/.project
index ef563c05..637978c1 100644
--- a/UICatalog/.project
+++ b/UICatalog/.project
@@ -10,14 +10,8 @@
-
- org.robovm.eclipse.RoboVMClassBuilder
-
-
-
- org.springsource.ide.eclipse.gradle.core.nature
org.eclipse.jdt.core.javanature
org.robovm.eclipse.RoboVMNature
diff --git a/UICatalog/Info.plist.xml b/UICatalog/Info.plist.xml
index c2956aaf..8fad5307 100644
--- a/UICatalog/Info.plist.xml
+++ b/UICatalog/Info.plist.xml
@@ -24,6 +24,10 @@
${app.build}
LSRequiresIPhoneOS
+ UIMainStoryboardFile
+ Main
+ MinimumOSVersion
+ 8.0
UIDeviceFamily
1
@@ -46,32 +50,5 @@
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
- CFBundleIcons
-
- CFBundlePrimaryIcon
-
- CFBundleIconFiles
-
- Icon-Small
- Icon-Small-40
- Icon
- Icon-60
- Icon-72
-
-
-
- CFBundleIcons~ipad
-
- CFBundlePrimaryIcon
-
- CFBundleIconFiles
-
- Icon-Small
- Icon-Small-40
- Icon-72
- Icon-76
-
-
-
diff --git a/UICatalog/README.md b/UICatalog/README.md
deleted file mode 100644
index 11318d29..00000000
--- a/UICatalog/README.md
+++ /dev/null
@@ -1 +0,0 @@
-# UICatalog
diff --git a/UICatalog/build.gradle b/UICatalog/build.gradle
deleted file mode 100644
index 00f75951..00000000
--- a/UICatalog/build.gradle
+++ /dev/null
@@ -1,3 +0,0 @@
-ext {
- mainClassName = "org.robovm.samples.uicatalog.UICatalog"
-}
\ No newline at end of file
diff --git a/UICatalog/pom.xml b/UICatalog/pom.xml
deleted file mode 100644
index f547e20c..00000000
--- a/UICatalog/pom.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.robovm
- robovm-samples-parent
- 1.0
-
-
- robovm-samples-uicatalog
- RoboVM version of Apple's UICatalog sample
-
- jar
-
-
- src/main/java
-
-
-
-
- org.robovm
- robovm-rt
-
-
- org.robovm
- robovm-cocoatouch
-
-
-
-
diff --git a/UICatalog/resources/12-6AM.png b/UICatalog/resources/12-6AM.png
deleted file mode 100644
index c7b411e1..00000000
Binary files a/UICatalog/resources/12-6AM.png and /dev/null differ
diff --git a/UICatalog/resources/12-6PM.png b/UICatalog/resources/12-6PM.png
deleted file mode 100644
index c5443400..00000000
Binary files a/UICatalog/resources/12-6PM.png and /dev/null differ
diff --git a/UICatalog/resources/6-12AM.png b/UICatalog/resources/6-12AM.png
deleted file mode 100644
index 77f5a506..00000000
Binary files a/UICatalog/resources/6-12AM.png and /dev/null differ
diff --git a/UICatalog/resources/6-12PM.png b/UICatalog/resources/6-12PM.png
deleted file mode 100644
index a77859e3..00000000
Binary files a/UICatalog/resources/6-12PM.png and /dev/null differ
diff --git a/UICatalog/resources/Base.lproj/Main.storyboard b/UICatalog/resources/Base.lproj/Main.storyboard
new file mode 100644
index 00000000..17287e9f
--- /dev/null
+++ b/UICatalog/resources/Base.lproj/Main.storyboard
@@ -0,0 +1,2788 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is a UITextView that uses attributed text. You can programmatically modify the display of the text by making it bold, highlighted, underlined, tinted, and more. These attributes are defined in NSAttributedString.h. You can even embed attachments in an NSAttributedString!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/UICatalog/resources/Default-667h@2x~iphone.png b/UICatalog/resources/Default-667h@2x~iphone.png
deleted file mode 100644
index 54ead7d9..00000000
Binary files a/UICatalog/resources/Default-667h@2x~iphone.png and /dev/null differ
diff --git a/UICatalog/resources/Default-736h@3x~iphone.png b/UICatalog/resources/Default-736h@3x~iphone.png
deleted file mode 100644
index 368bfdf1..00000000
Binary files a/UICatalog/resources/Default-736h@3x~iphone.png and /dev/null differ
diff --git a/UICatalog/resources/Icon-72.png b/UICatalog/resources/Icon-72.png
deleted file mode 100644
index aa9c3f05..00000000
Binary files a/UICatalog/resources/Icon-72.png and /dev/null differ
diff --git a/UICatalog/resources/Icon-72@2x.png b/UICatalog/resources/Icon-72@2x.png
deleted file mode 100644
index 43a08526..00000000
Binary files a/UICatalog/resources/Icon-72@2x.png and /dev/null differ
diff --git a/UICatalog/resources/Icon.png b/UICatalog/resources/Icon.png
deleted file mode 100644
index af4733a5..00000000
Binary files a/UICatalog/resources/Icon.png and /dev/null differ
diff --git a/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Contents.json b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 00000000..ffa15158
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,80 @@
+{
+ "images" : [
+ {
+ "size" : "29x29",
+ "idiom" : "iphone",
+ "filename" : "Icon-Small@2x-1.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "29x29",
+ "idiom" : "iphone",
+ "filename" : "Icon-Small@3x.png",
+ "scale" : "3x"
+ },
+ {
+ "size" : "40x40",
+ "idiom" : "iphone",
+ "filename" : "Icon-Small-40@2x-1.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "40x40",
+ "idiom" : "iphone",
+ "filename" : "Icon-Small-40@3x.png",
+ "scale" : "3x"
+ },
+ {
+ "size" : "60x60",
+ "idiom" : "iphone",
+ "filename" : "Icon-60@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "60x60",
+ "idiom" : "iphone",
+ "filename" : "Icon-60@3x.png",
+ "scale" : "3x"
+ },
+ {
+ "size" : "29x29",
+ "idiom" : "ipad",
+ "filename" : "Icon-Small.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "29x29",
+ "idiom" : "ipad",
+ "filename" : "Icon-Small@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "40x40",
+ "idiom" : "ipad",
+ "filename" : "Icon-Small-40.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "40x40",
+ "idiom" : "ipad",
+ "filename" : "Icon-Small-40@2x.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "76x76",
+ "idiom" : "ipad",
+ "filename" : "Icon-76.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "76x76",
+ "idiom" : "ipad",
+ "filename" : "Icon-76@2x.png",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Icon-60@2x.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png
similarity index 100%
rename from UICatalog/resources/Icon-60@2x.png
rename to UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png
diff --git a/UICatalog/resources/Icon-60@3x.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png
similarity index 100%
rename from UICatalog/resources/Icon-60@3x.png
rename to UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png
diff --git a/UICatalog/resources/Icon-76.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-76.png
similarity index 100%
rename from UICatalog/resources/Icon-76.png
rename to UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-76.png
diff --git a/UICatalog/resources/Icon-76@2x.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png
similarity index 100%
rename from UICatalog/resources/Icon-76@2x.png
rename to UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png
diff --git a/UICatalog/resources/Icon-Small-40.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40.png
similarity index 100%
rename from UICatalog/resources/Icon-Small-40.png
rename to UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40.png
diff --git a/UICatalog/resources/Icon-Small-40@2x.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png
similarity index 100%
rename from UICatalog/resources/Icon-Small-40@2x.png
rename to UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png
diff --git a/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png
new file mode 100644
index 00000000..8db82b0f
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png differ
diff --git a/UICatalog/resources/Icon-Small-40@3x.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png
similarity index 100%
rename from UICatalog/resources/Icon-Small-40@3x.png
rename to UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png
diff --git a/UICatalog/resources/Icon-Small.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small.png
similarity index 100%
rename from UICatalog/resources/Icon-Small.png
rename to UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small.png
diff --git a/UICatalog/resources/Icon-Small@2x.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png
similarity index 100%
rename from UICatalog/resources/Icon-Small@2x.png
rename to UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png
diff --git a/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png
new file mode 100644
index 00000000..6f9e1565
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png differ
diff --git a/UICatalog/resources/Icon-Small@3x.png b/UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png
similarity index 100%
rename from UICatalog/resources/Icon-Small@3x.png
rename to UICatalog/resources/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png
diff --git a/UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Contents.json b/UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Contents.json
new file mode 100644
index 00000000..5379aae6
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Contents.json
@@ -0,0 +1,57 @@
+{
+ "images" : [
+ {
+ "orientation" : "portrait",
+ "idiom" : "iphone",
+ "extent" : "full-screen",
+ "minimum-system-version" : "7.0",
+ "filename" : "Default@2x~iphone.png",
+ "scale" : "2x"
+ },
+ {
+ "extent" : "full-screen",
+ "idiom" : "iphone",
+ "subtype" : "retina4",
+ "filename" : "Default-568h@2x~iphone.png",
+ "minimum-system-version" : "7.0",
+ "orientation" : "portrait",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "ipad",
+ "extent" : "full-screen",
+ "minimum-system-version" : "7.0",
+ "filename" : "Default-Portrait~ipad.png",
+ "scale" : "1x"
+ },
+ {
+ "orientation" : "landscape",
+ "idiom" : "ipad",
+ "extent" : "full-screen",
+ "minimum-system-version" : "7.0",
+ "filename" : "Default-Landscape~ipad.png",
+ "scale" : "1x"
+ },
+ {
+ "orientation" : "portrait",
+ "idiom" : "ipad",
+ "extent" : "full-screen",
+ "minimum-system-version" : "7.0",
+ "filename" : "Default-Portrait@2x~ipad.png",
+ "scale" : "2x"
+ },
+ {
+ "orientation" : "landscape",
+ "idiom" : "ipad",
+ "extent" : "full-screen",
+ "minimum-system-version" : "7.0",
+ "filename" : "Default-Landscape@2x~ipad.png",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Default-568h@2x~iphone.png b/UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default-568h@2x~iphone.png
similarity index 100%
rename from UICatalog/resources/Default-568h@2x~iphone.png
rename to UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default-568h@2x~iphone.png
diff --git a/UICatalog/resources/Default-Landscape@2x~ipad.png b/UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default-Landscape@2x~ipad.png
similarity index 100%
rename from UICatalog/resources/Default-Landscape@2x~ipad.png
rename to UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default-Landscape@2x~ipad.png
diff --git a/UICatalog/resources/Default-Landscape~ipad.png b/UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default-Landscape~ipad.png
similarity index 100%
rename from UICatalog/resources/Default-Landscape~ipad.png
rename to UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default-Landscape~ipad.png
diff --git a/UICatalog/resources/Default-Portrait@2x~ipad.png b/UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default-Portrait@2x~ipad.png
similarity index 100%
rename from UICatalog/resources/Default-Portrait@2x~ipad.png
rename to UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default-Portrait@2x~ipad.png
diff --git a/UICatalog/resources/Default-Portrait~ipad.png b/UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default-Portrait~ipad.png
similarity index 100%
rename from UICatalog/resources/Default-Portrait~ipad.png
rename to UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default-Portrait~ipad.png
diff --git a/UICatalog/resources/Default@2x~iphone.png b/UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default@2x~iphone.png
similarity index 100%
rename from UICatalog/resources/Default@2x~iphone.png
rename to UICatalog/resources/Images.xcassets/LaunchImage.launchimage/Default@2x~iphone.png
diff --git a/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/Contents.json b/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/Contents.json
new file mode 100644
index 00000000..7af2ca6c
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "bookmark_icon_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "bookmark_icon_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "bookmark_icon_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/bookmark_icon_1x.png b/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/bookmark_icon_1x.png
new file mode 100644
index 00000000..89554c76
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/bookmark_icon_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/bookmark_icon_2x.png b/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/bookmark_icon_2x.png
new file mode 100644
index 00000000..5e21f1df
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/bookmark_icon_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/bookmark_icon_3x.png b/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/bookmark_icon_3x.png
new file mode 100644
index 00000000..d0767ae0
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/bookmark_icon.imageset/bookmark_icon_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/Contents.json b/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/Contents.json
new file mode 100644
index 00000000..ef53346b
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "bookmark_icon_highlighted_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "bookmark_icon_highlighted_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "bookmark_icon_highlighted_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/bookmark_icon_highlighted_1x.png b/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/bookmark_icon_highlighted_1x.png
new file mode 100644
index 00000000..603990f1
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/bookmark_icon_highlighted_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/bookmark_icon_highlighted_2x.png b/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/bookmark_icon_highlighted_2x.png
new file mode 100644
index 00000000..46832a94
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/bookmark_icon_highlighted_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/bookmark_icon_highlighted_3x.png b/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/bookmark_icon_highlighted_3x.png
new file mode 100644
index 00000000..a6414f1d
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/bookmark_icon_highlighted.imageset/bookmark_icon_highlighted_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/Contents.json b/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/Contents.json
new file mode 100644
index 00000000..a373b853
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "checkmark_icon_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "checkmark_icon_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "checkmark_icon_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/checkmark_icon_1x.png b/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/checkmark_icon_1x.png
new file mode 100644
index 00000000..8905a21a
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/checkmark_icon_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/checkmark_icon_2x.png b/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/checkmark_icon_2x.png
new file mode 100644
index 00000000..4392cb25
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/checkmark_icon_2x.png differ
diff --git a/UICatalog/resources/segment_search.png b/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/checkmark_icon_3x.png
similarity index 71%
rename from UICatalog/resources/segment_search.png
rename to UICatalog/resources/Images.xcassets/checkmark_icon.imageset/checkmark_icon_3x.png
index 0067075a..ecafedb7 100644
Binary files a/UICatalog/resources/segment_search.png and b/UICatalog/resources/Images.xcassets/checkmark_icon.imageset/checkmark_icon_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/image_animal_1.imageset/Contents.json b/UICatalog/resources/Images.xcassets/image_animal_1.imageset/Contents.json
new file mode 100644
index 00000000..f66728a0
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/image_animal_1.imageset/Contents.json
@@ -0,0 +1,24 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "image_animal_5.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/image_animal_1.imageset/image_animal_5.png b/UICatalog/resources/Images.xcassets/image_animal_1.imageset/image_animal_5.png
new file mode 100644
index 00000000..4dd3f51b
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/image_animal_1.imageset/image_animal_5.png differ
diff --git a/UICatalog/resources/Images.xcassets/image_animal_2.imageset/Contents.json b/UICatalog/resources/Images.xcassets/image_animal_2.imageset/Contents.json
new file mode 100644
index 00000000..4c5d51c2
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/image_animal_2.imageset/Contents.json
@@ -0,0 +1,24 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "image_animal_2.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/image_animal_2.imageset/image_animal_2.png b/UICatalog/resources/Images.xcassets/image_animal_2.imageset/image_animal_2.png
new file mode 100644
index 00000000..c6fc5a7a
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/image_animal_2.imageset/image_animal_2.png differ
diff --git a/UICatalog/resources/Images.xcassets/image_animal_3.imageset/Contents.json b/UICatalog/resources/Images.xcassets/image_animal_3.imageset/Contents.json
new file mode 100644
index 00000000..f8e920dd
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/image_animal_3.imageset/Contents.json
@@ -0,0 +1,24 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "image_animal_3.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/image_animal_3.imageset/image_animal_3.png b/UICatalog/resources/Images.xcassets/image_animal_3.imageset/image_animal_3.png
new file mode 100644
index 00000000..131ca380
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/image_animal_3.imageset/image_animal_3.png differ
diff --git a/UICatalog/resources/Images.xcassets/image_animal_4.imageset/Contents.json b/UICatalog/resources/Images.xcassets/image_animal_4.imageset/Contents.json
new file mode 100644
index 00000000..4bc5d329
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/image_animal_4.imageset/Contents.json
@@ -0,0 +1,24 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "image_animal_4.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/image_animal_4.imageset/image_animal_4.png b/UICatalog/resources/Images.xcassets/image_animal_4.imageset/image_animal_4.png
new file mode 100644
index 00000000..6d8e34b3
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/image_animal_4.imageset/image_animal_4.png differ
diff --git a/UICatalog/resources/Images.xcassets/image_animal_5.imageset/Contents.json b/UICatalog/resources/Images.xcassets/image_animal_5.imageset/Contents.json
new file mode 100644
index 00000000..13b202d9
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/image_animal_5.imageset/Contents.json
@@ -0,0 +1,24 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "image_animal_1.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/image_animal_5.imageset/image_animal_1.png b/UICatalog/resources/Images.xcassets/image_animal_5.imageset/image_animal_1.png
new file mode 100644
index 00000000..a5029b8d
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/image_animal_5.imageset/image_animal_1.png differ
diff --git a/UICatalog/resources/Images.xcassets/search_bar_background.imageset/Contents.json b/UICatalog/resources/Images.xcassets/search_bar_background.imageset/Contents.json
new file mode 100644
index 00000000..f8076822
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/search_bar_background.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "search_bar_bg_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "search_bar_bg_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "search_bar_background_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/search_bar_background.imageset/search_bar_background_3x.png b/UICatalog/resources/Images.xcassets/search_bar_background.imageset/search_bar_background_3x.png
new file mode 100644
index 00000000..486f5413
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/search_bar_background.imageset/search_bar_background_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/search_bar_background.imageset/search_bar_bg_1x.png b/UICatalog/resources/Images.xcassets/search_bar_background.imageset/search_bar_bg_1x.png
new file mode 100644
index 00000000..d20a0bb6
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/search_bar_background.imageset/search_bar_bg_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/search_bar_background.imageset/search_bar_bg_2x.png b/UICatalog/resources/Images.xcassets/search_bar_background.imageset/search_bar_bg_2x.png
new file mode 100644
index 00000000..88ecb2f1
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/search_bar_background.imageset/search_bar_bg_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/search_icon.imageset/Contents.json b/UICatalog/resources/Images.xcassets/search_icon.imageset/Contents.json
new file mode 100644
index 00000000..ba69b4c2
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/search_icon.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "search_icon_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "search_icon_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "search_icon_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/search_icon.imageset/search_icon_1x.png b/UICatalog/resources/Images.xcassets/search_icon.imageset/search_icon_1x.png
new file mode 100644
index 00000000..74f9e9ae
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/search_icon.imageset/search_icon_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/search_icon.imageset/search_icon_2x.png b/UICatalog/resources/Images.xcassets/search_icon.imageset/search_icon_2x.png
new file mode 100644
index 00000000..5c7df70e
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/search_icon.imageset/search_icon_2x.png differ
diff --git a/UICatalog/resources/segment_tools.png b/UICatalog/resources/Images.xcassets/search_icon.imageset/search_icon_3x.png
similarity index 69%
rename from UICatalog/resources/segment_tools.png
rename to UICatalog/resources/Images.xcassets/search_icon.imageset/search_icon_3x.png
index 6ed79582..c3cc4335 100644
Binary files a/UICatalog/resources/segment_tools.png and b/UICatalog/resources/Images.xcassets/search_icon.imageset/search_icon_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/Contents.json b/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/Contents.json
new file mode 100644
index 00000000..b68469ab
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "slider_blue_track_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "slider_blue_track_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "slider_blue_track_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/slider_blue_track_1x.png b/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/slider_blue_track_1x.png
new file mode 100644
index 00000000..3f104759
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/slider_blue_track_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/slider_blue_track_2x.png b/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/slider_blue_track_2x.png
new file mode 100644
index 00000000..7ba36165
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/slider_blue_track_2x.png differ
diff --git a/UICatalog/resources/yellowslide.png b/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/slider_blue_track_3x.png
similarity index 86%
rename from UICatalog/resources/yellowslide.png
rename to UICatalog/resources/Images.xcassets/slider_blue_track.imageset/slider_blue_track_3x.png
index 379b8696..7f47c6e3 100644
Binary files a/UICatalog/resources/yellowslide.png and b/UICatalog/resources/Images.xcassets/slider_blue_track.imageset/slider_blue_track_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/slider_green_track.imageset/Contents.json b/UICatalog/resources/Images.xcassets/slider_green_track.imageset/Contents.json
new file mode 100644
index 00000000..82ecb1b5
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/slider_green_track.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "slider_green_track_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "slider_green_track_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "slider_green_track_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/slider_green_track.imageset/slider_green_track_1x.png b/UICatalog/resources/Images.xcassets/slider_green_track.imageset/slider_green_track_1x.png
new file mode 100644
index 00000000..dd6087d2
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/slider_green_track.imageset/slider_green_track_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/slider_green_track.imageset/slider_green_track_2x.png b/UICatalog/resources/Images.xcassets/slider_green_track.imageset/slider_green_track_2x.png
new file mode 100644
index 00000000..5c6cd69e
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/slider_green_track.imageset/slider_green_track_2x.png differ
diff --git a/UICatalog/resources/orangeslide.png b/UICatalog/resources/Images.xcassets/slider_green_track.imageset/slider_green_track_3x.png
similarity index 86%
rename from UICatalog/resources/orangeslide.png
rename to UICatalog/resources/Images.xcassets/slider_green_track.imageset/slider_green_track_3x.png
index 30cf4cbd..75a6915a 100644
Binary files a/UICatalog/resources/orangeslide.png and b/UICatalog/resources/Images.xcassets/slider_green_track.imageset/slider_green_track_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/slider_thumb.imageset/Contents.json b/UICatalog/resources/Images.xcassets/slider_thumb.imageset/Contents.json
new file mode 100644
index 00000000..22aed622
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/slider_thumb.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "slider_thumb_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "slider_thumb_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "slider_thumb_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/slider_thumb.imageset/slider_thumb_1x.png b/UICatalog/resources/Images.xcassets/slider_thumb.imageset/slider_thumb_1x.png
new file mode 100644
index 00000000..44a2b0a1
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/slider_thumb.imageset/slider_thumb_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/slider_thumb.imageset/slider_thumb_2x.png b/UICatalog/resources/Images.xcassets/slider_thumb.imageset/slider_thumb_2x.png
new file mode 100644
index 00000000..6f843786
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/slider_thumb.imageset/slider_thumb_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/slider_thumb.imageset/slider_thumb_3x.png b/UICatalog/resources/Images.xcassets/slider_thumb.imageset/slider_thumb_3x.png
new file mode 100644
index 00000000..9a465906
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/slider_thumb.imageset/slider_thumb_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/Contents.json b/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/Contents.json
new file mode 100644
index 00000000..1b2b71f8
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "stepper_and_segment_background_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "stepper_and_segment_background_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "stepper_and_segment_background_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/stepper_and_segment_background_1x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/stepper_and_segment_background_1x.png
new file mode 100644
index 00000000..c65e3961
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/stepper_and_segment_background_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/stepper_and_segment_background_2x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/stepper_and_segment_background_2x.png
new file mode 100644
index 00000000..6e68c5bd
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/stepper_and_segment_background_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/stepper_and_segment_background_3x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/stepper_and_segment_background_3x.png
new file mode 100644
index 00000000..be149037
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_background.imageset/stepper_and_segment_background_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/Contents.json b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/Contents.json
new file mode 100644
index 00000000..20e88cc7
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "stepper_and_segment_background_disabled_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "stepper_and_segment_background_disabled_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "stepper_and_segment_background_disabled_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/stepper_and_segment_background_disabled_1x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/stepper_and_segment_background_disabled_1x.png
new file mode 100644
index 00000000..7abdc2bc
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/stepper_and_segment_background_disabled_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/stepper_and_segment_background_disabled_2x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/stepper_and_segment_background_disabled_2x.png
new file mode 100644
index 00000000..05804453
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/stepper_and_segment_background_disabled_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/stepper_and_segment_background_disabled_3x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/stepper_and_segment_background_disabled_3x.png
new file mode 100644
index 00000000..29805f32
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_disabled.imageset/stepper_and_segment_background_disabled_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/Contents.json b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/Contents.json
new file mode 100644
index 00000000..14643f59
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "stepper_and_segment_background_highlighted_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "stepper_and_segment_background_highlighted_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "stepper_and_segment_background_highlighted_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/stepper_and_segment_background_highlighted_1x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/stepper_and_segment_background_highlighted_1x.png
new file mode 100644
index 00000000..c623650d
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/stepper_and_segment_background_highlighted_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/stepper_and_segment_background_highlighted_2x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/stepper_and_segment_background_highlighted_2x.png
new file mode 100644
index 00000000..2a9ee5c1
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/stepper_and_segment_background_highlighted_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/stepper_and_segment_background_highlighted_3x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/stepper_and_segment_background_highlighted_3x.png
new file mode 100644
index 00000000..cf0a17a5
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_background_highlighted.imageset/stepper_and_segment_background_highlighted_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/Contents.json b/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/Contents.json
new file mode 100644
index 00000000..f406368a
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "stepper_and_segment_segment_divider_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "stepper_and_segment_segment_divider_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "stepper_and_segment_divider_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/stepper_and_segment_divider_3x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/stepper_and_segment_divider_3x.png
new file mode 100644
index 00000000..1aabd6a5
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/stepper_and_segment_divider_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/stepper_and_segment_segment_divider_1x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/stepper_and_segment_segment_divider_1x.png
new file mode 100644
index 00000000..2d092bd7
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/stepper_and_segment_segment_divider_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/stepper_and_segment_segment_divider_2x.png b/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/stepper_and_segment_segment_divider_2x.png
new file mode 100644
index 00000000..168bdfd4
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_and_segment_segment_divider.imageset/stepper_and_segment_segment_divider_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/Contents.json b/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/Contents.json
new file mode 100644
index 00000000..2e2b7c30
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "decrement_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "decrement_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "stepper_decrement_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/decrement_1x.png b/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/decrement_1x.png
new file mode 100644
index 00000000..18969fd0
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/decrement_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/decrement_2x.png b/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/decrement_2x.png
new file mode 100644
index 00000000..53d3860b
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/decrement_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/stepper_decrement_3x.png b/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/stepper_decrement_3x.png
new file mode 100644
index 00000000..fa2db736
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_decrement.imageset/stepper_decrement_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment.imageset/Contents.json b/UICatalog/resources/Images.xcassets/stepper_increment.imageset/Contents.json
new file mode 100644
index 00000000..ae2d8b09
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/stepper_increment.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "increment_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "increment_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "stepper_increment_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment.imageset/increment_1x.png b/UICatalog/resources/Images.xcassets/stepper_increment.imageset/increment_1x.png
new file mode 100644
index 00000000..774f66c5
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_increment.imageset/increment_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment.imageset/increment_2x.png b/UICatalog/resources/Images.xcassets/stepper_increment.imageset/increment_2x.png
new file mode 100644
index 00000000..28eb0355
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_increment.imageset/increment_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment.imageset/stepper_increment_3x.png b/UICatalog/resources/Images.xcassets/stepper_increment.imageset/stepper_increment_3x.png
new file mode 100644
index 00000000..868bea2b
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_increment.imageset/stepper_increment_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/Contents.json b/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/Contents.json
new file mode 100644
index 00000000..38646d34
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "increment_disabled_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "increment_disabled_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "stepper_increment_disabled_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/increment_disabled_1x.png b/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/increment_disabled_1x.png
new file mode 100644
index 00000000..70525912
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/increment_disabled_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/increment_disabled_2x.png b/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/increment_disabled_2x.png
new file mode 100644
index 00000000..d263ac4b
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/increment_disabled_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/stepper_increment_disabled_3x.png b/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/stepper_increment_disabled_3x.png
new file mode 100644
index 00000000..a855e592
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_increment_disabled.imageset/stepper_increment_disabled_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/Contents.json b/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/Contents.json
new file mode 100644
index 00000000..af9d9e78
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "increment_highlighted_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "increment_highlighted_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "stepper_increment_highlighted_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/increment_highlighted_1x.png b/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/increment_highlighted_1x.png
new file mode 100644
index 00000000..f092afa1
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/increment_highlighted_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/increment_highlighted_2x.png b/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/increment_highlighted_2x.png
new file mode 100644
index 00000000..a3fcd53d
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/increment_highlighted_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/stepper_increment_highlighted_3x.png b/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/stepper_increment_highlighted_3x.png
new file mode 100644
index 00000000..3d416b3a
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/stepper_increment_highlighted.imageset/stepper_increment_highlighted_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/text_field_background.imageset/Contents.json b/UICatalog/resources/Images.xcassets/text_field_background.imageset/Contents.json
new file mode 100644
index 00000000..1206564d
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/text_field_background.imageset/Contents.json
@@ -0,0 +1,48 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "resizing" : {
+ "mode" : "3-part-horizontal",
+ "center" : {
+ "mode" : "stretch",
+ "width" : 0
+ },
+ "capInsets" : {
+ "right" : 1,
+ "left" : 1
+ }
+ },
+ "idiom" : "universal",
+ "filename" : "text_field_background_1x.png",
+ "scale" : "1x"
+ },
+ {
+ "resizing" : {
+ "mode" : "3-part-horizontal",
+ "center" : {
+ "mode" : "stretch",
+ "width" : 0
+ },
+ "capInsets" : {
+ "right" : 1,
+ "left" : 1
+ }
+ },
+ "idiom" : "universal",
+ "filename" : "text_field_background_2x.png",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "text_field_background_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/text_field_background.imageset/text_field_background_1x.png b/UICatalog/resources/Images.xcassets/text_field_background.imageset/text_field_background_1x.png
new file mode 100644
index 00000000..5c3c3cf6
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/text_field_background.imageset/text_field_background_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/text_field_background.imageset/text_field_background_2x.png b/UICatalog/resources/Images.xcassets/text_field_background.imageset/text_field_background_2x.png
new file mode 100644
index 00000000..abf9f0a0
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/text_field_background.imageset/text_field_background_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/text_field_background.imageset/text_field_background_3x.png b/UICatalog/resources/Images.xcassets/text_field_background.imageset/text_field_background_3x.png
new file mode 100644
index 00000000..b121f9db
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/text_field_background.imageset/text_field_background_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/Contents.json b/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/Contents.json
new file mode 100644
index 00000000..460b5d53
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "text_field_purple_right_view_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "text_field_purple_right_view_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "text_field_purple_right_view_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/text_field_purple_right_view_1x.png b/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/text_field_purple_right_view_1x.png
new file mode 100644
index 00000000..c450af96
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/text_field_purple_right_view_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/text_field_purple_right_view_2x.png b/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/text_field_purple_right_view_2x.png
new file mode 100644
index 00000000..e81719e8
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/text_field_purple_right_view_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/text_field_purple_right_view_3x.png b/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/text_field_purple_right_view_3x.png
new file mode 100644
index 00000000..2957cbb6
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/text_field_purple_right_view.imageset/text_field_purple_right_view_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/Contents.json b/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/Contents.json
new file mode 100644
index 00000000..3288fc6f
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "text_view_attachment_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "text_view_attachment_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "text_view_attachment_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/text_view_attachment_1x.png b/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/text_view_attachment_1x.png
new file mode 100644
index 00000000..456bd617
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/text_view_attachment_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/text_view_attachment_2x.png b/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/text_view_attachment_2x.png
new file mode 100644
index 00000000..a97f7858
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/text_view_attachment_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/text_view_attachment_3x.png b/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/text_view_attachment_3x.png
new file mode 100644
index 00000000..98cae700
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/text_view_attachment.imageset/text_view_attachment_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/toolbar_background.imageset/Contents.json b/UICatalog/resources/Images.xcassets/toolbar_background.imageset/Contents.json
new file mode 100644
index 00000000..b7b5d197
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/toolbar_background.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "toolbar_background_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "toolbar_background_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "toolbar_background_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/toolbar_background.imageset/toolbar_background_1x.png b/UICatalog/resources/Images.xcassets/toolbar_background.imageset/toolbar_background_1x.png
new file mode 100644
index 00000000..f37907ff
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/toolbar_background.imageset/toolbar_background_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/toolbar_background.imageset/toolbar_background_2x.png b/UICatalog/resources/Images.xcassets/toolbar_background.imageset/toolbar_background_2x.png
new file mode 100644
index 00000000..a271d28d
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/toolbar_background.imageset/toolbar_background_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/toolbar_background.imageset/toolbar_background_3x.png b/UICatalog/resources/Images.xcassets/toolbar_background.imageset/toolbar_background_3x.png
new file mode 100644
index 00000000..486f5413
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/toolbar_background.imageset/toolbar_background_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/tools_icon.imageset/Contents.json b/UICatalog/resources/Images.xcassets/tools_icon.imageset/Contents.json
new file mode 100644
index 00000000..dd9d5e27
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/tools_icon.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "tools_icon_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "tools_icon_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "tools_icon_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/tools_icon.imageset/tools_icon_1x.png b/UICatalog/resources/Images.xcassets/tools_icon.imageset/tools_icon_1x.png
new file mode 100644
index 00000000..2491e6ae
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/tools_icon.imageset/tools_icon_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/tools_icon.imageset/tools_icon_2x.png b/UICatalog/resources/Images.xcassets/tools_icon.imageset/tools_icon_2x.png
new file mode 100644
index 00000000..933493f1
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/tools_icon.imageset/tools_icon_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/tools_icon.imageset/tools_icon_3x.png b/UICatalog/resources/Images.xcassets/tools_icon.imageset/tools_icon_3x.png
new file mode 100644
index 00000000..e91e7aa4
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/tools_icon.imageset/tools_icon_3x.png differ
diff --git a/UICatalog/resources/Images.xcassets/x_icon.imageset/Contents.json b/UICatalog/resources/Images.xcassets/x_icon.imageset/Contents.json
new file mode 100644
index 00000000..18d489ff
--- /dev/null
+++ b/UICatalog/resources/Images.xcassets/x_icon.imageset/Contents.json
@@ -0,0 +1,26 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "x_icon_1x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "x_icon_2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x",
+ "filename" : "x_icon_3x.png"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/UICatalog/resources/Images.xcassets/x_icon.imageset/x_icon_1x.png b/UICatalog/resources/Images.xcassets/x_icon.imageset/x_icon_1x.png
new file mode 100644
index 00000000..84b67200
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/x_icon.imageset/x_icon_1x.png differ
diff --git a/UICatalog/resources/Images.xcassets/x_icon.imageset/x_icon_2x.png b/UICatalog/resources/Images.xcassets/x_icon.imageset/x_icon_2x.png
new file mode 100644
index 00000000..71c09f4e
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/x_icon.imageset/x_icon_2x.png differ
diff --git a/UICatalog/resources/Images.xcassets/x_icon.imageset/x_icon_3x.png b/UICatalog/resources/Images.xcassets/x_icon.imageset/x_icon_3x.png
new file mode 100644
index 00000000..968331d6
Binary files /dev/null and b/UICatalog/resources/Images.xcassets/x_icon.imageset/x_icon_3x.png differ
diff --git a/UICatalog/resources/UIButton_custom.png b/UICatalog/resources/UIButton_custom.png
deleted file mode 100644
index dfe44114..00000000
Binary files a/UICatalog/resources/UIButton_custom.png and /dev/null differ
diff --git a/UICatalog/resources/blueButton.png b/UICatalog/resources/blueButton.png
deleted file mode 100644
index 0cfbee11..00000000
Binary files a/UICatalog/resources/blueButton.png and /dev/null differ
diff --git a/UICatalog/resources/bookmarkImage.png b/UICatalog/resources/bookmarkImage.png
deleted file mode 100644
index 6046c85e..00000000
Binary files a/UICatalog/resources/bookmarkImage.png and /dev/null differ
diff --git a/UICatalog/resources/bookmarkImageHighlighted.png b/UICatalog/resources/bookmarkImageHighlighted.png
deleted file mode 100644
index 41e62193..00000000
Binary files a/UICatalog/resources/bookmarkImageHighlighted.png and /dev/null differ
diff --git a/UICatalog/resources/divider.png b/UICatalog/resources/divider.png
deleted file mode 100644
index 145fa1d3..00000000
Binary files a/UICatalog/resources/divider.png and /dev/null differ
diff --git a/UICatalog/resources/scene1.jpg b/UICatalog/resources/scene1.jpg
deleted file mode 100644
index 532f73a2..00000000
Binary files a/UICatalog/resources/scene1.jpg and /dev/null differ
diff --git a/UICatalog/resources/scene2.jpg b/UICatalog/resources/scene2.jpg
deleted file mode 100644
index 50aa81eb..00000000
Binary files a/UICatalog/resources/scene2.jpg and /dev/null differ
diff --git a/UICatalog/resources/scene3.jpg b/UICatalog/resources/scene3.jpg
deleted file mode 100644
index ec308060..00000000
Binary files a/UICatalog/resources/scene3.jpg and /dev/null differ
diff --git a/UICatalog/resources/scene4.jpg b/UICatalog/resources/scene4.jpg
deleted file mode 100644
index 5b8c91c4..00000000
Binary files a/UICatalog/resources/scene4.jpg and /dev/null differ
diff --git a/UICatalog/resources/scene5.jpg b/UICatalog/resources/scene5.jpg
deleted file mode 100644
index d750682b..00000000
Binary files a/UICatalog/resources/scene5.jpg and /dev/null differ
diff --git a/UICatalog/resources/searchBarBackground.png b/UICatalog/resources/searchBarBackground.png
deleted file mode 100644
index 3a883919..00000000
Binary files a/UICatalog/resources/searchBarBackground.png and /dev/null differ
diff --git a/UICatalog/resources/segment_check.png b/UICatalog/resources/segment_check.png
deleted file mode 100644
index 9eb59390..00000000
Binary files a/UICatalog/resources/segment_check.png and /dev/null differ
diff --git a/UICatalog/resources/segmentedBackground.png b/UICatalog/resources/segmentedBackground.png
deleted file mode 100644
index 914f3a04..00000000
Binary files a/UICatalog/resources/segmentedBackground.png and /dev/null differ
diff --git a/UICatalog/resources/slider_ball.png b/UICatalog/resources/slider_ball.png
deleted file mode 100644
index d5429fd5..00000000
Binary files a/UICatalog/resources/slider_ball.png and /dev/null differ
diff --git a/UICatalog/resources/toolbarBackground.png b/UICatalog/resources/toolbarBackground.png
deleted file mode 100644
index 3a883919..00000000
Binary files a/UICatalog/resources/toolbarBackground.png and /dev/null differ
diff --git a/UICatalog/resources/whiteButton.png b/UICatalog/resources/whiteButton.png
deleted file mode 100644
index ce8c9cb4..00000000
Binary files a/UICatalog/resources/whiteButton.png and /dev/null differ
diff --git a/UICatalog/robovm.properties b/UICatalog/robovm.properties
index 1d0a273b..af9fcac1 100644
--- a/UICatalog/robovm.properties
+++ b/UICatalog/robovm.properties
@@ -1,6 +1,8 @@
+#
+#Tue Apr 28 15:32:15 CEST 2015
app.version=1.0
app.id=org.robovm.samples.uicatalog
app.mainclass=org.robovm.samples.uicatalog.UICatalog
app.executable=UICatalog
app.build=1
-app.name=UICatalog
\ No newline at end of file
+app.name=UICatalog
diff --git a/UICatalog/robovm.xml b/UICatalog/robovm.xml
index 73876651..88c5cf62 100644
--- a/UICatalog/robovm.xml
+++ b/UICatalog/robovm.xml
@@ -1,13 +1,13 @@
- ${app.executable}
- ${app.mainclass}
- ios
- thumbv7
-
-
- resources
-
-
- ios
- Info.plist.xml
+ ${app.executable}
+ ${app.mainclass}
+ ios
+ thumbv7
+
+
+ resources
+
+
+ ios
+ Info.plist.xml
\ No newline at end of file
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/Constants.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/Colors.java
similarity index 58%
rename from UICatalog/src/main/java/org/robovm/samples/uicatalog/Constants.java
rename to UICatalog/src/main/java/org/robovm/samples/uicatalog/Colors.java
index 092cecfb..8c12a28d 100644
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/Constants.java
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/Colors.java
@@ -1,5 +1,5 @@
- /*
- * Copyright (C) 2014 RoboVM AB
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,23 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
*/
-
package org.robovm.samples.uicatalog;
-/**
- * constants used in view controllers
- */
-public class Constants {
+import org.robovm.apple.uikit.UIColor;
- public static final float LEFT_MARGIN = 20.0f;
- public static final float TOP_MARGIN = 20.0f;
- public static final float RIGHT_MARGIN = 20.0f;
- public static final float TWEEN_MARGIN = 6.0f;
+public class Colors {
- public static final float TEXT_FIELD_WIDTH = 260.0f;
- public static final float TEXT_FIELD_HEIGHT = 30.0f;
+ public static final UIColor GREEN = UIColor.fromRGBA(0.255, 0.804, 0.470, 2);
+ public static final UIColor BLUE = UIColor.fromRGBA(0.333, 0.784, 1, 1);
+ public static final UIColor PURPLE = UIColor.fromRGBA(0.659, 0.271, 0.988, 1);
}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/UICatalog.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/UICatalog.java
index 00832568..d5347324 100644
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/UICatalog.java
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/UICatalog.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 RoboVM AB
+ * Copyright (C) 2013-2015 RoboVM AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,44 +13,38 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
*/
-
package org.robovm.samples.uicatalog;
import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.uikit.UIApplication;
import org.robovm.apple.uikit.UIApplicationDelegateAdapter;
import org.robovm.apple.uikit.UIApplicationLaunchOptions;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UINavigationController;
-import org.robovm.apple.uikit.UIScreen;
-import org.robovm.apple.uikit.UIWindow;
-import org.robovm.samples.uicatalog.viewcontrollers.MainViewController;
+import org.robovm.apple.uikit.UISplitViewController;
+import org.robovm.apple.uikit.UISplitViewControllerDelegateAdapter;
+import org.robovm.apple.uikit.UISplitViewControllerDisplayMode;
-/** Class which starts application. */
public class UICatalog extends UIApplicationDelegateAdapter {
- private UIWindow window;
- private MainViewController mainViewController;
@Override
- public boolean didFinishLaunching (UIApplication application, UIApplicationLaunchOptions launchOptions) {
- mainViewController = new MainViewController();
- UINavigationController navigationController = new UINavigationController(mainViewController);
-
- window = new UIWindow(UIScreen.getMainScreen().getBounds());
- window.setBackgroundColor(UIColor.lightGray());
- window.setRootViewController(navigationController);
- window.makeKeyAndVisible();
+ public boolean didFinishLaunching(UIApplication application, UIApplicationLaunchOptions launchOptions) {
+ UISplitViewController splitViewController = (UISplitViewController) getWindow().getRootViewController();
+ splitViewController.setDelegate(new UISplitViewControllerDelegateAdapter() {
+ @Override
+ public UISplitViewControllerDisplayMode getTargetDisplayMode(UISplitViewController svc) {
+ return UISplitViewControllerDisplayMode.AllVisible;
+ }
+ });
+ splitViewController.setPreferredDisplayMode(UISplitViewControllerDisplayMode.AllVisible);
return true;
}
- public static void main (String[] args) {
- NSAutoreleasePool pool = new NSAutoreleasePool();
- UIApplication.main(args, null, UICatalog.class);
- pool.close();
+ public static void main(String[] args) {
+ try (NSAutoreleasePool pool = new NSAutoreleasePool()) {
+ UIApplication.main(args, null, UICatalog.class);
+ }
}
-
}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/picker/CustomPickerDataSource.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/picker/CustomPickerDataSource.java
deleted file mode 100644
index 33591553..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/picker/CustomPickerDataSource.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.picker;
-
-import org.robovm.apple.foundation.NSArray;
-import org.robovm.apple.uikit.UIImage;
-import org.robovm.apple.uikit.UIPickerView;
-import org.robovm.apple.uikit.UIPickerViewDataSource;
-import org.robovm.apple.uikit.UIPickerViewDelegateAdapter;
-import org.robovm.apple.uikit.UIView;
-
-/** The data source for the Custom Picker that displays text and images. */
-public class CustomPickerDataSource extends UIPickerViewDelegateAdapter implements UIPickerViewDataSource {
-
- NSArray customPickerArray = new NSArray();
-
- /** Creates a custom picker prepopulated with images */
- public CustomPickerDataSource () {
-
- CustomView earlyMorningView = new CustomView("Early Morning", UIImage.create("12-6AM.png"));
- CustomView lateMorningView = new CustomView("Late Morning", UIImage.create("6-12AM.png"));
- CustomView afternoonView = new CustomView("Afternoon", UIImage.create("12-6PM.png"));
- CustomView eveningView = new CustomView("Evening", UIImage.create("6-12PM.png"));
-
- NSArray timeArray = new NSArray(earlyMorningView, lateMorningView, afternoonView, eveningView);
-
- customPickerArray = timeArray;
- }
-
- @Override
- public long getNumberOfComponents (UIPickerView pickerView) {
- return 1;
- }
-
- @Override
- public long getNumberOfRows (UIPickerView pickerView, long component) {
- return customPickerArray.size();
- }
-
- @Override
- public double getComponentWidth (UIPickerView pickerView, long component) {
- return CustomView.getViewWidth();
- }
-
- @Override
- public double getRowHeight (UIPickerView pickerView, long component) {
- return CustomView.getViewHeight();
- }
-
- @Override
- public UIView getRowView (UIPickerView pickerView, long row, long component, UIView view) {
- return customPickerArray.get((int)row);
- }
-
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/picker/CustomView.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/picker/CustomView.java
deleted file mode 100644
index 8e26c0f3..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/picker/CustomView.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.picker;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIImage;
-import org.robovm.apple.uikit.UIImageView;
-import org.robovm.apple.uikit.UILabel;
-import org.robovm.apple.uikit.UIView;
-
-/** The custom view holding the image and title for the custom picker. */
-public class CustomView extends UIView {
-
- private static final float VIEW_WIDTH = 200.0f;
- private static final float VIEW_HEIGHT = 44.0f;
- private static final double LABEL_HEIGHT = 20;
- private static final double MARGIN_SIZE = 10;
-
- private final UILabel titleLabel;
-
- public static double getViewWidth () {
- return VIEW_WIDTH;
- }
-
- public static double getViewHeight () {
- return VIEW_HEIGHT;
- }
-
- public CustomView (String title, UIImage image) {
- super(new CGRect(0.0, 0.0, VIEW_WIDTH, VIEW_HEIGHT));
-
- double yCoord = (getBounds().getSize().getHeight() - LABEL_HEIGHT) / 2;
- titleLabel = new UILabel(new CGRect(MARGIN_SIZE + image.getSize().getWidth() + MARGIN_SIZE, yCoord,
- (getFrame().getWidth()) - MARGIN_SIZE + image.getSize().getWidth() + MARGIN_SIZE, LABEL_HEIGHT));
-
- titleLabel.setText(title.toString());
- titleLabel.setBackgroundColor(UIColor.clear());
- addSubview(titleLabel);
-
- yCoord = (getBounds().getSize().getHeight() - image.getSize().getHeight()) / 2;
- UIImageView imageView = new UIImageView(new CGRect(MARGIN_SIZE, yCoord, image.getSize().getWidth(), image.getSize()
- .getHeight()));
-
- imageView.setImage(image);
- addSubview(imageView);
- }
-
- /** Enable accessibility for this view.
- *
- * @return */
- boolean isAccessibilityElement () {
- return true;
- }
-
- /** Return a string that describes this view.
- *
- * @return */
- String accessibilityLabel () {
- return titleLabel.getText();
- }
-
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchbar/AAPLCustomSearchBarViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchbar/AAPLCustomSearchBarViewController.java
new file mode 100644
index 00000000..2c7ab82a
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchbar/AAPLCustomSearchBarViewController.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.searchbar;
+
+import org.robovm.apple.uikit.UIControlState;
+import org.robovm.apple.uikit.UIImage;
+import org.robovm.apple.uikit.UISearchBar;
+import org.robovm.apple.uikit.UISearchBarDelegateAdapter;
+import org.robovm.apple.uikit.UISearchBarIcon;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLCustomSearchBarViewController")
+public class AAPLCustomSearchBarViewController extends UIViewController {
+ private UISearchBar searchBar;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureSearchBar();
+ }
+
+ private void configureSearchBar() {
+ searchBar.setDelegate(new UISearchBarDelegateAdapter() {
+ @Override
+ public void searchButtonClicked(UISearchBar searchBar) {
+ System.out.println(String.format("The custom search bar keyboard search button was tapped: %s.",
+ searchBar.getText()));
+
+ searchBar.resignFirstResponder();
+ }
+
+ @Override
+ public void cancelButtonClicked(UISearchBar searchBar) {
+ System.out.println("The custom search bar cancel button was tapped.");
+
+ searchBar.resignFirstResponder();
+ }
+
+ @Override
+ public void bookmarkButtonClicked(UISearchBar searchBar) {
+ System.out.println("The custom bookmark button inside the search bar was tapped.");
+ }
+ });
+
+ searchBar.setShowsCancelButton(true);
+ searchBar.setShowsBookmarkButton(true);
+
+ searchBar.setTintColor(Colors.PURPLE);
+
+ searchBar.setBackgroundImage(UIImage.create("search_bar_background"));
+
+ // Set the bookmark image for both normal and highlighted states.
+ UIImage bookmarkImage = UIImage.create("bookmark_icon");
+ searchBar.setImageForSearchBarIcon(bookmarkImage, UISearchBarIcon.Bookmark, UIControlState.Normal);
+
+ UIImage bookmarkHighlightedImage = UIImage.create("bookmark_icon_highlighted");
+ searchBar.setImageForSearchBarIcon(bookmarkHighlightedImage, UISearchBarIcon.Bookmark,
+ UIControlState.Highlighted);
+ }
+
+ @IBOutlet
+ private void setSearchBar(UISearchBar searchBar) {
+ this.searchBar = searchBar;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchbar/AAPLDefaultSearchBarViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchbar/AAPLDefaultSearchBarViewController.java
new file mode 100644
index 00000000..06509510
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchbar/AAPLDefaultSearchBarViewController.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.searchbar;
+
+import java.util.Arrays;
+
+import org.robovm.apple.uikit.UISearchBar;
+import org.robovm.apple.uikit.UISearchBarDelegateAdapter;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+
+@CustomClass("AAPLDefaultSearchBarViewController")
+public class AAPLDefaultSearchBarViewController extends UIViewController {
+ private UISearchBar searchBar;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureSearchBar();
+ }
+
+ private void configureSearchBar() {
+ searchBar.setDelegate(new UISearchBarDelegateAdapter() {
+ @Override
+ public void selectedScopeButtonIndexDidChange(UISearchBar searchBar, long selectedScope) {
+ System.out.println(String.format("The default search selected scope button index changed to %d.",
+ selectedScope));
+ }
+
+ @Override
+ public void searchButtonClicked(UISearchBar searchBar) {
+ System.out.println(String.format("The default search bar keyboard search button was tapped: %s.",
+ searchBar.getText()));
+
+ searchBar.resignFirstResponder();
+ }
+
+ @Override
+ public void cancelButtonClicked(UISearchBar searchBar) {
+ System.out.println("The default search bar cancel button was tapped.");
+
+ searchBar.resignFirstResponder();
+ }
+ });
+
+ searchBar.setShowsCancelButton(true);
+ searchBar.setShowsScopeBar(true);
+
+ searchBar.setScopeButtonTitles(Arrays.asList("Scope One", "Scope Two"));
+ }
+
+ @IBOutlet
+ private void setSearchBar(UISearchBar searchBar) {
+ this.searchBar = searchBar;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchBarEmbeddedInNavigationBarViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchBarEmbeddedInNavigationBarViewController.java
new file mode 100644
index 00000000..a798c4b1
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchBarEmbeddedInNavigationBarViewController.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.searchcontrollers;
+
+import org.robovm.apple.uikit.UISearchBarStyle;
+import org.robovm.apple.uikit.UISearchController;
+import org.robovm.objc.annotation.CustomClass;
+
+@CustomClass("AAPLSearchBarEmbeddedInNavigationBarViewController")
+public class AAPLSearchBarEmbeddedInNavigationBarViewController extends AAPLSearchControllerBaseViewController {
+ private UISearchController searchController;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ // Create the search results view controller and use it for the
+ // UISearchController.
+ AAPLSearchResultsViewController searchResultsController = (AAPLSearchResultsViewController) getStoryboard()
+ .instantiateViewController(
+ AAPLSearchResultsViewController.STORYBOARD_IDENTIFIER);
+
+ // Create the search controller and make it perform the results
+ // updating.
+ searchController = new UISearchController(searchResultsController);
+ searchController.setSearchResultsUpdater(searchResultsController);
+ searchController.setHidesNavigationBarDuringPresentation(false);
+
+ // Configure the search controller's search bar. For more information on
+ // how to configure
+ // search bars, see the "Search Bar" group under "Search".
+ searchController.getSearchBar().setSearchBarStyle(UISearchBarStyle.Minimal);
+ searchController.getSearchBar().setPlaceholder("Search");
+
+ // Include the search bar within the navigation bar.
+ getNavigationItem().setTitleView(searchController.getSearchBar());
+
+ setDefinesPresentationContext(true);
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchControllerBaseViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchControllerBaseViewController.java
new file mode 100644
index 00000000..64d97963
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchControllerBaseViewController.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.searchcontrollers;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.robovm.apple.foundation.NSIndexPath;
+import org.robovm.apple.uikit.UITableView;
+import org.robovm.apple.uikit.UITableViewCell;
+import org.robovm.apple.uikit.UITableViewController;
+import org.robovm.objc.annotation.CustomClass;
+
+@CustomClass("AAPLSearchControllerBaseViewController")
+public class AAPLSearchControllerBaseViewController extends UITableViewController {
+ private static final String CELL_IDENTIFIER = "searchResultsCell";
+
+ private List allResults;
+ private List visibleResults;
+
+ /*
+ * A null / empty filter string means show all results. Otherwise, show only
+ * results containing the filter.
+ */
+ private String filterString;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ allResults = Arrays.asList("Here's", "to", "the", "crazy", "ones.", "The", "misfits.", "The", "rebels.", "The",
+ "troublemakers.", "The", "round", "pegs", "in", "the", "square", "holes.", "The", "ones", "who", "see",
+ "things", "differently.", "They're", "not", "fond", "of", "rules.", "And", "they", "have", "no",
+ "respect", "for", "the", "status", "quo.", "You", "can", "quote", "them,", "disagree", "with", "them,",
+ "glorify", "or", "vilify", "them.", "About", "the", "only", "thing", "you", "can't", "do", "is",
+ "ignore", "them.", "Because", "they", "change", "things.", "They", "push", "the", "human", "race",
+ "forward.", "And", "while", "some", "may", "see", "them", "as", "the", "crazy", "ones,", "we", "see",
+ "genius.", "Because", "the", "people", "who", "are", "crazy", "enough", "to", "think", "they", "can",
+ "change", "the", "world,", "are", "the", "ones", "who", "do.");
+ visibleResults = new ArrayList(allResults);
+ }
+
+ public void setFilterString(String filterString) {
+ this.filterString = filterString;
+
+ visibleResults.clear();
+
+ if (filterString == null || filterString.length() <= 0) {
+ visibleResults.addAll(allResults);
+ } else {
+ for (String result : allResults) {
+ if (result.contains(filterString)) {
+ visibleResults.add(result);
+ }
+ }
+ }
+
+ getTableView().reloadData();
+ }
+
+ public String getFilterString() {
+ return filterString;
+ }
+
+ @Override
+ public long getNumberOfRowsInSection(UITableView tableView, long section) {
+ return visibleResults.size();
+ }
+
+ @Override
+ public UITableViewCell getCellForRow(UITableView tableView, NSIndexPath indexPath) {
+ return tableView.dequeueReusableCell(CELL_IDENTIFIER, indexPath);
+ }
+
+ @Override
+ public void willDisplayCell(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath) {
+ cell.getTextLabel().setText(visibleResults.get((int) indexPath.getRow()));
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchPresentOverNavigationBarViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchPresentOverNavigationBarViewController.java
new file mode 100644
index 00000000..1b93c79a
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchPresentOverNavigationBarViewController.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.searchcontrollers;
+
+import org.robovm.apple.uikit.UIBarButtonItem;
+import org.robovm.apple.uikit.UISearchController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBAction;
+
+@CustomClass("AAPLSearchPresentOverNavigationBarViewController")
+public class AAPLSearchPresentOverNavigationBarViewController extends AAPLSearchControllerBaseViewController {
+ private UISearchController searchController;
+
+ @IBAction
+ private void searchButtonClicked(UIBarButtonItem sender) {
+ // Create the search results view controller and use it for the
+ // UISearchController.
+ AAPLSearchResultsViewController searchResultsController = (AAPLSearchResultsViewController) getStoryboard()
+ .instantiateViewController(
+ AAPLSearchResultsViewController.STORYBOARD_IDENTIFIER);
+
+ // Create the search controller and make it perform the results
+ // updating.
+ searchController = new UISearchController(searchResultsController);
+ searchController.setSearchResultsUpdater(searchResultsController);
+ searchController.setHidesNavigationBarDuringPresentation(false);
+
+ // Present the view controller.
+ presentViewController(searchController, true, null);
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchResultsViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchResultsViewController.java
new file mode 100644
index 00000000..3a23a542
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchResultsViewController.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.searchcontrollers;
+
+import org.robovm.apple.uikit.UISearchController;
+import org.robovm.apple.uikit.UISearchResultsUpdating;
+import org.robovm.objc.annotation.CustomClass;
+
+@CustomClass("AAPLSearchResultsViewController")
+public class AAPLSearchResultsViewController extends AAPLSearchControllerBaseViewController implements
+ UISearchResultsUpdating {
+ public static final String STORYBOARD_IDENTIFIER = "AAPLSearchResultsViewControllerStoryboardIdentifier";
+
+ /**
+ * This is called when the controller is being dismissed to allow those who
+ * are using the controller they are search as the results controller a
+ * chance to reset their state. No need to update anything if we're being
+ * dismissed.
+ */
+ @Override
+ public void updateSearchResults(UISearchController searchController) {
+ if (!searchController.isActive()) {
+ return;
+ }
+
+ setFilterString(searchController.getSearchBar().getText());
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchShowResultsInSourceViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchShowResultsInSourceViewController.java
new file mode 100644
index 00000000..759ee853
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/searchcontrollers/AAPLSearchShowResultsInSourceViewController.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.searchcontrollers;
+
+import org.robovm.apple.uikit.UISearchController;
+import org.robovm.objc.annotation.CustomClass;
+
+@CustomClass("AAPLSearchShowResultsInSourceViewController")
+public class AAPLSearchShowResultsInSourceViewController extends AAPLSearchResultsViewController {
+ private UISearchController searchController;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ // Create the search controller, but we'll make sure that this
+ // AAPLSearchShowResultsInSourceViewController
+ // performs the results updating.
+ searchController = new UISearchController(null);
+ searchController.setSearchResultsUpdater(this);
+ searchController.setDimsBackgroundDuringPresentation(false);
+
+ // Make sure the that the search bar is visible within the navigation
+ // bar.
+ searchController.getSearchBar().sizeToFit();
+
+ // Include the search controller's search bar within the table's header
+ // view.
+ getTableView().setTableHeaderView(searchController.getSearchBar());
+
+ setDefinesPresentationContext(true);
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/toolbar/AAPLCustomToolbarViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/toolbar/AAPLCustomToolbarViewController.java
new file mode 100644
index 00000000..c0f2efff
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/toolbar/AAPLCustomToolbarViewController.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.toolbar;
+
+import org.robovm.apple.foundation.NSArray;
+import org.robovm.apple.uikit.NSAttributedStringAttributes;
+import org.robovm.apple.uikit.UIBarButtonItem;
+import org.robovm.apple.uikit.UIBarButtonItemStyle;
+import org.robovm.apple.uikit.UIBarButtonSystemItem;
+import org.robovm.apple.uikit.UIBarMetrics;
+import org.robovm.apple.uikit.UIBarPosition;
+import org.robovm.apple.uikit.UIControlState;
+import org.robovm.apple.uikit.UIImage;
+import org.robovm.apple.uikit.UIToolbar;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLCustomToolbarViewController")
+public class AAPLCustomToolbarViewController extends UIViewController implements UIBarButtonItem.OnClickListener {
+ private UIToolbar toolbar;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureToolbar();
+ }
+
+ private void configureToolbar() {
+ UIImage toolbarBackgroundImage = UIImage.create("toolbar_background");
+ toolbar.setBackgroundImage(toolbarBackgroundImage, UIBarPosition.Bottom, UIBarMetrics.Default);
+
+ NSArray toolbarButtonItems = new NSArray(getCustomImageBarButtonItem(),
+ getFlexibleSpaceBarButtonItem(), getCustomBarButtonItem());
+ toolbar.setItems(toolbarButtonItems, true);
+ }
+
+ private UIBarButtonItem getCustomImageBarButtonItem() {
+ UIImage customBarButtonItemImage = UIImage.create("tools_icon");
+ UIBarButtonItem customImageBarButtonItem = new UIBarButtonItem(customBarButtonItemImage,
+ UIBarButtonItemStyle.Plain, this);
+
+ customImageBarButtonItem.setTintColor(Colors.PURPLE);
+
+ return customImageBarButtonItem;
+ }
+
+ private UIBarButtonItem getFlexibleSpaceBarButtonItem() {
+ return new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null);
+ }
+
+ private UIBarButtonItem getCustomBarButtonItem() {
+ UIBarButtonItem barButtonItem = new UIBarButtonItem("Button", UIBarButtonItemStyle.Plain, this);
+
+ NSAttributedStringAttributes attributes = new NSAttributedStringAttributes().setForegroundColor(Colors.PURPLE);
+ barButtonItem.setTitleTextAttributes(attributes, UIControlState.Normal);
+
+ return barButtonItem;
+ }
+
+ @Override
+ public void onClick(UIBarButtonItem barButtonItem) {
+ System.out.println(String.format("A bar button item on the custom toolbar was clicked: %s.", barButtonItem));
+ }
+
+ @IBOutlet
+ private void setToolbar(UIToolbar toolbar) {
+ this.toolbar = toolbar;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/toolbar/AAPLDefaultToolbarViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/toolbar/AAPLDefaultToolbarViewController.java
new file mode 100644
index 00000000..1f100479
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/toolbar/AAPLDefaultToolbarViewController.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.toolbar;
+
+import org.robovm.apple.foundation.NSArray;
+import org.robovm.apple.uikit.UIBarButtonItem;
+import org.robovm.apple.uikit.UIBarButtonItemStyle;
+import org.robovm.apple.uikit.UIBarButtonSystemItem;
+import org.robovm.apple.uikit.UIToolbar;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+
+@CustomClass("AAPLDefaultToolbarViewController")
+public class AAPLDefaultToolbarViewController extends UIViewController implements UIBarButtonItem.OnClickListener {
+ private UIToolbar toolbar;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureToolbar();
+ }
+
+ private void configureToolbar() {
+ NSArray toolbarButtonItems = new NSArray(getTrashBarButtonItem(),
+ getFlexibleSpaceBarButtonItem(), getCustomTitleBarButtonItem());
+ toolbar.setItems(toolbarButtonItems, true);
+ }
+
+ private UIBarButtonItem getTrashBarButtonItem() {
+ return new UIBarButtonItem(UIBarButtonSystemItem.Trash, this);
+ }
+
+ private UIBarButtonItem getFlexibleSpaceBarButtonItem() {
+ return new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null);
+ }
+
+ private UIBarButtonItem getCustomTitleBarButtonItem() {
+ String customTitle = "Action";
+
+ return new UIBarButtonItem(customTitle, UIBarButtonItemStyle.Plain, this);
+ }
+
+ @Override
+ public void onClick(UIBarButtonItem barButtonItem) {
+ System.out.println(String.format("A bar button item on the default toolbar was clicked: %s.", barButtonItem));
+ }
+
+ @IBOutlet
+ private void setToolbar(UIToolbar toolbar) {
+ this.toolbar = toolbar;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/toolbar/AAPLTintedToolbarViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/toolbar/AAPLTintedToolbarViewController.java
new file mode 100644
index 00000000..947fa20e
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/toolbar/AAPLTintedToolbarViewController.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.toolbar;
+
+import org.robovm.apple.foundation.NSArray;
+import org.robovm.apple.uikit.UIBarButtonItem;
+import org.robovm.apple.uikit.UIBarButtonSystemItem;
+import org.robovm.apple.uikit.UIBarStyle;
+import org.robovm.apple.uikit.UIToolbar;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLTintedToolbarViewController")
+public class AAPLTintedToolbarViewController extends UIViewController implements UIBarButtonItem.OnClickListener {
+ private UIToolbar toolbar;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureToolbar();
+ }
+
+ private void configureToolbar() {
+ // See the UIBarStyle enum for more styles, including
+ // UIBarStyle.Default.
+ toolbar.setBarStyle(UIBarStyle.BlackTranslucent);
+
+ toolbar.setTintColor(Colors.GREEN);
+ toolbar.setBackgroundColor(Colors.BLUE);
+
+ NSArray toolbarButtonItems = new NSArray(getRefreshBarButtonItem(),
+ getFlexibleSpaceBarButtonItem(), getActionBarButtomItem());
+ toolbar.setItems(toolbarButtonItems, true);
+ }
+
+ private UIBarButtonItem getRefreshBarButtonItem() {
+ return new UIBarButtonItem(UIBarButtonSystemItem.Refresh, this);
+ }
+
+ private UIBarButtonItem getFlexibleSpaceBarButtonItem() {
+ return new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null);
+ }
+
+ private UIBarButtonItem getActionBarButtomItem() {
+ return new UIBarButtonItem(UIBarButtonSystemItem.Action, this);
+ }
+
+ @Override
+ public void onClick(UIBarButtonItem barButtonItem) {
+ System.out.println(String.format("A bar button item on the tinted toolbar was clicked: %s.", barButtonItem));
+ }
+
+ @IBOutlet
+ private void setToolbar(UIToolbar toolbar) {
+ this.toolbar = toolbar;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLActivityIndicatorViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLActivityIndicatorViewController.java
new file mode 100644
index 00000000..8e15c65f
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLActivityIndicatorViewController.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.uikit.UIActivityIndicatorView;
+import org.robovm.apple.uikit.UIActivityIndicatorViewStyle;
+import org.robovm.apple.uikit.UITableViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLActivityIndicatorViewController")
+public class AAPLActivityIndicatorViewController extends UITableViewController {
+ private UIActivityIndicatorView grayStyleActivityIndicatorView;
+ private UIActivityIndicatorView tintedActivityIndicatorView;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureGrayActivityIndicatorView();
+ configureTintedActivityIndicatorView();
+
+ // When activity is done, use UIActivityIndicatorView.stopAnimating().
+ }
+
+ private void configureGrayActivityIndicatorView() {
+ grayStyleActivityIndicatorView.setActivityIndicatorViewStyle(UIActivityIndicatorViewStyle.Gray);
+ grayStyleActivityIndicatorView.startAnimating();
+ grayStyleActivityIndicatorView.setHidesWhenStopped(true);
+ }
+
+ private void configureTintedActivityIndicatorView() {
+ tintedActivityIndicatorView.setActivityIndicatorViewStyle(UIActivityIndicatorViewStyle.Gray);
+ tintedActivityIndicatorView.setColor(Colors.PURPLE);
+ tintedActivityIndicatorView.startAnimating();
+ }
+
+ @IBOutlet
+ private void setGrayStyleActivityIndicatorView(UIActivityIndicatorView grayStyleActivityIndicatorView) {
+ this.grayStyleActivityIndicatorView = grayStyleActivityIndicatorView;
+ }
+
+ @IBOutlet
+ private void setTintedActivityIndicatorView(UIActivityIndicatorView tintedActivityIndicatorView) {
+ this.tintedActivityIndicatorView = tintedActivityIndicatorView;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLAlertControllerViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLAlertControllerViewController.java
new file mode 100644
index 00000000..ff2fe718
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLAlertControllerViewController.java
@@ -0,0 +1,413 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.foundation.NSIndexPath;
+import org.robovm.apple.foundation.NSNotificationCenter;
+import org.robovm.apple.foundation.NSObject;
+import org.robovm.apple.uikit.UIAlertAction;
+import org.robovm.apple.uikit.UIAlertActionStyle;
+import org.robovm.apple.uikit.UIAlertController;
+import org.robovm.apple.uikit.UIAlertControllerStyle;
+import org.robovm.apple.uikit.UIPopoverArrowDirection;
+import org.robovm.apple.uikit.UIPopoverPresentationController;
+import org.robovm.apple.uikit.UITableView;
+import org.robovm.apple.uikit.UITableViewCell;
+import org.robovm.apple.uikit.UITableViewController;
+import org.robovm.apple.uikit.UITextField;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.block.VoidBlock1;
+
+@CustomClass("AAPLAlertControllerViewController")
+public class AAPLAlertControllerViewController extends UITableViewController {
+
+ // Corresponds to the section index of the table view (whether we want to
+ // show an alert or action sheet style).
+ private enum Section {
+ Alert, ActionSheet
+ }
+
+ // Corresponds to the row in the alert style section.
+ private enum AlertRow {
+ Simple, OkayCancel, Other, TextEntry, TextEntrySecure
+ }
+
+ // Corresponds to the row in the action sheet style section.
+ private enum ActionSheetRow {
+ OkayCancel, Other
+ }
+
+ // Maintains a reference to the alert action that should be toggled when the
+ // text field changes (for the secure text entry alert).
+ private UIAlertAction secureTextAlertAction;
+ private NSObject textChangeNotification;
+
+ /**
+ * Show an alert with an "Okay" button.
+ */
+ private void showSimpleAlert() {
+ String title = "A Short Title Is Best";
+ String message = "A message should be a short, complete sentence.";
+ String cancelButtonTitle = "OK";
+
+ UIAlertController alertController = UIAlertController.create(title, message, UIAlertControllerStyle.Alert);
+
+ // Create the action.
+ UIAlertAction cancelAction = UIAlertAction.create(cancelButtonTitle, UIAlertActionStyle.Cancel,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The simple alert's cancel action occured.");
+ }
+ });
+
+ // Add the action.
+ alertController.addAction(cancelAction);
+
+ presentViewController(alertController, true, null);
+ }
+
+ /**
+ * Show an alert with an "Okay" and "Cancel" button.
+ */
+ private void showOkayCancelAlert() {
+ String title = "A Short Title Is Best";
+ String message = "A message should be a short, complete sentence.";
+ String cancelButtonTitle = "Cancel";
+ String otherButtonTitle = "OK";
+
+ UIAlertController alertController = UIAlertController.create(title, message, UIAlertControllerStyle.Alert);
+
+ // Create the actions.
+ UIAlertAction cancelAction = UIAlertAction.create(cancelButtonTitle, UIAlertActionStyle.Cancel,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Okay/Cancel\" alert's cancel action occured.");
+ }
+ });
+
+ UIAlertAction otherAction = UIAlertAction.create(otherButtonTitle, UIAlertActionStyle.Default,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Okay/Cancel\" alert's other action occured.");
+ }
+ });
+
+ // Add the actions.
+ alertController.addAction(cancelAction);
+ alertController.addAction(otherAction);
+
+ presentViewController(alertController, true, null);
+ }
+
+ // Show an alert with two custom buttons.
+ private void showOtherAlert() {
+ String title = "A Short Title Is Best";
+ String message = "A message should be a short, complete sentence.";
+ String cancelButtonTitle = "Cancel";
+ String otherButtonTitleOne = "Choice One";
+ String otherButtonTitleTwo = "Choice Two";
+
+ UIAlertController alertController = UIAlertController.create(title, message, UIAlertControllerStyle.Alert);
+
+ // Create the actions.
+ UIAlertAction cancelAction = UIAlertAction.create(cancelButtonTitle, UIAlertActionStyle.Cancel,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Other\" alert's cancel action occured.");
+ }
+ });
+
+ UIAlertAction otherButtonOneAction = UIAlertAction.create(otherButtonTitleOne, UIAlertActionStyle.Default,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Other\" alert's other button one action occured.");
+ }
+ });
+
+ UIAlertAction otherButtonTwoAction = UIAlertAction.create(otherButtonTitleTwo, UIAlertActionStyle.Default,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Other\" alert's other button two action occured.");
+ }
+ });
+
+ // Add the actions.
+ alertController.addAction(cancelAction);
+ alertController.addAction(otherButtonOneAction);
+ alertController.addAction(otherButtonTwoAction);
+
+ presentViewController(alertController, true, null);
+ }
+
+ /**
+ * Show a text entry alert with two custom buttons.
+ */
+ private void showTextEntryAlert() {
+ String title = "A Short Title Is Best";
+ String message = "A message should be a short, complete sentence.";
+ String cancelButtonTitle = "Cancel";
+ String otherButtonTitle = "OK";
+
+ UIAlertController alertController = UIAlertController.create(title, message, UIAlertControllerStyle.Alert);
+
+ // Add the text field for text entry.
+ alertController.addTextField(new VoidBlock1() {
+ @Override
+ public void invoke(UITextField a) {
+ // If you need to customize the text field, you can do so here.
+ }
+ });
+
+ // Create the actions.
+ UIAlertAction cancelAction = UIAlertAction.create(cancelButtonTitle, UIAlertActionStyle.Cancel,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Text Entry\" alert's cancel action occured.");
+ }
+ });
+
+ UIAlertAction otherAction = UIAlertAction.create(otherButtonTitle, UIAlertActionStyle.Default,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction textField) {
+ System.out.println("The \"Text Entry\" alert's other action occured.");
+ }
+ });
+
+ // Add the actions.
+ alertController.addAction(cancelAction);
+ alertController.addAction(otherAction);
+
+ presentViewController(alertController, true, null);
+ }
+
+ // Show a secure text entry alert with two custom buttons.
+ private void showSecureTextEntryAlert() {
+ String title = "A Short Title Is Best";
+ String message = "A message should be a short, complete sentence.";
+ String cancelButtonTitle = "Cancel";
+ String otherButtonTitle = "OK";
+
+ UIAlertController alertController = UIAlertController.create(title, message, UIAlertControllerStyle.Alert);
+
+ // Add the text field for the secure text entry.
+ alertController.addTextField(new VoidBlock1() {
+ @Override
+ public void invoke(UITextField textField) {
+ // Listen for changes to the text field's text so that we can
+ // toggle the current
+ // action's enabled property based on whether the user has
+ // entered a sufficiently
+ // secure entry.
+ textField.setSecureTextEntry(true);
+
+ textChangeNotification = UITextField.Notifications.observeTextDidChange(textField,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UITextField textField) {
+ // Enforce a minimum length of >= 5 characters
+ // for secure text alerts.
+ secureTextAlertAction.setEnabled(textField.getText().length() >= 5);
+ }
+ });
+ }
+ });
+
+ // Create the actions.
+ UIAlertAction cancelAction = UIAlertAction.create(cancelButtonTitle, UIAlertActionStyle.Cancel,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Secure Text Entry\" alert's cancel action occured.");
+
+ // Stop listening for text changed notifications.
+ NSNotificationCenter.getDefaultCenter().removeObserver(textChangeNotification);
+ }
+ });
+
+ UIAlertAction otherAction = UIAlertAction.create(otherButtonTitle, UIAlertActionStyle.Default,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Secure Text Entry\" alert's other action occured.");
+
+ // Stop listening for text changed notifications.
+ NSNotificationCenter.getDefaultCenter().removeObserver(textChangeNotification);
+ }
+ });
+
+ // The text field initially has no text in the text field, so we'll
+ // disable it.
+ otherAction.setEnabled(false);
+
+ // Hold onto the secure text alert action to toggle the enabled/disabled
+ // state when the text changed.
+ secureTextAlertAction = otherAction;
+
+ // Add the actions.
+ alertController.addAction(cancelAction);
+ alertController.addAction(otherAction);
+
+ presentViewController(alertController, true, null);
+ }
+
+ /**
+ * Show a dialog with an "Okay" and "Cancel" button.
+ *
+ * @param selectedPath
+ */
+ private void showOkayCancelActionSheet(NSIndexPath selectedPath) {
+ String cancelButtonTitle = "Cancel";
+ String destructiveButtonTitle = "OK";
+
+ UIAlertController alertController = UIAlertController.create(null, null, UIAlertControllerStyle.ActionSheet);
+
+ // Create the actions.
+ UIAlertAction cancelAction = UIAlertAction.create(cancelButtonTitle, UIAlertActionStyle.Cancel,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Okay/Cancel\" alert action sheet's cancel action occured.");
+ }
+ });
+
+ UIAlertAction destructiveAction = UIAlertAction.create(destructiveButtonTitle, UIAlertActionStyle.Destructive,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Okay/Cancel\" alert action sheet's destructive action occured.");
+ }
+ });
+
+ // Add the actions.
+ alertController.addAction(cancelAction);
+ alertController.addAction(destructiveAction);
+
+ // Configure the alert controller's popover presentation controller if
+ // it has one.
+ UIPopoverPresentationController popoverPresentationController = alertController
+ .getPopoverPresentationController();
+ if (popoverPresentationController != null) {
+ UITableViewCell selectedCell = getTableView().getCellForRow(selectedPath);
+ popoverPresentationController.setSourceRect(selectedCell.getFrame());
+ popoverPresentationController.setSourceView(getView());
+ popoverPresentationController.setPermittedArrowDirections(UIPopoverArrowDirection.Up);
+ }
+
+ presentViewController(alertController, true, null);
+ }
+
+ /**
+ * Show a dialog with two custom buttons.
+ *
+ * @param selectedPath
+ */
+ private void showOtherActionSheet(NSIndexPath selectedPath) {
+ String destructiveButtonTitle = "Destructive Choice";
+ String otherButtonTitle = "Safe Choice";
+
+ UIAlertController alertController = UIAlertController.create(null, null, UIAlertControllerStyle.ActionSheet);
+
+ // Create the actions.
+ UIAlertAction destructiveAction = UIAlertAction.create(destructiveButtonTitle, UIAlertActionStyle.Destructive,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Other\" alert action sheet's destructive action occured.");
+ }
+ });
+
+ UIAlertAction otherAction = UIAlertAction.create(otherButtonTitle, UIAlertActionStyle.Default,
+ new VoidBlock1() {
+ @Override
+ public void invoke(UIAlertAction a) {
+ System.out.println("The \"Other\" alert action sheet's other action occured.");
+ }
+ });
+
+ // Add the actions.
+ alertController.addAction(destructiveAction);
+ alertController.addAction(otherAction);
+
+ // Configure the alert controller's popover presentation controller if
+ // it has one.
+ UIPopoverPresentationController popoverPresentationController = alertController
+ .getPopoverPresentationController();
+ if (popoverPresentationController != null) {
+ UITableViewCell selectedCell = getTableView().getCellForRow(selectedPath);
+ popoverPresentationController.setSourceRect(selectedCell.getFrame());
+ popoverPresentationController.setSourceView(getView());
+ popoverPresentationController.setPermittedArrowDirections(UIPopoverArrowDirection.Up);
+ }
+
+ presentViewController(alertController, true, null);
+ }
+
+ // Determine the action to perform based on the selected cell.
+ @Override
+ public void didSelectRow(UITableView tableView, NSIndexPath indexPath) {
+ Section section = Section.values()[(int) indexPath.getSection()];
+
+ if (section == Section.Alert) {
+ AlertRow row = AlertRow.values()[(int) indexPath.getRow()];
+
+ switch (row) {
+ case Simple:
+ showSimpleAlert();
+ break;
+ case OkayCancel:
+ showOkayCancelAlert();
+ break;
+ case Other:
+ showOtherAlert();
+ break;
+ case TextEntry:
+ showTextEntryAlert();
+ break;
+ case TextEntrySecure:
+ showSecureTextEntryAlert();
+ break;
+ default:
+ break;
+ }
+ } else if (section == Section.ActionSheet) {
+ ActionSheetRow row = ActionSheetRow.values()[(int) indexPath.getRow()];
+
+ switch (row) {
+ case OkayCancel:
+ showOkayCancelActionSheet(indexPath);
+ break;
+ case Other:
+ showOtherActionSheet(indexPath);
+ break;
+ default:
+ break;
+ }
+ }
+
+ tableView.deselectRow(indexPath, true);
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLButtonViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLButtonViewController.java
new file mode 100644
index 00000000..cb6855ad
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLButtonViewController.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.foundation.NSAttributedString;
+import org.robovm.apple.uikit.NSAttributedStringAttributes;
+import org.robovm.apple.uikit.NSUnderlineStyle;
+import org.robovm.apple.uikit.UIButton;
+import org.robovm.apple.uikit.UIColor;
+import org.robovm.apple.uikit.UIControl;
+import org.robovm.apple.uikit.UIControlState;
+import org.robovm.apple.uikit.UIEvent;
+import org.robovm.apple.uikit.UIImage;
+import org.robovm.apple.uikit.UITableViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLButtonViewController")
+public class AAPLButtonViewController extends UITableViewController implements UIControl.OnTouchUpInsideListener {
+ private UIButton systemTextButton;
+ private UIButton systemContactAddButton;
+ private UIButton systemDetailDisclosureButton;
+ private UIButton imageButton;
+ private UIButton attributedTextButton;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ // All of the buttons are created in the storyboard, but configured
+ // below.
+ configureSystemTextButton();
+ configureSystemContactAddButton();
+ configureSystemDetailDisclosureButton();
+ configureImageButton();
+ configureAttributedTextSystemButton();
+ }
+
+ private void configureSystemTextButton() {
+ systemTextButton.setTitle("Button", UIControlState.Normal);
+ systemTextButton.addOnTouchUpInsideListener(this);
+ }
+
+ private void configureSystemContactAddButton() {
+ systemContactAddButton.setBackgroundColor(UIColor.clear());
+ systemContactAddButton.addOnTouchUpInsideListener(this);
+ }
+
+ private void configureSystemDetailDisclosureButton() {
+ systemDetailDisclosureButton.setBackgroundColor(UIColor.clear());
+ systemDetailDisclosureButton.addOnTouchUpInsideListener(this);
+ }
+
+ private void configureImageButton() {
+ // To create this button in code you can use UIButton.create() with a
+ // parameter value of UIButtonType.Custom.
+
+ // Remove the title text.
+ imageButton.setTitle("", UIControlState.Normal);
+
+ imageButton.setTintColor(Colors.PURPLE);
+
+ UIImage imageButtonNormalImage = UIImage.create("x_icon");
+ imageButton.setImage(imageButtonNormalImage, UIControlState.Normal);
+
+ // Add an accessibility label to the image.
+// imageButton.setAccessibilityLabel("X_Button"); TODO
+
+ imageButton.addOnTouchUpInsideListener(this);
+ }
+
+ private void configureAttributedTextSystemButton() {
+ // Set the button's title for normal state.
+ NSAttributedStringAttributes normalTitleAttributes = new NSAttributedStringAttributes().setForegroundColor(
+ Colors.BLUE).setStrikethroughStyle(NSUnderlineStyle.StyleSingle);
+ NSAttributedString normalAttributedTitle = new NSAttributedString("Button", normalTitleAttributes);
+
+ attributedTextButton.setAttributedTitle(normalAttributedTitle, UIControlState.Normal);
+
+ // Set the button's title for highlighted state.
+ NSAttributedStringAttributes highlightedTitleAttributes = new NSAttributedStringAttributes()
+ .setForegroundColor(Colors.GREEN).setStrikethroughStyle(NSUnderlineStyle.StyleThick);
+ NSAttributedString highlightedAttributedTitle = new NSAttributedString("Button", highlightedTitleAttributes);
+
+ attributedTextButton.setAttributedTitle(highlightedAttributedTitle, UIControlState.Highlighted);
+
+ attributedTextButton.addOnTouchUpInsideListener(this);
+ }
+
+ @Override
+ public void onTouchUpInside(UIControl control, UIEvent event) {
+ System.out.println(String.format("A button was clicked: %s", control));
+ }
+
+ @IBOutlet
+ private void setSystemTextButton(UIButton systemTextButton) {
+ this.systemTextButton = systemTextButton;
+ }
+
+ @IBOutlet
+ private void setSystemContactAddButton(UIButton systemContactAddButton) {
+ this.systemContactAddButton = systemContactAddButton;
+ }
+
+ @IBOutlet
+ private void setSystemDetailDisclosureButton(UIButton systemDetailDisclosureButton) {
+ this.systemDetailDisclosureButton = systemDetailDisclosureButton;
+ }
+
+ @IBOutlet
+ private void setImageButton(UIButton imageButton) {
+ this.imageButton = imageButton;
+ }
+
+ @IBOutlet
+ private void setAttributedTextButton(UIButton attributedTextButton) {
+ this.attributedTextButton = attributedTextButton;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLDatePickerController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLDatePickerController.java
new file mode 100644
index 00000000..f41582f2
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLDatePickerController.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.foundation.NSCalendar;
+import org.robovm.apple.foundation.NSCalendarOptions;
+import org.robovm.apple.foundation.NSDate;
+import org.robovm.apple.foundation.NSDateComponents;
+import org.robovm.apple.foundation.NSDateFormatter;
+import org.robovm.apple.foundation.NSDateFormatterStyle;
+import org.robovm.apple.uikit.UIControl;
+import org.robovm.apple.uikit.UIDatePicker;
+import org.robovm.apple.uikit.UIDatePickerMode;
+import org.robovm.apple.uikit.UILabel;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+
+@CustomClass("AAPLDatePickerController")
+public class AAPLDatePickerController extends UIViewController implements UIControl.OnValueChangedListener {
+ private UIDatePicker datePicker;
+ private UILabel dateLabel;
+
+ private NSDateFormatter dateFormatter;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ // Create a date formatter to be used to format the "date" property of
+ // "datePicker".
+ dateFormatter = new NSDateFormatter();
+ dateFormatter.setDateStyle(NSDateFormatterStyle.Medium);
+ dateFormatter.setTimeStyle(NSDateFormatterStyle.Short);
+
+ configureDatePicker();
+ }
+
+ private void configureDatePicker() {
+ datePicker.setDatePickerMode(UIDatePickerMode.DateAndTime);
+
+ // Set min/max date for the date picker.
+ // As an example we will limit the date between now and 7 days from now.
+ NSDate now = NSDate.now();
+ datePicker.setMinimumDate(now);
+
+ NSCalendar currentCalendar = NSCalendar.getCurrentCalendar();
+
+ NSDateComponents dateComponents = new NSDateComponents();
+ dateComponents.setDay(7);
+
+ NSDate sevenDaysFromNow = currentCalendar
+ .newDateByAddingComponents(dateComponents, now, NSCalendarOptions.None);
+ datePicker.setMaximumDate(sevenDaysFromNow);
+
+ // Display the "minutes" interval by increments of 1 minute (this is the
+ // default).
+ datePicker.setMinuteInterval(1);
+
+ datePicker.addOnValueChangedListener(this);
+
+ onValueChanged(null);
+ }
+
+ @IBOutlet
+ private void setDatePicker(UIDatePicker datePicker) {
+ this.datePicker = datePicker;
+ }
+
+ @IBOutlet
+ private void setDateLabel(UILabel dateLabel) {
+ this.dateLabel = dateLabel;
+ }
+
+ @Override
+ public void onValueChanged(UIControl control) {
+ dateLabel.setText(dateFormatter.format(datePicker.getDate()));
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLImageViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLImageViewController.java
new file mode 100644
index 00000000..3657dcd6
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLImageViewController.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.foundation.NSArray;
+import org.robovm.apple.uikit.UIColor;
+import org.robovm.apple.uikit.UIImage;
+import org.robovm.apple.uikit.UIImageView;
+import org.robovm.apple.uikit.UIViewContentMode;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.objc.annotation.CustomClass;
+
+@CustomClass("AAPLImageViewController")
+public class AAPLImageViewController extends UIViewController {
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ // The root view of the view controller set in Interface Builder is a
+ // UIImageView.
+ UIImageView imageView = (UIImageView) getView();
+
+ imageView.setAnimationImages(new NSArray(UIImage.create("image_animal_1"),
+ UIImage.create("image_animal_2"),
+ UIImage.create("image_animal_3"),
+ UIImage.create("image_animal_4"),
+ UIImage.create("image_animal_5")));
+
+ // We want the image to be scaled to the correct aspect ratio within
+ // imageView's bounds.
+ imageView.setContentMode(UIViewContentMode.ScaleAspectFit);
+
+ // If the image does not have the same aspect ratio as imageView's
+ // bounds, then imageView's backgroundColor will be applied to the
+ // "empty" space.
+ imageView.setBackgroundColor(UIColor.white());
+
+ imageView.setAnimationDuration(5);
+ imageView.startAnimating();
+
+// imageView.setAccessibilityElement(true); TODO
+// imageView.setAccessibilityLabel("Animated"); TODO
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLPageControlViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLPageControlViewController.java
new file mode 100644
index 00000000..cbd60641
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLPageControlViewController.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.uikit.UIColor;
+import org.robovm.apple.uikit.UIControl;
+import org.robovm.apple.uikit.UIPageControl;
+import org.robovm.apple.uikit.UIView;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLPageControlViewController")
+public class AAPLPageControlViewController extends UIViewController implements UIControl.OnValueChangedListener {
+ private UIPageControl pageControl;
+ private UIView colorView;
+ private UIColor[] colors;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ // Set a list of colors that correspond to the selected page.
+ colors = new UIColor[] { UIColor.black(), UIColor.gray(), UIColor.red(), UIColor.green(), UIColor.blue(),
+ UIColor.cyan(), UIColor.yellow(), UIColor.magenta(), UIColor.orange(), UIColor.purple() };
+
+ configurePageControl();
+ onValueChanged(null);
+ }
+
+ private void configurePageControl() {
+ // The total number of pages that are available is based on how many
+ // available colors we have.
+ pageControl.setNumberOfPages(colors.length);
+ pageControl.setCurrentPage(2);
+
+ pageControl.setTintColor(Colors.BLUE);
+ pageControl.setPageIndicatorTintColor(Colors.GREEN);
+ pageControl.setCurrentPageIndicatorTintColor(Colors.PURPLE);
+
+ pageControl.addOnValueChangedListener(this);
+ }
+
+ @IBOutlet
+ private void setPageControl(UIPageControl pageControl) {
+ this.pageControl = pageControl;
+ }
+
+ @IBOutlet
+ private void setColorView(UIView colorView) {
+ this.colorView = colorView;
+ }
+
+ @Override
+ public void onValueChanged(UIControl control) {
+ System.out.println(String.format("The page control changed its current page to %d.",
+ pageControl.getCurrentPage()));
+
+ colorView.setBackgroundColor(colors[(int) pageControl.getCurrentPage()]);
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLPickerViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLPickerViewController.java
new file mode 100644
index 00000000..e10b26b9
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLPickerViewController.java
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.foundation.NSAttributedString;
+import org.robovm.apple.uikit.NSAttributedStringAttributes;
+import org.robovm.apple.uikit.UIColor;
+import org.robovm.apple.uikit.UIPickerView;
+import org.robovm.apple.uikit.UIPickerViewAccessibilityDelegateAdapter;
+import org.robovm.apple.uikit.UIPickerViewDataSource;
+import org.robovm.apple.uikit.UIView;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+
+@CustomClass("AAPLPickerViewController")
+public class AAPLPickerViewController extends UIViewController implements UIPickerViewDataSource {
+ // The maximum RGB color
+ private static final double RGB_MAX = 255;
+ // The offset of each color value (from 0 to 255) for red, green, and blue.
+ private static final double COLOR_VALUE_OFFSET = 5;
+ // The number of colors within a color component.
+ private static final int NUMBER_OF_COLOR_VALUES_PER_COMPONENT = (int) (Math.ceil(RGB_MAX / COLOR_VALUE_OFFSET) + 1);
+
+ private UIPickerView pickerView;
+ private UIView colorSwatchView;
+
+ private double redColorComponent;
+ private double greenColorComponent;
+ private double blueColorComponent;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ // Show that a given row is selected. This is off by default.
+ pickerView.setShowsSelectionIndicator(true);
+
+ configurePickerView();
+ }
+
+ private void configurePickerView() {
+ pickerView.setDelegate(new UIPickerViewAccessibilityDelegateAdapter() {
+ @Override
+ public NSAttributedString getAttributedRowTitle(UIPickerView pickerView, long row, long component) {
+ int colorValue = (int) (row * COLOR_VALUE_OFFSET);
+
+ double colorComponent = colorValue / RGB_MAX;
+ double redColorComponent = 0;
+ double greenColorComponent = 0;
+ double blueColorComponent = 0;
+
+ switch ((int) component) {
+ case 0: // RED
+ redColorComponent = colorComponent;
+ break;
+ case 1: // GREEN
+ greenColorComponent = colorComponent;
+ break;
+ case 2: // BLUE
+ blueColorComponent = colorComponent;
+ break;
+ default:
+ System.out.println("Invalid row/component combination for picker view.");
+ break;
+ }
+
+ UIColor foregroundColor = UIColor.fromRGBA(redColorComponent, greenColorComponent, blueColorComponent,
+ 1);
+
+ String titleText = String.valueOf(colorValue);
+
+ // Set the foreground color for the attributed string.
+ NSAttributedStringAttributes attributes = new NSAttributedStringAttributes()
+ .setForegroundColor(foregroundColor);
+ NSAttributedString title = new NSAttributedString(titleText, attributes);
+
+ return title;
+ }
+
+ @Override
+ public void didSelectRow(UIPickerView pickerView, long row, long component) {
+ AAPLPickerViewController.this.didSelectRow((int) row, (int) component);
+ }
+
+ @Override
+ public String getAccessibilityLabel(UIPickerView pickerView, long component) {
+ String accessiblityLabel = null;
+
+ switch ((int) component) {
+ case 0: // RED
+ accessiblityLabel = "Red color component valu";
+ break;
+ case 1: // GREEN
+ accessiblityLabel = "Green color component valu";
+ break;
+ case 2: // BLUE
+ accessiblityLabel = "Blue color component valu";
+ break;
+ default:
+ System.out.println("Invalid row/component combination for picker view.");
+ break;
+ }
+
+ return accessiblityLabel;
+ }
+ });
+
+ // Set the default selected rows (the desired rows to initially select
+ // will vary by use case).
+ selectRowInPickerView(13, 0);
+ selectRowInPickerView(41, 1);
+ selectRowInPickerView(24, 2);
+ }
+
+ private void selectRowInPickerView(int row, int colorComponent) {
+ // Note that the delegate method on UIPickerViewDelegate is not
+ // triggered when manually calling UIPickerView.selectRow().
+ // To do this, we fire off the delegate method manually.
+ pickerView.selectRow(row, colorComponent, true);
+
+ didSelectRow(row, colorComponent);
+ }
+
+ private void updateColorSwatchViewBackgroundColor() {
+ colorSwatchView.setBackgroundColor(UIColor.fromRGBA(redColorComponent, greenColorComponent, blueColorComponent,
+ 1));
+ }
+
+ @Override
+ public long getNumberOfComponents(UIPickerView pickerView) {
+ return 3;
+ }
+
+ @Override
+ public long getNumberOfRows(UIPickerView pickerView, long component) {
+ return NUMBER_OF_COLOR_VALUES_PER_COMPONENT;
+ }
+
+ private void didSelectRow(int row, int component) {
+ double colorComponentValue = (COLOR_VALUE_OFFSET * row) / RGB_MAX;
+
+ switch (component) {
+ case 0: // RED
+ redColorComponent = colorComponentValue;
+ break;
+ case 1: // GREEN
+ greenColorComponent = colorComponentValue;
+ break;
+ case 2: // BLUE
+ blueColorComponent = colorComponentValue;
+ break;
+ default:
+ System.out.println("Invalid row/component combination selected for picker view.");
+ break;
+ }
+ updateColorSwatchViewBackgroundColor();
+ }
+
+ @IBOutlet
+ private void setPickerView(UIPickerView pickerView) {
+ this.pickerView = pickerView;
+ }
+
+ @IBOutlet
+ private void setColorSwatchView(UIView colorSwatchView) {
+ this.colorSwatchView = colorSwatchView;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLProgressViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLProgressViewController.java
new file mode 100644
index 00000000..961f1ab0
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLProgressViewController.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.foundation.NSOperationQueue;
+import org.robovm.apple.uikit.UIProgressView;
+import org.robovm.apple.uikit.UIProgressViewStyle;
+import org.robovm.apple.uikit.UITableViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLProgressViewController")
+public class AAPLProgressViewController extends UITableViewController {
+ private static final int MAX_PROGRESS = 100;
+
+ private UIProgressView defaultStyleProgressView;
+ private UIProgressView barStyleProgressView;
+ private UIProgressView tintedProgressView;
+
+ private NSOperationQueue operationQueue;
+ private int completedProgress = -1;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ // Set the initial progress for all progress views.
+ updateProgress(0);
+
+ configureDefaultStyleProgressView();
+ configureBarStyleProgressView();
+ configureTintedProgressView();
+
+ // As progress is received from another subsystem (i.e. NSProgress,
+ // NSURLSessionTaskDelegate, etc.), update the progressView's progress.
+ simulateProgress();
+ }
+
+ private void updateProgress(int completedProgress) {
+ if (this.completedProgress != completedProgress) {
+ float fractionalProgress = (float) completedProgress / MAX_PROGRESS;
+
+ boolean animated = this.completedProgress != 0;
+
+ defaultStyleProgressView.setProgress(fractionalProgress, animated);
+ barStyleProgressView.setProgress(fractionalProgress, animated);
+ tintedProgressView.setProgress(fractionalProgress, animated);
+
+ this.completedProgress = completedProgress;
+ }
+ }
+
+ private void configureDefaultStyleProgressView() {
+ defaultStyleProgressView.setProgressViewStyle(UIProgressViewStyle.Default);
+ }
+
+ private void configureBarStyleProgressView() {
+ barStyleProgressView.setProgressViewStyle(UIProgressViewStyle.Bar);
+ }
+
+ private void configureTintedProgressView() {
+ tintedProgressView.setProgressViewStyle(UIProgressViewStyle.Default);
+
+ tintedProgressView.setTrackTintColor(Colors.BLUE);
+ tintedProgressView.setProgressTintColor(Colors.PURPLE);
+ }
+
+ private void simulateProgress() {
+ // In this example we will simulate progress with a "sleep operation".
+ operationQueue = new NSOperationQueue();
+
+ for (int i = 0; i < MAX_PROGRESS; i++) {
+ operationQueue.addOperation(new Runnable() {
+ @Override
+ public void run() {
+ // Delay the system for a random number of seconds.
+ // This code is not intended for production purposes. The
+ // "sleep" call is meant to simulate work done in another
+ // subsystem.
+ try {
+ Thread.sleep((long) Math.floor(Math.random() * 10) * 1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ NSOperationQueue.getMainQueue().addOperation(new Runnable() {
+ @Override
+ public void run() {
+ updateProgress(completedProgress + 1);
+ }
+ });
+ }
+ });
+ }
+ }
+
+ @IBOutlet
+ private void setDefaultStyleProgressView(UIProgressView defaultStyleProgressView) {
+ this.defaultStyleProgressView = defaultStyleProgressView;
+ }
+
+ @IBOutlet
+ private void setBarStyleProgressView(UIProgressView barStyleProgressView) {
+ this.barStyleProgressView = barStyleProgressView;
+ }
+
+ @IBOutlet
+ private void setTintedProgressView(UIProgressView tintedProgressView) {
+ this.tintedProgressView = tintedProgressView;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLSegmentedControlViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLSegmentedControlViewController.java
new file mode 100644
index 00000000..f63cbb5f
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLSegmentedControlViewController.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.robovm.apple.uikit.NSAttributedStringAttributes;
+import org.robovm.apple.uikit.UIBarMetrics;
+import org.robovm.apple.uikit.UIControl;
+import org.robovm.apple.uikit.UIControlState;
+import org.robovm.apple.uikit.UIFont;
+import org.robovm.apple.uikit.UIFontDescriptor;
+import org.robovm.apple.uikit.UIFontTextStyle;
+import org.robovm.apple.uikit.UIImage;
+import org.robovm.apple.uikit.UISegmentedControl;
+import org.robovm.apple.uikit.UITableViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLSegmentedControlViewController")
+public class AAPLSegmentedControlViewController extends UITableViewController implements
+ UIControl.OnValueChangedListener {
+ private UISegmentedControl defaultSegmentedControl;
+ private UISegmentedControl tintedSegmentedControl;
+ private UISegmentedControl customSegmentsSegmentedControl;
+ private UISegmentedControl customBackgroundSegmentedControl;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureDefaultSegmentedControl();
+ configureTintedSegmentedControl();
+ configureCustomSegmentsSegmentedControl();
+ configureCustomBackgroundSegmentedControl();
+ }
+
+ private void configureDefaultSegmentedControl() {
+ defaultSegmentedControl.setMomentary(true);
+
+ defaultSegmentedControl.setEnabled(false, 0);
+
+ defaultSegmentedControl.addOnValueChangedListener(this);
+ }
+
+ private void configureTintedSegmentedControl() {
+ tintedSegmentedControl.setTintColor(Colors.BLUE);
+
+ tintedSegmentedControl.setSelectedSegment(1);
+
+ tintedSegmentedControl.addOnValueChangedListener(this);
+ }
+
+ private void configureCustomSegmentsSegmentedControl() {
+ Map imageToAccessibilityLabelMappings = new HashMap<>();
+ imageToAccessibilityLabelMappings.put("checkmark_icon", "Done");
+ imageToAccessibilityLabelMappings.put("search_icon", "Search");
+ imageToAccessibilityLabelMappings.put("tools_icon", "Settings");
+
+ int i = 0;
+ for (Map.Entry entry : imageToAccessibilityLabelMappings.entrySet()) {
+ UIImage image = UIImage.create(entry.getKey());
+// image.setAccessibilityLabel(entry.getValue()); TODO
+
+ customSegmentsSegmentedControl.setImage(image, i);
+ i++;
+ }
+
+ customSegmentsSegmentedControl.setSelectedSegment(0);
+
+ customSegmentsSegmentedControl.addOnValueChangedListener(this);
+ }
+
+ private void configureCustomBackgroundSegmentedControl() {
+ customBackgroundSegmentedControl.setSelectedSegment(2);
+
+ // Set the background images for each control state.
+ UIImage normalSegmentBackgroundImage = UIImage.create("stepper_and_segment_background");
+ customBackgroundSegmentedControl.setBackgroundImage(normalSegmentBackgroundImage, UIControlState.Normal,
+ UIBarMetrics.Default);
+
+ UIImage disabledSegmentBackgroundImage = UIImage.create("stepper_and_segment_background_disabled");
+ customBackgroundSegmentedControl.setBackgroundImage(disabledSegmentBackgroundImage, UIControlState.Disabled,
+ UIBarMetrics.Default);
+
+ UIImage highlightedSegmentBackgroundImage = UIImage.create("stepper_and_segment_background_highlighted");
+ customBackgroundSegmentedControl.setBackgroundImage(highlightedSegmentBackgroundImage,
+ UIControlState.Highlighted, UIBarMetrics.Default);
+
+ // Set the divider image.
+ UIImage segmentDividerImage = UIImage.create("stepper_and_segment_segment_divider");
+ customBackgroundSegmentedControl.setDividerImage(segmentDividerImage, UIControlState.Normal,
+ UIControlState.Normal, UIBarMetrics.Default);
+
+ // Create a font to use for the attributed title (both normal and
+ // highlighted states).
+ UIFontDescriptor captionFontDescriptor = UIFontDescriptor.getPreferredFontDescriptor(UIFontTextStyle.Caption1);
+ UIFont font = UIFont.getFont(captionFontDescriptor, 0);
+
+ NSAttributedStringAttributes normalTextAttributes = new NSAttributedStringAttributes().setForegroundColor(
+ Colors.PURPLE).setFont(font);
+ customBackgroundSegmentedControl.setTitleTextAttributes(normalTextAttributes, UIControlState.Normal);
+
+ NSAttributedStringAttributes highlightedTextAttributes = new NSAttributedStringAttributes().setForegroundColor(
+ Colors.GREEN).setFont(font);
+ customBackgroundSegmentedControl.setTitleTextAttributes(highlightedTextAttributes, UIControlState.Highlighted);
+
+ customBackgroundSegmentedControl.addOnValueChangedListener(this);
+ }
+
+ @Override
+ public void onValueChanged(UIControl control) {
+ System.out.println(String.format("The selected segment changed for: %s.", control));
+ }
+
+ @IBOutlet
+ private void setDefaultSegmentedControl(UISegmentedControl defaultSegmentedControl) {
+ this.defaultSegmentedControl = defaultSegmentedControl;
+ }
+
+ @IBOutlet
+ private void setTintedSegmentedControl(UISegmentedControl tintedSegmentedControl) {
+ this.tintedSegmentedControl = tintedSegmentedControl;
+ }
+
+ @IBOutlet
+ private void setCustomSegmentsSegmentedControl(UISegmentedControl customSegmentsSegmentedControl) {
+ this.customSegmentsSegmentedControl = customSegmentsSegmentedControl;
+ }
+
+ @IBOutlet
+ private void setCustomBackgroundSegmentedControl(UISegmentedControl customBackgroundSegmentedControl) {
+ this.customBackgroundSegmentedControl = customBackgroundSegmentedControl;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLSliderViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLSliderViewController.java
new file mode 100644
index 00000000..8931bf24
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLSliderViewController.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.uikit.UIControl;
+import org.robovm.apple.uikit.UIControl.OnValueChangedListener;
+import org.robovm.apple.uikit.UIControlState;
+import org.robovm.apple.uikit.UIImage;
+import org.robovm.apple.uikit.UISlider;
+import org.robovm.apple.uikit.UITableViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLSliderViewController")
+public class AAPLSliderViewController extends UITableViewController implements OnValueChangedListener {
+ private UISlider defaultSlider;
+ private UISlider tintedSlider;
+ private UISlider customSlider;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureDefaultSlider();
+ configureTintedSlider();
+ configureCustomSlider();
+ }
+
+ private void configureDefaultSlider() {
+ defaultSlider.setMinimumValue(0);
+ defaultSlider.setMaximumValue(100);
+ defaultSlider.setValue(42);
+ defaultSlider.setContinuous(true);
+
+ defaultSlider.addOnValueChangedListener(this);
+ }
+
+ private void configureTintedSlider() {
+ tintedSlider.setMinimumTrackTintColor(Colors.BLUE);
+ tintedSlider.setMaximumTrackTintColor(Colors.PURPLE);
+
+ tintedSlider.addOnValueChangedListener(this);
+ }
+
+ private void configureCustomSlider() {
+ UIImage leftTrackImage = UIImage.create("slider_blue_track");
+ customSlider.setMinimumTrackImage(leftTrackImage, UIControlState.Normal);
+
+ UIImage rightTrackImage = UIImage.create("slider_green_track");
+ customSlider.setMaximumTrackImage(rightTrackImage, UIControlState.Normal);
+
+ UIImage thumbImage = UIImage.create("slider_thumb");
+ customSlider.setThumbImage(thumbImage, UIControlState.Normal);
+
+ customSlider.setMinimumValue(0);
+ customSlider.setMaximumValue(100);
+ customSlider.setContinuous(false);
+ customSlider.setValue(84);
+
+ customSlider.addOnValueChangedListener(this);
+ }
+
+ @IBOutlet
+ private void setDefaultSlider(UISlider defaultSlider) {
+ this.defaultSlider = defaultSlider;
+ }
+
+ @IBOutlet
+ private void setTintedSlider(UISlider tintedSlider) {
+ this.tintedSlider = tintedSlider;
+ }
+
+ @IBOutlet
+ private void setCustomSlider(UISlider customSlider) {
+ this.customSlider = customSlider;
+ }
+
+ @Override
+ public void onValueChanged(UIControl control) {
+ System.out.println(String.format("A slider changed its value: %s", control));
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLStepperViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLStepperViewController.java
new file mode 100644
index 00000000..822cf52a
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLStepperViewController.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.uikit.UIControl;
+import org.robovm.apple.uikit.UIControlState;
+import org.robovm.apple.uikit.UIImage;
+import org.robovm.apple.uikit.UILabel;
+import org.robovm.apple.uikit.UIStepper;
+import org.robovm.apple.uikit.UITableViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLStepperViewController")
+public class AAPLStepperViewController extends UITableViewController implements UIControl.OnValueChangedListener {
+ private UIStepper defaultStepper;
+ private UIStepper tintedStepper;
+ private UIStepper customStepper;
+
+ private UILabel defaultStepperLabel;
+ private UILabel tintedStepperLabel;
+ private UILabel customStepperLabel;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureDefaultStepper();
+ configureTintedStepper();
+ configureCustomStepper();
+ }
+
+ private void configureDefaultStepper() {
+ defaultStepper.setValue(0);
+ defaultStepper.setMinimumValue(0);
+ defaultStepper.setMaximumValue(10);
+ defaultStepper.setStepValue(1);
+
+ defaultStepperLabel.setText(String.valueOf((int) defaultStepper.getValue()));
+
+ defaultStepper.addOnValueChangedListener(this);
+ }
+
+ private void configureTintedStepper() {
+ tintedStepper.setTintColor(Colors.BLUE);
+
+ tintedStepperLabel.setText(String.valueOf((int) tintedStepper.getValue()));
+
+ tintedStepper.addOnValueChangedListener(this);
+ }
+
+ private void configureCustomStepper() {
+ // Set the background image states.
+ UIImage stepperBackgroundImage = UIImage.create("stepper_and_segment_background");
+ customStepper.setBackgroundImage(stepperBackgroundImage, UIControlState.Normal);
+
+ UIImage stepperHighlightedBackgroundImage = UIImage.create("stepper_and_segment_background_highlighted");
+ customStepper.setBackgroundImage(stepperHighlightedBackgroundImage, UIControlState.Highlighted);
+
+ UIImage stepperDisabledBackgroundImage = UIImage.create("stepper_and_segment_background_disabled");
+ customStepper.setBackgroundImage(stepperDisabledBackgroundImage, UIControlState.Disabled);
+
+ // Set the image which will be painted in between the two stepper
+ // segments (depends on the states of both segments).
+ customStepper.setDividerImage(UIImage.create("stepper_and_segment_divider"), UIControlState.Normal,
+ UIControlState.Normal);
+
+ // Set the image for the + button.
+ UIImage stepperIncrementImage = UIImage.create("stepper_increment");
+ customStepper.setIncrementImage(stepperIncrementImage, UIControlState.Normal);
+
+ // Set the image for the - button.
+ UIImage stepperDecrementImage = UIImage.create("stepper_decrement");
+ customStepper.setDecrementImage(stepperDecrementImage, UIControlState.Normal);
+
+ customStepperLabel.setText(String.valueOf((int) customStepper.getValue()));
+
+ customStepper.addOnValueChangedListener(this);
+ }
+
+ @Override
+ public void onValueChanged(UIControl control) {
+ UIStepper stepper = (UIStepper) control;
+ System.out.println(String.format("A stepper changed its value: %s.", control));
+
+ // Figure out which stepper was selected and update its associated
+ // label.
+ UILabel stepperLabel = null;
+ if (defaultStepper == stepper) {
+ stepperLabel = defaultStepperLabel;
+ } else if (tintedStepper == stepper) {
+ stepperLabel = tintedStepperLabel;
+ } else if (customStepper == stepper) {
+ stepperLabel = customStepperLabel;
+ }
+
+ if (stepperLabel != null) {
+ stepperLabel.setText(String.valueOf((int) stepper.getValue()));
+ }
+ }
+
+ @IBOutlet
+ private void setDefaultStepper(UIStepper defaultStepper) {
+ this.defaultStepper = defaultStepper;
+ }
+
+ @IBOutlet
+ private void setTintedStepper(UIStepper tintedStepper) {
+ this.tintedStepper = tintedStepper;
+ }
+
+ @IBOutlet
+ private void setCustomStepper(UIStepper customStepper) {
+ this.customStepper = customStepper;
+ }
+
+ @IBOutlet
+ private void setDefaultStepperLabel(UILabel defaultStepperLabel) {
+ this.defaultStepperLabel = defaultStepperLabel;
+ }
+
+ @IBOutlet
+ private void setTintedStepperLabel(UILabel tintedStepperLabel) {
+ this.tintedStepperLabel = tintedStepperLabel;
+ }
+
+ @IBOutlet
+ private void setCustomStepperLabel(UILabel customStepperLabel) {
+ this.customStepperLabel = customStepperLabel;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLSwitchViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLSwitchViewController.java
new file mode 100644
index 00000000..af311cf5
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLSwitchViewController.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.uikit.UIControl;
+import org.robovm.apple.uikit.UISwitch;
+import org.robovm.apple.uikit.UITableViewController;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLSwitchViewController")
+public class AAPLSwitchViewController extends UITableViewController implements UIControl.OnValueChangedListener {
+ private UISwitch defaultSwitch;
+ private UISwitch tintedSwitch;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureDefaultSwitch();
+ configureTintedSwitch();
+ }
+
+ private void configureDefaultSwitch() {
+ defaultSwitch.setOn(true, true);
+ defaultSwitch.addOnValueChangedListener(this);
+ }
+
+ private void configureTintedSwitch() {
+ tintedSwitch.setTintColor(Colors.BLUE);
+ tintedSwitch.setOnTintColor(Colors.GREEN);
+ tintedSwitch.setThumbTintColor(Colors.PURPLE);
+
+ tintedSwitch.addOnValueChangedListener(this);
+ }
+
+ @Override
+ public void onValueChanged(UIControl control) {
+ System.out.println(String.format("A switch changed its value: %s.", control));
+ }
+
+ @IBOutlet
+ private void setDefaultSwitch(UISwitch defaultSwitch) {
+ this.defaultSwitch = defaultSwitch;
+ }
+
+ @IBOutlet
+ private void setTintedSwitch(UISwitch tintedSwitch) {
+ this.tintedSwitch = tintedSwitch;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLTextFieldViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLTextFieldViewController.java
new file mode 100644
index 00000000..e0169a77
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLTextFieldViewController.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.coregraphics.CGRect;
+import org.robovm.apple.foundation.NSRange;
+import org.robovm.apple.uikit.UIButton;
+import org.robovm.apple.uikit.UIButtonType;
+import org.robovm.apple.uikit.UIColor;
+import org.robovm.apple.uikit.UIControl;
+import org.robovm.apple.uikit.UIControlState;
+import org.robovm.apple.uikit.UIEdgeInsets;
+import org.robovm.apple.uikit.UIEvent;
+import org.robovm.apple.uikit.UIImage;
+import org.robovm.apple.uikit.UIKeyboardType;
+import org.robovm.apple.uikit.UIReturnKeyType;
+import org.robovm.apple.uikit.UITableViewController;
+import org.robovm.apple.uikit.UITextAutocorrectionType;
+import org.robovm.apple.uikit.UITextBorderStyle;
+import org.robovm.apple.uikit.UITextField;
+import org.robovm.apple.uikit.UITextFieldDelegate;
+import org.robovm.apple.uikit.UITextFieldViewMode;
+import org.robovm.apple.uikit.UIView;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLTextFieldViewController")
+public class AAPLTextFieldViewController extends UITableViewController implements UITextFieldDelegate {
+ private UITextField textField;
+ private UITextField tintedTextField;
+ private UITextField secureTextField;
+ private UITextField specificKeyboardTextField;
+ private UITextField customTextField;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureTextField();
+ configureTintedTextField();
+ configureSecureTextField();
+ configureSpecificKeyboardTextField();
+ configureCustomTextField();
+ }
+
+ private void configureTextField() {
+ textField.setPlaceholder("Placeholder text");
+ textField.setAutocorrectionType(UITextAutocorrectionType.Yes);
+ textField.setReturnKeyType(UIReturnKeyType.Done);
+ textField.setClearButtonMode(UITextFieldViewMode.Never);
+ }
+
+ private void configureTintedTextField() {
+ tintedTextField.setTintColor(Colors.BLUE);
+ tintedTextField.setTextColor(Colors.GREEN);
+
+ tintedTextField.setPlaceholder("Placeholder text");
+ tintedTextField.setReturnKeyType(UIReturnKeyType.Done);
+ tintedTextField.setClearButtonMode(UITextFieldViewMode.Never);
+ }
+
+ private void configureSecureTextField() {
+ secureTextField.setSecureTextEntry(true);
+
+ secureTextField.setPlaceholder("Placeholder text");
+ secureTextField.setReturnKeyType(UIReturnKeyType.Done);
+ secureTextField.setClearButtonMode(UITextFieldViewMode.Always);
+ }
+
+ /**
+ * There are many different types of keyboards that you may choose to use.
+ * This example shows how to display a keyboard to help enter email
+ * addresses.
+ */
+ private void configureSpecificKeyboardTextField() {
+ specificKeyboardTextField.setKeyboardType(UIKeyboardType.EmailAddress);
+
+ specificKeyboardTextField.setPlaceholder("Placeholder text");
+ specificKeyboardTextField.setReturnKeyType(UIReturnKeyType.Done);
+ }
+
+ private void configureCustomTextField() {
+ // Text fields with custom image backgrounds must have no border.
+ customTextField.setBorderStyle(UITextBorderStyle.None);
+
+ customTextField.setBackground(UIImage.create("text_field_background"));
+
+ // Create a purple button that, when selected, turns the custom text
+ // field's text color to purple.
+ UIImage purpleImage = UIImage.create("text_field_purple_right_view");
+ UIButton purpleImageButton = UIButton.create(UIButtonType.Custom);
+ purpleImageButton.setBounds(new CGRect(0, 0, purpleImage.getSize().getWidth(), purpleImage.getSize()
+ .getHeight()));
+ purpleImageButton.setImageEdgeInsets(new UIEdgeInsets(0, 0, 0, 5));
+ purpleImageButton.setImage(purpleImage, UIControlState.Normal);
+ purpleImageButton.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
+ @Override
+ public void onTouchUpInside(UIControl control, UIEvent event) {
+ customTextField.setTextColor(Colors.PURPLE);
+
+ System.out.println("The custom text field's purple right view button was clicked.");
+ }
+ });
+ customTextField.setRightView(purpleImageButton);
+ customTextField.setRightViewMode(UITextFieldViewMode.Always);
+
+ // Add an empty view as the left view to ensure inset between the text
+ // and the bounding rectangle.
+ UIView leftPaddingView = new UIView(new CGRect(0, 0, 10, 0));
+ leftPaddingView.setBackgroundColor(UIColor.clear());
+ customTextField.setLeftView(leftPaddingView);
+ customTextField.setLeftViewMode(UITextFieldViewMode.Always);
+
+ customTextField.setPlaceholder("Placeholder text");
+ customTextField.setAutocorrectionType(UITextAutocorrectionType.No);
+ customTextField.setReturnKeyType(UIReturnKeyType.Done);
+ }
+
+ @Override
+ public boolean shouldReturn(UITextField textField) {
+ textField.resignFirstResponder();
+ return true;
+ }
+
+ @Override
+ public boolean shouldBeginEditing(UITextField textField) {
+ return true;
+ }
+
+ @Override
+ public void didBeginEditing(UITextField textField) {}
+
+ @Override
+ public boolean shouldEndEditing(UITextField textField) {
+ return true;
+ }
+
+ @Override
+ public void didEndEditing(UITextField textField) {}
+
+ @Override
+ public boolean shouldChangeCharacters(UITextField textField, NSRange range, String string) {
+ return true;
+ }
+
+ @Override
+ public boolean shouldClear(UITextField textField) {
+ return true;
+ }
+
+ @IBOutlet
+ private void setTextField(UITextField textField) {
+ this.textField = textField;
+ }
+
+ @IBOutlet
+ private void setTintedTextField(UITextField tintedTextField) {
+ this.tintedTextField = tintedTextField;
+ }
+
+ @IBOutlet
+ private void setSecureTextField(UITextField secureTextField) {
+ this.secureTextField = secureTextField;
+ }
+
+ @IBOutlet
+ private void setSpecificKeyboardTextField(UITextField specificKeyboardTextField) {
+ this.specificKeyboardTextField = specificKeyboardTextField;
+ }
+
+ @IBOutlet
+ private void setCustomTextField(UITextField customTextField) {
+ this.customTextField = customTextField;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLTextViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLTextViewController.java
new file mode 100644
index 00000000..bf0bb1d9
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLTextViewController.java
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.coregraphics.CGRect;
+import org.robovm.apple.foundation.NSAttributedString;
+import org.robovm.apple.foundation.NSMutableAttributedString;
+import org.robovm.apple.foundation.NSNotificationCenter;
+import org.robovm.apple.foundation.NSObject;
+import org.robovm.apple.foundation.NSRange;
+import org.robovm.apple.foundation.NSString;
+import org.robovm.apple.uikit.NSAttributedStringAttribute;
+import org.robovm.apple.uikit.NSAttributedStringAttributes;
+import org.robovm.apple.uikit.NSLayoutConstraint;
+import org.robovm.apple.uikit.NSTextAttachment;
+import org.robovm.apple.uikit.NSUnderlineStyle;
+import org.robovm.apple.uikit.UIBarButtonItem;
+import org.robovm.apple.uikit.UIBarButtonSystemItem;
+import org.robovm.apple.uikit.UIColor;
+import org.robovm.apple.uikit.UIFont;
+import org.robovm.apple.uikit.UIFontDescriptor;
+import org.robovm.apple.uikit.UIFontDescriptorSymbolicTraits;
+import org.robovm.apple.uikit.UIFontTextStyle;
+import org.robovm.apple.uikit.UIImage;
+import org.robovm.apple.uikit.UIKeyboardAnimation;
+import org.robovm.apple.uikit.UITextView;
+import org.robovm.apple.uikit.UITextViewDelegateAdapter;
+import org.robovm.apple.uikit.UIView;
+import org.robovm.apple.uikit.UIViewAnimationOptions;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.apple.uikit.UIWindow;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+import org.robovm.objc.block.VoidBlock1;
+import org.robovm.samples.uicatalog.Colors;
+
+@CustomClass("AAPLTextViewController")
+public class AAPLTextViewController extends UIViewController implements UIBarButtonItem.OnClickListener {
+ private UITextView textView;
+
+ // Used to adjust the text view's height when the keyboard hides and shows.
+ private NSLayoutConstraint textViewBottomLayoutGuideConstraint;
+
+ private NSObject keyboardWillShowNotification;
+ private NSObject keyboardWillHideNotification;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureTextView();
+ }
+
+ @Override
+ public void viewWillAppear(boolean animated) {
+ super.viewWillAppear(animated);
+
+ // Listen for changes to keyboard visibility so that we can adjust the
+ // text view accordingly.
+ keyboardWillShowNotification = UIWindow.Notifications
+ .observeKeyboardWillShow(new VoidBlock1() {
+ @Override
+ public void invoke(UIKeyboardAnimation a) {
+ handleKeyboardNotification(a);
+ }
+ });
+ keyboardWillHideNotification = UIWindow.Notifications
+ .observeKeyboardWillHide(new VoidBlock1() {
+ @Override
+ public void invoke(UIKeyboardAnimation a) {
+ handleKeyboardNotification(a);
+ }
+ });
+ }
+
+ @Override
+ public void viewDidDisappear(boolean animated) {
+ super.viewDidDisappear(animated);
+
+ NSNotificationCenter.getDefaultCenter().removeObserver(keyboardWillShowNotification);
+ NSNotificationCenter.getDefaultCenter().removeObserver(keyboardWillHideNotification);
+ }
+
+ private void handleKeyboardNotification(UIKeyboardAnimation animation) {
+ double animationDuration = animation.getAnimationDuration();
+
+ // Convert the keyboard frame from screen to view coordinates.
+ CGRect keyboardScreenBeginFrame = animation.getStartFrame();
+ CGRect keyboardScreenEndFrame = animation.getEndFrame();
+
+ CGRect keyboardViewBeginFrame = getView().convertRectFromView(keyboardScreenBeginFrame, getView().getWindow());
+ CGRect keyboardViewEndFrame = getView().convertRectFromView(keyboardScreenEndFrame, getView().getWindow());
+ double originDelta = keyboardViewEndFrame.getOrigin().getY() - keyboardViewBeginFrame.getOrigin().getY();
+
+ // The text view should be adjusted, update the constant for this
+ // constraint.
+ textViewBottomLayoutGuideConstraint
+ .setConstant(textViewBottomLayoutGuideConstraint.getConstant() - originDelta);
+
+ getView().setNeedsUpdateConstraints();
+
+ UIView.animate(animationDuration, 0, UIViewAnimationOptions.BeginFromCurrentState, new Runnable() {
+ @Override
+ public void run() {
+ getView().layoutIfNeeded();
+ }
+ }, null);
+
+ // Scroll to the selected text once the keyboard frame changes.
+ NSRange selectedRange = textView.getSelectedRange();
+ textView.scrollRangeToVisible(selectedRange);
+ }
+
+ private void configureTextView() {
+ textView.setDelegate(new UITextViewDelegateAdapter() {
+ @Override
+ public void didBeginEditing(UITextView textView) {
+ // Provide a "Done" button for the user to select to signify
+ // completion with writing text in the text view.
+ UIBarButtonItem doneBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done,
+ AAPLTextViewController.this);
+
+ getNavigationItem().setRightBarButtonItem(doneBarButtonItem, true);
+ }
+ });
+
+ UIFontDescriptor bodyFontDescriptor = UIFontDescriptor.getPreferredFontDescriptor(UIFontTextStyle.Body);
+ textView.setFont(UIFont.getFont(bodyFontDescriptor, 0));
+
+ textView.setTextColor(UIColor.black());
+ textView.setBackgroundColor(UIColor.white());
+ textView.setScrollEnabled(true);
+
+ // Let's modify some of the attributes of the attributed string.
+ // You can modify these attributes yourself to get a better feel for
+ // what they do.
+ // Note that the initial text is visible in the storyboard.
+ NSMutableAttributedString attributedText = new NSMutableAttributedString(textView.getAttributedText());
+
+ String text = textView.getText();
+
+ // Find the range of each element to modify.
+ NSRange boldRange = NSString.rangeOf(text, "bold");
+ NSRange highlightedRange = NSString.rangeOf(text, "highlighted");
+ NSRange underlinedRange = NSString.rangeOf(text, "underlined");
+ NSRange tintedRange = NSString.rangeOf(text, "tinted");
+
+ // Add bold.
+ UIFontDescriptor boldFontDescriptor = textView.getFont().getFontDescriptor()
+ .newWithSymbolicTraits(UIFontDescriptorSymbolicTraits.TraitBold);
+ UIFont boldFont = UIFont.getFont(boldFontDescriptor, 0);
+ attributedText.addAttribute(NSAttributedStringAttribute.Font, boldFont, boldRange);
+
+ // Add highlight.
+ attributedText.addAttribute(NSAttributedStringAttribute.BackgroundColor, Colors.GREEN, highlightedRange);
+
+ // Add underline.
+ attributedText.addAttributes(
+ new NSAttributedStringAttributes().setUnderlineStyle(NSUnderlineStyle.StyleSingle), underlinedRange);
+
+ // Add tint.
+ attributedText.addAttribute(NSAttributedStringAttribute.ForegroundColor, Colors.BLUE, tintedRange);
+
+ // Add an image attachment.
+ NSTextAttachment textAttachment = new NSTextAttachment();
+ UIImage image = UIImage.create("text_view_attachment");
+ textAttachment.setImage(image);
+ textAttachment.setBounds(new CGRect(0, 0, image.getSize().getWidth(), image.getSize().getHeight()));
+
+ NSAttributedString textAttachmentString = NSAttributedString.create(textAttachment);
+ attributedText.append(textAttachmentString);
+
+ textView.setAttributedText(attributedText);
+ }
+
+ @Override
+ public void onClick(UIBarButtonItem barButtonItem) {
+ // Dismiss the keyboard by removing it as the first responder.
+ textView.resignFirstResponder();
+
+ getNavigationItem().setRightBarButtonItem(null, true);
+ }
+
+ @IBOutlet
+ private void setTextView(UITextView textView) {
+ this.textView = textView;
+ }
+
+ @IBOutlet
+ private void setTextViewBottomLayoutGuideConstraint(NSLayoutConstraint textViewBottomLayoutGuideConstraint) {
+ this.textViewBottomLayoutGuideConstraint = textViewBottomLayoutGuideConstraint;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLWebViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLWebViewController.java
new file mode 100644
index 00000000..8163b5d3
--- /dev/null
+++ b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AAPLWebViewController.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2013-2015 RoboVM AB
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Portions of this code is based on Apple Inc's UICatalog sample (v11.3)
+ * which is copyright (C) 2008-2015 Apple Inc.
+ */
+package org.robovm.samples.uicatalog.viewcontrollers;
+
+import org.robovm.apple.foundation.NSError;
+import org.robovm.apple.foundation.NSRange;
+import org.robovm.apple.foundation.NSURL;
+import org.robovm.apple.foundation.NSURLRequest;
+import org.robovm.apple.uikit.UIApplication;
+import org.robovm.apple.uikit.UIColor;
+import org.robovm.apple.uikit.UIDataDetectorTypes;
+import org.robovm.apple.uikit.UITextField;
+import org.robovm.apple.uikit.UITextFieldDelegate;
+import org.robovm.apple.uikit.UIViewController;
+import org.robovm.apple.uikit.UIWebView;
+import org.robovm.apple.uikit.UIWebViewDelegate;
+import org.robovm.apple.uikit.UIWebViewNavigationType;
+import org.robovm.objc.annotation.CustomClass;
+import org.robovm.objc.annotation.IBOutlet;
+
+@CustomClass("AAPLWebViewController")
+public class AAPLWebViewController extends UIViewController implements UIWebViewDelegate, UITextFieldDelegate {
+ private UIWebView webView;
+ private UITextField addressTextField;
+
+ @Override
+ public void viewDidLoad() {
+ super.viewDidLoad();
+
+ configureWebView();
+ loadAddressURL();
+ }
+
+ @Override
+ public void viewWillDisappear(boolean animated) {
+ super.viewWillDisappear(animated);
+
+ UIApplication.getSharedApplication().setNetworkActivityIndicatorVisible(false);
+ }
+
+ private void loadAddressURL() {
+ NSURL requestURL = new NSURL(addressTextField.getText());
+ NSURLRequest request = new NSURLRequest(requestURL);
+ webView.loadRequest(request);
+ }
+
+ private void configureWebView() {
+ webView.setBackgroundColor(UIColor.white());
+ webView.setScalesPageToFit(true);
+ webView.setDataDetectorTypes(UIDataDetectorTypes.All);
+ }
+
+ @Override
+ public boolean shouldStartLoad(UIWebView webView, NSURLRequest request, UIWebViewNavigationType navigationType) {
+ return true;
+ }
+
+ @Override
+ public void didStartLoad(UIWebView webView) {
+ UIApplication.getSharedApplication().setNetworkActivityIndicatorVisible(true);
+ }
+
+ @Override
+ public void didFinishLoad(UIWebView webView) {
+ UIApplication.getSharedApplication().setNetworkActivityIndicatorVisible(false);
+ }
+
+ @Override
+ public void didFailLoad(UIWebView webView, NSError error) {
+ // Report the error inside the web view.
+ String errorMessage = "An error occured:";
+ String errorFormatString = "%s%s
";
+
+ String errorHTML = String.format(errorFormatString, errorMessage, error.getLocalizedDescription());
+ webView.loadHTML(errorHTML, null);
+
+ UIApplication.getSharedApplication().setNetworkActivityIndicatorVisible(false);
+ }
+
+ // This helps dismiss the keyboard when the "Done" button is clicked.
+ @Override
+ public boolean shouldReturn(UITextField textField) {
+ textField.resignFirstResponder();
+
+ loadAddressURL();
+
+ return true;
+ }
+
+ @Override
+ public boolean shouldBeginEditing(UITextField textField) {
+ return true;
+ }
+
+ @Override
+ public void didBeginEditing(UITextField textField) {}
+
+ @Override
+ public boolean shouldEndEditing(UITextField textField) {
+ return true;
+ }
+
+ @Override
+ public void didEndEditing(UITextField textField) {}
+
+ @Override
+ public boolean shouldChangeCharacters(UITextField textField, NSRange range, String string) {
+ return true;
+ }
+
+ @Override
+ public boolean shouldClear(UITextField textField) {
+ return true;
+ }
+
+ @IBOutlet
+ private void setWebView(UIWebView webView) {
+ this.webView = webView;
+ }
+
+ @IBOutlet
+ private void setAddressTextField(UITextField addressTextField) {
+ this.addressTextField = addressTextField;
+ }
+}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AlertsViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AlertsViewController.java
deleted file mode 100644
index aeb57cd9..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/AlertsViewController.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import java.util.LinkedList;
-
-import org.robovm.apple.foundation.NSIndexPath;
-import org.robovm.apple.uikit.NSTextAlignment;
-import org.robovm.apple.uikit.UIActionSheet;
-import org.robovm.apple.uikit.UIActionSheetDelegateAdapter;
-import org.robovm.apple.uikit.UIActionSheetStyle;
-import org.robovm.apple.uikit.UIAlertView;
-import org.robovm.apple.uikit.UIAlertViewDelegateAdapter;
-import org.robovm.apple.uikit.UIAlertViewStyle;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIFont;
-import org.robovm.apple.uikit.UITableView;
-import org.robovm.apple.uikit.UITableViewCell;
-import org.robovm.apple.uikit.UITableViewCellSelectionStyle;
-import org.robovm.apple.uikit.UITableViewController;
-import org.robovm.rt.bro.annotation.MachineSizedFloat;
-import org.robovm.rt.bro.annotation.MachineSizedSInt;
-
-/** The view controller for hosting various kinds of alerts and action sheets */
-public class AlertsViewController extends UITableViewController {
-
- private static String ALERT_CELL_ID = "AlertCellID";
- private static String SOURCE_CELL_ID = "SourceCellID";
-
- private final LinkedList dataSourceArray = new LinkedList();
-
- private class ListItem {
- private final String sectionTitle;
- private final String label;
- private final String source;
-
- public ListItem (String sectionTitle, String label, String source) {
- super();
- this.sectionTitle = sectionTitle;
- this.label = label;
- this.source = source;
- }
-
- public String getSectionTitle () {
- return sectionTitle;
- }
-
- public String getLabel () {
- return label;
- }
-
- public String getSource () {
- return source;
- }
- }
-
- enum AlertTableSections {
- UIAction_Simple_Section, UIAction_OKCancel_Section, UIAction_Custom_Section, UIAlert_Simple_Section, UIAlert_OKCancel_Section, UIAlert_Custom_Section, UIAlert_SecureText_Section
- };
-
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
-
- setTitle("");
-
- dataSourceArray.add(new ListItem("UIActionSheet", "Show Simple", "dialogSimpleAction"));
- dataSourceArray.add(new ListItem("UIActionSheet", "Show OK-Cancel", "dialogOKCancelAction"));
- dataSourceArray.add(new ListItem("UIActionSheet", "Show Customized", "dialogOtherAction"));
- dataSourceArray.add(new ListItem("UIAlertView", "Show Simple", "alertSimpleAction"));
- dataSourceArray.add(new ListItem("UIAlertView", "Show OK-Cancel", "alertOKCancelAction"));
- dataSourceArray.add(new ListItem("UIAlertView", "Show Custom", "alertOtherAction"));
- dataSourceArray.add(new ListItem("UIAlertView", "Secure Text Input", "alertSecureTextAction"));
-
- // register our cell IDs for later when we are asked for
- // UITableViewCells
- getTableView().registerReusableCellClass(UITableViewCell.class, ALERT_CELL_ID);
- getTableView().registerReusableCellClass(UITableViewCell.class, SOURCE_CELL_ID);
-
- }
-
- // private void alertView(UIAlertView actionSheet, int buttonIndex) {
- // // use "buttonIndex" to decide your action
- // //
- //
- // }
-
- /** open a dialog with just an OK button */
- void dialogSimpleAction () {
-
- UIActionSheet actionSheet = new UIActionSheet("UIActionSheetTitle", new UIActionSheetDelegateAdapter() {
-
- @Override
- public void clicked (UIActionSheet actionSheet, long buttonIndex) {
- System.err.println("ButtonIndex: " + buttonIndex);
- }
-
- }, "Ok", null, new String[0]);
-
- actionSheet.setActionSheetStyle(UIActionSheetStyle.Default);
- actionSheet.showIn(getView()); // show from our table view (pops up
- // in the middle of the table)
- }
-
- /** open a dialog with an OK and cancel button */
- private void dialogOKCancelAction () {
- UIActionSheet actionSheet = new UIActionSheet("UIActionSheetTitle", new UIActionSheetDelegateAdapter() {
-
- @Override
- public void clicked (UIActionSheet actionSheet, long buttonIndex) {
- System.err.println("ButtonIndex: " + buttonIndex);
- }
-
- }, "Cancel", "Ok", new String[0]);
-
- actionSheet.setActionSheetStyle(UIActionSheetStyle.Default);
- actionSheet.showIn(getView()); // show from our table view (pops up
- // in the middle of the table)
- }
-
- /** open a dialog with two custom buttons */
- private void dialogOtherAction () {
- // open a dialog with two custom buttons
- UIActionSheet actionSheet = new UIActionSheet("UIActionSheetTitle", new UIActionSheetDelegateAdapter() {
-
- @Override
- public void clicked (UIActionSheet actionSheet, long buttonIndex) {
- System.err.println("ButtonIndex: " + buttonIndex);
- }
-
- }, null, null, new String[] {"ButtonTitle1", "ButtonTitle2"});
-
- actionSheet.setActionSheetStyle(UIActionSheetStyle.Default);
- actionSheet.setDestructiveButtonIndex(1); // make the second button red
- // (destructive)
- actionSheet.showIn(getView()); // show from our table view (pops up
- // in the middle of the table)
- }
-
- /** open an alert with just an OK button */
- private void alertSimpleAction () {
- // open an alert with just an OK button
-
- UIAlertView alert = new UIAlertView("UIAlertViewTitle", "AlertViewMessageGeneric", new UIAlertViewDelegateAdapter() {
-
- @Override
- public void clicked (UIAlertView actionSheet, long buttonIndex) {
- System.err.println("ButtonIndex: " + buttonIndex);
- }
-
- }, "Ok", new String[0]);
- alert.show();
- }
-
- /** open a alert with an OK and cancel button */
- private void alertOKCancelAction () {
- UIAlertView alert = new UIAlertView("UIAlertViewTitle", "AlertViewMessageGeneric", new UIAlertViewDelegateAdapter() {
-
- @Override
- public void clicked (UIAlertView actionSheet, long buttonIndex) {
- System.err.println("ButtonIndex: " + buttonIndex);
- }
-
- }, "Cancel", "Ok");
- alert.show();
- }
-
- /** open an alert with two custom buttons */
- private void alertOtherAction () {
- // open an alert with two custom buttons
-
- UIAlertView alert = new UIAlertView("UIAlertViewTitle", "AlertViewMessageGeneric", new UIAlertViewDelegateAdapter() {
-
- @Override
- public void clicked (UIAlertView actionSheet, long buttonIndex) {
- System.err.println("ButtonIndex: " + buttonIndex);
- }
-
- }, "Cancel", new String[] {"ButtonTitle1", "ButtonTitle2"});
- alert.show();
- }
-
- /** open an alert with two custom buttons */
- private void alertSecureTextAction () {
- // open an alert with two custom buttons
- UIAlertView alert = new UIAlertView("UIAlertViewTitle", "AlertViewMessageGeneric", new UIAlertViewDelegateAdapter() {
-
- @Override
- public void clicked (UIAlertView actionSheet, long buttonIndex) {
- System.err.println("ButtonIndex: " + buttonIndex);
- }
-
- }, "Cancel", "Ok");
- alert.setAlertViewStyle(UIAlertViewStyle.SecureTextInput);
- alert.show();
- }
-
- @Override
- public @MachineSizedSInt long getNumberOfSections (UITableView tableView) {
- return dataSourceArray.size();
- }
-
- @Override
- public String getTitleForHeader (UITableView tableView, @MachineSizedSInt long section) {
- return dataSourceArray.get((int)section).getSectionTitle();
- }
-
- @Override
- public @MachineSizedSInt long getNumberOfRowsInSection (UITableView tableView, @MachineSizedSInt long section) {
- return 2;
- }
-
- @Override
- public @MachineSizedFloat double getHeightForRow (UITableView tableView, NSIndexPath indexPath) {
- return (indexPath.getRow() == 0) ? 50.0 : 22.0;
- }
-
- /** the table's selection has changed, show the alert or action sheet */
- @Override
- public void didSelectRow (UITableView tableView, NSIndexPath indexPath) {
-
- NSIndexPath tableSelection = getTableView().getIndexPathForSelectedRow();
- getTableView().deselectRow(tableSelection, false);
-
- if (indexPath.getRow() == 0) {
- switch ((int)indexPath.getSection()) {
- case 0:
- dialogSimpleAction();
- break;
- case 1:
- dialogOKCancelAction();
- break;
- case 2:
- dialogOtherAction();
- break;
- case 3:
- alertSimpleAction();
- break;
- case 4:
- alertOKCancelAction();
- break;
- case 5:
- alertOtherAction();
- break;
- case 6:
- alertSecureTextAction();
- break;
- }
- }
- }
-
- @Override
- public UITableViewCell getCellForRow (UITableView tableView, NSIndexPath indexPath) {
- UITableViewCell cell = null;
- if (indexPath.getRow() == 0) {
- cell = getTableView().dequeueReusableCell(ALERT_CELL_ID, indexPath);
- cell.getTextLabel().setText(dataSourceArray.get((int)indexPath.getSection()).getLabel());
- } else {
- cell = getTableView().dequeueReusableCell(SOURCE_CELL_ID, indexPath);
- cell.setSelectionStyle(UITableViewCellSelectionStyle.None);
- cell.getTextLabel().setOpaque(false);
- cell.getTextLabel().setTextAlignment(NSTextAlignment.Center);
- cell.getTextLabel().setTextColor(UIColor.gray());
- cell.getTextLabel().setNumberOfLines(2);
- cell.getTextLabel().setHighlightedTextColor(UIColor.black());
- cell.getTextLabel().setFont(UIFont.getSystemFont(12.0));
- cell.getTextLabel().setText(dataSourceArray.get((int)indexPath.getSection()).getSource());
- }
-
- return cell;
- }
-
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ButtonsViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ButtonsViewController.java
deleted file mode 100644
index 30a2537d..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ButtonsViewController.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import java.util.LinkedList;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.foundation.NSIndexPath;
-import org.robovm.apple.foundation.NSMutableAttributedString;
-import org.robovm.apple.foundation.NSRange;
-import org.robovm.apple.uikit.NSAttributedStringAttributes;
-import org.robovm.apple.uikit.NSTextAlignment;
-import org.robovm.apple.uikit.UIButton;
-import org.robovm.apple.uikit.UIButtonType;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIControl;
-import org.robovm.apple.uikit.UIControlContentHorizontalAlignment;
-import org.robovm.apple.uikit.UIControlContentVerticalAlignment;
-import org.robovm.apple.uikit.UIControlState;
-import org.robovm.apple.uikit.UIEvent;
-import org.robovm.apple.uikit.UIFont;
-import org.robovm.apple.uikit.UIImage;
-import org.robovm.apple.uikit.UITableView;
-import org.robovm.apple.uikit.UITableViewCell;
-import org.robovm.apple.uikit.UITableViewCellSelectionStyle;
-import org.robovm.apple.uikit.UITableViewController;
-import org.robovm.apple.uikit.UIView;
-import org.robovm.apple.uikit.UIViewAutoresizing;
-import org.robovm.rt.bro.annotation.MachineSizedFloat;
-import org.robovm.rt.bro.annotation.MachineSizedSInt;
-
-/** The table view controller for hosting the UIButton features of this sample. */
-public class ButtonsViewController extends UITableViewController {
-
- private static final String DISPLAY_CELL_ID = "DisplayCellID";
- private static final String SOURCE_CELL_ID = "SourceCellID";
-
- private final int viewTag = 1;
-
- private final float stdButtonWidth = 106.0f;
- private final float stdButtonHeight = 40.0f;
-
- private UIButton grayButton;
- private UIButton imageButton;
- private UIButton attrTextButton;
- private UIButton roundedButtonType;
- private UIButton detailDisclosureButtonType;
- private UIButton infoLightButtonType;
- private UIButton infoDarkButtonType;
- private UIButton contactAddButtonType;
-
- private final LinkedList dataSourceArray = new LinkedList();
-
- /** List item which stores button meta data */
- private class ListItem {
- private final String sectionTitle;
- private final String label;
- private final String source;
- private final UIView view;
-
- public ListItem (String sectionTitle, String label, String source, UIView view) {
- super();
- this.sectionTitle = sectionTitle;
- this.label = label;
- this.source = source;
- this.view = view;
- }
-
- public String getSectionTitle () {
- return sectionTitle;
- }
-
- public String getLabel () {
- return label;
- }
-
- public String getSource () {
- return source;
- }
-
- public UIView getView () {
- return view;
- }
- }
-
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
-
- CGRect tableViewBounds = new CGRect(0.0, 64.0, 320, 247);
- setTableView(new UITableView(tableViewBounds));
-
- dataSourceArray.add(new ListItem("UIButton", "Background Image", "grayButton", getGrayButton()));
- dataSourceArray.add(new ListItem("UIButton", "Button with Image", "imageButton", getImageButton()));
- dataSourceArray
- .add(new ListItem("UIButtonTypeRoundedRect", "Rounded Button", "roundedButtonType", getRoundedButtonType()));
- dataSourceArray.add(new ListItem("UIButtonTypeRoundedRect", "Attributet Text", "attrTextButton", getAttrTextButton()));
- dataSourceArray.add(new ListItem("UIButtonTypeDetailDisclosure", "Detail Disclosure", "detailDisclosureButton",
- getDetailDisclosureButtonType()));
- dataSourceArray.add(new ListItem("UIButtonTypeInfoLight", "Info Light", "attrTextButton", getInfoLightButtonType()));
- dataSourceArray.add(new ListItem("UIButtonTypeRoundDark", "Info Dark", "attrTextButton", getInfoDarkButtonType()));
- dataSourceArray.add(new ListItem("UIButtonTypeContactAdd", "Add Contact", "contactAddButton", getContactAddButtonType()));
-
- // register our cell IDs for later when we are asked for UITableViewCells
- getTableView().registerReusableCellClass(UITableViewCell.class, DISPLAY_CELL_ID);
- getTableView().registerReusableCellClass(UITableViewCell.class, SOURCE_CELL_ID);
-
- }
-
- @Override
- public @MachineSizedSInt long getNumberOfSections (UITableView tableView) {
- return dataSourceArray.size();
- }
-
- @Override
- public String getTitleForHeader (UITableView tableView, @MachineSizedSInt long section) {
- return dataSourceArray.get((int)section).getSectionTitle();
- }
-
- @Override
- public @MachineSizedSInt long getNumberOfRowsInSection (UITableView tableView, @MachineSizedSInt long section) {
- return 2;
- }
-
- @Override
- public @MachineSizedFloat double getHeightForRow (UITableView tableView, NSIndexPath indexPath) {
- return (indexPath.getRow() == 0) ? 50.0 : 38.0;
- }
-
- @Override
- public UITableViewCell getCellForRow (UITableView tableView, NSIndexPath indexPath) {
- UITableViewCell cell = null;
- if (indexPath.getRow() == 0) {
- cell = getTableView().dequeueReusableCell(DISPLAY_CELL_ID, indexPath);
- cell.setSelectionStyle(UITableViewCellSelectionStyle.None);
- UIView viewToRemove = null;
- viewToRemove = cell.getContentView().getViewWithTag(viewTag);
- if (viewToRemove != null) {
- viewToRemove.removeFromSuperview();
- }
-
- cell.getTextLabel().setText(dataSourceArray.get((int)indexPath.getSection()).getLabel());
- UIButton button = (UIButton)dataSourceArray.get((int)indexPath.getSection()).getView();
- if (button == null) {
- System.err.println(dataSourceArray.get((int)indexPath.getSection()).getLabel());
- }
-
- CGRect newFrame = button.getFrame();
- newFrame.getOrigin().setX(cell.getContentView().getFrame().getWidth() - newFrame.getWidth() - 10.0);
- button.setFrame(newFrame);
-
- // if the cell is ever resized, keep the button over to the right
- button.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin);
- cell.getContentView().addSubview(button);
- } else {
- cell = getTableView().dequeueReusableCell(SOURCE_CELL_ID, indexPath);
- cell.setSelectionStyle(UITableViewCellSelectionStyle.None);
- cell.getTextLabel().setOpaque(false);
- cell.getTextLabel().setTextAlignment(NSTextAlignment.Center);
- cell.getTextLabel().setTextColor(UIColor.gray());
- cell.getTextLabel().setNumberOfLines(2);
- cell.getTextLabel().setHighlightedTextColor(UIColor.black());
- cell.getTextLabel().setFont(UIFont.getSystemFont(12.0));
- cell.getTextLabel().setText(dataSourceArray.get((int)indexPath.getSection()).getSource());
- }
-
- return cell;
- }
-
- /** Create button with provided parameters
- *
- * @param title title of button
- * @param frame frame of button
- * @param image image in button
- * @param imagePressed state to show when image is pressed
- * @param darkTextColor should text of dark color be displayed
- * @return a new UIButton */
- private static UIButton newButton (String title, CGRect frame, UIImage image, UIImage imagePressed, boolean darkTextColor) {
- UIButton button = new UIButton(frame);
- button.setContentVerticalAlignment(UIControlContentVerticalAlignment.Center);
- button.setContentHorizontalAlignment(UIControlContentHorizontalAlignment.Center);
-
- button.setTitle(title, UIControlState.Normal);
- if (darkTextColor) {
- button.setTitleColor(UIColor.black(), UIControlState.Normal);
- } else {
- button.setTitleColor(UIColor.white(), UIControlState.Normal);
- }
-
- UIImage newImage = image.createStretchable(12, 0);
- button.setBackgroundImage(newImage, UIControlState.Normal);
-
- UIImage newPressedImage = imagePressed.createStretchable(12, 0);
- button.setBackgroundImage(newPressedImage, UIControlState.Highlighted);
-
- // button.addTarget:target action:selector
- // forControlEvents:UIControlEventTouchUpInside];
-
- // in case the parent view draws with a custom color or gradient, use a
- // transparent color
- button.setBackgroundColor(UIColor.clear());
-
- return button;
- }
-
- /** create the UIButtons with various background images
- *
- * @return gray button */
- public UIButton getGrayButton () {
- if (grayButton == null) {
- UIImage buttonBackground = UIImage.create("whiteButton.png");
- UIImage buttonBackgroundPressed = UIImage.create("blueButton.png");
-
- CGRect frame = new CGRect(0.0, 5.0, stdButtonWidth, stdButtonHeight);
- grayButton = newButton("Gray", frame, buttonBackground, buttonBackgroundPressed, true);
- grayButton.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
- @Override
- public void onTouchUpInside (UIControl control, UIEvent event) {
- System.out.println("Gray button pressed!");
- }
-
- });
-
- grayButton.setTag(viewTag);
- }
-
- return grayButton;
- }
-
- /** create a UIButton with just an image instead of a title
- *
- * @return image button */
- public UIButton getImageButton () {
- if (imageButton == null) {
- UIImage buttonBackground = UIImage.create("whiteButton.png");
- UIImage buttonBackgroundPressed = UIImage.create("blueButton.png");
-
- CGRect frame = new CGRect(0.0, 5.0, stdButtonWidth, stdButtonHeight);
- imageButton = newButton("", frame, buttonBackground, buttonBackgroundPressed, true);
- imageButton.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
- @Override
- public void onTouchUpInside (UIControl control, UIEvent event) {
- System.out.println("Image button pressed");
- }
- });
-
- imageButton.setImage(UIImage.create("UIButton_custom.png"), UIControlState.Normal);
- imageButton.setAccessibilityIdentifier("ArrowButton");
- imageButton.setTag(viewTag);
- }
-
- return imageButton;
- }
-
- /** create a UIButton with just an image instead of a title
- *
- * @return attributed text button */
- public UIButton getAttrTextButton () {
- if (attrTextButton == null) {
- // create a UIButton with attributed text for its title
- attrTextButton = UIButton.create(UIButtonType.RoundedRect);
-
- attrTextButton.setFrame(new CGRect(0.0, 5.0, stdButtonWidth, stdButtonHeight));
- attrTextButton.setTitle("Rounded", UIControlState.Normal);
- attrTextButton.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
-
- @Override
- public void onTouchUpInside (UIControl control, UIEvent event) {
- System.out.println("AttrButton pressed!");
- }
- });
-
- // apply red text for normal state
- NSMutableAttributedString normalAttrString = new NSMutableAttributedString("Rounded");
- normalAttrString.addAttributes(new NSAttributedStringAttributes().setForegroundColor(UIColor.red()), new NSRange(0,
- normalAttrString.length()));
- attrTextButton.setAttributedTitle(normalAttrString, UIControlState.Normal);
-
- // apply green text for pressed state
- NSMutableAttributedString highlightedAttrString = new NSMutableAttributedString("Rounded");
- normalAttrString.addAttribute("Green", UIColor.green(), new NSRange(0, normalAttrString.length()));
-
- attrTextButton.setAttributedTitle(highlightedAttrString, UIControlState.Highlighted);
- attrTextButton.setTag(viewTag); // tag this view for later so we can
- // remove it from recycled table
- // cells
- }
- return attrTextButton;
- }
-
- /** create a UIButton (UIButtonTypeRoundedRect)
- *
- * @return Rounded UIButton */
- public UIButton getRoundedButtonType () {
- if (roundedButtonType == null) {
- roundedButtonType = UIButton.create(UIButtonType.RoundedRect);
- roundedButtonType.setFrame(new CGRect(0.0, 5.0, stdButtonWidth, stdButtonHeight));
- roundedButtonType.setTitle("Rounded", UIControlState.Normal);
- roundedButtonType.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
- @Override
- public void onTouchUpInside (UIControl control, UIEvent event) {
- System.out.println("Rounded pressed!");
- }
- });
- roundedButtonType.setTag(viewTag);
- }
- return roundedButtonType;
- }
-
- /** create a UIButton (UIButtonTypeDetailDisclosure)
- *
- * @return Detail button */
- public UIButton getDetailDisclosureButtonType () {
- if (detailDisclosureButtonType == null) {
- detailDisclosureButtonType = UIButton.create(UIButtonType.DetailDisclosure);
- detailDisclosureButtonType.setFrame(new CGRect(0.0, 8.0, 25.0, 25.0));
- detailDisclosureButtonType.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
- @Override
- public void onTouchUpInside (UIControl control, UIEvent event) {
- System.out.println("Detailed description pressed!");
- }
- });
- detailDisclosureButtonType.setTitle("Detail Disclosure", UIControlState.Normal);
- detailDisclosureButtonType.setBackgroundColor(UIColor.clear());
- detailDisclosureButtonType.setTag(viewTag);
- }
-
- return detailDisclosureButtonType;
- }
-
- /** create a UIButton (UIButtonTypeInfoDark)
- *
- * @return dark info button */
- public UIButton getInfoDarkButtonType () {
- if (infoDarkButtonType == null) {
- infoDarkButtonType = UIButton.create(UIButtonType.InfoDark);
- infoDarkButtonType.setFrame(new CGRect(0.0, 8.0, 25.0, 25.0));
- infoDarkButtonType.setTitle("Info Dark", UIControlState.Normal);
- infoDarkButtonType.setBackgroundColor(UIColor.clear());
- infoDarkButtonType.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
- @Override
- public void onTouchUpInside (UIControl control, UIEvent event) {
- System.out.println("Click dark info Button!");
- }
- });
- infoDarkButtonType.setTag(viewTag);
- }
- return infoDarkButtonType;
- }
-
- /** create a UIButton (UIButtonTypeInfoLight)
- *
- * @return light info button */
- public UIButton getInfoLightButtonType () {
- if (infoLightButtonType == null) {
- infoLightButtonType = UIButton.create(UIButtonType.InfoLight);
- infoLightButtonType.setFrame(new CGRect(0.0, 8.0, 25.0, 25.0));
- infoLightButtonType.setTitle("Info Light", UIControlState.Normal);
- infoLightButtonType.setBackgroundColor(UIColor.clear());
- infoLightButtonType.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
- @Override
- public void onTouchUpInside (UIControl control, UIEvent event) {
- System.out.println("Click light info Button!");
- }
- });
- infoLightButtonType.setBackgroundColor(UIColor.gray());
- }
- return infoLightButtonType;
- }
-
- /** create a UIButton (UIButtonTypeContactAdd)
- *
- * @return UIButton contact add */
- public UIButton getContactAddButtonType () {
- if (contactAddButtonType == null) {
- contactAddButtonType = UIButton.create(UIButtonType.ContactAdd);
- contactAddButtonType.setFrame(new CGRect(0.0, 8.0, 25.0, 25.0));
- contactAddButtonType.setTitle("Add Contact", UIControlState.Normal);
- contactAddButtonType.setBackgroundColor(UIColor.clear());
- contactAddButtonType.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
- @Override
- public void onTouchUpInside (UIControl control, UIEvent event) {
- System.out.println("Click contact add Button!");
- }
- });
-
- contactAddButtonType.setTag(viewTag);
- }
- return contactAddButtonType;
- }
-
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ControlsViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ControlsViewController.java
deleted file mode 100644
index 03bc5831..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ControlsViewController.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import java.util.LinkedList;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.foundation.NSIndexPath;
-import org.robovm.apple.uikit.NSTextAlignment;
-import org.robovm.apple.uikit.UIActivityIndicatorView;
-import org.robovm.apple.uikit.UIActivityIndicatorViewStyle;
-import org.robovm.apple.uikit.UIBarButtonItem;
-import org.robovm.apple.uikit.UIBarButtonItemStyle;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIControl;
-import org.robovm.apple.uikit.UIControlState;
-import org.robovm.apple.uikit.UIFont;
-import org.robovm.apple.uikit.UIImage;
-import org.robovm.apple.uikit.UIPageControl;
-import org.robovm.apple.uikit.UIProgressView;
-import org.robovm.apple.uikit.UIProgressViewStyle;
-import org.robovm.apple.uikit.UISlider;
-import org.robovm.apple.uikit.UIStepper;
-import org.robovm.apple.uikit.UISwitch;
-import org.robovm.apple.uikit.UITableView;
-import org.robovm.apple.uikit.UITableViewCell;
-import org.robovm.apple.uikit.UITableViewCellSelectionStyle;
-import org.robovm.apple.uikit.UITableViewController;
-import org.robovm.apple.uikit.UIView;
-import org.robovm.apple.uikit.UIViewAutoresizing;
-import org.robovm.rt.bro.annotation.MachineSizedFloat;
-import org.robovm.rt.bro.annotation.MachineSizedSInt;
-
-/** The view controller for hosting the UIControls features of this sample. */
-public class ControlsViewController extends UITableViewController {
-
- private final float SLIDER_HEIGHT = 7.0f;
- private final float PROGRESS_INDICATOR_SIZE = 40.0f;
- private final float UI_PROGRESS_BAR_WIDTH = 160.0f;
- private final float UI_PROGRESS_BAR_HEIGHT = 24.0f;
-
- final static String DISPLAY_CELL_ID = "DisplayCellID";
- final static String SOURCE_CELL_ID = "SourceCellID";
-
- private UISwitch switchCtl;
- private UISlider sliderCtl;
- private UISlider customSlider;
- private UIPageControl pageControl;
-
- private UIActivityIndicatorView progressInd;
- private UIColor progressIndSavedColor;
-
- private UIProgressView progressBar;
- private UIStepper stepper;
-
- private final int viewTag = 1;
-
- private final LinkedList dataSourceArray = new LinkedList();
-
- /** List item which stores controls meta data */
- private class ListItem {
- private final String sectionTitle;
- private final String label;
- private final String source;
- private final UIView view;
-
- public ListItem (String sectionTitle, String label, String source, UIView view) {
- super();
- this.sectionTitle = sectionTitle;
- this.label = label;
- this.source = source;
- this.view = view;
- }
-
- public String getSectionTitle () {
- return sectionTitle;
- }
-
- public String getLabel () {
- return label;
- }
-
- public String getSource () {
- return source;
- }
-
- public UIView getView () {
- return view;
- }
- }
-
- /** Setup view and load controls */
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
-
- CGRect tableViewBounds = new CGRect(0.0, 64.0, 320, 247);
- setTableView(new UITableView(tableViewBounds));
-
- UIBarButtonItem tintButton = new UIBarButtonItem();
- tintButton.setTitle("Tinted");
- tintButton.setStyle(UIBarButtonItemStyle.Done);
- tintButton.setOnClickListener(new UIBarButtonItem.OnClickListener() {
- /** Performs a tint action on applicable controls. */
- @Override
- public void onClick (UIBarButtonItem barButtonItem) {
- UIColor tintColor = (getProgressBar().getProgressTintColor() != null) ? null : UIColor.blue();
-
- getProgressBar().setProgressTintColor(tintColor);
- getProgressBar().setTrackTintColor(tintColor);
- sliderCtl.setMinimumTrackTintColor(tintColor);
- sliderCtl.setThumbTintColor(tintColor);
- switchCtl.setOnTintColor(tintColor);
- stepper.setTintColor(tintColor);
-
- UIColor thumbTintColor = (switchCtl.getThumbTintColor() != null) ? null : UIColor.red();
- switchCtl.setOnTintColor(tintColor);
- switchCtl.setThumbTintColor(thumbTintColor);
-
- UIColor progressIndColor = (getProgressInd().getColor() != progressIndSavedColor) ? progressIndSavedColor
- : UIColor.blue();
- progressInd.setColor(progressIndColor);
- }
- });
-
- getNavigationItem().setRightBarButtonItem(tintButton);
-
- dataSourceArray.add(new ListItem("UISwitch", "Standard Switch", "switchCtl", getSwitchCtl()));
-
- dataSourceArray.add(new ListItem("Standard Slider", "Standard Slider", "switchCtl", getSliderCtl()));
-
- dataSourceArray.add(new ListItem("UISlider", "Custom Slider", "sliderCtl", getCustomSlider()));
-
- dataSourceArray.add(new ListItem("UIPageControl", "Ten Pages", "pageControl", getPageControl()));
-
- dataSourceArray.add(new ListItem("UIActivityIndicatorView", "Style Gray", "progressInd", getProgressInd()));
-
- dataSourceArray.add(new ListItem("UIProgressView", "Style Default", "progressInd", getProgressBar()));
-
- dataSourceArray.add(new ListItem("UIStepper", "Stepper 1 to 10", "progressInd", getStepper()));
-
- // register our cell IDs for later when we are asked for
- // UITableViewCells
- getTableView().registerReusableCellClass(UITableViewCell.class, DISPLAY_CELL_ID);
- getTableView().registerReusableCellClass(UITableViewCell.class, SOURCE_CELL_ID);
-
- }
-
- @Override
- public @MachineSizedSInt long getNumberOfSections (UITableView tableView) {
- return dataSourceArray.size();
- }
-
- @Override
- public String getTitleForHeader (UITableView tableView, @MachineSizedSInt long section) {
- return dataSourceArray.get((int)section).getSectionTitle();
- }
-
- @Override
- public @MachineSizedSInt long getNumberOfRowsInSection (UITableView tableView, @MachineSizedSInt long section) {
- return 2;
- }
-
- @Override
- public @MachineSizedFloat double getHeightForRow (UITableView tableView, NSIndexPath indexPath) {
- return (indexPath.getRow() == 0) ? 50.0 : 38.0;
- }
-
- @Override
- public UITableViewCell getCellForRow (UITableView tableView, NSIndexPath indexPath) {
- UITableViewCell cell = null;
-
- if (indexPath.getRow() == 0) {
- cell = getTableView().dequeueReusableCell(DISPLAY_CELL_ID, indexPath);
-
- cell.setSelectionStyle(UITableViewCellSelectionStyle.None);
- UIView viewToRemove = null;
- viewToRemove = cell.getContentView().getViewWithTag(viewTag);
- if (viewToRemove != null) {
- viewToRemove.removeFromSuperview();
- }
-
- cell.getTextLabel().setText(dataSourceArray.get((int)indexPath.getSection()).getLabel());
-
- UIView control = dataSourceArray.get((int)indexPath.getSection()).getView();
-
- CGRect newFrame = control.getFrame();
- newFrame.getOrigin().setX(cell.getContentView().getFrame().getWidth() - newFrame.getWidth() - 10.0);
- control.setFrame(newFrame);
-
- // if the cell is ever resized, keep the button over to the right
- control.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin);
- cell.getContentView().addSubview(control);
- } else {
- cell = getTableView().dequeueReusableCell(SOURCE_CELL_ID, indexPath);
- cell.setSelectionStyle(UITableViewCellSelectionStyle.None);
- cell.getTextLabel().setOpaque(false);
- cell.getTextLabel().setTextAlignment(NSTextAlignment.Center);
- cell.getTextLabel().setTextColor(UIColor.gray());
- cell.getTextLabel().setNumberOfLines(2);
- cell.getTextLabel().setHighlightedTextColor(UIColor.black());
- cell.getTextLabel().setFont(UIFont.getSystemFont(12.0));
- cell.getTextLabel().setText(dataSourceArray.get((int)indexPath.getSection()).getSource());
- }
-
- return cell;
- }
-
- /** create UISwitch
- *
- * @return UISwitch */
- public UISwitch getSwitchCtl () {
- if (switchCtl == null) {
- CGRect frame = new CGRect(0.0, 12.0, 94.0, 27.0);
- switchCtl = new UISwitch(frame);
-
- switchCtl.setBackgroundColor(UIColor.clear());
- switchCtl.setTag(viewTag);
- }
- return switchCtl;
- }
-
- /** create Slider
- *
- * @return new slider */
- public UISlider getSliderCtl () {
- if (sliderCtl == null) {
- CGRect frame = new CGRect(0.0, 12.0, 120.0, SLIDER_HEIGHT);
- sliderCtl = new UISlider(frame);
- sliderCtl.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
- @Override
- public void onValueChanged (UIControl control) {
- System.err.println("Slider moved to:" + sliderCtl.getValue());
- }
- });
-
- // in case the parent view draws with a custom color or gradient,
- // use a transparent color
- sliderCtl.setBackgroundColor(UIColor.clear());
- sliderCtl.setMinimumValue(0.0f);
- sliderCtl.setMaximumValue(100.0f);
- sliderCtl.setContinuous(true);
- sliderCtl.setValue(50.0f);
- sliderCtl.setTag(viewTag); // tag this view for later so we can
- // remove it from recycled table cells
- }
- return sliderCtl;
- }
-
- /** gets custom slider
- *
- * @return slider */
- private UISlider getCustomSlider () {
- if (customSlider == null) {
- CGRect frame = new CGRect(0.0, 12.0, 130.0, SLIDER_HEIGHT);
- customSlider = new UISlider(frame);
- customSlider.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
- @Override
- public void onValueChanged (UIControl control) {
- System.err.println("custom slider moved to:" + customSlider.getValue());
- }
- });
-
- // in case the parent view draws with a custom color or gradient,
- // use a transparent color
- customSlider.setBackgroundColor(UIColor.clear());
-
- UIImage stetchLeftTrack = UIImage.create("orangeslide.png");
- stetchLeftTrack = stetchLeftTrack.createStretchable(10l, 0l);
-
- UIImage stetchRightTrack = UIImage.create("yellowslide.png");
- stetchRightTrack = stetchRightTrack.createStretchable(10l, 0l);
-
- customSlider.setThumbImage(UIImage.create("slider_ball.png"), UIControlState.Normal);
- customSlider.setMinimumTrackImage(stetchLeftTrack, UIControlState.Normal);
- customSlider.setMaximumTrackImage(stetchRightTrack, UIControlState.Normal);
- customSlider.setMinimumValue(0.0f);
- customSlider.setMaximumValue(100.0f);
- customSlider.setContinuous(true);
- customSlider.setValue(50.0f);
- }
- return customSlider;
- }
-
- /** gets a page control
- *
- * @return page control */
- private UIPageControl getPageControl () {
- if (pageControl == null) {
- CGRect frame = new CGRect(0.0, 14.0, 178.0, 20.0);
- pageControl = new UIPageControl(frame);
- pageControl.setBackgroundColor(UIColor.gray());
- pageControl.setNumberOfPages(10);
- pageControl.setTag(viewTag);
- }
- return pageControl;
- }
-
- /** gets a progress indicator
- *
- * @return progress indicator */
- private UIActivityIndicatorView getProgressInd () {
-
- if (progressInd == null) {
- CGRect frame = new CGRect(0.0, 12.0, PROGRESS_INDICATOR_SIZE, PROGRESS_INDICATOR_SIZE);
-
- progressInd = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray);
- getProgressInd().setColor(progressInd.getColor());
- progressInd.setFrame(frame);
- getProgressInd().sizeToFit();
- getProgressInd().setActivityIndicatorViewStyle(UIActivityIndicatorViewStyle.Gray);
-
- getProgressInd().setTag(viewTag); // tag this view for later so we
- // can remove it from recycled
- // table cells
- getProgressInd().startAnimating();
- }
-
- return progressInd;
- }
-
- /** Returns progress bar
- *
- * @return UIProgressView */
- private UIProgressView getProgressBar () {
- if (progressBar == null) {
- CGRect frame = new CGRect(0.0, 20.0, UI_PROGRESS_BAR_WIDTH, UI_PROGRESS_BAR_HEIGHT);
- progressBar = new UIProgressView(frame);
- progressBar.setProgressViewStyle(UIProgressViewStyle.Default);
- progressBar.setProgress(0.5f);
- progressBar.setTag(viewTag); // tag this view for later so we can
- // remove it from recycled table cells
- }
- return progressBar;
- }
-
- /** Returns stepper
- *
- * @return stepper */
- private UIStepper getStepper () {
- if (stepper == null) {
- CGRect frame = new CGRect(0.0, 10.0, 0.0, 0.0);
- stepper = new UIStepper(frame);
- stepper.sizeToFit(); // size the control to it's normal size
- stepper.setTag(viewTag); // tag this view for later so we can remove
- // it from recycled table cells
- stepper.setValue(0);
- stepper.setMinimumValue(0);
- stepper.setMaximumValue(10);
- stepper.setStepValue(1);
-
- stepper.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
- @Override
- public void onValueChanged (UIControl control) {
- System.out.println("Stepper value modified!:" + stepper.getValue());
- }
- });
- }
- return stepper;
- }
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ImageViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ImageViewController.java
deleted file mode 100644
index 43f32267..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ImageViewController.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.foundation.NSArray;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIControl;
-import org.robovm.apple.uikit.UIImage;
-import org.robovm.apple.uikit.UIImageView;
-import org.robovm.apple.uikit.UISlider;
-import org.robovm.apple.uikit.UIViewController;
-import org.robovm.objc.annotation.Method;
-
-/** The view controller for hosting the UIImageView containing multiple images. */
-public class ImageViewController extends UIViewController {
- private static final float MIN_DURATION = 0.0f;
- private static final float MAX_DURATION = 10.0f;
-
- private UIImageView imageView;
- private UISlider slider;
-
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
-
- imageView = new UIImageView(new CGRect(42, 70, 236, 174));
- slider = new UISlider(new CGRect(18, 398, 284, 23));
-
- NSArray images = new NSArray(UIImage.create("scene1.jpg"), UIImage.create("scene2.jpg"),
- UIImage.create("scene3.jpg"), UIImage.create("scene4.jpg"), UIImage.create("scene5.jpg"));
-
- imageView.setAnimationImages(images);
- UIImageView.setAnimationDurationInSeconds(5.0);
- imageView.setBackgroundColor(UIColor.black());
- imageView.setAnimationDuration(5.0f); // sync with slider below
- imageView.stopAnimating();
-
- slider.setMaximumValue(MIN_DURATION);
- slider.setMaximumValue(MAX_DURATION);
- slider.setValue(5.0f);
-
- slider.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
- @Override
- public void onValueChanged (UIControl control) {
- sliderAction();
- }
- });
-
- getView().addSubview(imageView);
- getView().addSubview(slider);
-
- }
-
- @Method
- private void sliderAction () {
- UISlider durationSlider = slider;
- imageView.setAnimationDuration(durationSlider.getValue());
- if (!imageView.isAnimating()) {
- imageView.startAnimating();
- }
- }
-
- @Override
- public void viewWillDisappear (boolean animated) {
- super.viewWillDisappear(animated);
- imageView.stopAnimating();
- }
-
- @Override
- public void viewWillAppear (boolean animated) {
- super.viewWillAppear(animated);
- imageView.startAnimating();
- getNavigationController().getNavigationBar().setTintColor(UIColor.black());
- }
-
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/MainViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/MainViewController.java
deleted file mode 100644
index cdbef24f..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/MainViewController.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import java.util.LinkedList;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.foundation.NSIndexPath;
-import org.robovm.apple.uikit.UIBarButtonItem;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UITableView;
-import org.robovm.apple.uikit.UITableViewCell;
-import org.robovm.apple.uikit.UITableViewCellAccessoryType;
-import org.robovm.apple.uikit.UITableViewCellStyle;
-import org.robovm.apple.uikit.UITableViewController;
-import org.robovm.apple.uikit.UIViewController;
-import org.robovm.rt.bro.annotation.MachineSizedSInt;
-
-/** The application's main view controller (front page) */
-public class MainViewController extends UITableViewController {
- private final static String MY_CELL_IDENTIFIER = "MyTableViewCell";
- private final LinkedList menuList = new LinkedList();
-
- private class MyTableViewCell extends UITableViewCell {
- @Override
- protected long init (UITableViewCellStyle style, String reuseIdentifier) {
- return super.init(UITableViewCellStyle.Subtitle, reuseIdentifier);
- }
- }
-
- /** Item storing meta data for menu items */
- private class MenuListItem {
- private final String title;
- private final String explanation;
- private final UIViewController viewController;
-
- public MenuListItem (String title, String explanation, UIViewController viewController) {
- super();
- this.title = title;
- this.explanation = explanation;
- this.viewController = viewController;
- }
-
- public String getTitle () {
- return title;
- }
-
- public String getExplanation () {
- return explanation;
- }
-
- public UIViewController getViewController () {
- return viewController;
- }
-
- }
-
- public MainViewController () {
- setTitle("UICatalog");
-
- CGRect tableViewBounds = new CGRect(0.0, 64.0, 320, 416);
- setTableView(new UITableView(tableViewBounds));
-
- // for showing various UIButtons:
- ButtonsViewController buttonsViewController = new ButtonsViewController();
- // for showing various UIControls:
- ControlsViewController controlsViewController = new ControlsViewController();
- // for showing various UITextFields:
- TextFieldController textfieldController = new TextFieldController();
- // for UISearchBar:
- SearchBarViewController searchBarViewController = new SearchBarViewController();
- // for showing UITextView:
- TextViewController textViewController = new TextViewController();
- // for showing various UIPickers:
- ImageViewController imageViewController = new ImageViewController();
- // for showing UIImageView:
- WebViewController webViewController = new WebViewController();
- // for showing UIWebView:
- TransitionViewController transitionController = new TransitionViewController();
- // for showing various UISegmentedControls:
- SegmentViewController segments = new SegmentViewController();
- // for showing various UIBarButtonItem items inside a UIToolbar:
- ToolbarViewController toolbarViewController = new ToolbarViewController();
- // for showing various UIActionSheets and UIAlertViews:
- AlertsViewController alertsViewController = new AlertsViewController();
- // for showing how to a use flip animation transition between two
- // UIViews:
- PickerViewController pickerViewController = new PickerViewController();
-
- // Add items to list where they will be retrieved when to display
- menuList.add(new MenuListItem("ButtonsTitle", "Various uses of UIButton", buttonsViewController));
- menuList.add(new MenuListItem("ControlsTitle", "Various uses of UIControl", controlsViewController));
- menuList.add(new MenuListItem("TextFieldTitle", "Uses of UITextField", textfieldController));
- menuList.add(new MenuListItem("SearchBar", "Use of UISearchBar", searchBarViewController));
- menuList.add(new MenuListItem("TextView", "Use of UITextField", textViewController));
- menuList.add(new MenuListItem("Pickers", "Uses of UIDatePicker, UIPickerView", pickerViewController));
- menuList.add(new MenuListItem("Images", "Use of UIWebView", imageViewController));
- menuList.add(new MenuListItem("WebView", "Various uses of UISegmentedControl", webViewController));
- menuList.add(new MenuListItem("Segments", "Various uses of UISegmentedControl", segments));
- menuList.add(new MenuListItem("Toolbars", "Uses of UIToolbar", toolbarViewController));
- menuList.add(new MenuListItem("Alerts", "Various uses of UIAlertView, UIActionSheet", alertsViewController));
- menuList.add(new MenuListItem("Transition", "Shows UIViewAnimationTransitions", transitionController));
-
- UIBarButtonItem temporaryBarButtonItem = new UIBarButtonItem();
- temporaryBarButtonItem.setTitle("Back");
- getNavigationItem().setBackBarButtonItem(temporaryBarButtonItem);
-
- getTableView().registerReusableCellClass(MyTableViewCell.class, MY_CELL_IDENTIFIER);
- }
-
- @Override
- public void viewWillAppear (boolean animated) {
- super.viewWillAppear(animated);
-
- // this UIViewController is about to re-appear, make sure we remove the
- // current selection in our table view
- NSIndexPath tableSelection = getTableView().getIndexPathForSelectedRow();
- getTableView().deselectRow(tableSelection, false);
-
- // some over view controller could have changed our nav bar tint color,
- // so reset it here
- getNavigationController().getNavigationBar().setTintColor(UIColor.darkGray());
- }
-
- /** the table's selection has changed, switch to that item's UIViewController */
- @Override
- public void didSelectRow (UITableView tableView, NSIndexPath indexPath) {
- MenuListItem item = menuList.get((int)indexPath.getRow());
-
- UIViewController targetViewController = item.getViewController();
- getNavigationController().pushViewController(targetViewController, true);
- }
-
- @Override
- public @MachineSizedSInt long getNumberOfRowsInSection (UITableView tableView, @MachineSizedSInt long section) {
- return menuList.size();
- }
-
- @Override
- public UITableViewCell getCellForRow (UITableView tableView, NSIndexPath indexPath) {
- UITableViewCell cell = getTableView().dequeueReusableCell(MY_CELL_IDENTIFIER, indexPath);
-
- cell.setAccessoryType(UITableViewCellAccessoryType.DisclosureIndicator);
- cell.getTextLabel().setText(menuList.get((int)indexPath.getRow()).getTitle());
- cell.getDetailTextLabel().setText(menuList.get((int)indexPath.getRow()).getExplanation());
- return cell;
- }
-
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/PickerViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/PickerViewController.java
deleted file mode 100644
index 3f8f02ca..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/PickerViewController.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.coregraphics.CGSize;
-import org.robovm.apple.foundation.NSArray;
-import org.robovm.apple.foundation.NSAttributedString;
-import org.robovm.apple.foundation.NSDate;
-import org.robovm.apple.foundation.NSMutableArray;
-import org.robovm.apple.foundation.NSMutableAttributedString;
-import org.robovm.apple.foundation.NSRange;
-import org.robovm.apple.foundation.NSString;
-import org.robovm.apple.uikit.NSAttributedStringAttribute;
-import org.robovm.apple.uikit.NSTextAlignment;
-import org.robovm.apple.uikit.UIBarButtonItem;
-import org.robovm.apple.uikit.UIBarButtonItemStyle;
-import org.robovm.apple.uikit.UIBarButtonSystemItem;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIControl;
-import org.robovm.apple.uikit.UIDatePicker;
-import org.robovm.apple.uikit.UIDatePickerMode;
-import org.robovm.apple.uikit.UIFont;
-import org.robovm.apple.uikit.UILabel;
-import org.robovm.apple.uikit.UIPickerView;
-import org.robovm.apple.uikit.UIPickerViewDataSourceAdapter;
-import org.robovm.apple.uikit.UIPickerViewDelegateAdapter;
-import org.robovm.apple.uikit.UIScrollView;
-import org.robovm.apple.uikit.UISegmentedControl;
-import org.robovm.apple.uikit.UIToolbar;
-import org.robovm.apple.uikit.UIView;
-import org.robovm.apple.uikit.UIViewAutoresizing;
-import org.robovm.apple.uikit.UIViewController;
-import org.robovm.samples.uicatalog.Constants;
-import org.robovm.samples.uicatalog.picker.CustomPickerDataSource;
-import org.robovm.samples.uicatalog.picker.CustomView;
-
-/** The view controller for hosting the UIPickerView of this sample. */
-public class PickerViewController extends UIViewController {
- private static final float OPTIMUM_PICKER_HEIGHT = 216;
- private static final float OPTIMUM_PICKER_WIDTH = 320;
-
- private UIScrollView scrollView;
-
- private UIPickerView myPickerView;
- private UIDatePicker datePickerView;
- private NSMutableArray pickerViewArray;
-
- private UILabel label;
-
- private UIPickerView customPickerView;
- private CustomPickerDataSource customPickerDataSource;
-
- private UIView currentPicker;
-
- private UISegmentedControl buttonBarSegmentedControl;
- private UISegmentedControl pickerStyleSegmentedControl;
- private UILabel segmentLabel;
- private UIToolbar toolbar;
-
- private final UIControl.OnValueChangedListener togglePickers = new UIControl.OnValueChangedListener() {
- /** for changing between UIPickerView, UIDatePickerView and custom picker
- *
- * @param control */
- @Override
- public void onValueChanged (UIControl control) {
- UISegmentedControl segControl = (UISegmentedControl)control;
- switch ((int)segControl.getSelectedSegment()) {
- case 0: // UIPickerView
- pickerStyleSegmentedControl.setHidden(true);
- segmentLabel.setHidden(true);
- showPicker(myPickerView);
-
- // report the selection to the UI label
- String labelStr = String.format("%s - %d", pickerViewArray.get((int)myPickerView.getSelectedRow(0)),
- myPickerView.getSelectedRow(1));
- label.setText(labelStr);
- break;
- case 1: // UIDatePicker
- pickerStyleSegmentedControl.setHidden(false);
- segmentLabel.setHidden(false);
- showPicker(datePickerView);
- togglePickerStyle.onValueChanged(pickerStyleSegmentedControl);
- break;
-
- case 2: // Custom
- pickerStyleSegmentedControl.setHidden(true);
- segmentLabel.setHidden(true);
- showPicker(customPickerView);
- break;
- }
- }
- };
- private final UIControl.OnValueChangedListener togglePickerStyle = new UIControl.OnValueChangedListener() {
- /** for changing the date picker's style
- *
- * @param control */
- @Override
- public void onValueChanged (UIControl control) {
- UISegmentedControl segControl = (UISegmentedControl)control;
-
- switch ((int)segControl.getSelectedSegment()) {
-
- case 0: // Time
- datePickerView.setDatePickerMode(UIDatePickerMode.Time);
- segmentLabel.setText("UIDatePickerModeTime");
- break;
- case 1: // Date
- datePickerView.setDatePickerMode(UIDatePickerMode.Date);
- segmentLabel.setText("UIDatePickerModeDate");
- break;
- case 2: // Date & Time
- datePickerView.setDatePickerMode(UIDatePickerMode.DateAndTime);
- segmentLabel.setText("UIDatePickerModeDateAndTime");
- break;
- case 3: // Counter
- datePickerView.setDatePickerMode(UIDatePickerMode.CountDownTimer);
- segmentLabel.setText("UIDatePickerModeCountDownTimer");
- break;
- }
-
- // in case we previously chose the Counter style picker, make sure
- // the current date is restored
- // @TODO check that current date is inited by default
- NSDate today = new NSDate();
- datePickerView.setDate(today);
- }
- };
-
- /** Sets up UI components */
- private void initUI () {
- setView(new UIView(new CGRect(0, 0, 320, 460)));
-
- scrollView = new UIScrollView(new CGRect(0, 0, 320, 416));
-
- getView().addSubview(scrollView);
- segmentLabel = new UILabel(new CGRect(20, 243, 320, 21));
- segmentLabel.setHidden(true);
-
- scrollView.addSubview(label);
-
- pickerStyleSegmentedControl = new UISegmentedControl(NSArray.fromStrings("1", "2", "3", "4"));
-
- pickerStyleSegmentedControl.setFrame(new CGRect(57, 266, 207, 30));
- pickerStyleSegmentedControl.setTintColor(UIColor.fromWhiteAlpha(0.3333333, 1.0));
- pickerStyleSegmentedControl.addOnValueChangedListener(togglePickerStyle);
- pickerStyleSegmentedControl.setHidden(true);
-
- scrollView.addSubview(pickerStyleSegmentedControl);
-
- List buttonItems = new LinkedList();
-
- buttonItems.add(new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null));
-
- buttonBarSegmentedControl = new UISegmentedControl(NSArray.fromStrings("UIPicker", "UIDatePicker", "Custom"));
- buttonBarSegmentedControl.setFrame(new CGRect(11, 7, 299, 30));
- buttonBarSegmentedControl.setAutoresizingMask(UIViewAutoresizing.FlexibleRightMargin
- .set(UIViewAutoresizing.FlexibleBottomMargin));
- buttonBarSegmentedControl.addOnValueChangedListener(togglePickers);
- buttonBarSegmentedControl.setSelectedSegment(0);
-
- UIBarButtonItem plainButton = new UIBarButtonItem("", UIBarButtonItemStyle.Plain, null);
- plainButton.setCustomView(buttonBarSegmentedControl);
-
- buttonItems.add(plainButton);
- buttonItems.add(new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null));
-
- toolbar = new UIToolbar(new CGRect(0.0, 416, 320, 44));
- toolbar.setTintColor(UIColor.fromWhiteAlpha(0.333333333333333, 1.0));
- toolbar.setItems(new NSArray(buttonItems));
-
- getView().addSubview(toolbar);
- }
-
- private CGRect pickerFrameWithSize (CGSize size) {
- CGRect resultFrame;
- double height = size.getHeight();
- double width = size.getWidth();
-
- if (size.getHeight() < OPTIMUM_PICKER_HEIGHT) {
- // if in landscape, the picker height can be sized too small, so use
- // a optimum height
- height = OPTIMUM_PICKER_HEIGHT;
- }
-
- if (size.getWidth() > OPTIMUM_PICKER_WIDTH) {
- // keep the width an optimum size as well
- width = OPTIMUM_PICKER_WIDTH;
- }
-
- resultFrame = new CGRect(0.0, -1.0, width, height);
- return resultFrame;
- }
-
- /** Creates standard picker */
- private void createPicker () {
-
- pickerViewArray = new NSMutableArray(NSArray.fromStrings("John Appleseed", "Serena Auroux", "Susan Bean",
- "Luis Becerra", "Kate Bell", "Alain Briere"));
-
- myPickerView = new UIPickerView(new CGRect(0, 0, 0, 0));
-
- myPickerView.sizeToFit();
-
- CGSize pickerSize = myPickerView.getFrame().getSize();
- myPickerView.setFrame(pickerFrameWithSize(pickerSize));
-
- myPickerView.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin.set(UIViewAutoresizing.FlexibleRightMargin));
-
- myPickerView.setShowsSelectionIndicator(true); // note this is
- // defaulted to NO
-
- // this view controller is the data source and delegate
- myPickerView.setDelegate(new UIPickerViewDel());
-
- myPickerView.setDataSource(new UIPickerViewDataSourceAdpt());
-
- // add this picker to our view controller, initially hidden
- myPickerView.setHidden(true);
- scrollView.addSubview(myPickerView);
- }
-
- /** Creates date picker */
- private void createDatePicker () {
- datePickerView = new UIDatePicker(new CGRect(0, 0, 0, 0));
- datePickerView.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin.set(UIViewAutoresizing.FlexibleRightMargin));
- datePickerView.setDatePickerMode(UIDatePickerMode.Date);
-
- datePickerView.sizeToFit();
- CGSize pickerSize = datePickerView.getFrame().getSize();
- datePickerView.setFrame(pickerFrameWithSize(pickerSize));
-
- // add this picker to our view controller, initially hidden
- datePickerView.setHidden(true);
- scrollView.addSubview(datePickerView);
- }
-
- /** Creates a custom picker with images using custom constructs
- *
- * @see CustomPickerDataSource
- * @see CustomView */
- private void createCustomPicker () {
- customPickerView = new UIPickerView(new CGRect(0, 0, 0, 0));
- customPickerView.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin.set(UIViewAutoresizing.FlexibleRightMargin));
-
- // setup the data source and delegate for this picker
- customPickerDataSource = new CustomPickerDataSource();
- customPickerView.setDataSource(customPickerDataSource);
- customPickerView.setDelegate(customPickerDataSource);
-
- // note we are using CGRectZero for the dimensions of our picker view,
- // this is because picker views have a built in optimum size,
- // you just need to set the correct origin in your view.
- customPickerView.sizeToFit();
- CGSize pickerSize = customPickerView.getFrame().getSize();
- customPickerView.setFrame(pickerFrameWithSize(pickerSize));
- customPickerView.setShowsSelectionIndicator(true);
-
- // add this picker to our view controller, initially hidden
- customPickerView.setHidden(true);
- scrollView.addSubview(customPickerView);
- }
-
- /** load controls once view has been shown */
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
-
- initUI();
-
- setTitle("PickerTitle");
-
- // set the content size of our scroll view to match the entire screen,
- // this will allow the content to scroll in landscape
- //
- scrollView.setContentSize(new CGSize(scrollView.getFrame().getWidth(), (scrollView.getBounds().getHeight())
- - getNavigationController().getNavigationBar().getFrame().getHeight()));
-
- // Create pickers
- createPicker();
- createDatePicker();
- createCustomPicker();
-
- showPicker(myPickerView);
-
- // label for picker selection output
- CGRect labelFrame = new CGRect(Constants.LEFT_MARGIN, myPickerView.getFrame().getMaxY() + 10.0, getView().getBounds()
- .getWidth() - (Constants.RIGHT_MARGIN * 2.0), 14.0);
-
- label = new UILabel(labelFrame);
- label.setFont(UIFont.getSystemFont(12.0));
- label.setTextAlignment(NSTextAlignment.Center);
- label.setTextColor(UIColor.black());
- label.setBackgroundColor(UIColor.clear());
- label.setAutoresizingMask(UIViewAutoresizing.FlexibleWidth);
- scrollView.addSubview(label);
-
- // start by showing the normal picker in date mode
- buttonBarSegmentedControl = new UISegmentedControl(new CGRect(11, 8, 299, 30));
- buttonBarSegmentedControl.setSelectedSegment(0);
-
- datePickerView.setDatePickerMode(UIDatePickerMode.Date);
-
- pickerStyleSegmentedControl.setSelectedSegment(1);
- }
-
- private void showPicker (UIView picker) {
- // hide the current picker and show the new one
- if (currentPicker != null) {
- currentPicker.setHidden(true);
- label.setText("");
- }
- picker.setHidden(false);
- currentPicker = picker; // remember the current picker so we can remove
- // it later when another one is chosen
- }
-
- public void pickerView (UIPickerView pickerView, long row, long component) {
- if (pickerView == myPickerView) { // don't show selection for the
- // custom picker
- // report the selection to the UI label
- String labelStr = String.format("%@ - %d", pickerViewArray.get((int)myPickerView.getSelectedRow(0)),
- myPickerView.getSelectedRow(1));
- label.setText(labelStr);
- }
- }
-
- @Override
- public void viewWillAppear (boolean animated) {
- super.viewWillAppear(animated);
- togglePickers.onValueChanged(buttonBarSegmentedControl); // make sure the last picker
- // is still showing
-
- // for aesthetic reasons (the background is black), make the nav bar
- // black for this particular page
- getNavigationController().getNavigationBar().setTintColor(UIColor.black());
- }
-
- @Override
- public void viewWillDisappear (boolean animated) {
- super.viewWillDisappear(animated);
- currentPicker.setHidden(true);
- }
-
- public class UIPickerViewDataSourceAdpt extends UIPickerViewDataSourceAdapter {
-
- @Override
- public long getNumberOfComponents (UIPickerView pickerView) {
- return 2;
- }
-
- @Override
- public long getNumberOfRows (UIPickerView pickerView, long component) {
- return pickerViewArray.size();
- }
- }
-
- public class UIPickerViewDel extends UIPickerViewDelegateAdapter {
-
- @Override
- public void didSelectRow (UIPickerView pickerView, long row, long component) {
- if (pickerView == myPickerView) { // don't
- // show
- // selection
- // for
- // the
- // custom
- // picker
- // report the selection to the UI label
- String labelStr = String.format("%s - %d", pickerViewArray.get((int)myPickerView.getSelectedRow(0)),
- myPickerView.getSelectedRow(1));
- label.setText(labelStr);
- }
- }
-
- @Override
- public double getComponentWidth (UIPickerView pickerView, long component) {
- double componentWidth = 0.0;
-
- if (component == 0) {
- componentWidth = 240.0; // first column size is wider to hold
- // names
- } else {
- componentWidth = 40.0; // second column is narrower to show
- // numbers
- }
- return componentWidth;
- }
-
- @Override
- public double getRowHeight (UIPickerView pickerView, long component) {
- return 40.0;
- }
-
- @Override
- public String getRowTitle (UIPickerView pickerView, long row, long component) {
- String returnStr = "";
-
- // note: for the custom picker we use custom views instead of titles
- if (pickerView == myPickerView) {
- if (component == 0) {
- returnStr = pickerViewArray.get((int)row).toString();
- } else {
- returnStr = String.valueOf(row);
- }
- }
- return returnStr;
- }
-
- @Override
- public NSAttributedString getAttributedRowTitle (UIPickerView pickerView, long row, long component) {
- NSMutableAttributedString attrTitle = null;
-
- // note: for the custom picker we use custom views instead of titles
- if (pickerView == myPickerView) {
- if (row == 0) {
- String title;
- if (component == 0) {
- title = pickerViewArray.get((int)row).toString();
- } else {
- title = String.valueOf(row);
- }
-
- // apply red text for normal state
- attrTitle = new NSMutableAttributedString(title);
- attrTitle.addAttribute(NSAttributedStringAttribute.ForegroundColor, UIColor.red(),
- new NSRange(0, attrTitle.length()));
- }
- }
-
- return attrTitle;
- }
- };
-
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/SearchBarViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/SearchBarViewController.java
deleted file mode 100644
index 1af165b9..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/SearchBarViewController.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.foundation.NSArray;
-import org.robovm.apple.foundation.NSMutableArray;
-import org.robovm.apple.foundation.NSString;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIControl;
-import org.robovm.apple.uikit.UIControlState;
-import org.robovm.apple.uikit.UIImage;
-import org.robovm.apple.uikit.UISearchBar;
-import org.robovm.apple.uikit.UISearchBarDelegateAdapter;
-import org.robovm.apple.uikit.UISearchBarIcon;
-import org.robovm.apple.uikit.UISegmentedControl;
-import org.robovm.apple.uikit.UIView;
-import org.robovm.apple.uikit.UIViewAutoresizing;
-import org.robovm.apple.uikit.UIViewController;
-
-/** The view controller for hosting the UIPickerView of this sample. */
-public class SearchBarViewController extends UIViewController {
-
- private UISearchBar mySearchBar;
- private UISegmentedControl contentOptions;
-
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
-
- setView(new UIView(new CGRect(0, 20, 320, 460)));
- setTitle("SearchBarTitle");
-
- mySearchBar = new UISearchBar(new CGRect(0.0f, 65.0f, getView().getBounds().getWidth(), 44.0f));
- mySearchBar.setDelegate(new UISearchBarDelegateAdapter() {
- @Override
- public void searchButtonClicked (UISearchBar searchBar) {
- mySearchBar.resignFirstResponder();
- }
-
- @Override
- public void bookmarkButtonClicked (UISearchBar searchBar) {
-
- }
-
- @Override
- public void cancelButtonClicked (UISearchBar searchBar) {
- mySearchBar.resignFirstResponder();
- }
-
- });
-
- NSMutableArray list = new NSMutableArray();
- list.add(new NSString("Normal"));
- list.add(new NSString("Tinted"));
- list.add(new NSString("Background"));
-
- // mySearchBar.addListener
- contentOptions = new UISegmentedControl(NSArray.fromStrings("Normal", "Tinted", "Background"));
- contentOptions.setFrame(new CGRect(34, 125, 252, 30));
-
- mySearchBar.setShowsCancelButton(true);
- mySearchBar.setShowsBookmarkButton(true);
-
- contentOptions.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
- /** contentChoice - changes background of search bar depending on option selection
- *
- * @param selectedSegmentIndex */
- @Override
- public void onValueChanged (UIControl control) {
- mySearchBar.setTintColor(null);
- mySearchBar.setBackgroundImage(null);
- mySearchBar.setImageForSearchBarIcon(null, UISearchBarIcon.Bookmark, UIControlState.Normal);
-
- UISegmentedControl segControl = (UISegmentedControl)control;
- switch ((int)segControl.getSelectedSegment()) {
- case 1:
- // tinted background
- mySearchBar.setTintColor(UIColor.blue());
- break;
- case 2:
- // image background
- mySearchBar.setBackgroundImage(UIImage.create("searchBarBackground"));
- mySearchBar.setImageForSearchBarIcon(UIImage.create("bookmarkImage"), UISearchBarIcon.Bookmark,
- UIControlState.Normal);
- mySearchBar.setImageForSearchBarIcon(UIImage.create("bookmarkImageHighlighted"), UISearchBarIcon.Bookmark,
- UIControlState.Highlighted);
- }
- }
- });
-
- getView().addSubview(mySearchBar);
- getView().addSubview(contentOptions);
- mySearchBar.setAutoresizingMask(UIViewAutoresizing.FlexibleWidth);
-
- }
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/SegmentViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/SegmentViewController.java
deleted file mode 100644
index e375796d..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/SegmentViewController.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.coregraphics.CGSize;
-import org.robovm.apple.foundation.NSArray;
-import org.robovm.apple.foundation.NSMutableArray;
-import org.robovm.apple.foundation.NSString;
-import org.robovm.apple.uikit.NSAttributedStringAttributes;
-import org.robovm.apple.uikit.NSTextAlignment;
-import org.robovm.apple.uikit.UIBarMetrics;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIControl;
-import org.robovm.apple.uikit.UIControlState;
-import org.robovm.apple.uikit.UIFont;
-import org.robovm.apple.uikit.UIImage;
-import org.robovm.apple.uikit.UILabel;
-import org.robovm.apple.uikit.UIScrollView;
-import org.robovm.apple.uikit.UISegmentedControl;
-import org.robovm.apple.uikit.UISegmentedControlStyle;
-import org.robovm.apple.uikit.UIView;
-import org.robovm.apple.uikit.UIViewAutoresizing;
-import org.robovm.apple.uikit.UIViewController;
-import org.robovm.samples.uicatalog.Constants;
-
-/** The view controller for hosting the UISegmentedControl features of this sample. */
-@SuppressWarnings("deprecation")
-public class SegmentViewController extends UIViewController {
-
- private final float SegmentedControlHeight = 40.0f;
- private final float LabelHeight = 20.0f;
-
- private UIScrollView scrollView;
-
- private final UIControl.OnValueChangedListener segmentAction = new UIControl.OnValueChangedListener() {
- @Override
- public void onValueChanged (UIControl control) {
- System.err.println("segmentAction: selected segment = " + ((UISegmentedControl)control).getSelectedSegment());
- }
- };
-
- /** reusable method to generate a UILabel to title each segmented control
- *
- * @param frame
- * @param title
- * @return */
- private static UILabel createLabel (CGRect frame, String title) {
- UILabel label = new UILabel(frame);
- label.setTextAlignment(NSTextAlignment.Left);
- label.setText(title);
- label.setFont(UIFont.getBoldSystemFont(17.0));
- label.setTextColor(new UIColor(76.0 / 255.0, 86.0 / 255.0, 108.0 / 255.0, 1.0));
- label.setBackgroundColor(UIColor.clear());
- label.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin.set(UIViewAutoresizing.FlexibleRightMargin));
- return label;
- }
-
- /** Creates all segmented controls and adds them to view */
- private void createControls () {
-
- NSMutableArray optionArray = new NSMutableArray();
- optionArray.add(new NSString("Check"));
- optionArray.add(new NSString("Search"));
- optionArray.add(new NSString("Tools"));
-
- double yPlacement = Constants.TOP_MARGIN;
- CGRect frame = new CGRect(Constants.LEFT_MARGIN, yPlacement, getView().getBounds().getWidth()
- - (Constants.RIGHT_MARGIN * 2.0), LabelHeight);
-
- scrollView.addSubview(SegmentViewController.createLabel(frame, "UISegmentedControl:"));
-
- Set images = new HashSet();
-
- images.add(UIImage.create("segment_check.png"));
- images.add(UIImage.create("segment_search.png"));
- images.add(UIImage.create("segment_tools.png"));
-
- NSArray imageArray = new NSArray(images);
- UISegmentedControl segmentedControl = new UISegmentedControl(imageArray);
-
- yPlacement += Constants.TWEEN_MARGIN + LabelHeight;
-
- frame = new CGRect(Constants.LEFT_MARGIN, yPlacement, getView().getBounds().getWidth() - (Constants.RIGHT_MARGIN * 2.0),
- SegmentedControlHeight);
- segmentedControl.setFrame(frame);
- segmentedControl.addOnValueChangedListener(segmentAction);
- segmentedControl.setControlStyle(UISegmentedControlStyle.Plain);
- segmentedControl.setSelectedSegment(1);
- segmentedControl.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin.set(UIViewAutoresizing.FlexibleRightMargin));
-
- scrollView.addSubview(segmentedControl);
-
- // label
- yPlacement += (Constants.TWEEN_MARGIN * 2.0) + SegmentedControlHeight;
- frame = new CGRect(Constants.LEFT_MARGIN, yPlacement, getView().getBounds().getWidth() - (Constants.RIGHT_MARGIN * 2.0),
- LabelHeight);
-
- scrollView.addSubview(SegmentViewController.createLabel(frame, "UISegmentControlStyleBordered:"));
-
- segmentedControl = new UISegmentedControl(optionArray);// initWithItems:segmentTextContent];
- yPlacement += Constants.TWEEN_MARGIN + LabelHeight;
- frame = new CGRect(Constants.LEFT_MARGIN, yPlacement, getView().getBounds().getWidth() - (Constants.RIGHT_MARGIN * 2.0),
- SegmentedControlHeight);
- segmentedControl.setFrame(frame);
- segmentedControl.addOnValueChangedListener(segmentAction);
- segmentedControl.setControlStyle(UISegmentedControlStyle.Plain);
- segmentedControl.setSelectedSegment(1);
- segmentedControl.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin.set(UIViewAutoresizing.FlexibleRightMargin));
- scrollView.addSubview(segmentedControl);
-
- // label
- yPlacement += (Constants.TWEEN_MARGIN * 2.0) + SegmentedControlHeight;
- frame = new CGRect(Constants.LEFT_MARGIN, yPlacement, getView().getBounds().getWidth() - (Constants.RIGHT_MARGIN * 2.0),
- LabelHeight);
-
- scrollView.addSubview(SegmentViewController.createLabel(frame, "UISegmentControlStyleBar:"));
-
- yPlacement += Constants.TWEEN_MARGIN + LabelHeight;
- segmentedControl = new UISegmentedControl(optionArray);
- frame = new CGRect(Constants.LEFT_MARGIN, yPlacement, getView().getBounds().getWidth() - (Constants.RIGHT_MARGIN * 2.0),
- SegmentedControlHeight);
-
- segmentedControl.setFrame(frame);
- segmentedControl.addOnValueChangedListener(segmentAction);
- segmentedControl.setControlStyle(UISegmentedControlStyle.Bar);
- segmentedControl.setSelectedSegment(1);
- segmentedControl.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin.set(UIViewAutoresizing.FlexibleRightMargin));
-
- scrollView.addSubview(segmentedControl);
-
- yPlacement += (Constants.TWEEN_MARGIN * 2.0) + SegmentedControlHeight;
- frame = new CGRect(Constants.LEFT_MARGIN, yPlacement, getView().getBounds().getWidth() - Constants.RIGHT_MARGIN * 2.0,
- LabelHeight);
- scrollView.addSubview(SegmentViewController.createLabel(frame, "UISegmentControlStyleBar: tint"));
- segmentedControl = new UISegmentedControl(optionArray);
-
- segmentedControl = new UISegmentedControl(optionArray);
- yPlacement += Constants.TWEEN_MARGIN + LabelHeight;
- frame = new CGRect(Constants.LEFT_MARGIN, yPlacement, getView().getBounds().getWidth() - Constants.RIGHT_MARGIN * 2.0,
- SegmentedControlHeight);
- segmentedControl.setFrame(frame);
- segmentedControl.addOnValueChangedListener(segmentAction);
- segmentedControl.setControlStyle(UISegmentedControlStyle.Bar);
- segmentedControl.setTintColor(new UIColor(0.7, 0.171, 0.1, 1.0));
- segmentedControl.setSelectedSegment(1);
- segmentedControl.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin.set(UIViewAutoresizing.FlexibleRightMargin));
- scrollView.addSubview(segmentedControl);
-
- yPlacement += Constants.TWEEN_MARGIN * 2.0 + SegmentedControlHeight;
- frame = new CGRect(Constants.LEFT_MARGIN, yPlacement, getView().getBounds().getWidth() - Constants.RIGHT_MARGIN * 2.0,
- LabelHeight);
- scrollView.addSubview(SegmentViewController.createLabel(frame, "UISegmentControlStyleBar: image"));
-
- segmentedControl = new UISegmentedControl(optionArray);
- yPlacement += Constants.TWEEN_MARGIN + LabelHeight;
- frame = new CGRect(Constants.LEFT_MARGIN, yPlacement, getView().getBounds().getWidth() - (Constants.RIGHT_MARGIN * 2.0),
- SegmentedControlHeight);
- segmentedControl.setFrame(frame);
-
- segmentedControl.addOnValueChangedListener(segmentAction);
- segmentedControl.setControlStyle(UISegmentedControlStyle.Bar);
- segmentedControl.setSelectedSegment(1);
- segmentedControl.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin.set(UIViewAutoresizing.FlexibleRightMargin));
- segmentedControl.setBackgroundImage(UIImage.create("segmentedBackground.png"), UIControlState.Normal,
- UIBarMetrics.Default);
- segmentedControl.setDividerImage(UIImage.create("divider.png"), UIControlState.Normal, UIControlState.Normal,
- UIBarMetrics.Default);
-
- NSAttributedStringAttributes textAttributes = new NSAttributedStringAttributes();
- textAttributes.setForegroundColor(UIColor.blue());
- textAttributes.setFont(UIFont.getBoldSystemFont(13.0));
- segmentedControl.setTitleTextAttributes(textAttributes, UIControlState.Normal);
-
- NSAttributedStringAttributes textHighlightedAttributes = new NSAttributedStringAttributes();
- textHighlightedAttributes.setForegroundColor(UIColor.red());
- textHighlightedAttributes.setFont(UIFont.getBoldSystemFont(13.0));
- segmentedControl.setTitleTextAttributes(textHighlightedAttributes, UIControlState.Highlighted);
-
- scrollView.addSubview(segmentedControl);
- getView().addSubview(scrollView);
- }
-
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
- setTitle("SegmentTitle");
-
- setView(new UIView(new CGRect(0, 0, 320, 460)));
- scrollView = new UIScrollView(new CGRect(0, 0, 320, 460));
- scrollView.setContentSize(new CGSize(scrollView.getFrame().getWidth(), scrollView.getFrame().getHeight()
- - getNavigationController().getNavigationBar().getFrame().getHeight() + 80));
-
- createControls(); // create the showcase of segment controls
- }
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/TextFieldController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/TextFieldController.java
deleted file mode 100644
index bf041b96..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/TextFieldController.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import java.util.LinkedList;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.coregraphics.CGSize;
-import org.robovm.apple.foundation.NSIndexPath;
-import org.robovm.apple.uikit.NSTextAlignment;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIFont;
-import org.robovm.apple.uikit.UIKeyboardType;
-import org.robovm.apple.uikit.UIReturnKeyType;
-import org.robovm.apple.uikit.UITableView;
-import org.robovm.apple.uikit.UITableViewCell;
-import org.robovm.apple.uikit.UITableViewCellSelectionStyle;
-import org.robovm.apple.uikit.UITableViewController;
-import org.robovm.apple.uikit.UITextAutocorrectionType;
-import org.robovm.apple.uikit.UITextBorderStyle;
-import org.robovm.apple.uikit.UITextField;
-import org.robovm.apple.uikit.UITextFieldDelegateAdapter;
-import org.robovm.apple.uikit.UITextFieldViewMode;
-import org.robovm.apple.uikit.UIView;
-import org.robovm.apple.uikit.UIViewAutoresizing;
-import org.robovm.rt.bro.annotation.MachineSizedFloat;
-import org.robovm.rt.bro.annotation.MachineSizedSInt;
-import org.robovm.samples.uicatalog.Constants;
-
-/** The view controller for hosting the UITextField features of this sample. */
-public class TextFieldController extends UITableViewController {
-
- // tableView cell id constants
- static String TEXT_FIELD_CELL_ID = "TextFieldCellID";
- static String SOURCE_CELL_ID = "SourceCellID";
-
- private final int viewTag = 1;
-
- private UITextField textFieldNormal;
- private UITextField textFieldRounded;
- private UITextField textFieldSecure;
- private UITextField textFieldLeftView;
-
- /** Adapter overloading default behaviour of shouldReturn to enable close-on-done when showing on screen keyboard */
- private class TextFieldAdapter extends UITextFieldDelegateAdapter {
-
- @Override
- public boolean shouldReturn (UITextField textField) {
- // the user pressed the "Done" button, so dismiss the keyboard
- textField.resignFirstResponder();
- return true;
- }
-
- }
-
- private final LinkedList dataSourceArray = new LinkedList();
-
- /** Item storing TextField meta data */
- private class ListItem {
-
- private final String sectionTitle;
-
- private final String source;
-
- private final UIView view;
-
- public ListItem (String sectionTitle, String source, UIView view) {
- super();
- this.sectionTitle = sectionTitle;
- this.source = source;
- this.view = view;
- }
-
- public String getSectionTitle () {
- return sectionTitle;
- }
-
- public String getSource () {
- return source;
- }
-
- public UIView getView () {
- return view;
- }
-
- }
-
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
-
- CGRect tableViewBounds = new CGRect(0.0, 64.0, 320, 247);
- setTableView(new UITableView(tableViewBounds));
-
- setTitle("TextFieldTitle");
- setEditing(false);
-
- dataSourceArray.add(new ListItem("UITextField", "textFieldNormal", getTextFieldNormal()));
- dataSourceArray.add(new ListItem("UITextField Rounded", "textFieldRounded", getTextFieldRounded()));
- dataSourceArray.add(new ListItem("UITextField Secure", "textFieldSecure", getTextFieldSecure()));
- dataSourceArray.add(new ListItem("UITextField Left", "textFieldLeft", getTextFieldLeftView()));
-
- // register our cell IDs for later when we are asked for
- // UITableViewCells
- getTableView().registerReusableCellClass(UITableViewCell.class, TEXT_FIELD_CELL_ID);
- getTableView().registerReusableCellClass(UITableViewCell.class, SOURCE_CELL_ID);
-
- }
-
- @Override
- public @MachineSizedSInt long getNumberOfSections (UITableView tableView) {
- return dataSourceArray.size();
- }
-
- @Override
- public String getTitleForHeader (UITableView tableView, @MachineSizedSInt long section) {
- return dataSourceArray.get((int)section).getSectionTitle();
- }
-
- @Override
- public @MachineSizedSInt long getNumberOfRowsInSection (UITableView tableView, @MachineSizedSInt long section) {
- return 2;
- }
-
- @Override
- public @MachineSizedFloat double getHeightForRow (UITableView tableView, NSIndexPath indexPath) {
- return (indexPath.getRow() == 0) ? 50.0 : 22.0;
- }
-
- @Override
- public UITableViewCell getCellForRow (UITableView tableView, NSIndexPath indexPath) {
- UITableViewCell cell = null;
-
- if (indexPath.getRow() == 0) {
- cell = getTableView().dequeueReusableCell(TEXT_FIELD_CELL_ID, indexPath);
-
- cell.setSelectionStyle(UITableViewCellSelectionStyle.None);
- UIView viewToRemove = null;
- viewToRemove = cell.getContentView().getViewWithTag(viewTag);
- if (viewToRemove != null) {
- viewToRemove.removeFromSuperview();
- }
-
- UITextField textField = (UITextField)dataSourceArray.get((int)indexPath.getSection()).getView();
-
- CGRect newFrame = textField.getFrame();
- newFrame.setSize(new CGSize(cell.getContentView().getFrame().getWidth() - Constants.LEFT_MARGIN * 2, cell
- .getContentView().getFrame().getHeight()));
- textField.setFrame(newFrame);
-
- // if the cell is ever resized, keep the button over to the right
- textField.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin);
- cell.getContentView().addSubview(textField);
- } else {
- cell = getTableView().dequeueReusableCell(SOURCE_CELL_ID, indexPath);
- cell.setSelectionStyle(UITableViewCellSelectionStyle.None);
- cell.getTextLabel().setTextAlignment(NSTextAlignment.Left);
- cell.getTextLabel().setTextColor(UIColor.gray());
- cell.getTextLabel().setHighlightedTextColor(UIColor.black());
- cell.getTextLabel().setFont(UIFont.getSystemFont(12.0));
- cell.getTextLabel().setText(dataSourceArray.get((int)indexPath.getSection()).getSource());
- }
-
- return cell;
- }
-
- /** Creates default text field
- *
- * @return */
- UITextField getTextFieldNormal () {
- if (textFieldNormal == null) {
- CGRect frame = new CGRect(Constants.LEFT_MARGIN, 4.0f, Constants.TEXT_FIELD_WIDTH, Constants.TEXT_FIELD_HEIGHT);
- textFieldNormal = new UITextField(frame);
-
- textFieldNormal.setBorderStyle(UITextBorderStyle.Bezel);
- textFieldNormal.setTextColor(UIColor.gray());
-
- textFieldNormal.setFont(UIFont.getSystemFont(17.0f));
- textFieldNormal.setPlaceholder("");
- textFieldNormal.setBackgroundColor(UIColor.white());
-
- textFieldNormal.setAutocorrectionType(UITextAutocorrectionType.No);
- textFieldNormal.setKeyboardType(UIKeyboardType.Default);
-
- textFieldNormal.setReturnKeyType(UIReturnKeyType.Default);
- textFieldNormal.setClearButtonMode(UITextFieldViewMode.WhileEditing);
- textFieldNormal.setTag(viewTag); // tag this control so we can
- // remove it later for recycled
- // cells
- textFieldNormal.setDelegate(new TextFieldAdapter()); // let us be
- // the delegate
- // so we know
- // when the
- // keyboard's
- // "Done"
- // button is
- // pressed
-
- }
- return textFieldNormal;
- }
-
- /** Create textfield with rounded corners
- *
- * @return */
- public UITextField getTextFieldRounded () {
- if (textFieldRounded == null) {
- CGRect frame = new CGRect(Constants.LEFT_MARGIN, 4.0, Constants.TEXT_FIELD_WIDTH, Constants.TEXT_FIELD_HEIGHT);
- textFieldRounded = new UITextField(frame);
- textFieldRounded.setBorderStyle(UITextBorderStyle.RoundedRect);
- textFieldRounded.setTextColor(UIColor.black());
-
- textFieldRounded.setFont(UIFont.getSystemFont(17.0f));
- textFieldRounded.setPlaceholder("");
- textFieldRounded.setBackgroundColor(UIColor.white());
-
- textFieldRounded.setAutocorrectionType(UITextAutocorrectionType.No);
- textFieldRounded.setKeyboardType(UIKeyboardType.Default);
-
- textFieldRounded.setReturnKeyType(UIReturnKeyType.Default);
- textFieldRounded.setClearButtonMode(UITextFieldViewMode.WhileEditing);
- textFieldRounded.setTag(viewTag); // tag this control so we can
- // remove it later for recycled
- // cells
- textFieldRounded.setDelegate(new TextFieldAdapter()); // let us be
- // the
- // delegate so
- // we know
- // when the
- // keyboard's
- // "Done"
- // button is
- // pressed
-
- }
- return textFieldRounded;
- }
-
- /** Creates text field secure
- *
- * @return */
- public UITextField getTextFieldSecure () {
-
- if (textFieldSecure == null) {
- CGRect frame = new CGRect(Constants.LEFT_MARGIN, 4.0, Constants.TEXT_FIELD_WIDTH, Constants.TEXT_FIELD_HEIGHT);
- textFieldSecure = new UITextField(frame);
- textFieldSecure.setBorderStyle(UITextBorderStyle.Bezel);
- textFieldSecure.setTextColor(UIColor.black());
-
- textFieldSecure.setFont(UIFont.getSystemFont(17.0f));
- textFieldSecure.setPlaceholder("");
- textFieldSecure.setBackgroundColor(UIColor.white());
-
- // textFieldSecure.setAutocorrectionType(UITextAutocorrectionType.No);
- textFieldSecure.setKeyboardType(UIKeyboardType.Default);
-
- textFieldSecure.setReturnKeyType(UIReturnKeyType.Done);
- textFieldSecure.setSecureTextEntry(true); // make the text entry
- // secure (bullets)
-
- textFieldSecure.setClearButtonMode(UITextFieldViewMode.WhileEditing);
- textFieldSecure.setTag(viewTag); // tag this control so we can
- // remove it later for recycled
- // cells
- textFieldSecure.setDelegate(new TextFieldAdapter());
-
- }
- return textFieldSecure;
- }
-
- /** Creates TextField with left view
- *
- * @return */
- UITextField getTextFieldLeftView () {
- if (textFieldLeftView == null) {
- CGRect frame = new CGRect(Constants.LEFT_MARGIN, 4.0, Constants.TEXT_FIELD_WIDTH, Constants.TEXT_FIELD_HEIGHT);
- textFieldLeftView = new UITextField(frame);
-
- textFieldLeftView.setBorderStyle(UITextBorderStyle.Bezel);
- textFieldLeftView.setTextColor(UIColor.black());
-
- textFieldLeftView.setFont(UIFont.getSystemFont(17.0f));
- textFieldLeftView.setPlaceholder("");
- textFieldLeftView.setBackgroundColor(UIColor.white());
-
- // textFieldLeftView.setAutocorrectionType(UITextAutocorrectionType.No);
- textFieldLeftView.setKeyboardType(UIKeyboardType.Default);
- textFieldLeftView.setDelegate(new TextFieldAdapter());
-
- textFieldLeftView.setReturnKeyType(UIReturnKeyType.Done);
- textFieldLeftView.setClearButtonMode(UITextFieldViewMode.WhileEditing);
-
- textFieldLeftView.setTag(viewTag);
- }
- return textFieldLeftView;
- }
-
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/TextViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/TextViewController.java
deleted file mode 100644
index dbf85828..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/TextViewController.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.foundation.NSMutableAttributedString;
-import org.robovm.apple.foundation.NSNotificationCenter;
-import org.robovm.apple.foundation.NSNumber;
-import org.robovm.apple.foundation.NSObject;
-import org.robovm.apple.foundation.NSRange;
-import org.robovm.apple.uikit.NSAttributedStringAttribute;
-import org.robovm.apple.uikit.UIBarButtonItem;
-import org.robovm.apple.uikit.UIBarButtonSystemItem;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIFont;
-import org.robovm.apple.uikit.UIInterfaceOrientation;
-import org.robovm.apple.uikit.UIKeyboardAnimation;
-import org.robovm.apple.uikit.UIKeyboardType;
-import org.robovm.apple.uikit.UIReturnKeyType;
-import org.robovm.apple.uikit.UITextAutocorrectionType;
-import org.robovm.apple.uikit.UITextView;
-import org.robovm.apple.uikit.UITextViewDelegateAdapter;
-import org.robovm.apple.uikit.UIView;
-import org.robovm.apple.uikit.UIViewAutoresizing;
-import org.robovm.apple.uikit.UIViewController;
-import org.robovm.apple.uikit.UIWindow;
-import org.robovm.objc.block.VoidBlock1;
-
-/** The view controller for hosting the UITextView features of this sample. */
-public class TextViewController extends UIViewController {
- private UITextView textView;
- private NSObject keyboardWillShowObserver;
- private NSObject keyboardWillHideObserver;
-
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
-
- setTitle("");
- setupTextView();
- }
-
- /** setup components and load to UI */
- private void setupTextView () {
- getView().setFrame(new CGRect(0, 0, 320, 460));
- textView = new UITextView(getView().getFrame());
- textView.setTextColor(UIColor.black());
- textView.setFont(UIFont.getFont("Arial", 18.0));
- textView.setDelegate(new UITextViewDelegateAdapter() {
- @Override
- public void didBeginEditing (UITextView textView) {
- UIBarButtonItem saveItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, new UIBarButtonItem.OnClickListener() {
- @Override
- public void onClick (UIBarButtonItem barButtonItem) {
- /** Called when to finish typing text/dismiss the keyboard by removing it as the first responder */
- TextViewController.this.textView.resignFirstResponder();
- getNavigationItem().setRightBarButtonItem(null); // this will remove the "save" button
- }
- });
- getNavigationItem().setRightBarButtonItem(saveItem);
- }
- });
- textView.setBackgroundColor(UIColor.white());
- textView.setAutoresizingMask(UIViewAutoresizing.FlexibleWidth.set(UIViewAutoresizing.FlexibleHeight));
-
- String textToAdd = "Now is the time for all good developers to come to serve their country.\n\nNow is the time for all good developers to come to serve their country.\r\rThis text view can also use attributed strings.";
- NSMutableAttributedString attrString = new NSMutableAttributedString(textToAdd);
- attrString.addAttribute(NSAttributedStringAttribute.ForegroundColor, UIColor.red(), new NSRange(textToAdd.length() - 19,
- 19));
- attrString.addAttribute(NSAttributedStringAttribute.ForegroundColor, UIColor.blue(), new NSRange(textToAdd.length() - 23,
- 3));
- attrString.addAttribute(NSAttributedStringAttribute.UnderlineStyle, NSNumber.valueOf(1l), new NSRange(
- textToAdd.length() - 23, 3));
- textView.setAttributedText(attrString);
-
- textView.setReturnKeyType(UIReturnKeyType.Default);
- textView.setKeyboardType(UIKeyboardType.Default);
- textView.setScrollEnabled(true);
- textView.setAutocorrectionType(UITextAutocorrectionType.No);
-
- getView().addSubview(textView);
- }
-
- @Override
- public void viewWillAppear (boolean animated) {
- super.viewWillAppear(animated);
- keyboardWillShowObserver = UIWindow.Notifications.observeKeyboardWillShow(new VoidBlock1() {
- @Override
- public void invoke (UIKeyboardAnimation a) {
- adjustViewForKeyboardReveal(true, a);
- }
- });
- keyboardWillHideObserver = UIWindow.Notifications.observeKeyboardWillHide(new VoidBlock1() {
- @Override
- public void invoke (UIKeyboardAnimation a) {
- adjustViewForKeyboardReveal(false, a);
- }
- });
- }
-
- private boolean isPortrait (UIInterfaceOrientation orientation) {
- return ((orientation == UIInterfaceOrientation.Portrait) || (orientation == UIInterfaceOrientation.PortraitUpsideDown));
- }
-
- /** Modifies keyboards size to fit screen.
- *
- * @param showKeyboard
- * @param notificationInfo */
- private void adjustViewForKeyboardReveal (boolean showKeyboard, UIKeyboardAnimation animation) {
- // the keyboard is showing so resize the table's height
-
- CGRect keyboardRect = animation.getEndFrame();
- double animationDuration = animation.getAnimationDuration();
-
- CGRect frame = textView.getFrame();
-
- // the keyboard rect's width and height are reversed in landscape
- double adjustDelta = isPortrait(getInterfaceOrientation()) ? keyboardRect.getHeight() : keyboardRect.getWidth();
-
- if (showKeyboard) {
- frame.getSize().setHeight(frame.getSize().getHeight() - adjustDelta);
- } else {
- frame.getSize().setHeight(frame.getSize().getHeight() + adjustDelta);
- }
-
- UIView.beginAnimations("ResizeForKeyboard", null);
- UIView.setAnimationDurationInSeconds(animationDuration);
- textView.setFrame(frame);
- UIView.commitAnimations();
- }
-
- @Override
- public void viewDidDisappear (boolean animated) {
- super.viewDidDisappear(animated);
-
- NSNotificationCenter.getDefaultCenter().removeObserver(keyboardWillShowObserver);
- NSNotificationCenter.getDefaultCenter().removeObserver(keyboardWillHideObserver);
- }
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ToolbarViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ToolbarViewController.java
deleted file mode 100644
index 301e8199..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/ToolbarViewController.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.coregraphics.CGSize;
-import org.robovm.apple.foundation.NSArray;
-import org.robovm.apple.foundation.NSMutableArray;
-import org.robovm.apple.foundation.NSObject;
-import org.robovm.apple.foundation.NSString;
-import org.robovm.apple.uikit.NSAttributedStringAttributes;
-import org.robovm.apple.uikit.UIBarButtonItem;
-import org.robovm.apple.uikit.UIBarButtonItemStyle;
-import org.robovm.apple.uikit.UIBarButtonSystemItem;
-import org.robovm.apple.uikit.UIBarMetrics;
-import org.robovm.apple.uikit.UIBarPosition;
-import org.robovm.apple.uikit.UIBarStyle;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIControl;
-import org.robovm.apple.uikit.UIControlState;
-import org.robovm.apple.uikit.UIFont;
-import org.robovm.apple.uikit.UIImage;
-import org.robovm.apple.uikit.UILabel;
-import org.robovm.apple.uikit.UIPickerView;
-import org.robovm.apple.uikit.UIPickerViewDataSourceAdapter;
-import org.robovm.apple.uikit.UIPickerViewDelegateAdapter;
-import org.robovm.apple.uikit.UIScrollView;
-import org.robovm.apple.uikit.UISegmentedControl;
-import org.robovm.apple.uikit.UISwitch;
-import org.robovm.apple.uikit.UIToolbar;
-import org.robovm.apple.uikit.UIViewAutoresizing;
-import org.robovm.apple.uikit.UIViewController;
-
-/** The view controller for hosting the UIToolbar and UIBarButtonItem features of this sample. */
-public class ToolbarViewController extends UIViewController {
- private UIScrollView scrollView;
-
- private UISegmentedControl barStyleSegControl;
- private UISwitch tintSwitch;
-
- private UISwitch imageSwitch;
- private UILabel imageSwitchLabel;
-
- private UISegmentedControl buttonItemStyleSegControl;
- private UIPickerView systemButtonPicker;
-
- private UIToolbar toolbar;
- private NSArray pickerViewArray;
-
- private UIBarButtonSystemItem currentSystemItem;
-
- private double savedContentHightSize;
-
- private final UIBarButtonItem.OnClickListener action = new UIBarButtonItem.OnClickListener() {
- @Override
- public void onClick (UIBarButtonItem barButtonItem) {
- System.err.println("action!");
- }
- };
-
- private void initUI () {
- scrollView = new UIScrollView(new CGRect(0, 0, 320, 460));
-
- UILabel barLabel = new UILabel(new CGRect(20, 86 + 60, 280, 21));
- barLabel.setText("Button Style");
- barLabel.setFont(UIFont.getBoldSystemFont(12));
-
- barStyleSegControl = new UISegmentedControl(new CGRect(20, 23 + 60, 280, 30));
- barStyleSegControl = new UISegmentedControl(new CGRect(20, 23, 280, 30));
- barStyleSegControl.insertSegment("Default", 0, false);
- barStyleSegControl.insertSegment("Black", 1, false);
- barStyleSegControl.insertSegment("Translucent", 2, false);
- barStyleSegControl.setSelectedSegment(0);
- barStyleSegControl.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
- @Override
- public void onValueChanged (UIControl control) {
- toggleBarStyle(control);
- }
- });
-
- scrollView.addSubview(barLabel);
- scrollView.addSubview(barStyleSegControl);
-
- UILabel tintLabel = new UILabel(new CGRect(30, 57 + 60, 48, 21));
- tintLabel.setText("Tint:");
- tintSwitch = new UISwitch(new CGRect(64, 56 + 55, 94, 27));
- tintSwitch.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
- @Override
- public void onValueChanged (UIControl control) {
- toggleTintColor(control);
- }
- });
- tintLabel.setFont(UIFont.getBoldSystemFont(12));
-
- scrollView.addSubview(tintLabel);
- scrollView.addSubview(tintSwitch);
-
- imageSwitchLabel = new UILabel(new CGRect(150, 57 + 60, 40, 21));
- imageSwitchLabel.setText("Image:");
- imageSwitch = new UISwitch(new CGRect(200, 56 + 55, 94, 27));
- imageSwitch.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
- @Override
- public void onValueChanged (UIControl control) {
- toggleImage(control);
- }
- });
- imageSwitchLabel.setFont(UIFont.getBoldSystemFont(12));
-
- scrollView.addSubview(imageSwitchLabel);
- scrollView.addSubview(imageSwitch);
-
- UILabel buttonLabel = new UILabel(new CGRect(20, 5, 280, 21));
- buttonLabel.setText("Bar Style:");
- buttonLabel.setFont(UIFont.getBoldSystemFont(12));
-
- buttonItemStyleSegControl = new UISegmentedControl(new CGRect(20, 103 + 60, 280, 30));
- buttonItemStyleSegControl.insertSegment("Plain", 0, false);
- buttonItemStyleSegControl.insertSegment("Bordered", 1, false);
- buttonItemStyleSegControl.insertSegment("Done", 2, false);
- buttonItemStyleSegControl.setSelectedSegment(0);
- buttonItemStyleSegControl.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
- @Override
- public void onValueChanged (UIControl control) {
- toggleStyle(control);
- }
- });
-
- scrollView.addSubview(buttonLabel);
- scrollView.addSubview(buttonItemStyleSegControl);
-
- systemButtonPicker = new UIPickerView(new CGRect(0, 159 + 120, 320, 216));
- systemButtonPicker.setDelegate(new UIPickerViewDelegateAdapter() {
- @Override
- public double getComponentWidth (UIPickerView pickerView, long component) {
- return 240.0;
- }
-
- @Override
- public double getRowHeight (UIPickerView pickerView, long component) {
- return 40.0;
- }
-
- @Override
- public String getRowTitle (UIPickerView pickerView, long row, long component) {
- return pickerViewArray.get((int)row).toString();
- }
-
- @Override
- public void didSelectRow (UIPickerView pickerView, long row, long component) {
- currentSystemItem = UIBarButtonSystemItem.valueOf(pickerView.getSelectedRow(component));
- createToolbarItems();
- }
- });
-
- systemButtonPicker.setDataSource(new UIPickerViewDataSourceAdapter() {
- @Override
- public long getNumberOfComponents (UIPickerView pickerView) {
- return 1l;
- }
-
- @Override
- public long getNumberOfRows (UIPickerView pickerView, long component) {
- return pickerViewArray.size();
- }
- });
-
- UILabel pickerLabel = new UILabel(new CGRect(20, 142 + 60, 280, 17));
- pickerLabel.setText("Picker");
- pickerLabel.setFont(UIFont.getBoldSystemFont(12));
-
- scrollView.addSubview(pickerLabel);
- scrollView.addSubview(systemButtonPicker);
- getView().addSubview(scrollView);
-
- pickerViewArray = NSArray.fromStrings("Done", "Cancel", "Edit", "Save", "Add", "FlexibleSpace", "FixedSpace", "Compose",
- "Reply", "Action", "Organize", "Bookmarks", "Search", "Refresh", "Stop", "Camera", "Trash", "Play", "Pause",
- "Rewind", "FastForward", "Undo", "Redo", "PageCurl");
- }
-
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
-
- initUI();
-
- setTitle("");
-
- // create the UIToolbar at the bottom of the view controller
- //
- toolbar = new UIToolbar(new CGRect(0, 0, 0, 0));
- // toolbar.setS
-
- toolbar.setBarStyle(UIBarStyle.Default);
- adjustToolbarSize();
-
- // systemButtonPicker = new UIPickerView(new CGRect(0, 159, 320,
- // 216));
- // size up the toolbar and set its frame
- toolbar.setFrame(new CGRect(getView().getBounds().getMinX(), getView().getBounds().getMinY()
- + getView().getBounds().getHeight() - toolbar.getFrame().getHeight(), getView().getBounds().getWidth(), toolbar
- .getFrame().getHeight()));
-
- // make so the toolbar stays to the bottom and keep the width matching
- // the device's screen width
- toolbar.setAutoresizingMask(UIViewAutoresizing.FlexibleWidth.set(UIViewAutoresizing.FlexibleTopMargin));
-
- getView().addSubview(toolbar);
-
- currentSystemItem = UIBarButtonSystemItem.Done;
- createToolbarItems();
-
- // remember our scroll view's content height (a fixed size) later when
- // we set its content size in viewWillAppear
- savedContentHightSize = scrollView.getFrame().getSize().getHeight()
- - getNavigationController().getNavigationBar().getFrame().getHeight() - toolbar.getFrame().getSize().getHeight();
-
- // @TODO check ...
- getView().addSubview(systemButtonPicker);
-
- }
-
- /** adjusts toolbar to fit screen */
- private void adjustToolbarSize () {
- // size up the toolbar and set its frame
- toolbar.sizeToFit();
-
- // since the toolbar may have adjusted its height, it's origin will have
- // to be adjusted too
- CGRect mainViewBounds = getView().getBounds();
- toolbar.setFrame(new CGRect(mainViewBounds.getMinX(), mainViewBounds.getMinY() + mainViewBounds.getHeight()
- - toolbar.getBounds().getHeight(), mainViewBounds.getWidth(), toolbar.getFrame().getHeight()));
- }
-
- // return the picker frame based on its size, positioned at the bottom of
- // the page
- // private CGRect pickerFrameWithSize(CGSize size){
- // CGRect screenRect = UIScreen.getMainScreen().getApplicationFrame();
- // CGRect pickerRect = new CGRect(0.0, screenRect.getHeight()-84.0f -
- // size.height(), size.width(), size.height());
- // return pickerRect;
- // }
-
- /** Creates toolbar with associated buttons */
- private void createToolbarItems () {
- scrollView.addSubview(buttonItemStyleSegControl);
-
- UIBarButtonItemStyle style = UIBarButtonItemStyle.valueOf(buttonItemStyleSegControl.getSelectedSegment());
-
- // create the system-defined "OK or Done" button
- UIBarButtonItem systemItem = new UIBarButtonItem(currentSystemItem, action);
- systemItem.setStyle(style);
-
- // flex item used to separate the left groups items and right grouped
- // items
- UIBarButtonItem flexItem = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null);
-
- // create a special tab bar item with a custom image and title
- UIBarButtonItem infoItem = new UIBarButtonItem(UIImage.create("segment_tools.png"), style, action);
-
- // create a custom button with a background image with black text for
- // its title:
- UIBarButtonItem customItem1 = new UIBarButtonItem("Item1", UIBarButtonItemStyle.Done, action);
-
- UIImage baseImage = UIImage.create("whiteButton.png");
- UIImage backroundImage = baseImage.createStretchable(12, 0);
- customItem1.setBackgroundImage(backroundImage, UIControlState.Normal, UIBarMetrics.Default);
-
- NSAttributedStringAttributes textAttributes = new NSAttributedStringAttributes();
- textAttributes.setForegroundColor(UIColor.black());
- customItem1.setTitleTextAttributes(textAttributes, UIControlState.Normal);
-
- UIBarButtonItem customItem2 = new UIBarButtonItem("Item2", style, action);
-
- List buttonSet = new LinkedList();
- buttonSet.add(systemItem);
- buttonSet.add(flexItem);
- buttonSet.add(customItem1);
- buttonSet.add(customItem2);
- buttonSet.add(infoItem);
-
- NSMutableArray array = new NSMutableArray(buttonSet);
- toolbar.setItems(array, false);
- }
-
- @Override
- public void viewWillAppear (boolean animated) {
- super.viewWillAppear(animated);
- adjustToolbarSize();
-
- // adjust the scroll view's height since the toolbar may have been
- // resized
- double adjustedHeight = getView().getBounds().getHeight() - toolbar.getFrame().getHeight();
- CGRect newFrame = scrollView.getFrame();
- newFrame.getSize().setHeight(adjustedHeight);
- scrollView.setFrame(newFrame);
-
- // finally set the content size so that it scrolls in landscape but not
- // in portrait
- scrollView.setContentSize(new CGSize(scrollView.getFrame().getWidth(), savedContentHightSize));
- }
-
- /** Toggles styles of UIBarButtons
- *
- * @param sender */
- private void toggleStyle (NSObject sender) {
- UIBarButtonItemStyle style = UIBarButtonItemStyle.Plain;
-
- switch ((int)((UISegmentedControl)sender).getSelectedSegment()) {
- case 0:
- style = UIBarButtonItemStyle.Plain;
- break;
-
- case 1:
- style = UIBarButtonItemStyle.Bordered;
- break;
-
- case 2:
- style = UIBarButtonItemStyle.Done;
- break;
- }
-
- // change all necessary bar button items to the given style
- NSArray toolbarItems = toolbar.getItems();
- for (int i = 0; i < toolbarItems.size(); i++) {
- // skip setting the style of image-based UIBarButtonItems
- UIBarButtonItem item = toolbarItems.get(i);
-
- // @TODO check null for image here
- UIImage image = item.getBackgroundImage(UIControlState.Normal, UIBarMetrics.Default);
-
- // UIImage image = [item
- // backgroundImageForState:UIControlStateNormal
- // barMetrics:UIBarMetricsDefault];
- if (image == null) {
- item.setStyle(style);
- }
- }
- }
-
- /** toggles bar style
- *
- * @param sender */
- private void toggleBarStyle (NSObject sender) {
- switch ((int)((UISegmentedControl)sender).getSelectedSegment()) {
- case 0:
- toolbar.setBarStyle(UIBarStyle.Default);
- break;
- case 1:
- toolbar.setBarStyle(UIBarStyle.BlackOpaque);
- break;
- case 2:
- toolbar.setBarStyle(UIBarStyle.BlackTranslucent);
- break;
- }
- }
-
- /** toggles tint color
- *
- * @param sender */
- private void toggleTintColor (NSObject sender) {
- UISwitch switchCtl = (UISwitch)sender;
- if (switchCtl.isOn()) {
- toolbar.setTintColor(UIColor.red());
- imageSwitch.setEnabled(false);
- barStyleSegControl.setEnabled(false);
- imageSwitch.setAlpha(0.5);
- barStyleSegControl.setAlpha(0.50);
-
- } else {
- if (imageSwitch.isOn()) {
- imageSwitch.setEnabled(false);
- barStyleSegControl.setEnabled(false);
- } else {
- imageSwitch.setEnabled(true);
- barStyleSegControl.setEnabled(true);
- toolbar.setTintColor(null); // no color
- imageSwitch.setAlpha(1.0);
- barStyleSegControl.setAlpha(1.0);
- }
- }
- }
-
- /** toggles image
- *
- * @param sender */
- private void toggleImage (NSObject sender) {
- UISwitch switchCtl = (UISwitch)sender;
-
- if (switchCtl.isOn()) {
- toolbar.setBackgroundImage(UIImage.create("toolbarBackground.png"), UIBarPosition.Bottom, UIBarMetrics.Default);
-
- tintSwitch.setEnabled(false);
- barStyleSegControl.setEnabled(false);
- tintSwitch.setAlpha(0.5f);
- barStyleSegControl.setAlpha(0.5f);
- } else {
-
- toolbar.setBackgroundImage(null, UIBarPosition.Bottom, UIBarMetrics.Default);
-
- tintSwitch.setEnabled(true);
- barStyleSegControl.setEnabled(true);
- tintSwitch.setAlpha(1.0);
- barStyleSegControl.setAlpha(1.0);
- }
- }
-
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/TransitionViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/TransitionViewController.java
deleted file mode 100644
index 3e89a15b..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/TransitionViewController.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.foundation.NSMutableArray;
-import org.robovm.apple.uikit.UIBarButtonItem;
-import org.robovm.apple.uikit.UIBarButtonItemStyle;
-import org.robovm.apple.uikit.UIBarButtonSystemItem;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIImage;
-import org.robovm.apple.uikit.UIImageView;
-import org.robovm.apple.uikit.UIToolbar;
-import org.robovm.apple.uikit.UIView;
-import org.robovm.apple.uikit.UIViewAnimationTransition;
-import org.robovm.apple.uikit.UIViewAutoresizing;
-import org.robovm.apple.uikit.UIViewController;
-
-/** The view controller for showing transitions with UIView. */
-public class TransitionViewController extends UIViewController {
-
- private final float imageHeight = 200.0f;
- private final float imageWidth = 250.0f;
- private final float transitionDuration = 0.75f;
- private final float topPlacement = 120.0f; // y coord for the images
-
- private UIView containerView;
- private UIImageView mainView;
- private UIImageView flipToView;
- private UIToolbar toolBar;
-
- private UIBarButtonItem flipItem;
- private UIBarButtonItem curlItem;
-
- /** setup buttons controls with associated behaviour and load images */
- @Override
- public void viewDidLoad () {
- super.viewDidLoad();
- setTitle("");
-
- flipItem = new UIBarButtonItem();
- flipItem.setTitle("Flip Image");
- flipItem.setStyle(UIBarButtonItemStyle.Bordered);
- flipItem.setOnClickListener(new UIBarButtonItem.OnClickListener() {
- @Override
- public void onClick (UIBarButtonItem barButtonItem) {
- UIView.beginAnimations(null, null);
- UIView.setAnimationDurationInSeconds(transitionDuration);
-
- UIView.setAnimationTransition(mainView.getSuperview() != null ? UIViewAnimationTransition.FlipFromLeft
- : UIViewAnimationTransition.FlipFromRight, containerView, true);
- if (flipToView.getSuperview() != null) {
- flipToView.removeFromSuperview();
- containerView.addSubview(mainView);
- } else {
- mainView.removeFromSuperview();
- containerView.addSubview(flipToView);
- }
- UIView.commitAnimations();
- }
- });
-
- curlItem = new UIBarButtonItem();
- curlItem.setTitle("Curl Image");
- curlItem.setStyle(UIBarButtonItemStyle.Bordered);
- curlItem.setOnClickListener(new UIBarButtonItem.OnClickListener() {
- @Override
- public void onClick (UIBarButtonItem barButtonItem) {
- UIView.beginAnimations(null, null);
- UIView.setAnimationDurationInSeconds(transitionDuration);
-
- UIView.setAnimationTransition((mainView.getSuperview() != null ? UIViewAnimationTransition.CurlUp
- : UIViewAnimationTransition.CurlDown), containerView, false);
-
- if (flipToView.getSuperview() != null) {
- flipToView.removeFromSuperview();
- containerView.addSubview(mainView);
- } else {
- mainView.removeFromSuperview();
- containerView.addSubview(flipToView);
- }
-
- UIView.commitAnimations();
- }
- });
-
- // create the container view which we will use for transition animation
- // (centered horizontally)
- CGRect frame = new CGRect(((getView().getBounds().getWidth() - imageWidth) / 2.0f), topPlacement, imageWidth, imageHeight);
-
- containerView = new UIView(frame);
- getView().addSubview(containerView);
- containerView.setAutoresizingMask(UIViewAutoresizing.FlexibleLeftMargin.set(UIViewAutoresizing.FlexibleRightMargin));
-
- // create the initial image view
- frame = new CGRect(0.0, 0.0, imageWidth, imageHeight);
- mainView = new UIImageView(frame);
- mainView.setImage(UIImage.create("scene1.jpg"));
- containerView.addSubview(mainView);
-
- // create the alternate image view (to transition between), we don't add
- // it as a subview yet
- CGRect imageFrame = new CGRect(0.0, 0.0, imageWidth, imageHeight);
- flipToView = new UIImageView(imageFrame);
- flipToView.setImage(UIImage.create("scene2.jpg"));
- toolBar = new UIToolbar(new CGRect(0, 416, 320, 44));
-
- UIBarButtonItem flexSpace1 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null);
- UIBarButtonItem flexSpace2 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null);
-
- List items = new LinkedList();
- items.add(flexSpace1);
- items.add(flipItem);
- items.add(curlItem);
- items.add(flexSpace2);
-
- NSMutableArray itemArray = new NSMutableArray(items);
-
- toolBar.setItems(itemArray);
- getView().setBackgroundColor(UIColor.black());
- getView().addSubview(toolBar);
- }
-
- // called after this controller's view will appear
- @Override
- public void viewWillAppear (boolean animated) {
- super.viewWillAppear(animated);
-
- // for aesthetic reasons (the background is black), make the nav bar
- // black for this particular page
- getNavigationController().getNavigationBar().setTintColor(UIColor.black());
- }
-}
diff --git a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/WebViewController.java b/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/WebViewController.java
deleted file mode 100644
index f9080417..00000000
--- a/UICatalog/src/main/java/org/robovm/samples/uicatalog/viewcontrollers/WebViewController.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2014 RoboVM AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Portions of this code is based on Apple Inc's UICatalog sample (v2.11)
- * which is copyright (C) 2008-2013 Apple Inc.
- */
-
-package org.robovm.samples.uicatalog.viewcontrollers;
-
-import org.robovm.apple.coregraphics.CGRect;
-import org.robovm.apple.foundation.NSURL;
-import org.robovm.apple.foundation.NSURLRequest;
-import org.robovm.apple.uikit.UIApplication;
-import org.robovm.apple.uikit.UIColor;
-import org.robovm.apple.uikit.UIKeyboardType;
-import org.robovm.apple.uikit.UIReturnKeyType;
-import org.robovm.apple.uikit.UITextAutocapitalizationType;
-import org.robovm.apple.uikit.UITextAutocorrectionType;
-import org.robovm.apple.uikit.UITextBorderStyle;
-import org.robovm.apple.uikit.UITextField;
-import org.robovm.apple.uikit.UITextFieldDelegateAdapter;
-import org.robovm.apple.uikit.UITextFieldViewMode;
-import org.robovm.apple.uikit.UIViewAutoresizing;
-import org.robovm.apple.uikit.UIViewController;
-import org.robovm.apple.uikit.UIWebView;
-import org.robovm.apple.uikit.UIWebViewDelegateAdapter;
-import org.robovm.objc.annotation.Method;
-import org.robovm.samples.uicatalog.Constants;
-
-/** The view controller for hosting the UIWebView feature of this sample. */
-public class WebViewController extends UIViewController {
-
- private UIWebView myWebView;
-
- /** show url bar and load webview */
- @Override
- @Method
- public void viewDidLoad () {
- super.viewDidLoad();
- setTitle("");
-
- CGRect textFieldFrame = new CGRect(Constants.LEFT_MARGIN, Constants.TWEEN_MARGIN + 70, getView().getBounds().getWidth()
- - Constants.LEFT_MARGIN * 2.0, Constants.TEXT_FIELD_HEIGHT);
-
- UITextField urlField = new UITextField(textFieldFrame);
- urlField.setBorderStyle(UITextBorderStyle.Bezel);
- urlField.setTextColor(UIColor.black());
- urlField.setDelegate(new UITextFieldDelegateAdapter() {
- @Override
- public boolean shouldReturn (UITextField textField) {
- textField.resignFirstResponder();
- myWebView.loadRequest(new NSURLRequest(new NSURL(textField.getText())));
- return true;
- }
- });
-
- urlField.setPlaceholder("");
- urlField.setText("http://www.apple.com");
- urlField.setBackgroundColor(UIColor.white());
- urlField.setAutoresizingMask(UIViewAutoresizing.FlexibleWidth);
- urlField.setReturnKeyType(UIReturnKeyType.Go);
- urlField.setKeyboardType(UIKeyboardType.URL);
- urlField.setAutocapitalizationType(UITextAutocapitalizationType.None);
- urlField.setAutocorrectionType(UITextAutocorrectionType.No);
- urlField.setClearButtonMode(UITextFieldViewMode.Always);
-
- getView().addSubview(urlField);
-
- // create the UIWebView
- CGRect webFrame = getView().getFrame();
- webFrame.getOrigin()
- .setY(webFrame.getOrigin().getY() + (Constants.TWEEN_MARGIN * 2.0) + Constants.TEXT_FIELD_HEIGHT + 70); // leave
- // room
- // for
- // the
- // URL
- // input
- // field
- webFrame.getSize().setHeight(webFrame.getSize().getHeight() - 40.0);
-
- myWebView = new UIWebView(webFrame);
- myWebView.setBackgroundColor(UIColor.white());
- myWebView.setScalesPageToFit(true);
- myWebView.setAutoresizingMask(UIViewAutoresizing.FlexibleWidth);
- myWebView.setDelegate(new WebViewDelegate());
- getView().addSubview(myWebView);
-
- myWebView.loadRequest(new NSURLRequest(new NSURL("http://www.apple.com/")));
- }
-
- private class WebViewDelegate extends UIWebViewDelegateAdapter {
- @Override
- public void didStartLoad (UIWebView webView) {
- UIApplication.getSharedApplication().setNetworkActivityIndicatorVisible(true);
- }
-
- @Override
- public void didFinishLoad (UIWebView webView) {
- UIApplication.getSharedApplication().setNetworkActivityIndicatorVisible(false);
- }
- }
-
- @Override
- public void viewWillAppear (boolean animated) {
- super.viewWillAppear(animated);
-
- myWebView.setDelegate(new WebViewDelegate()); // setup the delegate as
- // the web view is shown
- }
-
- @Override
- public void viewWillDisappear (boolean animated) {
- super.viewWillDisappear(animated);
-
- myWebView.stopLoading(); // in case the web view is still loading its
- // content
- myWebView.setDelegate(null); // disconnect the delegate as the webview
- // is hidden
- UIApplication.getSharedApplication().setNetworkActivityIndicatorVisible(false);
- }
-
-}