enter.nim 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 setStyle(style({
  28. border-radius: 8,
  29. border-detail: 8,
  30. border-color: rgba(100, 111, 122, 0.4),
  31. border-width: 1
  32. }))
  33. - Button send:
  34. call setText("ENTER")
  35. send.normal_background.setStyle(style({
  36. border-radius: 8,
  37. border-detail: 8,
  38. background-color: rgba(100, 111, 122, 0.4),
  39. background-width: 1
  40. }))
  41. send.hover_background.setStyle(style({
  42. border-radius: 8,
  43. border-detail: 8,
  44. background-color: rgba(100, 111, 122, 0.6),
  45. background-width: 1
  46. }))
  47. send.press_background.setStyle(style({
  48. border-radius: 8,
  49. border-detail: 8,
  50. background-color: rgba(100, 111, 122, 0.8),
  51. background-width: 1
  52. }))
  53. login.hint = stext"Username"
  54. login.hint.setColor(Color("#ebebeb"))
  55. login.text.setColor(Color("#fff"))
  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")