enter.nim 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import
  2. ../server_api/api,
  3. asyncdispatch,
  4. nodesnim
  5. var
  6. gradient = GradientDrawable()
  7. gradient.setCornerColors(Color("#cac"), Color("#cac"), Color("#acc"), Color("#acc"))
  8. build:
  9. - Scene (enter_scene):
  10. - Control background:
  11. call setSizeAnchor(1, 1)
  12. call setBackground(gradient)
  13. - VBox input:
  14. separator: 8
  15. call:
  16. setAnchor(0.5, 0.5, 0.5, 0.5)
  17. setChildAnchor(0.5, 0.5, 0.5, 0.5)
  18. resize(256, 256+64)
  19. setStyle(style({
  20. border-radius: 8,
  21. border-detail: 8,
  22. background-color: rgba(100, 111, 122, 0.4)
  23. }))
  24. - EditText login:
  25. caret: false
  26. call:
  27. setTextAlign(0.5, 0.5, 0.5, 0.5)
  28. setHint("Username")
  29. setHintColor(Color("#ebebeb"))
  30. setTextColor(Color("#fff"))
  31. setStyle(style({
  32. border-radius: 8,
  33. border-detail: 8,
  34. border-color: rgba(100, 111, 122, 0.4),
  35. border-width: 1
  36. }))
  37. - Button send:
  38. call setText("ENTER")
  39. send.normal_background.setStyle(style({
  40. border-radius: 8,
  41. border-detail: 8,
  42. background-color: rgba(100, 111, 122, 0.4),
  43. background-width: 1
  44. }))
  45. send.hover_background.setStyle(style({
  46. border-radius: 8,
  47. border-detail: 8,
  48. background-color: rgba(100, 111, 122, 0.6),
  49. background-width: 1
  50. }))
  51. send.press_background.setStyle(style({
  52. border-radius: 8,
  53. border-detail: 8,
  54. background-color: rgba(100, 111, 122, 0.8),
  55. background-width: 1
  56. }))
  57. send@onClick(self, x, y):
  58. username = login.getText()
  59. if username.len > 0:
  60. var response = waitFor enter()
  61. if response:
  62. changeScene("chat_scene")