@@ -24,6 +24,7 @@ import qualified Functora.Miso.Widgets.Grid as Grid
24
24
import qualified Functora.Miso.Widgets.Qr as Qr
25
25
import qualified Language.Javascript.JSaddle as JS
26
26
import qualified Material.Button as Button
27
+ import qualified Material.IconButton as IconButton
27
28
import qualified Material.LayoutGrid as LayoutGrid
28
29
import qualified Material.Select as Select
29
30
import qualified Material.Select.Item as SelectItem
@@ -710,6 +711,31 @@ constTextField txt opts action =
710
711
)
711
712
]
712
713
714
+ cell :: Opts model action -> [View action ] -> View action
715
+ cell Opts {optsFullWidth = full} =
716
+ LayoutGrid. cell
717
+ $ if full
718
+ then
719
+ [ LayoutGrid. span12Desktop,
720
+ LayoutGrid. span8Tablet,
721
+ LayoutGrid. span4Phone,
722
+ LayoutGrid. alignMiddle,
723
+ style_
724
+ [ (" display" , " flex" ),
725
+ (" align-items" , " center" )
726
+ ]
727
+ ]
728
+ else
729
+ [ LayoutGrid. span6Desktop,
730
+ LayoutGrid. span4Tablet,
731
+ LayoutGrid. span4Phone,
732
+ LayoutGrid. alignMiddle,
733
+ style_
734
+ [ (" display" , " flex" ),
735
+ (" align-items" , " center" )
736
+ ]
737
+ ]
738
+
713
739
--
714
740
-- TODO : support optional copying widgets
715
741
--
@@ -728,7 +754,7 @@ dynamicFieldViewer action value =
728
754
FieldTypeTitle -> header out
729
755
FieldTypeHtml -> genericFieldViewer action value rawHtml
730
756
FieldTypePassword -> genericFieldViewer action value $ const " *****"
731
- FieldTypeQrCode -> Qr. qr out
757
+ FieldTypeQrCode -> Qr. qr out <> genericFieldViewer action value text
732
758
where
733
759
--
734
760
-- TODO : use input instead!!!
@@ -749,27 +775,61 @@ header txt =
749
775
]
750
776
]
751
777
752
- cell :: Opts model action -> [View action ] -> View action
753
- cell Opts {optsFullWidth = full} =
754
- LayoutGrid. cell
755
- $ if full
756
- then
757
- [ LayoutGrid. span12Desktop,
758
- LayoutGrid. span8Tablet,
759
- LayoutGrid. span4Phone,
760
- LayoutGrid. alignMiddle,
761
- style_
762
- [ (" display" , " flex" ),
763
- (" align-items" , " center" )
764
- ]
765
- ]
766
- else
767
- [ LayoutGrid. span6Desktop,
768
- LayoutGrid. span4Tablet,
769
- LayoutGrid. span4Phone,
770
- LayoutGrid. alignMiddle,
771
- style_
772
- [ (" display" , " flex" ),
773
- (" align-items" , " center" )
774
- ]
775
- ]
778
+ genericFieldViewer ::
779
+ ( Foldable1 f
780
+ ) =>
781
+ ((model -> JSM model ) -> action ) ->
782
+ Field typ f ->
783
+ (MisoString -> View action ) ->
784
+ [View action ]
785
+ genericFieldViewer action value widget =
786
+ if input == mempty
787
+ then mempty
788
+ else
789
+ [ span_
790
+ [ Typography. typography,
791
+ Css. fullWidth,
792
+ class_ " mdc-text-field" ,
793
+ class_ " mdc-text-field--filled" ,
794
+ style_
795
+ [ (" align-items" , " center" ),
796
+ (" align-content" , " center" ),
797
+ (" word-break" , " normal" ),
798
+ (" overflow-wrap" , " anywhere" ),
799
+ (" min-height" , " 56px" ),
800
+ (" height" , " auto" ),
801
+ (" padding-top" , " 8px" ),
802
+ (" padding-bottom" , " 8px" ),
803
+ (" border-radius" , " 4px" ),
804
+ (" line-height" , " 150%" )
805
+ ]
806
+ ]
807
+ [ div_ mempty
808
+ $ [ widget $ toMisoString input
809
+ ]
810
+ <> ( if not allowCopy
811
+ then mempty
812
+ else
813
+ [ IconButton. iconButton
814
+ ( IconButton. config
815
+ & IconButton. setOnClick
816
+ ( action $ Jsm. shareText input
817
+ )
818
+ & IconButton. setAttributes
819
+ [ Theme. primary,
820
+ style_
821
+ [ (" height" , " auto" ),
822
+ (" padding-top" , " inherit" ),
823
+ (" padding-bottom" , " inherit" ),
824
+ (" vertical-align" , " middle" )
825
+ ]
826
+ ]
827
+ )
828
+ " content_copy"
829
+ ]
830
+ )
831
+ ]
832
+ ]
833
+ where
834
+ input = fold1 $ value ^. # fieldInput
835
+ allowCopy = value ^. # fieldAllowCopy
0 commit comments