Let a Flutter checkbutton answer a tap
`:on-toggled` takes no arguments everywhere it is written — the settings tick is `actions/toggle-hide-join-part!`, a 0-arity defn, and the connect screen's TLS tick is a zero-arity `#(do ...)`. The renderer handed Checkbox's own new boolean to it, so every tap threw inside the callback and neither tick moved. Call it the way every other handler here is called, and read the state back out of `:active` on the next render. The label joins the target while we are here: 20 logical pixels is a tick under a pointer and a miss under a thumb. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ed528b2 parent: 68c21c7 modified
flutter/src/frq/hiccup.cljd +22 -11 | @@ -900,18 +900,29 @@ | ||
| 900 | 900 | (let [size (dbl (or (:size p) (:gap p) (:width-request p)) t/space-xxs)] |
| 901 | 901 | (m/SizedBox .width size .height size)) |
| 902 | 902 | |
| 903 | + ;; A tick and its words. `:on-toggled` takes no arguments — it is the | |
| 904 | + ;; same zero-arity handler every other tag here is given, and the box | |
| 905 | + ;; reads its state back out of `:active` on the next render rather than | |
| 906 | + ;; being told what it now is. Handing Checkbox's own bool to it is what | |
| 907 | + ;; left the settings tick dead: `toggle-hide-join-part!` is 0-arity. | |
| 908 | + ;; | |
| 909 | + ;; The label is part of the target. 20 logical pixels is a fine tick on | |
| 910 | + ;; a desktop pointer and a miss on a thumb, so the whole row taps. | |
| 903 | 911 | :checkbutton |
| 904 | - (let [on (:on-toggled p)] | |
| 905 | - (m/Row | |
| 906 | - .mainAxisSize m/MainAxisSize.min | |
| 907 | - .spacing t/space-xxxs | |
| 908 | - .children [(m/SizedBox | |
| 909 | - .width 20.0 .height 20.0 | |
| 910 | - .child (m/Checkbox | |
| 911 | - .value (boolean (:active p)) | |
| 912 | - .activeColor t/accent | |
| 913 | - .onChanged (when on (fn [v] (on (boolean v)))))) | |
| 914 | - (txt ctx (:label p "") t/text-body t/on-bg)])) | |
| 912 | + (let [on (:on-toggled p) | |
| 913 | + row (m/Row | |
| 914 | + .mainAxisSize m/MainAxisSize.min | |
| 915 | + .spacing t/space-xxxs | |
| 916 | + .children [(m/SizedBox | |
| 917 | + .width 20.0 .height 20.0 | |
| 918 | + .child (m/Checkbox | |
| 919 | + .value (boolean (:active p)) | |
| 920 | + .activeColor t/accent | |
| 921 | + .onChanged (when on (fn [_] (on))))) | |
| 922 | + (txt ctx (:label p "") t/text-body t/on-bg)])] | |
| 923 | + (if on | |
| 924 | + (m/InkWell .onTap #(on) .child row) | |
| 925 | + row)) | |
| 915 | 926 | |
| 916 | 927 | ;; text_input: a filled rounded field, no outline. COSMIC entries sit in |
| 917 | 928 | ;; the component colour rather than behind a border. |
| @@ -900,18 +900,29 @@ | |||
| 900 | (let [size (dbl (or (:size p) (:gap p) (:width-request p)) t/space-xxs)] | 900 | (let [size (dbl (or (:size p) (:gap p) (:width-request p)) t/space-xxs)] |
| 901 | (m/SizedBox .width size .height size)) | 901 | (m/SizedBox .width size .height size)) |
| 902 | 902 | ||
| 903 | + ;; A tick and its words. `:on-toggled` takes no arguments — it is the | ||
| 904 | + ;; same zero-arity handler every other tag here is given, and the box | ||
| 905 | + ;; reads its state back out of `:active` on the next render rather than | ||
| 906 | + ;; being told what it now is. Handing Checkbox's own bool to it is what | ||
| 907 | + ;; left the settings tick dead: `toggle-hide-join-part!` is 0-arity. | ||
| 908 | + ;; | ||
| 909 | + ;; The label is part of the target. 20 logical pixels is a fine tick on | ||
| 910 | + ;; a desktop pointer and a miss on a thumb, so the whole row taps. | ||
| 903 | :checkbutton | 911 | :checkbutton |
| 904 | - (let [on (:on-toggled p)] | 912 | + (let [on (:on-toggled p) |
| 905 | - (m/Row | 913 | + row (m/Row |
| 906 | - .mainAxisSize m/MainAxisSize.min | 914 | + .mainAxisSize m/MainAxisSize.min |
| 907 | - .spacing t/space-xxxs | 915 | + .spacing t/space-xxxs |
| 908 | - .children [(m/SizedBox | 916 | + .children [(m/SizedBox |
| 909 | - .width 20.0 .height 20.0 | 917 | + .width 20.0 .height 20.0 |
| 910 | - .child (m/Checkbox | 918 | + .child (m/Checkbox |
| 911 | - .value (boolean (:active p)) | 919 | + .value (boolean (:active p)) |
| 912 | - .activeColor t/accent | 920 | + .activeColor t/accent |
| 913 | - .onChanged (when on (fn [v] (on (boolean v)))))) | 921 | + .onChanged (when on (fn [_] (on))))) |
| 914 | - (txt ctx (:label p "") t/text-body t/on-bg)])) | 922 | + (txt ctx (:label p "") t/text-body t/on-bg)])] |
| 923 | + (if on | ||
| 924 | + (m/InkWell .onTap #(on) .child row) | ||
| 925 | + row)) | ||
| 915 | 926 | ||
| 916 | ;; text_input: a filled rounded field, no outline. COSMIC entries sit in | 927 | ;; text_input: a filled rounded field, no outline. COSMIC entries sit in |
| 917 | ;; the component colour rather than behind a border. | 928 | ;; the component colour rather than behind a border. |