@@ -110,12 +110,7 @@ screenWidget st@Model {modelState = St {stScreen = QrCode sc}} =
110
110
]
111
111
)
112
112
screenWidget st@ Model {modelState = St {stScreen = Converter }} =
113
- let oof =
114
- st
115
- ^. # modelState
116
- . # stDoc
117
- . # stDocOnlineOrOffline
118
- amountWidget' loc =
113
+ let amountWidget' loc =
119
114
Field. ratioField
120
115
st
121
116
( Misc. getConverterAmountOptic loc
@@ -153,34 +148,83 @@ screenWidget st@Model {modelState = St {stScreen = Converter}} =
153
148
currencyWidget' Bottom ,
154
149
SwapAmounts. swapAmounts,
155
150
Currency. swapCurrencies,
156
- LayoutGrid. cell
157
- [ LayoutGrid. span12,
158
- Typography. caption,
159
- style_
160
- $ [(" text-align" , " center" )]
161
- <> ( if oof == Offline
162
- then [(" color" , " #B00020" )]
163
- else mempty
164
- )
165
- ]
166
- [ Miso. text
167
- $ inspect oof
168
- <> " exchange rate"
169
- <> ( case oof of
170
- Offline -> mempty
171
- Online ->
172
- " on "
173
- <> ( st
174
- ^. # modelState
175
- . # stDoc
176
- . # stDocCreatedAt
177
- . to utctDay
178
- . to inspect
179
- )
180
- )
181
- ]
151
+ ratesWidget st
182
152
]
183
153
154
+ ratesWidget :: Model -> View Action
155
+ ratesWidget st =
156
+ LayoutGrid. cell
157
+ [ LayoutGrid. span12,
158
+ Typography. caption,
159
+ style_
160
+ $ [(" text-align" , " center" )]
161
+ <> ( case oof of
162
+ Offline -> [(" color" , " #B00020" )]
163
+ Online -> mempty
164
+ )
165
+ ]
166
+ [ a_
167
+ [ style_ [(" cursor" , " pointer" )],
168
+ onClick $ Misc. copyIntoClipboardAction st msg
169
+ ]
170
+ [ Miso. text msg
171
+ ]
172
+ ]
173
+ where
174
+ oof = st ^. # modelState . # stDoc . # stDocOnlineOrOffline
175
+ top = st ^. # modelState . # stDoc . # stDocTopMoney
176
+ topAmt = top ^. # moneyAmount . # fieldOutput
177
+ topCur =
178
+ top
179
+ ^. # moneyCurrency
180
+ . # currencyOutput
181
+ . # currencyInfoCode
182
+ . # unCurrencyCode
183
+ bottom = st ^. # modelState . # stDoc . # stDocBottomMoney
184
+ bottomAmt = bottom ^. # moneyAmount . # fieldOutput
185
+ bottomCur =
186
+ bottom
187
+ ^. # moneyCurrency
188
+ . # currencyOutput
189
+ . # currencyInfoCode
190
+ . # unCurrencyCode
191
+ bottomPerTop =
192
+ if topAmt == 0
193
+ then 0
194
+ else bottomAmt / topAmt
195
+ topPerBottom =
196
+ if bottomAmt == 0
197
+ then 0
198
+ else topAmt / bottomAmt
199
+ msg =
200
+ inspect oof
201
+ <> " exchange rates"
202
+ <> ( case oof of
203
+ Offline -> mempty
204
+ Online ->
205
+ " on "
206
+ <> ( st
207
+ ^. # modelState
208
+ . # stDoc
209
+ . # stDocCreatedAt
210
+ . to utctDay
211
+ . to inspect
212
+ )
213
+ )
214
+ <> " : 1 "
215
+ <> topCur
216
+ <> " \8776 "
217
+ <> inspectRatioDef bottomPerTop
218
+ <> " "
219
+ <> bottomCur
220
+ <> " , 1 "
221
+ <> bottomCur
222
+ <> " \8776 "
223
+ <> inspectRatioDef topPerBottom
224
+ <> " "
225
+ <> topCur
226
+ <> " ."
227
+
184
228
tosWidget :: View Action
185
229
tosWidget =
186
230
LayoutGrid. cell
0 commit comments