Skip to content

Commit 4397c9c

Browse files
committed
fix donate widget
1 parent 472fe26 commit 4397c9c

File tree

7 files changed

+66
-18
lines changed

7 files changed

+66
-18
lines changed

ghcjs/delivery-calculator/delivery-calculator.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ common pkg
1919
App.I18n
2020
App.Jsm
2121
App.Types
22-
App.Widgets.AppLinks
2322
App.Widgets.Asset
23+
App.Widgets.Donate
24+
App.Widgets.GooglePlay
2425
App.Widgets.Main
2526
App.Widgets.MarketLinks
2627
App.Widgets.Menu

ghcjs/delivery-calculator/src/App/Types.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import qualified Text.URI as URI
6464
data Model = Model
6565
{ modelSink :: MVar (Action -> IO ()),
6666
modelMenu :: OpenedOrClosed,
67+
modelDonate :: OpenedOrClosed,
6768
modelAppLinks :: OpenedOrClosed,
6869
modelShareApp :: OpenedOrClosed,
6970
modelPlaceOrder :: OpenedOrClosed,
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
module App.Widgets.Donate (donate) where
2+
3+
import App.Types
4+
import Functora.Miso.Prelude
5+
import qualified Functora.Miso.Widgets.Dialog as Dialog
6+
import qualified Functora.Miso.Widgets.FieldPairs as FieldPairs
7+
import qualified Functora.Miso.Widgets.Icon as Icon
8+
9+
donate :: Model -> [View Action]
10+
donate st =
11+
if not . null $ st ^. #modelState . #stAssets
12+
then mempty
13+
else
14+
( button_
15+
[ onClick openWidget
16+
]
17+
[ icon Icon.IconBitcoin,
18+
text " Donate"
19+
]
20+
)
21+
: Dialog.dialog
22+
( Dialog.defOpts
23+
& #optsTitle
24+
.~ Just ("Donate" :: Unicode)
25+
& #optsFlexCol
26+
.~ False
27+
& #optsTitleIcon
28+
.~ Just Icon.IconBitcoin
29+
)
30+
Dialog.Args
31+
{ Dialog.argsModel = st,
32+
Dialog.argsOptic = #modelDonate,
33+
Dialog.argsAction = PushUpdate,
34+
Dialog.argsContent =
35+
FieldPairs.fieldPairsViewer
36+
FieldPairs.defOpts
37+
FieldPairs.Args
38+
{ FieldPairs.argsModel = st,
39+
FieldPairs.argsOptic = #modelDonateViewer,
40+
FieldPairs.argsAction = PushUpdate,
41+
FieldPairs.argsEmitter = emitter st
42+
}
43+
}
44+
where
45+
openWidget =
46+
PushUpdate
47+
. PureUpdate
48+
$ #modelDonate
49+
.~ Opened

ghcjs/delivery-calculator/src/App/Widgets/AppLinks.hs renamed to ghcjs/delivery-calculator/src/App/Widgets/GooglePlay.hs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
module App.Widgets.AppLinks (appLinks) where
1+
module App.Widgets.GooglePlay (googlePlay) where
22

33
import App.Types
4+
import qualified App.Widgets.Donate as Donate
45
import qualified Functora.Miso.Jsm as Jsm
56
import Functora.Miso.Prelude
67
import qualified Functora.Miso.Widgets.BrowserLink as BrowserLink
78
import qualified Functora.Miso.Widgets.Dialog as Dialog
89
import qualified Functora.Miso.Widgets.Icon as Icon
910

10-
appLinks :: Model -> [View Action]
11-
appLinks st =
11+
googlePlay :: Model -> [View Action]
12+
googlePlay st =
1213
if not . null $ st ^. #modelState . #stAssets
1314
then mempty
1415
else
@@ -91,14 +92,9 @@ appLinks st =
9192
]
9293
[ icon Icon.IconUser,
9394
text " Author"
94-
],
95-
button_
96-
[ onClick $ setScreenAction Donate
97-
]
98-
[ icon Icon.IconBitcoin,
99-
text " Donate"
10095
]
10196
]
97+
<> Donate.donate st
10298
}
10399
where
104100
openWidget =

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

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

33
import App.Types
4-
import qualified App.Widgets.AppLinks as AppLinks
54
import qualified App.Widgets.Asset as Asset
5+
import qualified App.Widgets.GooglePlay as GooglePlay
66
import qualified App.Widgets.MarketLinks as MarketLinks
77
import qualified App.Widgets.Menu as Menu
88
import qualified App.Widgets.PlaceOrder as PlaceOrder
@@ -154,7 +154,7 @@ screenWidget st@Model {modelState = St {stScreen = Main}} =
154154
]
155155
)
156156
: ShareApp.shareApp st
157-
<> AppLinks.appLinks st
157+
<> GooglePlay.googlePlay st
158158
<> RemoveOrder.removeOrder st
159159
<> PlaceOrder.placeOrder st
160160

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ newModel webOpts sink mSt uri = do
2727
Model
2828
{ modelSink = sink,
2929
modelMenu = Closed,
30+
modelDonate = Closed,
3031
modelAppLinks = Closed,
3132
modelShareApp = Closed,
3233
modelPlaceOrder = Closed,
@@ -45,19 +46,19 @@ newModel webOpts sink mSt uri = do
4546

4647
newDonateViewer :: (MonadIO m) => m [FieldPair DynamicField Unique]
4748
newDonateViewer = do
48-
title <- newFieldPair mempty $ DynamicFieldText "Hello, User!"
49-
message <- newFieldPair mempty $ DynamicFieldText exampleDonationText
49+
message <- newFieldPair "Hello, User!" $ DynamicFieldText exampleDonationText
5050
btcMtd <- newFieldPair "BTC - Bitcoin" $ DynamicFieldText exampleBtcAddress
5151
xmrMtd <- newFieldPair "XMR - Monero" $ DynamicFieldText exampleXmrAddress
5252
pure
53-
[ title & #fieldPairValue . #fieldType .~ FieldTypeTitle,
54-
message,
53+
[ noTrunc message,
5554
qr btcMtd,
5655
qr xmrMtd
5756
]
5857
where
5958
qr :: FieldPair a b -> FieldPair a b
60-
qr = (& #fieldPairValue . #fieldType .~ FieldTypeQrCode)
59+
qr = noTrunc . (#fieldPairValue . #fieldType .~ FieldTypeQrCode)
60+
noTrunc :: FieldPair a b -> FieldPair a b
61+
noTrunc = #fieldPairValue . #fieldOpts . #fieldOptsTruncateLimit .~ Nothing
6162

6263
exampleBtcAddress :: Unicode
6364
exampleBtcAddress = "bc1qa3qk8d4mxl6qkpvahl5xvg6c5k33kmuwvt9v8q"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ header txt =
723723
if txt == mempty
724724
then mempty
725725
else
726-
[ div_
726+
[ dt_
727727
[ style_ [("text-align", "center")]
728728
]
729729
[ text txt

0 commit comments

Comments
 (0)