Skip to content

Instantly share code, notes, and snippets.

@dastels
Created October 1, 2013 01:37
Show Gist options
  • Select an option

  • Save dastels/6772814 to your computer and use it in GitHub Desktop.

Select an option

Save dastels/6772814 to your computer and use it in GitHub Desktop.
test
(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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment