Skip to content

Commit

Permalink
[sample.fizzbuzz] Fix null error and work around rendering bug
Browse files Browse the repository at this point in the history
- The app displayed a null error message during the first second after startup. Providing :default values to the :watch directives fixed this.
- :sub/opts map deleted because my understanding is that this functionality was removed when cljd.flutter came out of alpha status
- (on Linux with a font size of 64) the number was rendered 1 or 2 pixels higher when "Fizz" and/or "Buzz"  is rendered. Using a single space instead of an empty string as the placeholders fixes this.
  • Loading branch information
eNotchy authored May 8, 2024
1 parent 9b25553 commit d704362
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions samples/fizzbuzz/src/sample/fizzbuzz.cljd
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
(m/Column .mainAxisAlignment m/MainAxisAlignment.center .crossAxisAlignment m/CrossAxisAlignment.stretch)
.children
[(f/widget
:watch [n s1]
:watch [n s1
:default 0]
(m/Text (str n) .textAlign m/TextAlign.center .style text-style))
(f/widget
:watch [n (f/sub [s1 s3] (fn [[n n3]] (if (= n n3) "Fizz" "")))
; default opts to f
:sub/opts [{:default 777} {:default 888}]]
:watch [n (f/sub [s1 s3] (fn [[n n3]] (if (= n n3) "Fizz" " ")))
:default " "]
(m/Text n .textAlign m/TextAlign.center .style (.apply text-style .color m/Colors.red.shade200)))
(f/widget
:watch [n (f/sub [s1 s5] (fn [[n n5]] (if (= n n5) "Buzz" "")))]
:watch [n (f/sub [s1 s5] (fn [[n n5]] (if (= n n5) "Buzz" " ")))
:default " "]
(m/Text n .textAlign m/TextAlign.center .style (.apply text-style .color m/Colors.green.shade200)))]))

0 comments on commit d704362

Please sign in to comment.