Hey Devin, You had asked to see some code. Here is a little, to give a feel for the “top level” without digging into the plumbing.
Let's say you want an authentication UI that lets you enter a 6-digit code with a keypad and asterisk indicators showing how many digits have been keyed. Here is a screenshot of that UI (actually being driven by ClojureScript): <https://lh4.googleusercontent.com/-2RTQ5tlyTZo/U50NOx2DvDI/AAAAAAAAAJM/PrwustID-0E/s1600/keypad.png> This UI simply comprises some labels and some buttons. The ClojureScript code that runs the UI binds to those iOS components via tag number (which is set in interface builder), and has a little logic to maintain a model that consists of a vector of the digits entered so far, and code to color the asterisks. In the picture above, two button presses have occurred and the code has logged: *2014-06-14 22:47:11.291 Test App[2428:60b] JS: code-entered: [1]* *2014-06-14 22:47:12.213 Test App[2428:60b] JS: code-entered: [1 4]* The “view controller namespace” hooked up to this view is this ClojureScript code below. In it you can see an atom per UI element along with bits of code manipulating the maps in the atoms (such as set-enabled!). The “plumbing” that I haven't shown is a bit of boring code that marshals information between the atom values and the iOS components. A sample atom value for a text field might look like {:text "foo" :enabled true}. (ns test-app.view-controller (:require [fikesfarm.ios.interop :refer [bind!]] [fikesfarm.ios.view-model :refer [set-text! set-callback! set-enabled! set-hidden!]]) (:require-macros [fikesfarm.ios.util :refer [with-try]])) ;; View-Model (def asterisk-labels (vec (repeatedly 6 #(atom {})))) (def number-buttons (vec (repeatedly 10 #(atom {})))) (def clear-button (atom {})) ;; Model (def code-entered (atom [] :validator #(< (count %) 7))) (defn- update-asterisk-labels! [count-entered] (dorun (map-indexed (fn [n asterisk-label] (set-enabled! asterisk-label (< n count-entered))) asterisk-labels))) (defn- set-number-buttons-enabled! [enabled] (dorun (map #(set-enabled! % enabled) number-buttons))) (defn ^:export init-myvc! [view] (with-try ;; Bind the UI elements (dorun (map #(bind! view %1 %2) (range 21 27) asterisk-labels)) (dorun (map #(bind! view %1 %2 :touch-up-inside) (range 1 11) number-buttons)) (bind! view 11 clear-button :touch-up-inside) ;; When a number button is pressed, conj value to the code-entered vector (dorun (map #(set-callback! %1 (fn [] (swap! code-entered conj (mod %2 10)))) number-buttons (range 1 11))) ;; Empty the code-entered vector if clear button pressed (set-callback! clear-button (fn [] (reset! code-entered []))) ;; Set the asterisk labels to the correct initial rendering (update-asterisk-labels! 0) ;; As the code-entered model changes, update the number of asterisks shown (add-watch code-entered :code-entered (fn [_ _ old-code-entered new-code-entered] (when-not (= old-code-entered new-code-entered) (println "code-entered:" new-code-entered) (update-asterisk-labels! (count new-code-entered)) (when (= new-code-entered [1 4 7 2 5 8]) (set-number-buttons-enabled! false) (set-enabled! clear-button false))))))) - Mike On Wednesday, June 11, 2014 10:46:28 PM UTC-4, Devin Walters (devn) wrote: > > If I had a small fortune I would pay you to sit down and show me how this > business you're talking about works. Sounds really cool. Is doing this kind > if thing documented well anywhere? I'd love to see some code and your > workflow. > > '(Devin Walters) > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.