Skip to content

Commit 6b54d61

Browse files
committed
wip
1 parent 68b66d9 commit 6b54d61

File tree

7 files changed

+96
-69
lines changed

7 files changed

+96
-69
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ module App.Widgets.Asset
44
where
55

66
import App.Types
7-
import qualified Functora.Miso.Css as Css
87
import qualified Functora.Miso.Jsm as Jsm
98
import Functora.Miso.Prelude
109
import qualified Functora.Miso.Widgets.Dialog as Dialog
@@ -59,16 +58,14 @@ assetViewer st idx =
5958
$ Jsm.removeAt
6059
( #modelState . #stAssets
6160
)
62-
idx,
63-
Css.fullWidth
61+
idx
6462
]
6563
[ text "Remove"
6664
]
6765
],
6866
Grid.mediumCell
6967
[ button_
70-
[ onClick closeAction,
71-
Css.fullWidth
68+
[ onClick closeAction
7269
]
7370
[ text "Save"
7471
]

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ where
66
import App.Types
77
import App.Widgets.Templates
88
import qualified Data.Map as Map
9-
import qualified Functora.Miso.Css as Css
109
import qualified Functora.Miso.Jsm as Jsm
1110
import Functora.Miso.Prelude
1211
import qualified Functora.Miso.Widgets.Dialog as Dialog
@@ -115,8 +114,7 @@ favItem :: Model -> Unicode -> Fav -> View Action
115114
favItem st label Fav {favUri = uri} =
116115
Grid.bigCell
117116
[ button_
118-
[ onClick openAction,
119-
Css.fullWidth
117+
[ onClick openAction
120118
]
121119
[ text label
122120
]

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module App.Widgets.Main (mainWidget) where
33
import App.Types
44
import qualified App.Widgets.Asset as Asset
55
import qualified App.Widgets.Menu as Menu
6-
import qualified Functora.Miso.Css as Css
76
import qualified Functora.Miso.Jsm as Jsm
87
import Functora.Miso.Prelude
98
import qualified Functora.Miso.Widgets.BrowserLink as BrowserLink
@@ -36,7 +35,9 @@ mainWidget st =
3635
]
3736
<> [ footer_
3837
[style_ [("text-align", "center")]]
39-
[tosWidget]
38+
$ tosWidget
39+
: Menu.qrButton st
40+
: Menu.linksWidget st
4041
]
4142
<> ( if not $ st ^. #modelLoading
4243
then mempty
@@ -67,8 +68,7 @@ screenWidget st@Model {modelState = St {stScreen = QrCode sc}} =
6768
]
6869
<> [ Grid.bigCell
6970
[ button_
70-
[ onClick . setScreenAction $ unQrCode sc,
71-
Css.fullWidth
71+
[ onClick . setScreenAction $ unQrCode sc
7272
]
7373
[ text "Open"
7474
]
@@ -84,8 +84,7 @@ screenWidget st@Model {modelState = St {stScreen = Donate}} =
8484
}
8585
<> [ Grid.bigCell
8686
[ button_
87-
[ onClick $ setScreenAction Main,
88-
Css.fullWidth
87+
[ onClick $ setScreenAction Main
8988
]
9089
[ text "Open"
9190
]
@@ -106,8 +105,7 @@ screenWidget st@Model {modelState = St {stScreen = Main}} =
106105
buttons =
107106
[ Grid.mediumCell
108107
[ button_
109-
[ Css.fullWidth,
110-
onClick . PushUpdate . Instant . ImpureUpdate $ do
108+
[ onClick . PushUpdate . Instant . ImpureUpdate $ do
111109
asset <- newAsset
112110
pure
113111
$ #modelState
@@ -119,8 +117,7 @@ screenWidget st@Model {modelState = St {stScreen = Main}} =
119117
],
120118
Grid.mediumCell
121119
[ button_
122-
[ Css.fullWidth,
123-
onClick
120+
[ onClick
124121
. PushUpdate
125122
. Instant
126123
. either impureThrow Jsm.openBrowserPage

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

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
module App.Widgets.Menu
22
( menu,
3+
qrButton,
4+
linksWidget,
35
)
46
where
57

68
import App.Types
79
import qualified App.Widgets.Fav as Fav
810
import qualified App.Xlsx as Xlsx
9-
import qualified Functora.Miso.Css as Css
1011
import qualified Functora.Miso.Jsm as Jsm
1112
import Functora.Miso.Prelude
1213
import qualified Functora.Miso.Widgets.BrowserLink as BrowserLink
@@ -181,8 +182,9 @@ menu st =
181182
in Field.defOpts @Model @Action
182183
& #optsDisabled
183184
.~ disabled
184-
& #optsPlaceholder
185-
.~ ( "1 "
185+
& #optsLabel
186+
.~ Just
187+
( "1 "
186188
<> toUpper
187189
( Money.inspectCurrencyCode
188190
$ st
@@ -191,7 +193,14 @@ menu st =
191193
. #currencyOutput
192194
. #currencyInfoCode
193195
)
194-
<> " \8776 X "
196+
<> " \8776 "
197+
<> inspectRatioDef
198+
( st
199+
^. #modelState
200+
. #stExchangeRate
201+
. #fieldOutput
202+
)
203+
<> " "
195204
<> toUpper
196205
( Money.inspectCurrencyCode
197206
$ st
@@ -200,7 +209,7 @@ menu st =
200209
. #currencyOutput
201210
. #currencyInfoCode
202211
)
203-
)
212+
)
204213
& ( if disabled
205214
then #optsTrailingWidget .~ Nothing
206215
else id
@@ -217,8 +226,8 @@ menu st =
217226
pushActionQueue st . Instant
218227
}
219228
( Field.defOpts
220-
& #optsPlaceholder
221-
.~ ("Merchant fee %" :: Unicode)
229+
& #optsLabel
230+
.~ Just ("Merchant fee %" :: Unicode)
222231
)
223232
<> Field.textField
224233
Field.Args
@@ -228,8 +237,8 @@ menu st =
228237
Field.argsEmitter = pushActionQueue st . Instant
229238
}
230239
( Field.defOpts
231-
& #optsPlaceholder
232-
.~ ("Merchant telegram" :: Unicode)
240+
& #optsLabel
241+
.~ Just ("Merchant telegram" :: Unicode)
233242
)
234243
<> Field.textField
235244
Field.Args
@@ -239,25 +248,29 @@ menu st =
239248
Field.argsEmitter = pushActionQueue st . Instant
240249
}
241250
( Field.defOpts @Model @Action
242-
& #optsPlaceholder
243-
.~ ("QR title" :: Unicode)
251+
& #optsLabel
252+
.~ Just ("QR title" :: Unicode)
244253
)
245-
<> [ button_
246-
[ Css.fullWidth,
247-
onClick
248-
. screen
249-
$ if isQrCode sc
250-
then Main
251-
else QrCode sc
252-
]
253-
[ text
254-
$ if isQrCode sc
255-
then "Delivery Calculator"
256-
else "QR"
257-
]
258-
]
259-
<> linksWidget st
260254
}
255+
256+
qrButton :: Model -> View Action
257+
qrButton st =
258+
button_
259+
[ onClick
260+
. screen
261+
$ if isQrCode sc
262+
then Main
263+
else QrCode sc
264+
]
265+
[ icon
266+
$ if isQrCode sc
267+
then Icon.IconDelivery
268+
else Icon.IconQr,
269+
text
270+
$ if isQrCode sc
271+
then " Calculator"
272+
else " QR"
273+
]
261274
where
262275
screen next =
263276
PushUpdate
@@ -272,10 +285,10 @@ menu st =
272285
linksWidget :: Model -> [View Action]
273286
linksWidget st =
274287
[ button_
275-
[ onClick openWidget,
276-
Css.fullWidth
288+
[ onClick openWidget
277289
]
278-
[ text "App"
290+
[ icon Icon.IconGooglePlay,
291+
text " Google Play"
279292
]
280293
]
281294
<> Dialog.dialog
@@ -315,38 +328,32 @@ linksWidget st =
315328
},
316329
text " directly.",
317330
button_
318-
[ onClick $ openBrowser testGroupLink,
319-
Css.fullWidth
331+
[ onClick $ openBrowser testGroupLink
320332
]
321333
[ text "Join testing (closed beta)"
322334
],
323335
button_
324-
[ onClick $ openBrowser googlePlayLink,
325-
Css.fullWidth
336+
[ onClick $ openBrowser googlePlayLink
326337
]
327338
[ text "Google Play (closed beta)"
328339
],
329340
button_
330-
[ onClick $ openBrowser apkLink,
331-
Css.fullWidth
341+
[ onClick $ openBrowser apkLink
332342
]
333343
[ text "Download APK"
334344
],
335345
button_
336-
[ onClick $ openBrowser sourceLink,
337-
Css.fullWidth
346+
[ onClick $ openBrowser sourceLink
338347
]
339348
[ text "Source"
340349
],
341350
button_
342-
[ onClick $ openBrowser functoraLink,
343-
Css.fullWidth
351+
[ onClick $ openBrowser functoraLink
344352
]
345353
[ text "Author"
346354
],
347355
button_
348-
[ onClick $ setScreenAction Donate,
349-
Css.fullWidth
356+
[ onClick $ setScreenAction Donate
350357
]
351358
[ text "Donate"
352359
]

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ dialog opts args =
6767
<> newFlex
6868
footer_
6969
id
70-
(optsFooterLeft opts defFooterRight)
71-
(optsFooterRight opts mempty)
70+
(optsFooterLeft opts mempty)
71+
(optsFooterRight opts defFooterRight)
7272
where
7373
opened =
7474
args ^? #argsModel . cloneTraversal (argsOptic args) == Just Opened
@@ -94,7 +94,9 @@ dialog opts args =
9494
defFooterRight =
9595
[ button_
9696
[onClick $ closeDialogAction opts args]
97-
[text "Back"]
97+
[ optsIcon opts Icon.IconBack,
98+
text " Back"
99+
]
98100
]
99101

100102
newFlex ::

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ data Full model action t f = Full
4545
deriving stock (Generic)
4646

4747
data Opts model action = Opts
48-
{ optsDisabled :: Bool,
48+
{ optsLabel :: Maybe Unicode,
49+
optsDisabled :: Bool,
4950
optsFullWidth :: Bool,
5051
optsPlaceholder :: Unicode,
5152
optsOnInputAction :: Maybe (Update model -> action),
@@ -65,7 +66,8 @@ data OptsWidgetPair model action = OptsWidgetPair
6566
defOpts :: Opts model action
6667
defOpts =
6768
Opts
68-
{ optsDisabled = False,
69+
{ optsLabel = Nothing,
70+
optsDisabled = False,
6971
optsFullWidth = False,
7072
optsPlaceholder = mempty,
7173
optsOnInputAction = Nothing,
@@ -137,14 +139,21 @@ field Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts =
137139
_ -> mempty
138140
fieldModal args x1
139141
)
140-
<> [ input_
142+
<> [ maybe
143+
id
144+
(\x -> label_ mempty . (text x :) . singleton)
145+
(optsLabel opts)
146+
. input_
141147
$ ( catMaybes
142148
[ fmap
143149
(type_ . htmlFieldType)
144150
(st ^? cloneTraversal optic . #fieldType),
145151
Just $ onInput onInputAction,
146152
Just . disabled_ $ opts ^. #optsDisabled,
147-
Just . placeholder_ $ opts ^. #optsPlaceholder,
153+
fmap placeholder_
154+
$ if null placeholder
155+
then optsLabel opts
156+
else Just placeholder,
148157
Just
149158
. id_
150159
. either impureThrow id
@@ -175,6 +184,7 @@ field Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts =
175184
st = argsModel args
176185
optic = argsOptic args
177186
action = argsAction args
187+
placeholder = optsPlaceholder opts
178188
widgetOptic =
179189
if null . fromMaybe mempty $ getInput st
180190
then #optsWidgetPairEmpty

0 commit comments

Comments
 (0)