|
1 | 1 | module App.Widgets.Main (mainWidget) where
|
2 | 2 |
|
3 |
| -import qualified App.Misc as Misc |
4 | 3 | import App.Types
|
5 | 4 | import qualified App.Widgets.Decrypt as Decrypt
|
6 | 5 | import qualified App.Widgets.Menu as Menu
|
7 |
| -import qualified App.Widgets.SwapAmounts as SwapAmounts |
8 |
| -import qualified App.Widgets.SwapCurrencies as SwapCurrencies |
9 | 6 | import qualified Functora.Miso.Css as Css
|
10 |
| -import qualified Functora.Miso.Jsm as Jsm |
11 | 7 | import Functora.Miso.Prelude
|
12 | 8 | import qualified Functora.Miso.Widgets.BrowserLink as BrowserLink
|
13 |
| -import qualified Functora.Miso.Widgets.Currency as Currency |
14 | 9 | import qualified Functora.Miso.Widgets.Field as Field
|
15 | 10 | import qualified Functora.Miso.Widgets.FieldPairs as FieldPairs
|
16 | 11 | import qualified Functora.Miso.Widgets.Header as Header
|
17 | 12 | import qualified Functora.Miso.Widgets.Qr as Qr
|
18 |
| -import Functora.Money hiding (Text) |
19 | 13 | import qualified Material.Button as Button
|
20 | 14 | import qualified Material.LayoutGrid as LayoutGrid
|
21 | 15 | import qualified Material.Theme as Theme
|
@@ -120,140 +114,25 @@ screenWidget st@Model {modelState = St {stScreen = QrCode sc}} =
|
120 | 114 | ]
|
121 | 115 | )
|
122 | 116 | screenWidget st@Model {modelState = St {stScreen = Converter}} =
|
123 |
| - let amountWidget' loc = |
124 |
| - Field.ratioField |
| 117 | + FieldPairs.fieldPairsViewer |
| 118 | + FieldPairs.Args |
| 119 | + { FieldPairs.argsModel = st, |
| 120 | + FieldPairs.argsOptic = #modelState . #stDoc . #stDocFieldPairs, |
| 121 | + FieldPairs.argsAction = PushUpdate . Instant |
| 122 | + } |
| 123 | + <> [ Field.textField |
125 | 124 | Field.Args
|
126 | 125 | { Field.argsModel = st,
|
127 |
| - Field.argsOptic = Misc.getConverterAmountOptic loc, |
128 |
| - Field.argsAction = PushUpdate . Instant |
| 126 | + Field.argsOptic = #modelState . #stDoc . #stDocLnInvoice, |
| 127 | + Field.argsAction = PushUpdate . Delayed 300 |
129 | 128 | }
|
130 | 129 | ( Field.defOpts @Model @Action
|
131 |
| - & #optsOnInputAction |
132 |
| - .~ Just |
133 |
| - ( PushUpdate |
134 |
| - . Delayed 300 |
135 |
| - . ( >=> |
136 |
| - pure |
137 |
| - . ( & |
138 |
| - #modelState |
139 |
| - . #stDoc |
140 |
| - . #stDocTopOrBottom |
141 |
| - .~ loc |
142 |
| - ) |
143 |
| - ) |
144 |
| - ) |
| 130 | + & #optsFullWidth |
| 131 | + .~ True |
145 | 132 | & #optsPlaceholder
|
146 |
| - .~ ( st |
147 |
| - ^. cloneLens (Misc.getConverterCurrencyOptic loc) |
148 |
| - . #currencyOutput |
149 |
| - . to (inspectCurrencyInfo @MisoString) |
150 |
| - ) |
| 133 | + .~ "Lightning Invoice" |
151 | 134 | )
|
152 |
| - currencyWidget' tob = |
153 |
| - Currency.selectCurrency |
154 |
| - Currency.Args |
155 |
| - { Currency.argsModel = st, |
156 |
| - Currency.argsOptic = Misc.getConverterCurrencyOptic tob, |
157 |
| - Currency.argsAction = PushUpdate . Instant, |
158 |
| - Currency.argsCurrencies = #modelCurrencies |
159 |
| - } |
160 |
| - Currency.Opts |
161 |
| - { Currency.optsExtraOnClick = (& #modelLoading .~ True) |
162 |
| - } |
163 |
| - in ( FieldPairs.fieldPairsViewer |
164 |
| - FieldPairs.Args |
165 |
| - { FieldPairs.argsModel = st, |
166 |
| - FieldPairs.argsOptic = |
167 |
| - #modelState |
168 |
| - . #stDoc |
169 |
| - . #stDocFieldPairs, |
170 |
| - FieldPairs.argsAction = PushUpdate . Instant |
171 |
| - } |
172 |
| - ) |
173 |
| - <> [ amountWidget' Top, |
174 |
| - currencyWidget' Top, |
175 |
| - amountWidget' Bottom, |
176 |
| - currencyWidget' Bottom, |
177 |
| - SwapAmounts.swapAmounts, |
178 |
| - SwapCurrencies.swapCurrencies, |
179 |
| - ratesWidget st |
180 |
| - ] |
181 |
| - |
182 |
| -ratesWidget :: Model -> View Action |
183 |
| -ratesWidget st = |
184 |
| - LayoutGrid.cell |
185 |
| - [ LayoutGrid.span12, |
186 |
| - Typography.caption, |
187 |
| - style_ |
188 |
| - $ [("text-align", "center")] |
189 |
| - <> ( case oof of |
190 |
| - Offline -> [("color", "#B00020")] |
191 |
| - Online -> mempty |
192 |
| - ) |
193 |
| - ] |
194 |
| - [ a_ |
195 |
| - [ style_ [("cursor", "pointer")], |
196 |
| - onClick . PushUpdate . Instant $ Jsm.shareText msg |
197 |
| - ] |
198 |
| - [ Miso.text msg |
199 |
| - ] |
200 |
| - ] |
201 |
| - where |
202 |
| - oof = st ^. #modelState . #stDoc . #stDocOnlineOrOffline |
203 |
| - top = st ^. #modelState . #stDoc . #stDocTopMoney |
204 |
| - topAmt = top ^. #moneyAmount . #fieldOutput |
205 |
| - topCur = |
206 |
| - top |
207 |
| - ^. #moneyCurrency |
208 |
| - . #currencyOutput |
209 |
| - . #currencyInfoCode |
210 |
| - . #unCurrencyCode |
211 |
| - . to toMisoString |
212 |
| - bottom = st ^. #modelState . #stDoc . #stDocBottomMoney |
213 |
| - bottomAmt = bottom ^. #moneyAmount . #fieldOutput |
214 |
| - bottomCur = |
215 |
| - bottom |
216 |
| - ^. #moneyCurrency |
217 |
| - . #currencyOutput |
218 |
| - . #currencyInfoCode |
219 |
| - . #unCurrencyCode |
220 |
| - . to toMisoString |
221 |
| - bottomPerTop = |
222 |
| - if topAmt == 0 |
223 |
| - then 0 |
224 |
| - else bottomAmt / topAmt |
225 |
| - topPerBottom = |
226 |
| - if bottomAmt == 0 |
227 |
| - then 0 |
228 |
| - else topAmt / bottomAmt |
229 |
| - msg = |
230 |
| - inspect oof |
231 |
| - <> " exchange rates" |
232 |
| - <> ( case oof of |
233 |
| - Offline -> mempty |
234 |
| - Online -> |
235 |
| - " on " |
236 |
| - <> ( st |
237 |
| - ^. #modelState |
238 |
| - . #stDoc |
239 |
| - . #stDocCreatedAt |
240 |
| - . to utctDay |
241 |
| - . to inspect |
242 |
| - ) |
243 |
| - ) |
244 |
| - <> ": 1 " |
245 |
| - <> topCur |
246 |
| - <> " \8776 " |
247 |
| - <> inspectRatioDef bottomPerTop |
248 |
| - <> " " |
249 |
| - <> bottomCur |
250 |
| - <> ", 1 " |
251 |
| - <> bottomCur |
252 |
| - <> " \8776 " |
253 |
| - <> inspectRatioDef topPerBottom |
254 |
| - <> " " |
255 |
| - <> topCur |
256 |
| - <> "." |
| 135 | + ] |
257 | 136 |
|
258 | 137 | tosWidget :: View Action
|
259 | 138 | tosWidget =
|
|
0 commit comments