Skip to content

Commit b7af9d5

Browse files
committed
wip
1 parent 80292a7 commit b7af9d5

File tree

4 files changed

+423
-597
lines changed

4 files changed

+423
-597
lines changed

ghcjs/delivery-calculator/src/App/Widgets/Asset.hs

Lines changed: 56 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ import App.Types
88
import qualified Functora.Miso.Css as Css
99
import qualified Functora.Miso.Jsm as Jsm
1010
import Functora.Miso.Prelude
11+
import qualified Functora.Miso.Widgets.Dialog as Dialog
1112
import qualified Functora.Miso.Widgets.FieldPairs as FieldPairs
1213
import qualified Functora.Miso.Widgets.Grid as Grid
13-
import qualified Material.Button as Button
14-
import qualified Material.Dialog as Dialog
15-
import qualified Material.IconButton as IconButton
16-
import qualified Material.Theme as Theme
1714

1815
assetsViewer :: Model -> [View Action]
1916
assetsViewer st = do
@@ -25,74 +22,64 @@ assetViewer st idx =
2522
[ h1_
2623
mempty
2724
[ text title,
28-
IconButton.iconButton
29-
( IconButton.config
30-
& IconButton.setAttributes
31-
[ Theme.primary
32-
]
33-
& IconButton.setOnClick
34-
( PushUpdate
35-
. Instant
36-
. PureUpdate
37-
$ cloneTraversal modalOptic
38-
.~ Opened
39-
)
40-
)
41-
"settings"
25+
button_
26+
[ onClick
27+
. PushUpdate
28+
. Instant
29+
. PureUpdate
30+
$ cloneTraversal modalOptic
31+
.~ Opened
32+
]
33+
[ text "settings"
34+
]
4235
]
4336
]
44-
<> ( if st ^? cloneTraversal modalOptic /= Just Opened
45-
then mempty
46-
else
47-
[ Dialog.dialog
48-
( Dialog.config
49-
& Dialog.setOpen True
50-
& Dialog.setOnClose closeAction
51-
)
52-
( Dialog.dialogContent
53-
Nothing
54-
[ Grid.grid
55-
mempty
56-
$ [ h1_ mempty
57-
$ [text title]
58-
]
59-
<> ( FieldPairs.fieldPairsEditor
60-
args
61-
$ FieldPairs.defOpts
62-
& #optsAdvanced
63-
.~ False
64-
)
65-
<> [ Grid.mediumCell
66-
[ Button.raised
67-
( Button.config
68-
& Button.setIcon (Just "delete_forever")
69-
& Button.setAttributes [Css.fullWidth]
70-
& Button.setOnClick
71-
( PushUpdate
72-
. Instant
73-
$ Jsm.removeAt
74-
( #modelState
75-
. #stAssets
76-
)
77-
idx
78-
)
79-
)
80-
"Remove"
81-
],
82-
Grid.mediumCell
83-
[ Button.raised
84-
( Button.config
85-
& Button.setOnClick closeAction
86-
& Button.setIcon (Just "save")
87-
& Button.setAttributes [Css.fullWidth]
88-
)
89-
"Save"
90-
]
91-
]
92-
]
37+
<> ( Dialog.dialog
38+
( Dialog.defOpts
39+
& #optsTitle
40+
.~ Just title
41+
)
42+
Dialog.Args
43+
{ Dialog.argsModel = st,
44+
Dialog.argsOptic = modalOptic,
45+
Dialog.argsAction = PushUpdate . Instant,
46+
Dialog.argsContent =
47+
[ Grid.grid
9348
mempty
94-
)
95-
]
49+
$ [ h1_ mempty
50+
$ [text title]
51+
]
52+
<> ( FieldPairs.fieldPairsEditor
53+
args
54+
$ FieldPairs.defOpts
55+
& #optsAdvanced
56+
.~ False
57+
)
58+
<> [ Grid.mediumCell
59+
[ button_
60+
[ onClick
61+
. PushUpdate
62+
. Instant
63+
$ Jsm.removeAt
64+
( #modelState . #stAssets
65+
)
66+
idx,
67+
Css.fullWidth
68+
]
69+
[ text "Remove"
70+
]
71+
],
72+
Grid.mediumCell
73+
[ button_
74+
[ onClick closeAction,
75+
Css.fullWidth
76+
]
77+
[ text "Save"
78+
]
79+
]
80+
]
81+
]
82+
}
9683
)
9784
<> FieldPairs.fieldPairsViewer args
9885
where

ghcjs/delivery-calculator/src/App/Widgets/Fav.hs

Lines changed: 50 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,79 +10,56 @@ import qualified Data.Map as Map
1010
import qualified Functora.Miso.Css as Css
1111
import qualified Functora.Miso.Jsm as Jsm
1212
import Functora.Miso.Prelude
13+
import qualified Functora.Miso.Widgets.Dialog as Dialog
1314
import qualified Functora.Miso.Widgets.Field as Field
1415
import qualified Functora.Miso.Widgets.Grid as Grid
15-
import qualified Material.Button as Button
16-
import qualified Material.Dialog as Dialog
17-
import qualified Material.Theme as Theme
1816

1917
fav :: Model -> [View Action]
2018
fav st =
21-
if st ^. #modelFav == Closed
22-
then mempty
23-
else
24-
[ Dialog.dialog
25-
( Dialog.config
26-
& Dialog.setOnClose closeAction
27-
& Dialog.setOpen (Opened == st ^. #modelFav)
28-
)
29-
( Dialog.dialogContent
30-
Nothing
31-
[ Grid.grid
32-
mempty
33-
$ favItems st
34-
<> [ Grid.bigCell
35-
[ Field.textField
36-
Field.Args
37-
{ Field.argsModel = st,
38-
Field.argsOptic = #modelState . #stFavName,
39-
Field.argsAction = PushUpdate . Instant,
40-
Field.argsEmitter =
41-
Misc.pushActionQueue st . Instant
42-
}
43-
Field.defOpts
44-
{ Field.optsPlaceholder = "Name",
45-
Field.optsOnKeyDownAction = onKeyDownAction,
46-
Field.optsTrailingWidget =
47-
let w =
48-
Field.ActionWidget
49-
"favorite"
50-
mempty
51-
. PushUpdate
52-
$ Instant saveAction
53-
in Just
54-
$ Field.OptsWidgetPair w w,
55-
Field.optsLeadingWidget =
56-
let w =
57-
Field.ActionWidget
58-
"delete_forever"
59-
mempty
60-
deleteAction
61-
in Just
62-
$ Field.OptsWidgetPair w w
63-
}
64-
],
65-
Grid.bigCell
66-
[ Button.raised
67-
( Button.config
68-
& Button.setOnClick closeAction
69-
& Button.setIcon (Just "arrow_back")
70-
& Button.setAttributes [Css.fullWidth]
71-
)
72-
"Back"
73-
]
74-
]
75-
]
76-
mempty
77-
)
78-
]
19+
Dialog.dialog
20+
Dialog.defOpts
21+
Dialog.Args
22+
{ Dialog.argsModel = st,
23+
Dialog.argsOptic = #modelFav,
24+
Dialog.argsAction = PushUpdate . Instant,
25+
Dialog.argsContent =
26+
[ Grid.grid mempty
27+
$ favItems st
28+
<> [ Grid.bigCell
29+
[ Field.textField
30+
Field.Args
31+
{ Field.argsModel = st,
32+
Field.argsOptic = #modelState . #stFavName,
33+
Field.argsAction = PushUpdate . Instant,
34+
Field.argsEmitter =
35+
Misc.pushActionQueue st . Instant
36+
}
37+
Field.defOpts
38+
{ Field.optsPlaceholder = "Name",
39+
Field.optsOnKeyDownAction = onKeyDownAction,
40+
Field.optsTrailingWidget =
41+
let w =
42+
Field.ActionWidget
43+
"favorite"
44+
mempty
45+
. PushUpdate
46+
$ Instant saveAction
47+
in Just
48+
$ Field.OptsWidgetPair w w,
49+
Field.optsLeadingWidget =
50+
let w =
51+
Field.ActionWidget
52+
"delete_forever"
53+
mempty
54+
deleteAction
55+
in Just
56+
$ Field.OptsWidgetPair w w
57+
}
58+
]
59+
]
60+
]
61+
}
7962
where
80-
closeAction =
81-
PushUpdate
82-
. Instant
83-
. PureUpdate
84-
$ #modelFav
85-
.~ Closed
8663
saveAction =
8764
ImpureUpdate $ do
8865
ct <- getCurrentTime
@@ -140,15 +117,12 @@ favItems st =
140117
favItem :: Model -> Unicode -> Fav -> View Action
141118
favItem st label Fav {favUri = uri} =
142119
Grid.bigCell
143-
[ Button.raised
144-
( Button.config
145-
& Button.setOnClick openAction
146-
& Button.setAttributes
147-
[ Css.fullWidth,
148-
Theme.secondaryBg
149-
]
150-
)
151-
label
120+
[ button_
121+
[ onClick openAction,
122+
Css.fullWidth
123+
]
124+
[ text label
125+
]
152126
]
153127
where
154128
openAction = PushUpdate . Instant . ImpureUpdate $ do

0 commit comments

Comments
 (0)