Created
October 2, 2013 18:10
-
-
Save dastels/6798015 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (let ((w (.window *app*)) | |
| (root (.init (UIView.))) | |
| (input (.init (UITextField.))) | |
| (output (.init (UITextField.))) | |
| (convert-f-c (UIButton/buttonWithType: UIButtonTypeSystem)) | |
| (convert-c-f (UIButton/buttonWithType: UIButtonTypeSystem)) | |
| (close (UIButton/buttonWithType: UIButtonTypeSystem))) | |
| (.frame= root '((10 200) (220 200))) | |
| (.backgroundColor= root (UIColor/lightGrayColor)) | |
| (.frame= input '((10 10) (200 44))) | |
| (.placeholder= input "Degrees F or C") | |
| (.frame= output '((10 100) (200 44))) | |
| (.frame= convert-f-c '((10 60) (100 44))) | |
| (.backgroundColor= convert-f-c (UIColor/lightGrayColor)) | |
| (.setTitle:forState: convert-f-c "F -> C" UIControlStateNormal) | |
| (.setTitleColor:forState: convert-f-c (UIColor/blackColor) UIControlStateNormal) | |
| (.when convert-f-c UIControlEventTouchUpInside | |
| (lambda () | |
| (let ((f (float (.text input))) | |
| (c (* (/ 5.0 9.0) (- f 32)))) | |
| (.text= output (str c))))) | |
| (.frame= convert-c-f '((110 60) (100 44))) | |
| (.backgroundColor= convert-c-f (UIColor/lightGrayColor)) | |
| (.setTitle:forState: convert-c-f "C -> F" UIControlStateNormal) | |
| (.setTitleColor:forState: convert-c-f (UIColor/blackColor) UIControlStateNormal) | |
| (.when convert-c-f UIControlEventTouchUpInside | |
| (lambda () | |
| (let ((c (float (.text input))) | |
| (f (+ (* (/ 9.0 5.0) c) 32))) | |
| (.text= output (str f))))) | |
| (.frame= close '((10 150) (200 44))) | |
| (.setTitle:forState: close "Close" UIControlStateNormal) | |
| (.when close UIControlEventTouchUpInside | |
| (lambda () | |
| (.removeFromSuperview root))) | |
| (.addSubview root input) | |
| (.addSubview root convert-f-c) | |
| (.addSubview root convert-c-f) | |
| (.addSubview root output) | |
| (.addSubview root close) | |
| (.addSubview w root)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment