@@ -9,7 +9,7 @@ use crate::app::stroke::content::StrokeState;
99use iced:: event:: Event as MainEvent ;
1010use iced:: keyboard:: key:: Named ;
1111use iced:: keyboard:: Key ;
12- use iced:: widget:: { vertical_rule , Space } ;
12+ use iced:: widget:: { rule , Space } ;
1313use iced:: widget:: { Button , Column , Container , Row , Text } ;
1414use iced:: { keyboard, Alignment , Element , Length } ;
1515use iced:: { Subscription , Task } ;
@@ -118,16 +118,13 @@ impl EditorApp {
118118 }
119119
120120 pub fn subscription ( & self ) -> Subscription < AppMessage > {
121- keyboard:: on_key_press ( |key, _mods| {
122- match key. as_ref ( ) {
123- Key :: Named ( Named :: ArrowDown ) => {
124- Some ( AppMessage :: NextTest )
125- }
126- Key :: Named ( Named :: ArrowUp ) => {
127- Some ( AppMessage :: PrevTest )
128- }
121+ keyboard:: listen ( ) . filter_map ( |event| match event {
122+ keyboard:: Event :: KeyPressed { key, .. } => match key {
123+ Key :: Named ( Named :: ArrowDown ) => Some ( AppMessage :: NextTest ) ,
124+ Key :: Named ( Named :: ArrowUp ) => Some ( AppMessage :: PrevTest ) ,
129125 _ => None ,
130- }
126+ } ,
127+ _ => None ,
131128 } )
132129 }
133130
@@ -145,7 +142,7 @@ impl EditorApp {
145142 }
146143 }
147144
148- pub fn view ( & self ) -> Element < AppMessage > {
145+ pub fn view ( & self ) -> Element < ' _ , AppMessage > {
149146 let content = Row :: new ( ) . push (
150147 Container :: new ( self . main_navigation ( ) )
151148 . width ( Length :: Fixed ( 160.0 ) )
@@ -155,25 +152,29 @@ impl EditorApp {
155152
156153 let content = match self . state . selected_action {
157154 MainAction :: Boolean => content
158- . push ( vertical_rule ( 1 ) . style ( style_separator) )
155+ . push ( rule :: vertical ( 1 ) . style ( style_separator) )
159156 . push ( self . boolean_content ( ) ) ,
160157 MainAction :: String => content
161- . push ( vertical_rule ( 1 ) . style ( style_separator) )
158+ . push ( rule :: vertical ( 1 ) . style ( style_separator) )
162159 . push ( self . string_content ( ) ) ,
163160 MainAction :: Stroke => content
164- . push ( vertical_rule ( 1 ) . style ( style_separator) )
161+ . push ( rule :: vertical ( 1 ) . style ( style_separator) )
165162 . push ( self . stroke_content ( ) ) ,
166163 MainAction :: Outline => content
167- . push ( vertical_rule ( 1 ) . style ( style_separator) )
164+ . push ( rule :: vertical ( 1 ) . style ( style_separator) )
168165 . push ( self . outline_content ( ) ) ,
169166 } ;
170167
171168 content. height ( Length :: Fill ) . into ( )
172169 }
173170
174- fn main_navigation ( & self ) -> Column < AppMessage > {
171+ fn main_navigation ( & self ) -> Column < ' _ , AppMessage > {
175172 self . main_actions . iter ( ) . fold (
176- Column :: new ( ) . push ( Space :: new ( Length :: Fill , Length :: Fixed ( 2.0 ) ) ) ,
173+ Column :: new ( ) . push (
174+ Space :: new ( )
175+ . width ( Length :: Fill )
176+ . height ( Length :: Fixed ( 2.0 ) ) ,
177+ ) ,
177178 |column, item| {
178179 let is_selected = self . state . selected_action . eq ( item) ;
179180 column. push (
0 commit comments