main.swift 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import Foundation
  2. import ark_ui_basic
  3. // In a real framework, ark_ui_basic would automatically use ArkGraphics as a render backend.
  4. // For now, we simulate the backend processing the SwiftUI View graph.
  5. struct AppUI: View {
  6. var body: some View {
  7. ZStack {
  8. Color.blue
  9. Button(action: {
  10. print("Button tapped")
  11. }) {
  12. Color.blue
  13. }
  14. .background(Color.blue)
  15. }
  16. }
  17. }
  18. struct UITestApp {
  19. static let fontMap: [Character: [String]] = [
  20. "S": [".###.", "#...#", "#....", ".###.", "....#", "#...#", ".###."],
  21. "t": [".#...", ".###.", ".#...", ".#...", ".#...", ".#..#", "..##."],
  22. "a": [".....", ".....", ".###.", "....#", ".####", "#...#", ".####"],
  23. "r": [".....", ".....", "#.##.", "##..#", "#....", "#....", "#...."],
  24. "G": [".###.", "#...#", "#....", "#.###", "#...#", "#...#", ".###."],
  25. "e": [".....", ".....", ".###.", "#...#", "#####", "#....", ".###."],
  26. "s": [".....", ".....", ".###.", "#....", ".###.", "....#", ".###."],
  27. "d": ["....#", "....#", ".####", "#...#", "#...#", "#...#", ".####"],
  28. "-": [".....", ".....", ".....", "#####", ".....", ".....", "....."],
  29. ">": ["#....", ".#...", "..#..", "...#.", "..#..", ".#...", "#...."],
  30. " ": [".....", ".....", ".....", ".....", ".....", ".....", "....."]
  31. ]
  32. static func drawText(_ graphics: ArkGraphics, _ text: String, x: Int, y: Int, size: Int, r: UInt8, g: UInt8, b: UInt8) {
  33. var cursorX = x
  34. for char in text {
  35. if let lines = fontMap[char] {
  36. for (row, line) in lines.enumerated() {
  37. var cursorY = y + (row * size)
  38. for (col, pixel) in line.enumerated() {
  39. if pixel == "#" {
  40. graphics.fillRectRGB(x: cursorX + (col * size), y: cursorY, w: size, h: size, r: r, g: g, b: b)
  41. }
  42. }
  43. }
  44. }
  45. cursorX += 6 * size
  46. }
  47. }
  48. static func main() {
  49. print("ui_test: Starting OS Native UI App (Waiting for splash...)")
  50. sleep(4) // Wait for atom splash animation to finish (approx 3.8s)
  51. let graphics = ArkGraphics()
  52. // 1. Bright White Background so we know it's not a black screen!
  53. graphics.fillRectRGB(x: 0, y: 0, w: 1024, h: 768, r: 255, g: 255, b: 255)
  54. // 2. Draw "Get started" button (Bright Blue)
  55. let btn1W = 280
  56. let btn1H = 60
  57. let btn1X = (1024 - btn1W) / 2
  58. let btn1Y = 300
  59. graphics.fillRectRGB(x: btn1X, y: btn1Y, w: btn1W, h: btn1H, r: 0, g: 122, b: 255)
  60. // 3. Draw "Start ->" button (Green)
  61. let btn2W = 280
  62. let btn2H = 60
  63. let btn2X = (1024 - btn2W) / 2
  64. let btn2Y = 400
  65. graphics.fillRectRGB(x: btn2X, y: btn2Y, w: btn2W, h: btn2H, r: 52, g: 199, b: 89)
  66. // Draw Text! (Black text)
  67. drawText(graphics, "Get started", x: btn1X + 45, y: btn1Y + 18, size: 3, r: 0, g: 0, b: 0)
  68. drawText(graphics, "Start ->", x: btn2X + 65, y: btn2Y + 18, size: 3, r: 0, g: 0, b: 0)
  69. graphics.pan()
  70. print("ui_test: UI Layout mapped and sent to Display Daemon.")
  71. while true {
  72. sleep(1)
  73. }
  74. }
  75. }
  76. UITestApp.main()