enter.nim 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. call rename("Enter")
  11. - Control background:
  12. call setSizeAnchor(1, 1)
  13. call setBackground(gradient)
  14. - VBox input:
  15. separator: 8
  16. call setAnchor(0.5, 0.5, 0.5, 0.5)
  17. call setChildAnchor(0.5, 0.5, 0.5, 0.5)
  18. call resize(256, 256+64)
  19. call 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 setTextAlign(0.5, 0.5, 0.5, 0.5)
  27. call setHint("Username")
  28. call setHintColor(Color("#ebebeb"))
  29. call setTextColor(Color("#fff"))
  30. call setStyle(style({
  31. border-radius: 8,
  32. border-detail: 8,
  33. border-color: rgba(100, 111, 122, 0.4),
  34. border-width: 1
  35. }))
  36. - Button send:
  37. call setText("ENTER")
  38. send.normal_background.setStyle(style({
  39. border-radius: 8,
  40. border-detail: 8,
  41. background-color: rgba(100, 111, 122, 0.4),
  42. background-width: 1
  43. }))
  44. send.hover_background.setStyle(style({
  45. border-radius: 8,
  46. border-detail: 8,
  47. background-color: rgba(100, 111, 122, 0.6),
  48. background-width: 1
  49. }))
  50. send.press_background.setStyle(style({
  51. border-radius: 8,
  52. border-detail: 8,
  53. background-color: rgba(100, 111, 122, 0.8),
  54. background-width: 1
  55. }))
  56. send@onClick(self, x, y):
  57. username = login.getText()
  58. if username.len > 0:
  59. var response = waitFor enter()
  60. if response:
  61. changeScene("Chat")