@@ -14,7 +14,6 @@ import qualified Functora.Miso.Widgets.Field as Field
14
14
import qualified Functora.Miso.Widgets.Grid as Grid
15
15
import qualified Material.Button as Button
16
16
import qualified Material.Dialog as Dialog
17
- import qualified Material.Theme as Theme
18
17
import qualified Text.URI as URI
19
18
20
19
fav :: Model -> [View Action ]
@@ -32,46 +31,31 @@ fav st =
32
31
[ Grid. grid
33
32
mempty
34
33
$ favItems st
35
- <> [ Grid. mediumCell
34
+ <> [ Grid. bigCell
36
35
$ Field. textField
37
36
Field. Args
38
37
{ Field. argsModel = st,
39
38
Field. argsOptic = # modelFavName,
40
39
Field. argsAction = PushUpdate . Instant
41
40
}
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
+ },
75
59
Grid. bigCell
76
60
$ Button. raised
77
61
( Button. config
@@ -87,7 +71,7 @@ fav st =
87
71
]
88
72
where
89
73
closeAction = PushUpdate . Instant $ pure . (& # modelFav .~ Closed )
90
- saveAction = PushUpdate . Instant $ \ nextSt -> do
74
+ saveAction nextSt = do
91
75
ct <- getCurrentTime
92
76
let txt = makeFavName st
93
77
let uri = either impureThrow id . URI. mkURI $ shareLink nextSt
@@ -122,6 +106,10 @@ fav st =
122
106
& # modelFavMap
123
107
. at nextFavName
124
108
.~ Nothing
109
+ onKeyDownAction uid code =
110
+ if code == KeyCode 13
111
+ then saveAction
112
+ else Jsm. enterOrEscapeBlur uid code
125
113
126
114
makeFavName :: Model -> MisoString
127
115
makeFavName st =
0 commit comments