|
@@ -1,17 +1,17 @@
|
|
|
(ns sample.core
|
|
|
(:require [uikit.core :as uikit]
|
|
|
[com.stuartsierra.component :as component]
|
|
|
- [com.github.harlanji.clojure_stack.greetings :as c]))
|
|
|
-
|
|
|
-; last idea: name mangling of dash/underscore isn't right... try eliminating from package. must sleep.
|
|
|
-
|
|
|
+ [com.github.harlanji.clojure_stack.greetings :as c])
|
|
|
+ (:import ;[com.google.j2objc.net IosHttpURLConnection]
|
|
|
+ [java.net URL]))
|
|
|
(def white (-> ($ UIColor)
|
|
|
($ :whiteColor)))
|
|
|
|
|
|
-(declare abc)
|
|
|
+(declare abc say-hi)
|
|
|
|
|
|
(defn on-tap [scope]
|
|
|
- (println "Tap"))
|
|
|
+ (println "Tap")
|
|
|
+ (say-hi))
|
|
|
|
|
|
(defn- my-screen [g] [:UIView :main
|
|
|
{:setBackgroundColor white
|
|
@@ -20,6 +20,38 @@
|
|
|
[(uikit/button 1) :button {:setTitle:forState [g 0]
|
|
|
:gestures {:UITapGestureRecognizer #'on-tap}}]])
|
|
|
|
|
|
+(defn say-hi []
|
|
|
+ (let [c (.openConnection (URL. "http://localhost:3000/hi"))]
|
|
|
+ (println "hi: :)" (slurp (.getContent c)))))
|
|
|
+
|
|
|
+(comment defn say-hi []
|
|
|
+ (let [uri (str "http://localhost:3000/hi")
|
|
|
+ session ($ ($ NSURLSession) :sharedSession)
|
|
|
+ _ (println "session:" session)
|
|
|
+ url ($ ($ NSURL) :URLWithString uri)
|
|
|
+ _ (println "url:" url)
|
|
|
+ req ($ session
|
|
|
+ :dataTaskWithURL url
|
|
|
+ :completionHandler (fn [a b c]
|
|
|
+ (println "got hi :)")))
|
|
|
+ _ (println "req:" req)
|
|
|
+ done ($ req :resume)]
|
|
|
+
|
|
|
+ (println "uh, done:" done)))
|
|
|
+
|
|
|
+; https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/net/IosHttpURLConnection.java#L369
|
|
|
+(comment "
|
|
|
+ NSURLSession *session = [NSURLSession sharedSession];
|
|
|
+ [[session dataTaskWithURL:[NSURL URLWithString:londonWeatherUrl]
|
|
|
+ completionHandler:^(NSData *data,
|
|
|
+ NSURLResponse *response,
|
|
|
+ NSError *error) {
|
|
|
+ // handle response
|
|
|
+
|
|
|
+ }] resume];
|
|
|
+
|
|
|
+")
|
|
|
+
|
|
|
(defrecord MainUI []
|
|
|
component/Lifecycle
|
|
|
(start [component]
|
|
@@ -49,6 +81,7 @@
|
|
|
(defonce system (atom (component/system-map :ui (->MainUI))))
|
|
|
|
|
|
(defn main []
|
|
|
- (println "Hai! hello:" (c/hello-again))
|
|
|
- (let [{:keys [ui]} (swap! system component/start)]
|
|
|
- ui))
|
|
|
+ (println "Hai! hello:" (c/hello-again))
|
|
|
+
|
|
|
+ (let [{:keys [ui]} (swap! system component/start)]
|
|
|
+ ui))
|