Skip to content

Commit fe8934b

Browse files
committed
better links widgets
1 parent 13084be commit fe8934b

File tree

5 files changed

+163
-83
lines changed

5 files changed

+163
-83
lines changed

ghcjs/currency-converter/src/App/Misc.hs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ module App.Misc
1919
newFieldPairAction,
2020
newPaymentMethodAction,
2121
openBrowserPageAction,
22+
browserLink,
2223
)
2324
where
2425

2526
import App.Types
2627
import qualified Data.Generics as Syb
2728
import Functora.Miso.Prelude
2829
import Functora.Money hiding (Text)
30+
import qualified Functora.Prelude as Prelude
2931
import qualified Language.Javascript.JSaddle as JS
3032
import qualified Material.Snackbar as Snackbar
3133
import qualified Text.URI as URI
@@ -250,3 +252,15 @@ openBrowserPageAction uri =
250252
PushUpdate $ do
251253
void $ JS.global ^. JS.js1 @MisoString "openBrowserPage" (URI.render uri)
252254
pure $ ChanItem 0 id
255+
256+
browserLink :: Prelude.Text -> MisoString -> View Action
257+
browserLink uri txt =
258+
a_
259+
[ href_ "#!",
260+
onClick
261+
. openBrowserPageAction
262+
. either impureThrow id
263+
$ URI.mkURI uri
264+
]
265+
[ text txt
266+
]

ghcjs/currency-converter/src/App/Types.hs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ module App.Types
2020
vsn,
2121
usd,
2222
btc,
23+
googlePlayLink,
24+
testGroupLink,
25+
functoraLink,
26+
sourceLink,
27+
apkLink,
2328
module X,
2429
)
2530
where
@@ -44,6 +49,7 @@ import qualified Text.URI as URI
4449
data Model = Model
4550
{ modelFav :: OpenedOrClosed,
4651
modelMenu :: OpenedOrClosed,
52+
modelLinks :: OpenedOrClosed,
4753
modelLoading :: Bool,
4854
modelState :: St Unique,
4955
modelMarket :: MVar Rates.Market,
@@ -285,3 +291,24 @@ usd = CurrencyInfo (CurrencyCode "usd") mempty
285291

286292
btc :: CurrencyInfo
287293
btc = CurrencyInfo (CurrencyCode "btc") mempty
294+
295+
googlePlayLink :: Prelude.Text
296+
googlePlayLink = "https://play.google.com/apps/testing/com.functora.currency_converter"
297+
298+
testGroupLink :: Prelude.Text
299+
testGroupLink = "https://groups.google.com/g/currency-converter"
300+
301+
functoraLink :: Prelude.Text
302+
functoraLink = "https://functora.github.io/"
303+
304+
sourceLink :: Prelude.Text
305+
sourceLink =
306+
"https://github.com/functora/functora.github.io/tree/master/ghcjs/currency-converter"
307+
308+
apkLink :: Prelude.Text
309+
apkLink =
310+
"https://github.com/functora/functora.github.io/releases/download/currency-converter-v"
311+
<> fromMisoString vsn
312+
<> "/currency-converter-v"
313+
<> fromMisoString vsn
314+
<> ".apk"

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import qualified App.Widgets.Qr as Qr
1212
import qualified App.Widgets.SwapAmounts as SwapAmounts
1313
import Functora.Miso.Prelude
1414
import Functora.Money hiding (Text)
15-
import qualified Functora.Prelude as Prelude
1615
import qualified Material.Button as Button
1716
import qualified Material.LayoutGrid as LayoutGrid
1817
import qualified Material.Snackbar as Snackbar
@@ -240,23 +239,11 @@ tosWidget =
240239
]
241240
]
242241
[ Miso.text "\169 2024 ",
243-
browserLink "https://functora.github.io/" "Functora",
242+
Misc.browserLink "https://functora.github.io/" "Functora",
244243
Miso.text ". All rights reserved. ",
245244
Miso.text "By continuing to use this software, you agree to the ",
246245
a_ [href_ "license.html"] [Miso.text "Terms of Service"],
247246
Miso.text " and ",
248247
a_ [href_ "privacy.html"] [Miso.text "Privacy Policy"],
249248
Miso.text $ ". Version " <> vsn <> "."
250249
]
251-
252-
browserLink :: Prelude.Text -> MisoString -> View Action
253-
browserLink uri txt =
254-
a_
255-
[ href_ "#!",
256-
onClick
257-
. Misc.openBrowserPageAction
258-
. either impureThrow id
259-
$ URI.mkURI uri
260-
]
261-
[ Miso.text txt
262-
]

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

Lines changed: 120 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -328,82 +328,133 @@ defFavName st =
328328
. to toMisoString
329329

330330
linksWidget :: Model -> [View Action]
331-
linksWidget _ =
332-
[ Cell.mediumCell
331+
linksWidget st =
332+
[ Cell.bigCell
333333
$ Button.raised
334334
( Button.config
335-
& Button.setOnClick
336-
( open
337-
"https://groups.google.com/g/currency-converter"
338-
)
335+
& Button.setOnClick openWidget
339336
& Button.setIcon (Just "android")
340337
& Button.setAttributes [class_ "fill"]
341338
)
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"
339+
"App"
404340
]
341+
<> ( if st ^. #modelLinks == Closed
342+
then mempty
343+
else
344+
[ Dialog.dialog
345+
( Dialog.config
346+
& Dialog.setOnClose closeWidget
347+
& Dialog.setOpen (Opened == st ^. #modelLinks)
348+
)
349+
( Dialog.dialogContent
350+
Nothing
351+
[ Cell.grid
352+
mempty
353+
[ Cell.bigCell
354+
$ span_
355+
mempty
356+
[ text
357+
"The Android app is in closed beta. To install it, join the ",
358+
Misc.browserLink testGroupLink "closed beta group",
359+
text " and then install the app from ",
360+
Misc.browserLink googlePlayLink "Google Play",
361+
text ", or download the ",
362+
Misc.browserLink apkLink "APK file",
363+
text " directly."
364+
],
365+
Cell.mediumCell
366+
$ Button.raised
367+
( Button.config
368+
& Button.setIcon (Just "android")
369+
& Button.setOnClick (openBrowser testGroupLink)
370+
& Button.setAttributes
371+
[ Theme.secondaryBg,
372+
class_ "fill"
373+
]
374+
)
375+
"Join testing (closed beta)",
376+
Cell.mediumCell
377+
$ Button.raised
378+
( Button.config
379+
& Button.setIcon (Just "android")
380+
& Button.setOnClick (openBrowser googlePlayLink)
381+
& Button.setAttributes
382+
[ Theme.secondaryBg,
383+
class_ "fill"
384+
]
385+
)
386+
"Google Play (closed beta)",
387+
Cell.mediumCell
388+
$ Button.raised
389+
( Button.config
390+
& Button.setIcon (Just "download")
391+
& Button.setOnClick (openBrowser apkLink)
392+
& Button.setAttributes
393+
[ Theme.secondaryBg,
394+
class_ "fill"
395+
]
396+
)
397+
"Download APK",
398+
Cell.mediumCell
399+
$ Button.raised
400+
( Button.config
401+
& Button.setIcon (Just "code")
402+
& Button.setOnClick (openBrowser sourceLink)
403+
& Button.setAttributes
404+
[ Theme.secondaryBg,
405+
class_ "fill"
406+
]
407+
)
408+
"Source",
409+
Cell.mediumCell
410+
$ Button.raised
411+
( Button.config
412+
& Button.setIcon (Just "person")
413+
& Button.setOnClick (openBrowser functoraLink)
414+
& Button.setAttributes
415+
[ Theme.secondaryBg,
416+
class_ "fill"
417+
]
418+
)
419+
"Author",
420+
Cell.mediumCell
421+
$ Button.raised
422+
( Button.config
423+
& Button.setIcon (Just "volunteer_activism")
424+
& Button.setOnClick
425+
( PushUpdate $ do
426+
doc <- liftIO Templates.newDonateDoc
427+
pure
428+
. ChanItem 0
429+
$ (& #modelMenu .~ Closed)
430+
. (& #modelLinks .~ Closed)
431+
. (& #modelLoading .~ True)
432+
. (& #modelState . #stDoc .~ doc)
433+
)
434+
& Button.setAttributes
435+
[ Theme.secondaryBg,
436+
class_ "fill"
437+
]
438+
)
439+
"Donate",
440+
Cell.bigCell
441+
$ Button.raised
442+
( Button.config
443+
& Button.setOnClick closeWidget
444+
& Button.setIcon (Just "arrow_back")
445+
& Button.setAttributes [class_ "fill"]
446+
)
447+
"Back"
448+
]
449+
]
450+
mempty
451+
)
452+
]
453+
)
405454
where
406-
open =
455+
openWidget = pureUpdate 0 (& #modelLinks .~ Opened)
456+
closeWidget = pureUpdate 0 (& #modelLinks .~ Closed)
457+
openBrowser =
407458
Misc.openBrowserPageAction
408459
. either impureThrow id
409460
. URI.mkURI

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ newModel webOpts mSt uri = do
100100
Model
101101
{ modelFav = Closed,
102102
modelMenu = Closed,
103+
modelLinks = Closed,
103104
modelLoading = True,
104105
modelState = st,
105106
modelMarket = market,

0 commit comments

Comments
 (0)