Skip to content

Commit 5fb84a8

Browse files
committed
wip
1 parent 3679b70 commit 5fb84a8

File tree

2 files changed

+137
-138
lines changed
  • ghcjs
    • delivery-calculator/src/App/Widgets
    • miso-functora/src/Functora/Miso/Widgets

2 files changed

+137
-138
lines changed

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

Lines changed: 128 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -115,27 +115,27 @@ menu st =
115115
Dialog.argsOptic = #modelMenu,
116116
Dialog.argsAction = PushUpdate . Instant,
117117
Dialog.argsContent =
118-
[ Currency.selectCurrency
119-
Currency.defOpts
120-
{ Currency.optsExtraOnClick =
121-
(& #modelLoading .~ True),
122-
Currency.optsButtonViewer =
123-
mappend "Marketplace - "
124-
. Money.inspectCurrencyCode
125-
. Money.currencyInfoCode
126-
}
127-
Currency.Args
128-
{ Currency.argsModel = st,
129-
Currency.argsOptic =
130-
#modelState . #stAssetCurrency,
131-
Currency.argsAction =
132-
PushUpdate . Instant,
133-
Currency.argsEmitter =
134-
pushActionQueue st . Instant,
135-
Currency.argsCurrencies =
136-
#modelCurrencies
137-
},
138-
Currency.selectCurrency
118+
Currency.selectCurrency
119+
Currency.defOpts
120+
{ Currency.optsExtraOnClick =
121+
(& #modelLoading .~ True),
122+
Currency.optsButtonViewer =
123+
mappend "Marketplace - "
124+
. Money.inspectCurrencyCode
125+
. Money.currencyInfoCode
126+
}
127+
Currency.Args
128+
{ Currency.argsModel = st,
129+
Currency.argsOptic =
130+
#modelState . #stAssetCurrency,
131+
Currency.argsAction =
132+
PushUpdate . Instant,
133+
Currency.argsEmitter =
134+
pushActionQueue st . Instant,
135+
Currency.argsCurrencies =
136+
#modelCurrencies
137+
}
138+
<> Currency.selectCurrency
139139
Currency.defOpts
140140
{ Currency.optsExtraOnClick =
141141
(& #modelLoading .~ True),
@@ -154,115 +154,115 @@ menu st =
154154
pushActionQueue st . Instant,
155155
Currency.argsCurrencies =
156156
#modelCurrencies
157-
},
158-
Select.select
159-
( Select.defOpts
160-
& #optsLabel
161-
.~ Just "Exchange rate"
162-
)
163-
Select.Args
164-
{ Select.argsModel =
165-
st,
166-
Select.argsOptic =
167-
#modelState . #stOnlineOrOffline,
168-
Select.argsAction =
169-
PushUpdate . Instant,
170-
Select.argsOptions =
171-
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
182157
}
183-
( let disabled =
184-
st
185-
^. #modelState
186-
. #stOnlineOrOffline
187-
== Online
188-
in Field.defOpts @Model @Action
189-
& #optsDisabled
190-
.~ disabled
158+
<> [ Select.select
159+
( Select.defOpts
160+
& #optsLabel
161+
.~ Just "Exchange rate"
162+
)
163+
Select.Args
164+
{ Select.argsModel =
165+
st,
166+
Select.argsOptic =
167+
#modelState . #stOnlineOrOffline,
168+
Select.argsAction =
169+
PushUpdate . Instant,
170+
Select.argsOptions =
171+
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
191227
& #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
247-
}
248-
( Field.defOpts @Model @Action
249-
& #optsPlaceholder
250-
.~ ("QR title" :: Unicode)
251-
),
252-
button_
253-
[ Css.fullWidth,
254-
onClick
255-
. screen
256-
$ if isQrCode sc
257-
then Main
258-
else QrCode sc
259-
]
260-
[ text
261-
$ if isQrCode sc
262-
then "Delivery Calculator"
263-
else "QR"
264-
]
265-
]
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
247+
}
248+
( Field.defOpts @Model @Action
249+
& #optsPlaceholder
250+
.~ ("QR title" :: Unicode)
251+
),
252+
button_
253+
[ Css.fullWidth,
254+
onClick
255+
. screen
256+
$ if isQrCode sc
257+
then Main
258+
else QrCode sc
259+
]
260+
[ text
261+
$ if isQrCode sc
262+
then "Delivery Calculator"
263+
else "QR"
264+
]
265+
]
266266
<> linksWidget st
267267
}
268268
where

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defOpts =
3636
optsButtonViewer = inspectCurrencyInfo
3737
}
3838

39-
selectCurrency :: Opts model -> Args model action -> View action
39+
selectCurrency :: Opts model -> Args model action -> [View action]
4040
selectCurrency
4141
opts@Opts
4242
{ optsExtraOnClick = extraOnClick
@@ -47,15 +47,14 @@ selectCurrency
4747
argsAction = action,
4848
argsEmitter = emitter
4949
} =
50-
div_ mempty
51-
$ [ button_ [onClick open]
52-
. singleton
53-
. text
54-
. (opts ^. #optsButtonViewer)
55-
$ fromMaybe
56-
(CurrencyInfo (CurrencyCode "XXX") mempty)
57-
(st ^? cloneTraversal optic . #currencyOutput)
58-
]
50+
[ button_ [onClick open]
51+
. singleton
52+
. text
53+
. (opts ^. #optsButtonViewer)
54+
$ fromMaybe
55+
(CurrencyInfo (CurrencyCode "XXX") mempty)
56+
(st ^? cloneTraversal optic . #currencyOutput)
57+
]
5958
<> Dialog.dialog
6059
Dialog.defOpts
6160
{ Dialog.optsExtraOnClose =

0 commit comments

Comments
 (0)