Skip to content

Commit

Permalink
better :when and fixed bug about lost (unused) keys
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrand committed Dec 12, 2023
1 parent 097a431 commit 0c131dd
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions clj/src/cljd/flutter.cljd
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@
(-widget-cont ~(assoc env :key nil :closest-ctx false) ~@forms))))

(defn ^:macro-support expand-vsync [env name forms]
`(reify :extends (widgets/StatefulWidget .key ~(:env key))
`(reify :extends (widgets/StatefulWidget .key ~(:key env))
:no-meta true
(~'createState [_#]
(reify :extends widgets/State
Expand Down Expand Up @@ -563,28 +563,27 @@

(defn ^:macro-support expand-padding [env padding forms]
`(widgets/Padding
.key ~(:env key)
.key ~(:key env)
.padding (edge-insets-geometry ~padding)
.child (-widget-cont ~(assoc env :key nil :closest-ctx false) ~@forms)))

(defn ^:macro-support expand-color [env color forms]
`(widgets/ColoredBox
.key ~(:env key)
.key ~(:key env)
.color ~color
.child (-widget-cont ~(assoc env :key nil :closest-ctx false) ~@forms)))

(defn ^:macro-support expand-visible [env visible forms]
`(widgets/Visibility
.key ~(:env key)
.visible (boolean ~visible)
.child (-widget-cont ~(assoc env :key nil :closest-ctx false) ~@forms)))
`(if ~visible
(-widget-cont ~env ~@forms)
(widgets/SizedBox.shrink .key ~(:key env))))

(defn ^:macro-support expand-height-width [env forms]
(let [dims (take-while (fn [[k]] (case k (:height :width) true false)) (partition 2 forms))
forms (drop (* 2 (count dims)) forms)
{:keys [height width]} (reduce (fn [m [k v]] (assoc m k v)) {} dims)]
`(widgets/SizedBox
.key ~(:env key)
.key ~(:key env)
.width ~width
.height ~height
.child (-widget-cont ~(assoc env :key nil :closest-ctx false) ~@forms))))
Expand Down

0 comments on commit 0c131dd

Please sign in to comment.