Skip to content

Commit 6dc3470

Browse files
committed
better fav wip
1 parent e3caf6d commit 6dc3470

File tree

3 files changed

+60
-36
lines changed

3 files changed

+60
-36
lines changed

ghcjs/lightning-verifier/src/App/Widgets/Fav.hs

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import qualified Functora.Miso.Widgets.Field as Field
1414
import qualified Functora.Miso.Widgets.Grid as Grid
1515
import qualified Material.Button as Button
1616
import qualified Material.Dialog as Dialog
17-
import qualified Material.Theme as Theme
1817
import qualified Text.URI as URI
1918

2019
fav :: Model -> [View Action]
@@ -32,46 +31,31 @@ fav st =
3231
[ Grid.grid
3332
mempty
3433
$ favItems st
35-
<> [ Grid.mediumCell
34+
<> [ Grid.bigCell
3635
$ Field.textField
3736
Field.Args
3837
{ Field.argsModel = st,
3938
Field.argsOptic = #modelFavName,
4039
Field.argsAction = PushUpdate . Instant
4140
}
42-
( Field.defOpts
43-
& #optsPlaceholder
44-
.~ ( let name = makeFavName st
45-
in "Name"
46-
<> ( if name == mempty
47-
then mempty
48-
else " - "
49-
)
50-
<> name
51-
)
52-
),
53-
Grid.smallCell
54-
$ Button.raised
55-
( Button.config
56-
& Button.setOnClick saveAction
57-
& Button.setIcon (Just "favorite")
58-
& Button.setAttributes
59-
[ Theme.secondaryBg,
60-
Css.fullWidth
61-
]
62-
)
63-
"Save",
64-
Grid.smallCell
65-
$ Button.raised
66-
( Button.config
67-
& Button.setOnClick deleteAction
68-
& Button.setIcon (Just "delete_forever")
69-
& Button.setAttributes
70-
[ Theme.secondaryBg,
71-
Css.fullWidth
72-
]
73-
)
74-
"Delete",
41+
Field.defOpts
42+
{ Field.optsPlaceholder = "Name",
43+
Field.optsFilledOrOutlined = Outlined,
44+
Field.optsOnKeyDownAction = onKeyDownAction,
45+
Field.optsTrailingWidget =
46+
Just
47+
. Field.ActionWidget
48+
"favorite"
49+
mempty
50+
. PushUpdate
51+
$ Instant saveAction,
52+
Field.optsLeadingWidget =
53+
Just
54+
$ Field.ActionWidget
55+
"delete_forever"
56+
mempty
57+
deleteAction
58+
},
7559
Grid.bigCell
7660
$ Button.raised
7761
( Button.config
@@ -87,7 +71,7 @@ fav st =
8771
]
8872
where
8973
closeAction = PushUpdate . Instant $ pure . (& #modelFav .~ Closed)
90-
saveAction = PushUpdate . Instant $ \nextSt -> do
74+
saveAction nextSt = do
9175
ct <- getCurrentTime
9276
let txt = makeFavName st
9377
let uri = either impureThrow id . URI.mkURI $ shareLink nextSt
@@ -122,6 +106,10 @@ fav st =
122106
& #modelFavMap
123107
. at nextFavName
124108
.~ Nothing
109+
onKeyDownAction uid code =
110+
if code == KeyCode 13
111+
then saveAction
112+
else Jsm.enterOrEscapeBlur uid code
125113

126114
makeFavName :: Model -> MisoString
127115
makeFavName st =

ghcjs/miso-widgets/shell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ in
1919
functora-pkgs.libwebp
2020
functora-pkgs.nodejs
2121
functora-pkgs.terser
22+
functora-pkgs.secp256k1
2223
]
2324
++ prev.buildInputs
2425
++ pkgs.lib.lists.take (pkgs.lib.lists.length functora-tools - 1)

pub/functora/src/test/Functora/Bolt11Spec.hs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,41 @@ goodSamples =
8282
bolt11SigRecoveryFlag = 0
8383
}
8484
}
85+
),
86+
( "lnbc2500u1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpu9qrsgquk0rl77nj30yxdy8j9vdx85fkpmdla2087ne0xh8nhedh8w27kyke0lp53ut353s06fv3qfegext0eh0ymjpf39tuven09sam30g4vgpfna3rh",
87+
Bolt11
88+
{ bolt11Hrp =
89+
Bolt11Hrp
90+
{ bolt11HrpNet = BitcoinMainnet,
91+
bolt11HrpAmt =
92+
Just (Bolt11HrpAmt {bolt11HrpAmtNum = 2500, bolt11HrpAmtMul = Micro})
93+
},
94+
bolt11Timestamp = 1496314658,
95+
bolt11Tags =
96+
[ PaymentSecret "1111111111111111111111111111111111111111111111111111111111111111",
97+
PaymentHash "0001020304050607080900010203040506070809000102030405060708090102",
98+
Description "1 cup coffee",
99+
Expiry 60,
100+
Features
101+
[ Feature
102+
{ featureBits = 8,
103+
featureName = Var_onion_optin,
104+
featureRequiredOrSuported = Required
105+
},
106+
Feature
107+
{ featureBits = 14,
108+
featureName = Payment_secret,
109+
featureRequiredOrSuported = Required
110+
}
111+
]
112+
],
113+
bolt11Signature =
114+
Bolt11Sig
115+
{ bolt11SigVal =
116+
"e59e3ffbd3945e4334879158d31e89b076dff54f3fa7979ae79df2db9dcaf5896cbfe1a478b8d2307e92c88139464cb7e6ef26e414c4abe33337961ddc5e8ab1",
117+
bolt11SigRecoveryFlag = 1
118+
}
119+
}
85120
)
86121
]
87122

0 commit comments

Comments
 (0)