Skip to content

Commit b3a8b7e

Browse files
committed
wip
1 parent a6ed9ca commit b3a8b7e

File tree

5 files changed

+84
-72
lines changed

5 files changed

+84
-72
lines changed

ghcjs/delivery-calculator/delivery-calculator.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: delivery-calculator
3-
version: 0.1.0.2
3+
version: 0.1.0.3
44
synopsis: Delivery Calculator
55
category: Web
66
build-type: Simple

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

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,41 @@ assetViewer st idx =
3838
: FieldPairs.fieldPairsViewer FieldPairs.defOpts args
3939
]
4040
<> ( Dialog.dialog
41-
( Dialog.defOpts @Model @Action
42-
& #optsTitle
43-
.~ Just title
44-
& #optsFooterRight
45-
.~ const
46-
[ button_
47-
[ type_ "reset",
48-
onClick
49-
. PushUpdate
50-
. Instant
51-
$ Jsm.removeAt
52-
( #modelState . #stAssets
53-
)
54-
idx
55-
]
56-
[ icon Icon.IconDelete,
57-
text " Remove"
41+
( Dialog.defOpts
42+
{ Dialog.optsTitle = Just title,
43+
Dialog.optsHeaderRight =
44+
const
45+
[ button_
46+
[ type_ "reset",
47+
onClick removeAction
48+
]
49+
[ icon Icon.IconDelete
50+
],
51+
button_
52+
[ type_ "submit",
53+
onClick saveAction
54+
]
55+
[ icon Icon.IconSave
56+
]
5857
],
59-
button_
60-
[ type_ "submit",
61-
onClick closeAction
62-
]
63-
[ icon Icon.IconSave,
64-
text " Save"
58+
Dialog.optsFooterRight =
59+
const
60+
[ button_
61+
[ type_ "reset",
62+
onClick removeAction
63+
]
64+
[ icon Icon.IconDelete,
65+
text " Remove"
66+
],
67+
button_
68+
[ type_ "submit",
69+
onClick saveAction
70+
]
71+
[ icon Icon.IconSave,
72+
text " Save"
73+
]
6574
]
66-
]
75+
}
6776
)
6877
Dialog.Args
6978
{ Dialog.argsModel = st,
@@ -95,7 +104,11 @@ assetViewer st idx =
95104
. #stAssets
96105
. ix idx
97106
. #assetModalState
98-
closeAction =
107+
removeAction =
108+
PushUpdate
109+
. Instant
110+
$ Jsm.removeAt (#modelState . #stAssets) idx
111+
saveAction =
99112
PushUpdate
100113
. Instant
101114
. PureUpdate

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
module App.Widgets.Main (mainWidget) where
22

3+
import qualified App.Jsm as Jsm
34
import App.Types
45
import qualified App.Widgets.Asset as Asset
56
import qualified App.Widgets.Menu as Menu
7+
import qualified App.Xlsx as Xlsx
8+
import qualified Data.ByteString.Lazy as BL
69
import qualified Functora.Miso.Jsm as Jsm
710
import Functora.Miso.Prelude
811
import qualified Functora.Miso.Widgets.BrowserLink as BrowserLink
@@ -143,6 +146,18 @@ screenWidget st@Model {modelState = St {stScreen = Main}} =
143146
]
144147
[ icon Icon.IconTelegram,
145148
text " Order via Telegram"
149+
],
150+
button_
151+
[ type_ "submit",
152+
onClick . PushUpdate . Instant . EffectUpdate $ do
153+
let doc = st ^. #modelState
154+
imgs <- Jsm.fetchBlobUris doc
155+
Jsm.saveFile Xlsx.xlsxFile Xlsx.xlsxMime
156+
. from @BL.ByteString @ByteString
157+
$ Xlsx.newXlsx doc imgs
158+
]
159+
[ icon Icon.IconDownload,
160+
text " Download excel file"
146161
]
147162
]
148163

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

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ module App.Widgets.Menu
55
)
66
where
77

8-
import qualified App.Jsm as Jsm
98
import App.Types
10-
import qualified App.Xlsx as Xlsx
11-
import qualified Data.ByteString.Lazy as BL
129
import qualified Functora.Miso.Jsm as Jsm
1310
import Functora.Miso.Prelude
1411
import qualified Functora.Miso.Widgets.BrowserLink as BrowserLink
@@ -25,24 +22,10 @@ menu st =
2522
[ keyed "menu"
2623
$ nav_
2724
[ style_
28-
[ ("grid-template-columns", "auto 1fr auto auto auto auto")
25+
[ ("grid-template-columns", "1fr auto")
2926
]
3027
]
3128
[ button_
32-
[ role_ "button",
33-
style_
34-
[ ("min-width", "0")
35-
],
36-
onClick
37-
. PushUpdate
38-
. Instant
39-
. PureUpdate
40-
$ #modelMenu
41-
.~ Opened
42-
]
43-
[ icon Icon.IconMenu
44-
],
45-
button_
4629
[ role_ "button",
4730
style_
4831
[ ("min-width", "0"),
@@ -54,7 +37,8 @@ menu st =
5437
doc <- liftIO newSt
5538
pure $ #modelState .~ doc
5639
]
57-
[ text "Delivery Calculator"
40+
[ icon Icon.IconDelivery,
41+
text " Delivery Calculator"
5842
],
5943
button_
6044
[ role_ "button",
@@ -64,37 +48,27 @@ menu st =
6448
onClick
6549
. PushUpdate
6650
. Instant
67-
. Jsm.shareText
68-
. from @String @Unicode
69-
. either impureThrow URI.renderStr
70-
$ stUri st
71-
]
72-
[ icon Icon.IconShare
73-
],
74-
button_
75-
[ role_ "button",
76-
style_
77-
[ ("min-width", "0")
78-
],
79-
onClick . PushUpdate . Instant . EffectUpdate $ do
80-
let doc = st ^. #modelState
81-
imgs <- Jsm.fetchBlobUris doc
82-
Jsm.saveFile Xlsx.xlsxFile Xlsx.xlsxMime
83-
. from @BL.ByteString @ByteString
84-
$ Xlsx.newXlsx doc imgs
51+
. PureUpdate
52+
$ #modelMenu
53+
.~ Opened
8554
]
86-
[ icon Icon.IconDownload
55+
[ icon Icon.IconMenu
8756
]
8857
]
8958
]
9059
<> Dialog.dialog
9160
( Dialog.defOpts
92-
& #optsTitleIcon
93-
.~ Just Icon.IconSettings
94-
& #optsKeyed
95-
.~ Just ("menu" :: Unicode)
96-
& #optsTitle
97-
.~ Just "Settings"
61+
{ Dialog.optsTitleIcon = Just Icon.IconSettings,
62+
Dialog.optsKeyed = Just "menu",
63+
Dialog.optsTitle = Just "Settings",
64+
Dialog.optsHeaderRight =
65+
( ( button_
66+
[shareOnClick]
67+
[Dialog.optsIcon Dialog.defOpts Icon.IconShare]
68+
)
69+
:
70+
)
71+
}
9872
)
9973
Dialog.Args
10074
{ Dialog.argsModel = st,
@@ -225,6 +199,16 @@ menu st =
225199
]
226200
)
227201
}
202+
where
203+
shareOnClick :: Attribute Action
204+
shareOnClick =
205+
onClick
206+
. PushUpdate
207+
. Instant
208+
. Jsm.shareText
209+
. from @String @Unicode
210+
. either impureThrow URI.renderStr
211+
$ stUri st
228212

229213
qrButton :: Model -> View Action
230214
qrButton st =

ghcjs/delivery-calculator/trapeze.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
platforms:
22
android:
33
appName: Delivery Calculator
4-
versionCode: 2
5-
versionName: 0.1.0.2
4+
versionCode: 3
5+
versionName: 0.1.0.3
66
packageName: com.functora.delivery_calculator
77
manifest:
88
- file: AndroidManifest.xml

0 commit comments

Comments
 (0)