@@ -8,6 +8,7 @@ module App.Types
8
8
newSt ,
9
9
Asset (.. ),
10
10
newAsset ,
11
+ newFieldPair ,
11
12
Screen (.. ),
12
13
isQrCode ,
13
14
unQrCode ,
@@ -36,7 +37,8 @@ import Data.Functor.Barbie
36
37
import qualified Data.Version as Version
37
38
import Functora.Cfg
38
39
import Functora.Miso.Prelude
39
- import Functora.Miso.Types as X hiding (Asset (.. ), newAsset )
40
+ import Functora.Miso.Types as X hiding (Asset (.. ), newAsset , newFieldPair )
41
+ import qualified Functora.Miso.Types as FM
40
42
import Functora.Money hiding (Currency , Money , Text )
41
43
import qualified Functora.Prelude as Prelude
42
44
import qualified Functora.Rates as Rates
@@ -123,11 +125,8 @@ newSt = do
123
125
}
124
126
125
127
data Asset f = Asset
126
- { assetLink :: Field Unicode f ,
127
- assetPhoto :: Field Unicode f ,
128
- assetPrice :: Field Rational f ,
129
- assetQty :: Field Rational f ,
130
- assetOoc :: OpenedOrClosed
128
+ { assetFieldPairs :: [FieldPair DynamicField f ],
129
+ assetModalState :: OpenedOrClosed
131
130
}
132
131
deriving stock (Generic )
133
132
@@ -147,19 +146,37 @@ deriving via GenericType (Asset Identity) instance Binary (Asset Identity)
147
146
148
147
newAsset :: (MonadIO m ) => m (Asset Unique )
149
148
newAsset = do
150
- link <- newTextField mempty
151
- photo <- newTextField mempty
152
- price <- newRatioField 0
153
- qty <- newRatioField 1
149
+ link <-
150
+ newFieldPair " Link"
151
+ $ DynamicFieldText " https://bitcoin.org/en/"
152
+ photo <-
153
+ newFieldPair " Photo"
154
+ $ DynamicFieldText " https://bitcoin.org/img/home/bitcoin-img.svg?1725887272"
155
+ price <-
156
+ newFieldPair " Price" $ DynamicFieldNumber 0
157
+ qty <-
158
+ newFieldPair " Quantity" $ DynamicFieldNumber 1
154
159
pure
155
160
Asset
156
- { assetLink = link,
157
- assetPhoto = photo,
158
- assetPrice = price,
159
- assetQty = qty,
160
- assetOoc = Opened
161
+ { assetFieldPairs = [link, photo, price, qty],
162
+ assetModalState = Opened
161
163
}
162
164
165
+ newFieldPair ::
166
+ ( MonadIO m
167
+ ) =>
168
+ Unicode ->
169
+ DynamicField ->
170
+ m (FieldPair DynamicField Unique )
171
+ newFieldPair key val = do
172
+ res <- FM. newFieldPair key val
173
+ pure
174
+ $ res
175
+ & # fieldPairValue
176
+ . # fieldOpts
177
+ . # fieldOptsQrState
178
+ .~ Nothing
179
+
163
180
data Screen
164
181
= Main
165
182
| Donate
0 commit comments