Skip to content

Commit 87cb52b

Browse files
committed
wip
1 parent 5fb84a8 commit 87cb52b

File tree

7 files changed

+268
-308
lines changed

7 files changed

+268
-308
lines changed

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

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,34 @@ fav st =
2525
[ Grid.grid mempty
2626
$ favItems st
2727
<> [ Grid.bigCell
28-
[ Field.textField
29-
Field.Args
30-
{ Field.argsModel = st,
31-
Field.argsOptic = #modelState . #stFavName,
32-
Field.argsAction = PushUpdate . Instant,
33-
Field.argsEmitter = pushActionQueue st . Instant
34-
}
35-
Field.defOpts
36-
{ Field.optsPlaceholder = "Name",
37-
Field.optsOnKeyDownAction = onKeyDownAction,
38-
Field.optsTrailingWidget =
39-
let w =
40-
Field.ActionWidget
41-
"favorite"
42-
mempty
43-
. PushUpdate
44-
$ Instant saveAction
45-
in Just
46-
$ Field.OptsWidgetPair w w,
47-
Field.optsLeadingWidget =
48-
let w =
49-
Field.ActionWidget
50-
"delete_forever"
51-
mempty
52-
deleteAction
53-
in Just
54-
$ Field.OptsWidgetPair w w
55-
}
56-
]
28+
$ Field.textField
29+
Field.Args
30+
{ Field.argsModel = st,
31+
Field.argsOptic = #modelState . #stFavName,
32+
Field.argsAction = PushUpdate . Instant,
33+
Field.argsEmitter = pushActionQueue st . Instant
34+
}
35+
Field.defOpts
36+
{ Field.optsPlaceholder = "Name",
37+
Field.optsOnKeyDownAction = onKeyDownAction,
38+
Field.optsTrailingWidget =
39+
let w =
40+
Field.ActionWidget
41+
"favorite"
42+
mempty
43+
. PushUpdate
44+
$ Instant saveAction
45+
in Just
46+
$ Field.OptsWidgetPair w w,
47+
Field.optsLeadingWidget =
48+
let w =
49+
Field.ActionWidget
50+
"delete_forever"
51+
mempty
52+
deleteAction
53+
in Just
54+
$ Field.OptsWidgetPair w w
55+
}
5756
]
5857
]
5958
}

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

Lines changed: 80 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -169,87 +169,88 @@ menu st =
169169
PushUpdate . Instant,
170170
Select.argsOptions =
171171
constTraversal $ enumerate @OnlineOrOffline
172-
},
173-
Field.ratioField
174-
Field.Args
175-
{ Field.argsModel = st,
176-
Field.argsOptic =
177-
#modelState . #stExchangeRate,
178-
Field.argsAction =
179-
PushUpdate . Instant,
180-
Field.argsEmitter =
181-
pushActionQueue st . Instant
182-
}
183-
( let disabled =
184-
st
185-
^. #modelState
186-
. #stOnlineOrOffline
187-
== Online
188-
in Field.defOpts @Model @Action
189-
& #optsDisabled
190-
.~ disabled
191-
& #optsPlaceholder
192-
.~ ( "1 "
193-
<> toUpper
194-
( Money.inspectCurrencyCode
195-
$ st
196-
^. #modelState
197-
. #stAssetCurrency
198-
. #currencyOutput
199-
. #currencyInfoCode
200-
)
201-
<> " \8776 X "
202-
<> toUpper
203-
( Money.inspectCurrencyCode
204-
$ st
205-
^. #modelState
206-
. #stMerchantCurrency
207-
. #currencyOutput
208-
. #currencyInfoCode
209-
)
210-
)
211-
& ( if disabled
212-
then #optsTrailingWidget .~ Nothing
213-
else id
214-
)
215-
),
216-
Field.dynamicField
217-
Field.Args
218-
{ Field.argsModel = st,
219-
Field.argsOptic =
220-
#modelState . #stMerchantFeePercent,
221-
Field.argsAction =
222-
PushUpdate . Instant,
223-
Field.argsEmitter =
224-
pushActionQueue st . Instant
225-
}
226-
( Field.defOpts
227-
& #optsPlaceholder
228-
.~ ("Merchant fee %" :: Unicode)
229-
),
230-
Field.textField
231-
Field.Args
232-
{ Field.argsModel = st,
233-
Field.argsOptic = #modelState . #stMerchantTele,
234-
Field.argsAction = PushUpdate . Instant,
235-
Field.argsEmitter = pushActionQueue st . Instant
236-
}
237-
( Field.defOpts
238-
& #optsPlaceholder
239-
.~ ("Merchant telegram" :: Unicode)
240-
),
241-
Field.textField
242-
Field.Args
243-
{ Field.argsModel = st,
244-
Field.argsOptic = #modelState . #stPreview,
245-
Field.argsAction = PushUpdate . Instant,
246-
Field.argsEmitter = pushActionQueue st . Instant
247172
}
248-
( Field.defOpts @Model @Action
173+
]
174+
<> Field.ratioField
175+
Field.Args
176+
{ Field.argsModel = st,
177+
Field.argsOptic =
178+
#modelState . #stExchangeRate,
179+
Field.argsAction =
180+
PushUpdate . Instant,
181+
Field.argsEmitter =
182+
pushActionQueue st . Instant
183+
}
184+
( let disabled =
185+
st
186+
^. #modelState
187+
. #stOnlineOrOffline
188+
== Online
189+
in Field.defOpts @Model @Action
190+
& #optsDisabled
191+
.~ disabled
249192
& #optsPlaceholder
250-
.~ ("QR title" :: Unicode)
251-
),
252-
button_
193+
.~ ( "1 "
194+
<> toUpper
195+
( Money.inspectCurrencyCode
196+
$ st
197+
^. #modelState
198+
. #stAssetCurrency
199+
. #currencyOutput
200+
. #currencyInfoCode
201+
)
202+
<> " \8776 X "
203+
<> toUpper
204+
( Money.inspectCurrencyCode
205+
$ st
206+
^. #modelState
207+
. #stMerchantCurrency
208+
. #currencyOutput
209+
. #currencyInfoCode
210+
)
211+
)
212+
& ( if disabled
213+
then #optsTrailingWidget .~ Nothing
214+
else id
215+
)
216+
)
217+
<> Field.dynamicField
218+
Field.Args
219+
{ Field.argsModel = st,
220+
Field.argsOptic =
221+
#modelState . #stMerchantFeePercent,
222+
Field.argsAction =
223+
PushUpdate . Instant,
224+
Field.argsEmitter =
225+
pushActionQueue st . Instant
226+
}
227+
( Field.defOpts
228+
& #optsPlaceholder
229+
.~ ("Merchant fee %" :: Unicode)
230+
)
231+
<> Field.textField
232+
Field.Args
233+
{ Field.argsModel = st,
234+
Field.argsOptic = #modelState . #stMerchantTele,
235+
Field.argsAction = PushUpdate . Instant,
236+
Field.argsEmitter = pushActionQueue st . Instant
237+
}
238+
( Field.defOpts
239+
& #optsPlaceholder
240+
.~ ("Merchant telegram" :: Unicode)
241+
)
242+
<> Field.textField
243+
Field.Args
244+
{ Field.argsModel = st,
245+
Field.argsOptic = #modelState . #stPreview,
246+
Field.argsAction = PushUpdate . Instant,
247+
Field.argsEmitter = pushActionQueue st . Instant
248+
}
249+
( Field.defOpts @Model @Action
250+
& #optsPlaceholder
251+
.~ ("QR title" :: Unicode)
252+
)
253+
<> [ button_
253254
[ Css.fullWidth,
254255
onClick
255256
. screen

ghcjs/miso-functora/src/Functora/Miso/Widgets/Currency.hs

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,22 @@ selectCurrency
5757
]
5858
<> Dialog.dialog
5959
Dialog.defOpts
60-
{ Dialog.optsExtraOnClose =
60+
{ Dialog.optsTitle = Just "Currency",
61+
Dialog.optsHeaderRight =
62+
( <>
63+
Field.textField
64+
Field.Args
65+
{ Field.argsModel = st,
66+
Field.argsOptic = cloneTraversal optic . #currencyInput,
67+
Field.argsAction = action,
68+
Field.argsEmitter = emitter
69+
}
70+
( Field.defOpts
71+
& #optsPlaceholder
72+
.~ "Search"
73+
)
74+
),
75+
Dialog.optsExtraOnClose =
6176
cloneTraversal optic
6277
. #currencyInput
6378
. #fieldInput
@@ -68,20 +83,7 @@ selectCurrency
6883
{ Dialog.argsModel = st,
6984
Dialog.argsOptic = cloneTraversal optic . #currencyModalState,
7085
Dialog.argsAction = action,
71-
Dialog.argsContent =
72-
[ currencyListWidget opts args,
73-
Field.textField
74-
Field.Args
75-
{ Field.argsModel = st,
76-
Field.argsOptic = cloneTraversal optic . #currencyInput,
77-
Field.argsAction = action,
78-
Field.argsEmitter = emitter
79-
}
80-
( Field.defOpts
81-
& #optsPlaceholder
82-
.~ "Search"
83-
)
84-
]
86+
Dialog.argsContent = currencyListWidget opts args
8587
}
8688
where
8789
open =
@@ -103,16 +105,15 @@ selectCurrency
103105
.~ mempty
104106
& extraOnClick
105107

106-
currencyListWidget :: Opts model -> Args model action -> View action
108+
currencyListWidget :: Opts model -> Args model action -> [View action]
107109
currencyListWidget
108110
opts
109111
args@Args
110112
{ argsModel = st,
111113
argsOptic = optic,
112114
argsCurrencies = currencies
113115
} =
114-
ul_ [class_ "tree-view"]
115-
$ fmap (currencyListItemWidget opts args current) matching
116+
fmap (currencyListItemWidget opts args current) matching
116117
where
117118
current =
118119
fromMaybe
@@ -165,31 +166,31 @@ currencyListItemWidget
165166
}
166167
current
167168
fuzz =
168-
li_
169-
[ onClick
170-
. action
171-
. PureUpdate
172-
$ \st ->
173-
st
174-
& cloneTraversal optic
175-
. #currencyModalState
176-
.~ Closed
177-
& cloneTraversal optic
178-
. #currencyInput
179-
. #fieldInput
180-
. #uniqueValue
181-
.~ mempty
182-
& cloneTraversal optic
183-
. #currencyOutput
184-
.~ item
185-
& extraOnClick
186-
]
187-
[ ( if current == item
188-
then strong_ mempty
189-
else span_ mempty
190-
)
191-
. singleton
192-
. Miso.rawHtml
169+
button_
170+
( [ onClick
171+
. action
172+
. PureUpdate
173+
$ \st ->
174+
st
175+
& cloneTraversal optic
176+
. #currencyModalState
177+
.~ Closed
178+
& cloneTraversal optic
179+
. #currencyInput
180+
. #fieldInput
181+
. #uniqueValue
182+
.~ mempty
183+
& cloneTraversal optic
184+
. #currencyOutput
185+
.~ item
186+
& extraOnClick
187+
]
188+
<> ( if current == item
189+
then [type_ "submit"]
190+
else mempty
191+
)
192+
)
193+
[ Miso.rawHtml
193194
$ Fuzzy.rendered fuzz
194195
]
195196
where

0 commit comments

Comments
 (0)