@@ -215,6 +215,11 @@ live_design! {
215215
216216static MATRIX_SIGN_UP_URL : & str = "https://matrix.org/docs/chat_basics/matrix-for-im/#creating-a-matrix-account" ;
217217
218+ // An unfortunate hack we must do to get the colors to work in Rust code.
219+ const COLOR_DANGER_RED : Vec4 = Vec4 { x : 220f32 /255f32 , y : 0f32 , z : 5f32 /255f32 , w : 1f32 } ;
220+ const COLOR_ACCEPT_GREEN : Vec4 = Vec4 { x : 19f32 /255f32 , y : 136f32 /255f32 , z : 8f32 /255f32 , w : 1f32 } ;
221+ const MESSAGE_TEXT_COLOR : Vec4 = Vec4 { x : 68f32 /255f32 , y : 68f32 /255f32 , z : 68f32 /255f32 , w : 1f32 } ;
222+
218223#[ derive( Live , LiveHook , Widget ) ]
219224pub struct LoginScreen {
220225 #[ deref] view : View ,
@@ -241,8 +246,14 @@ impl Widget for LoginScreen {
241246 let password = password_input. text ( ) ;
242247 let homeserver = homeserver_input. text ( ) ;
243248 if user_id. is_empty ( ) || password. is_empty ( ) {
249+ status_label. apply_over ( cx, live ! {
250+ draw_text: { color: ( COLOR_DANGER_RED ) }
251+ } ) ;
244252 status_label. set_text ( "Please enter both User ID and Password." ) ;
245253 } else {
254+ status_label. apply_over ( cx, live ! {
255+ draw_text: { color: ( MESSAGE_TEXT_COLOR ) }
256+ } ) ;
246257 status_label. set_text ( "Waiting for login response..." ) ;
247258 submit_async_request ( MatrixRequest :: Login ( LoginRequest {
248259 user_id,
@@ -260,6 +271,9 @@ impl Widget for LoginScreen {
260271 }
261272 Some ( LoginAction :: Status ( status) ) => {
262273 status_label. set_text ( status) ;
274+ status_label. apply_over ( cx, live ! {
275+ draw_text: { color: ( MESSAGE_TEXT_COLOR ) }
276+ } ) ;
263277 self . redraw ( cx) ;
264278 }
265279 Some ( LoginAction :: LoginSuccess ) => {
@@ -269,10 +283,16 @@ impl Widget for LoginScreen {
269283 password_input. set_text ( "" ) ;
270284 homeserver_input. set_text ( "" ) ;
271285 status_label. set_text ( "Login successful!" ) ;
286+ status_label. apply_over ( cx, live ! {
287+ draw_text: { color: ( COLOR_ACCEPT_GREEN ) }
288+ } ) ;
272289 self . redraw ( cx) ;
273290 }
274291 Some ( LoginAction :: LoginFailure ( error) ) => {
275292 status_label. set_text ( error) ;
293+ status_label. apply_over ( cx, live ! {
294+ draw_text: { color: ( COLOR_DANGER_RED ) }
295+ } ) ;
276296 self . redraw ( cx) ;
277297 }
278298 _ => { }
0 commit comments