|
(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))) |
|
|
|
(.frame= root '((10 200) (300 300))) |
|
(.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))))) |
|
|
|
(.addSubview root input) |
|
(.addSubview root convert-f-c) |
|
(.addSubview root convert-c-f) |
|
(.addSubview root output) |
|
(.addSubview w root)) |