Skip to content

Commit 13084be

Browse files
committed
linksWidget WIP
1 parent 25abf6e commit 13084be

File tree

4 files changed

+123
-27
lines changed

4 files changed

+123
-27
lines changed

ghcjs/currency-converter/src/App/Widgets/Currency.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ currencyListItemWidget optic current fuzz =
228228
& ListItem.setOnClick
229229
( pureUpdate 0 $ \st ->
230230
st
231+
& #modelLoading
232+
.~ True
231233
& cloneTraversal optic
232234
. #currencyModalState
233235
.~ Closed

ghcjs/currency-converter/src/App/Widgets/Main.hs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -243,34 +243,9 @@ tosWidget =
243243
browserLink "https://functora.github.io/" "Functora",
244244
Miso.text ". All rights reserved. ",
245245
Miso.text "By continuing to use this software, you agree to the ",
246-
a_
247-
[ href_ "license.html"
248-
]
249-
[ Miso.text "Terms of Service"
250-
],
246+
a_ [href_ "license.html"] [Miso.text "Terms of Service"],
251247
Miso.text " and ",
252-
a_
253-
[ href_ "privacy.html"
254-
]
255-
[ Miso.text "Privacy Policy"
256-
],
257-
Miso.text ". To install the ",
258-
browserLink
259-
"https://play.google.com/apps/testing/com.functora.currency_converter"
260-
"Android app",
261-
Miso.text ", either join the ",
262-
browserLink
263-
"https://groups.google.com/g/currency-converter"
264-
"testing group",
265-
Miso.text " or download the ",
266-
browserLink
267-
( "https://github.com/functora/functora.github.io/releases/download/currency-converter-v"
268-
<> fromMisoString vsn
269-
<> "/currency-converter-v"
270-
<> fromMisoString vsn
271-
<> ".apk"
272-
)
273-
"APK file",
248+
a_ [href_ "privacy.html"] [Miso.text "Privacy Policy"],
274249
Miso.text $ ". Version " <> vsn <> "."
275250
]
276251

ghcjs/currency-converter/src/App/Widgets/Menu.hs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import qualified App.Widgets.Cell as Cell
99
import qualified App.Widgets.Fav as Fav
1010
import qualified App.Widgets.Field as Field
1111
import qualified App.Widgets.FieldPairs as FieldPairs
12+
import qualified App.Widgets.Templates as Templates
1213
import Functora.Miso.Prelude
1314
import qualified Language.Javascript.JSaddle as JS
1415
import qualified Material.Button as Button
@@ -18,6 +19,7 @@ import qualified Material.Select as Select
1819
import qualified Material.Select.Item as SelectItem
1920
import qualified Material.Theme as Theme
2021
import qualified Material.TopAppBar as TopAppBar
22+
import qualified Text.URI as URI
2123

2224
menu :: Model -> [View Action]
2325
menu st =
@@ -260,6 +262,7 @@ menu st =
260262
. #stDocFieldPairs
261263
)
262264
)
265+
<> linksWidget st
263266
<> [ Cell.bigCell
264267
$ Button.raised
265268
( Button.config
@@ -323,3 +326,84 @@ defFavName st =
323326
. #currencyInfoCode
324327
. #unCurrencyCode
325328
. to toMisoString
329+
330+
linksWidget :: Model -> [View Action]
331+
linksWidget _ =
332+
[ Cell.mediumCell
333+
$ Button.raised
334+
( Button.config
335+
& Button.setOnClick
336+
( open
337+
"https://groups.google.com/g/currency-converter"
338+
)
339+
& Button.setIcon (Just "android")
340+
& Button.setAttributes [class_ "fill"]
341+
)
342+
"Join testing (closed beta)",
343+
Cell.mediumCell
344+
$ Button.raised
345+
( Button.config
346+
& Button.setOnClick
347+
( open
348+
"https://play.google.com/apps/testing/com.functora.currency_converter"
349+
)
350+
& Button.setIcon (Just "android")
351+
& Button.setAttributes [class_ "fill"]
352+
)
353+
"Google Play (closed beta)",
354+
Cell.mediumCell
355+
$ Button.raised
356+
( Button.config
357+
& Button.setOnClick
358+
( open
359+
$ "https://github.com/functora/functora.github.io/releases/download/currency-converter-v"
360+
<> fromMisoString vsn
361+
<> "/currency-converter-v"
362+
<> fromMisoString vsn
363+
<> ".apk"
364+
)
365+
& Button.setIcon (Just "download")
366+
& Button.setAttributes [class_ "fill"]
367+
)
368+
"Download APK",
369+
Cell.mediumCell
370+
$ Button.raised
371+
( Button.config
372+
& Button.setOnClick
373+
( open
374+
"https://github.com/functora/functora.github.io/tree/master/ghcjs/currency-converter"
375+
)
376+
& Button.setIcon (Just "code")
377+
& Button.setAttributes [class_ "fill"]
378+
)
379+
"Source",
380+
Cell.mediumCell
381+
$ Button.raised
382+
( Button.config
383+
& Button.setOnClick (open "https://functora.github.io/")
384+
& Button.setIcon (Just "person")
385+
& Button.setAttributes [class_ "fill"]
386+
)
387+
"Author",
388+
Cell.mediumCell
389+
$ Button.raised
390+
( Button.config
391+
& Button.setOnClick
392+
( PushUpdate $ do
393+
doc <- liftIO Templates.newDonateDoc
394+
pure
395+
. ChanItem 0
396+
$ (& #modelMenu .~ Closed)
397+
. (& #modelLoading .~ True)
398+
. (& #modelState . #stDoc .~ doc)
399+
)
400+
& Button.setIcon (Just "volunteer_activism")
401+
& Button.setAttributes [class_ "fill"]
402+
)
403+
"Donate"
404+
]
405+
where
406+
open =
407+
Misc.openBrowserPageAction
408+
. either impureThrow id
409+
. URI.mkURI

ghcjs/currency-converter/src/App/Widgets/Templates.hs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module App.Widgets.Templates
22
( newModel,
3+
newDonateDoc,
34
)
45
where
56

@@ -116,3 +117,37 @@ newModel webOpts mSt uri = do
116117
modelOnlineAt = fromMaybe ct (mSt ^? _Just . #modelOnlineAt),
117118
modelWebOpts = webOpts
118119
}
120+
121+
newDonateDoc :: IO (StDoc Unique)
122+
newDonateDoc = do
123+
doc <- newStDoc
124+
title <- newFieldPair mempty $ DynamicFieldText "Hello, User!"
125+
message <- newFieldPair mempty $ DynamicFieldText exampleDonationText
126+
btcMtd <- newFieldPair "BTC - Bitcoin" $ DynamicFieldText exampleBtcAddress
127+
xmrMtd <- newFieldPair "XMR - Monero" $ DynamicFieldText exampleXmrAddress
128+
pure
129+
doc
130+
{ stDocFieldPairs =
131+
[ title
132+
& #fieldPairValue
133+
. #fieldType
134+
.~ FieldTypeTitle,
135+
message,
136+
qr btcMtd,
137+
qr xmrMtd
138+
]
139+
}
140+
where
141+
qr :: FieldPair a b -> FieldPair a b
142+
qr = (& #fieldPairValue . #fieldType .~ FieldTypeQrCode)
143+
144+
exampleBtcAddress :: MisoString
145+
exampleBtcAddress = "bc1qa3qk8d4mxl6qkpvahl5xvg6c5k33kmuwvt9v8q"
146+
147+
exampleXmrAddress :: MisoString
148+
exampleXmrAddress =
149+
"48sTw2TvjuWKkaomi9J7gLExRUJLJCvUHLrbf8M8qmayQ9zkho1GYdCXVtpTPawNWH7mNS49N4E6HNDF95dtggMMCigrVyG"
150+
151+
exampleDonationText :: MisoString
152+
exampleDonationText =
153+
"I'm Functora, the creator of this software. If you're enjoying it, a donation would be greatly appreciated. Sincerely yours, Functora."

0 commit comments

Comments
 (0)